Ticket #251 (closed bug: fixed)
Loading a game doesn't load which units were recycled
| Reported by: | goku75703@… | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | 2.3.1 |
| Component: | other | Version: | git/master |
| Keywords: | Saving Units Experience in Recycle | Cc: | |
| Blocked By: | Blocking: | #965 | |
| Operating System: | All/Non-Specific |
Description
I started a campaign game with the Grim's GFX mod, played for a bit, and send 3 units to be recycled. I then setup an order to build 3 more units (to get the experienced units back), after 1 unit was build I saved the game and quit.
When I loaded the game back and the next 2 units came out, they did not have any kills (the previous were all ranked). The one that came out before I quit was set properly though.
Vista 32-Bit Home Basic
Email me if you have any need for further information.
Attachments
Change History
comment:3 Changed 3 years ago by anonymous
But the new format wouldn't be incompatible, would it? It just needs a new block "experience for new units", and if that doesn't exist (in old saves) just go on without it. It's quite annoying, so a fix for 2.2 would be very nice.
comment:4 Changed 3 years ago by Buginator
We can't change the structure, if we do, it will break the savegame. It does a binary blob dump...
comment:5 follow-up: ↓ 6 Changed 3 years ago by cybersphinx
What exactly breaks? Newer Warzone can load older saves, right? But older Warzone cannot load new saves?
comment:6 in reply to: ↑ 5 Changed 3 years ago by Buginator
Replying to cybersphinx:
What exactly breaks? Newer Warzone can load older saves, right? But older Warzone cannot load new saves?
That would be correct.
comment:8 Changed 2 years ago by Zarel
WAIT.
We already have the savegame structure in place!
game.c:1220
#define GAME_SAVE_V27 \ GAME_SAVE_V24; \ uint16_t awDroidExperience[MAX_PLAYERS][MAX_RECYCLED_DROIDS]
We can do this without a new savegame version!
comment:9 follow-up: ↓ 10 Changed 2 years ago by stiv
- Status changed from new to pending
Unsupported version.
comment:10 in reply to: ↑ 9 Changed 2 years ago by cybersphinx
- Status changed from pending to closed
- Operating System changed from Microsoft Windows to All/Non-Specific
- Resolution set to closed
- Version changed from 2.1.1 (unsupported!) to svn/2.3
- Milestone changed from 3.0 to 2.3.1
comment:11 Changed 2 years ago by cybersphinx
- Status changed from closed to reopened
- Resolution closed deleted
comment:12 Changed 2 years ago by Zarel
We should really only be closing "unsupported version" bug tickets if they are difficult to reproduce.
comment:13 Changed 2 years ago by stiv
Feel free to add a test case showing the problem in a current version.
comment:14 Changed 2 years ago by cybersphinx
Load the savegame, recycle unit, save game, reload the new save, build unit. Unit doesn't get experience.
comment:15 Changed 2 years ago by cybersphinx
I've looked at the code a bit, and it looks at least like it should work, I've put some printfs in the save routine and those show some non-zero values (9 and 7 for the two units near the command center in the above save). But reloading then shows all as 0... (Putting a watch on the experience array in gdb to see where it is accessed delayed startup somewhat, I think it ran for over an hour when I noticed my CPU load and killed it...)
The savegame is for trunk, btw, not sure if it works in 2.3, but the same happens there.
comment:16 Changed 2 years ago by cybersphinx
My debug printfs were wrong, actually the experience is reloaded correctly. But then, we use buildDroid to construct droids when loading a game, and that eats up the saved experience.
Changed 2 years ago by cybersphinx
- Attachment 0001-Don-t-use-recycled-experience-when-game-time-is-stop.patch added
comment:17 follow-up: ↓ 22 Changed 2 years ago by cybersphinx
Ok, so we used buildDroid() both in game and for loading, and it used up recycled experience when loading a game. Above patch fixes that, by checking if the game time is running (which it isn't when loading a game, but maybe there's a better indicator for that). There's one strange thing in src/game.c:2297 (trunk), where game time is started when loading a saved game fails (was already that way in the original source). If time isn't stopped somewhere before loading a game again, this might lead to this fix not working after a failed load.
comment:18 Changed 2 years ago by Per
So the experience was not lost, it was just distributed to random other units while loading the game?
comment:19 Changed 2 years ago by cybersphinx
And then it was overwritten by the loaded experience, so effectively lost after all.
comment:20 Changed 2 years ago by Zarel
Okay, so: Load the experience after calling buildDroid on all the droids?
comment:21 Changed 2 years ago by Zarel
i.e. instead of this:
- Recall saved experience pool
- Call buildDroid
- Overwrite new droids with stored experience value.
do this:
- Call buildDroid
- Overwrite new droids with stored experience value.
- Recall saved experience pool
comment:22 in reply to: ↑ 17 Changed 2 years ago by Buginator
Replying to cybersphinx:
Ok, so we used buildDroid() both in game and for loading, and it used up recycled experience when loading a game. Above patch fixes that, by checking if the game time is running (which it isn't when loading a game, but maybe there's a better indicator for that). There's one strange thing in src/game.c:2297 (trunk), where game time is started when loading a saved game fails (was already that way in the original source). If time isn't stopped somewhere before loading a game again, this might lead to this fix not working after a failed load.
With my rather limited testing, it looks like that patch works.
comment:23 Changed 2 years ago by the_cybersphinx
- Status changed from reopened to closed
- Resolution set to fixed
(In [10584]) Don't use recycled experience when game time is stopped.
Should fix #251. The problem was that buildDroid() is used both for loading and in game, so it used up the recycled experience for droids when loading a game.
This could lead to other problems, if there is a valid reason why buildDroid() would be called in a situation where game time is stopped, but we _want_ to use recycled experience.
comment:26 Changed 2 years ago by Git SVN Gateway <gateway@…>
(In [a044ab3e6fbacf0038846b2e016560f58d9bd3c4]) Don't use recycled experience when game time is stopped.
Should fix #251. The problem was that buildDroid() is used both for loading and in game, so it used up the recycled experience for droids when loading a game.
This could lead to other problems, if there is a valid reason why buildDroid() would be called in a situation where game time is stopped, but we _want_ to use recycled experience.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@10584 4a71c877-e1ca-e34f-864e-861f7616d084
comment:24 Changed 2 years ago by the_cybersphinx
(In [10604]) 2.3: Don't use recycled experience when game time is stopped.
Should fix #251. The problem was that buildDroid() is used both for loading and in game, so it used up the recycled experience for droids when loading a game.
This could lead to other problems, if there is a valid reason why buildDroid() would be called in a situation where game time is stopped, but we _want_ to use recycled experience.
src/droid.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)

This is a savegame limitation. Would require a new savegame format to fix.