Skip to content
This repository was archived by the owner on Apr 17, 2022. It is now read-only.

Loading a game doesn't load which units were recycled #251

Closed
wzdev-ci opened this issue Feb 9, 2009 · 36 comments
Closed

Loading a game doesn't load which units were recycled #251

wzdev-ci opened this issue Feb 9, 2009 · 36 comments

Comments

@wzdev-ci
Copy link
Contributor

wzdev-ci commented Feb 9, 2009

keyword_Saving_Units_Experience_in_Recycle resolution_fixed type_bug | by goku75703@...


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.


Issue migrated from trac:251 at 2022-04-15 17:54:59 -0700

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented May 3, 2009

Buginator commented


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

@wzdev-ci
Copy link
Contributor Author

Buginator changed milestone from 2.2 to 2.3

@wzdev-ci
Copy link
Contributor Author

anonymous commented


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.

@wzdev-ci
Copy link
Contributor Author

Buginator commented


We can't change the structure, if we do, it will break the savegame. It does a binary blob dump...

@wzdev-ci
Copy link
Contributor Author

cybersphinx commented


What exactly breaks? Newer Warzone can load older saves, right? But older Warzone cannot load new saves?

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Jun 20, 2009

Buginator commented


Replying to Warzone2100/old-trac-import#251 (comment:5):

What exactly breaks? Newer Warzone can load older saves, right? But older Warzone cannot load new saves?

That would be correct.

@wzdev-ci
Copy link
Contributor Author

cybersphinx changed blocking which not transferred by tractive

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Apr 5, 2010

Zarel commented


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!

@wzdev-ci
Copy link
Contributor Author

stiv changed status from new to pending

@wzdev-ci
Copy link
Contributor Author

stiv commented


Unsupported version.

@wzdev-ci
Copy link
Contributor Author

cybersphinx changed status from pending to closed

@wzdev-ci
Copy link
Contributor Author

cybersphinx changed operating_system which not transferred by tractive

@wzdev-ci
Copy link
Contributor Author

cybersphinx set resolution to closed

@wzdev-ci
Copy link
Contributor Author

cybersphinx changed milestone from 3.0 to 2.3.1

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Apr 14, 2010

cybersphinx commented


Replying to Warzone2100/old-trac-import#251 (comment:9):

Unsupported version.

So? The problem still exists.

@wzdev-ci
Copy link
Contributor Author

cybersphinx changed status from closed to reopened

@wzdev-ci
Copy link
Contributor Author

cybersphinx changed resolution from closed to ``

@wzdev-ci
Copy link
Contributor Author

Zarel commented


We should really only be closing "unsupported version" bug tickets if they are difficult to reproduce.

@wzdev-ci
Copy link
Contributor Author

stiv commented


Feel free to add a test case showing the problem in a current version.

@wzdev-ci
Copy link
Contributor Author

cybersphinx uploaded file a1-2.tar.bz2 (98.3 KiB)

@wzdev-ci
Copy link
Contributor Author

cybersphinx commented


Load the savegame, recycle unit, save game, reload the new save, build unit. Unit doesn't get experience.

@wzdev-ci
Copy link
Contributor Author

cybersphinx commented


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.

@wzdev-ci
Copy link
Contributor Author

cybersphinx commented


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.

@wzdev-ci
Copy link
Contributor Author

cybersphinx uploaded file 0001-Don-t-use-recycled-experience-when-game-time-is-stop.patch (1.4 KiB)

@wzdev-ci
Copy link
Contributor Author

cybersphinx commented


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.

@wzdev-ci
Copy link
Contributor Author

Per commented


So the experience was not lost, it was just distributed to random other units while loading the game?

@wzdev-ci
Copy link
Contributor Author

cybersphinx commented


And then it was overwritten by the loaded experience, so effectively lost after all.

@wzdev-ci
Copy link
Contributor Author

Zarel commented


Okay, so: Load the experience after calling buildDroid on all the droids?

@wzdev-ci
Copy link
Contributor Author

Zarel commented


i.e. instead of this:

  1. Recall saved experience pool
  2. Call buildDroid
  3. Overwrite new droids with stored experience value.

do this:

  1. Call buildDroid
  2. Overwrite new droids with stored experience value.
  3. Recall saved experience pool

@wzdev-ci
Copy link
Contributor Author

wzdev-ci commented Apr 14, 2010

Buginator commented


Replying to Warzone2100/old-trac-import#251 (comment:17):

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.

@wzdev-ci
Copy link
Contributor Author

the_cybersphinx changed status from reopened to closed

@wzdev-ci
Copy link
Contributor Author

the_cybersphinx changed resolution from `` to fixed

@wzdev-ci
Copy link
Contributor Author

the_cybersphinx commented


(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.

@wzdev-ci
Copy link
Contributor Author

Git SVN Gateway <gateway@...> commented


(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

@wzdev-ci
Copy link
Contributor Author

the_cybersphinx commented


(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(-)

@wzdev-ci
Copy link
Contributor Author

Git SVN Gateway <gateway@...> commented


In [a044ab3e6fbacf0038846b2e016560f58d9bd3c4]:

#CommitTicketReference repository="" revision="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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant