mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 23:14:53 +09:00
Fix research sync applying progress to wrong level
When the level of a technology changes either by setting level directly or by setting researched to true, the saved progress of the research is reset only if the technology is not the current research. If during the initial synchronisation with the controller an instance has progressed on a multi level research, it's the current research, and the controller's level of that research is higher, then the level is set to the higher level and the game keeps the progress. This in turn results in all of the progress made on the previous level being added to the higher level. Fix by setting the progress to zero when changing the level or researched status of a technology that's the active research.
This commit is contained in:
1 parent
6bf2bf51f2
commit
dcf216ca09
2 files changed
+13
-1
No files matched your search
@@ -137,10 +137,21 @@ function research_sync.sync_technologies(data)
|
||||
for _, tech_data in pairs(game.json_to_table(data)) do
|
||||
local tech = force.technologies[tech_data[nameIndex]]
|
||||
if tech and tech.level <= tech_data[levelIndex] then
|
||||
tech.level = math.min(tech_data[levelIndex], tech.prototype.max_level)
|
||||
local new_level = math.min(tech_data[levelIndex], tech.prototype.max_level)
|
||||
if new_level ~= tech.level then
|
||||
-- when the level of the current research changes the
|
||||
-- progress is not automatically reset.
|
||||
if force.current_research == tech then
|
||||
force.research_progress = 0
|
||||
end
|
||||
tech.level = new_level
|
||||
end
|
||||
|
||||
local progress
|
||||
if tech_data[researchedIndex] then
|
||||
if force.current_research == tech then
|
||||
force.research_progress = 0
|
||||
end
|
||||
tech.researched = true
|
||||
progress = nil
|
||||
elseif tech_data[progressIndex] then
|
||||
|
||||
Reference in new issue
Block a user