mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +09:00
Fix level > max_level crash in research_sync
Fix crash when technologiy level stored on the master is greater than the max_level for the technology in Factorio. This can happen with mods that for example reduce the max_level from inifity to a finite level.
This commit is contained in:
1 parent
446333f4aa
commit
e9fab3cc10
1 file changed
+8
@@ -141,6 +141,10 @@ function research_sync.sync_technologies(data)
|
|||||||
for _, tech_data in pairs(game.json_to_table(data)) do
|
for _, tech_data in pairs(game.json_to_table(data)) do
|
||||||
local tech = force.technologies[tech_data[nameIndex]]
|
local tech = force.technologies[tech_data[nameIndex]]
|
||||||
if tech and tech.enabled and tech.level <= tech_data[levelIndex] then
|
if tech and tech.enabled and tech.level <= tech_data[levelIndex] then
|
||||||
|
if tech_data[levelIndex] > tech.prototype.max_level then
|
||||||
|
tech_data[levelIndex] = tech.prototype.max_level
|
||||||
|
end
|
||||||
|
|
||||||
tech.level = tech_data[levelIndex]
|
tech.level = tech_data[levelIndex]
|
||||||
local progress
|
local progress
|
||||||
if tech_data[researchedIndex] then
|
if tech_data[researchedIndex] then
|
||||||
@@ -188,6 +192,10 @@ function research_sync.research_technology(name, level)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if level > tech.prototype.max_level then
|
||||||
|
level = tech.prototype.max_level
|
||||||
|
end
|
||||||
|
|
||||||
global.research_sync.ignore_research_finished = true
|
global.research_sync.ignore_research_finished = true
|
||||||
if tech == force.current_research and tech.level == level then
|
if tech == force.current_research and tech.level == level then
|
||||||
force.research_progress = 1
|
force.research_progress = 1
|
||||||
|
|||||||
Reference in new issue
Block a user