Loading savegames loses upgrade effects #4215
Comments
Althalus uploaded file Late game skirmish save |
NoQ commented Per is actively working on it in |
Per changed blocking which not transferred by tractive |
Per changed blockedby which not transferred by tractive |
Per commented I'm not changing the loading sequence, though, which is a horrid mess due to all the partial loading in campaign. |
Althalus commented I have made a patch that solves the problem. It introduces a flag tracking whether scripts are usable or not, and a queue to which events that come when the above flag is not set are added. When the flag is set to true, the queue is emptied and its events are re-triggered. For consideration :
|
Althalus uploaded file output of git diff from master branch |
per changed status from |
per changed resolution from `` to |
per commented Fix issue where loading savegames loses upgrade effects. Also fix duplicate Changeset: b800411b580d3343f32b6391e45875e6c7bc6ea8 |
Per commented Sorry it took so long to commit this. I really wanted to find a less hacky fix, but that turned out to require way too much work. Also found another, related bug with map labels that I fixed at the same time. |
resolution_fixed
type_bug
| by AlthalusThis bug is related to both #4178 and #4020, and I suspect they have the same causes.
The observable bug is that whenever I load a savegame in skirmish mode, all the upgradable stats (hitpoints, armor, damage, research points, ...) are reset to the base values.
I haven't tried with campaign saves, but #4178 is about campaign, so I think the bug could trigger too.
I have tracked down the possible causes, and I found that the actual application of the upgrades is done via javascript (mainly the
eventResearched
function in rules.js), but the code that initializes the relevant data structures, which I believe is mainly the functionregisterFunctions
in qtscriptfuncs.cpp, is called after the events have been processed.The nearest common caller of these functions is
levLoadData
in levels.cpp, with the research events being triggered byloadGame
at line 887, while initialization of the scripts is done byloadMultiScripts
at line 1004.I have tried to put the call to
loadMultiScripts
earlier, but putting it around line 852 leads to a crash, and putting it around line 885 leads to a game playable, with upgrades as they should be, but I get a number of assertion failures so I suspect this is not a good solution either.As a reference, I am attaching a late-game save, where it is obvious whether upgrades are applied or not (factory has 1000 hp without upgrades, 3700 with, for example).
Issue migrated from trac:4215 at 2022-04-16 11:44:28 -0700
The text was updated successfully, but these errors were encountered: