Fix crash in recount_cluster_research_progress

Check that the relevant research is present in the research mapping
before accessing it in recount_cluster_research_progress.
This commit is contained in:
Hornwitser committed 2019-10-12 17:07:08 +02:00
1 parent 075d54f708
commit 0cdb5d0ce4
2 files changed
+10 -3

No files matched your search

+2
View File
@@ -10,6 +10,8 @@ Version 1.2.2
when researching it and another node completes it in researchSync.
- Fixed progress of a previous infinite tech from another node being applied
to the current one in researchSync.
- Fixed crash in researchSync when modded technologies are present only on some
nodes.
Version 1.2.1
+8 -3
View File
@@ -211,8 +211,13 @@ class ResearchSync {
}
recount_cluster_research_progress(slaves_data, cluster_researches) {
for (let [name, tech] of Object.entries(cluster_researches))
tech.progress = this.research[name].contribution
for (let [name, tech] of Object.entries(cluster_researches)) {
if (Object.hasOwnProperty.call(this.research, name)) {
tech.progress = this.research[name].contribution
} else {
tech.progress = 0;
}
}
for (let slave_data of slaves_data) {
for (let [name, tech] of Object.entries(slave_data.meta.research)) {
@@ -236,7 +241,7 @@ class ResearchSync {
}
for (let [name, tech] of Object.entries(cluster_researches)) {
if (tech.progress > 1) {
if (Object.hasOwnProperty.call(this.research, name) && tech.progress > 1) {
tech.progress = null
tech.researched = 1
this.research[name].contribution = 0