mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +09:00
Fixed research sync for levels and repeated execution
This commit is contained in:
1 parent
19913af056
commit
1c8deea2dc
1 file changed
+3
-3
@@ -43,7 +43,7 @@ class ResearchSync {
|
|||||||
if(researchList){
|
if(researchList){
|
||||||
Object.keys(researchList).forEach(researchName => {
|
Object.keys(researchList).forEach(researchName => {
|
||||||
if (needResearch.hasOwnProperty(researchName)) {
|
if (needResearch.hasOwnProperty(researchName)) {
|
||||||
if (needResearch[researchName].researched !== 0) {
|
if (needResearch[researchName].researched === 0) {
|
||||||
needResearch[researchName].researched = parseInt(researchList[researchName].researched);
|
needResearch[researchName].researched = parseInt(researchList[researchName].researched);
|
||||||
}
|
}
|
||||||
if (needResearch[researchName].level < parseInt(researchList[researchName].level)) {
|
if (needResearch[researchName].level < parseInt(researchList[researchName].level)) {
|
||||||
@@ -67,7 +67,7 @@ class ResearchSync {
|
|||||||
}
|
}
|
||||||
this.messageInterface(command);
|
this.messageInterface(command);
|
||||||
this.messageInterface("Unlocking research: " + key + " at research state = " + (difference[key].researched === 0 ? 'false' : 'true') + ' and level ' + difference[key].level);
|
this.messageInterface("Unlocking research: " + key + " at research state = " + (difference[key].researched === 0 ? 'false' : 'true') + ' and level ' + difference[key].level);
|
||||||
// this.messageInterface("/c game.forces['player'].technologies['" + key + "'].researched=true");
|
this.research[key] = difference[key];
|
||||||
});
|
});
|
||||||
if(Object.keys(difference).length > 0){
|
if(Object.keys(difference).length > 0){
|
||||||
this.messageInterface("difference from other servers", JSON.stringify(difference));
|
this.messageInterface("difference from other servers", JSON.stringify(difference));
|
||||||
@@ -86,7 +86,7 @@ class ResearchSync {
|
|||||||
let diff = {};
|
let diff = {};
|
||||||
Object.keys(localResearch).forEach((key) => {
|
Object.keys(localResearch).forEach((key) => {
|
||||||
if (remoteResearch.hasOwnProperty(key)) {
|
if (remoteResearch.hasOwnProperty(key)) {
|
||||||
if (localResearch[key].researched !== remoteResearch[key].researched || localResearch[key].level !== remoteResearch[key].level) {
|
if (localResearch[key].researched !== remoteResearch[key].researched || localResearch[key].level < remoteResearch[key].level) {
|
||||||
diff[key] = remoteResearch[key];
|
diff[key] = remoteResearch[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user