Loading saves after game update

Started by Snarky, Tue 03/05/2016 11:03:20

Previous topic - Next topic

Snarky

Would be great if that were solved, CW! Did you happen to see this blog post by Ron Gilbert about how he dealt with the same issue for his Thimbleweed Park engine?

https://blog.thimbleweedpark.com/savegame

Crimson Wizard

#1
Quote from: Snarky on Tue 03/05/2016 11:03:20
Would be great if that were solved, CW! Did you happen to see this blog post by Ron Gilbert about how he dealt with the same issue for his Thimbleweed Park engine?

https://blog.thimbleweedpark.com/savegame
Thank you, I will read that in time, but the first glance made me think the issues they were dealing with are in ways different from the ones we have in AGS, partly because their engine is new and made in "clean" way.

I was thinking about how to deal with saved games alot, just did not find time to post my thoughts on forums yet.

Also, I heard monkey0506 is currently trying to make AGS support adding new objects into game without breaking saves, which (supposedly) should be easier than making universal update system.

Snarky

Well, the specific bit I thought might be useful was the idea of having hooks for preSave() and postLoad() that could be used to ensure that the game state is consistent even across versions, where variables and game logic may have changed (e.g. initialize new variables, and convert some obsolete state from the savegame to the representation used in the current version).

The whole issue of how to serialize and deserialize the engine state in the first place would probably have to be approached differently, and maybe that's a more immediate concern.

Monsieur OUXX

#3
Quote from: Snarky on Tue 03/05/2016 11:03:20
this blog post by Ron Gilbert about how he dealt with the same issue for his Thimbleweed Park engine?: https://blog.thimbleweedpark.com/savegame

It's actually weird to read that mix of seriousness and absolute candor from Ron Gilbert. A very experienced programmer, but who also loves to re-invent the wheel.
 

Ponch

Quote from: Crimson Wizard on Tue 03/05/2016 13:39:58
Also, I heard monkey0506 is currently trying to make AGS support adding new objects into game without breaking saves, which (supposedly) should be easier than making universal update system.
I would love to see that added to the engine. Easily integrated patchable/DLC content would be a dream come true. :cheesy:

Dualnames

Well, i have to say, that even though it's a platformer, the game is entirely coded in such way that saves don't matter or get affected at all, because the game stores important data, in non-ags files instead. Much less data than an adventure game sure, but still, it's amazing to be able to patch the game and not care about this for a change.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

JanetC

Quote from: Crimson Wizard on Tue 03/05/2016 13:39:58
Also, I heard monkey0506 is currently trying to make AGS support adding new objects into game without breaking saves, which (supposedly) should be easier than making universal update system.


Unfortunately this didn't work out. It was vastly more complicated than we suspected :(

Crimson Wizard

#7
Quote from: JanetC on Tue 17/05/2016 18:27:03
Unfortunately this didn't work out. It was vastly more complicated than we suspected :(

That's sad to hear.
I would like to know the technical details, if possible.
In any case, I was getting ready to try this out myself, if something gets wrong with the first attempt. Even if this requires more work, some easier parts could be done in advance. Maybe implement this step by step.

monkey0506

The problems I encountered were centered around the AlignedStream class. Trying to read saves without the AlignedStreams caused the engine to crash with an unknown error. Trying to add items like Characters or GUIs put things out of order somewhere though, and I wasn't able to figure out where. Trying to follow the flow of the binary file proved nearly impossible. I was going to start putting logging statements in, but time constraints from other life events just didn't permit it.

Dialogs and views were able to be added without any problem.

Crimson Wizard

#9
Quote from: monkey0506 on Tue 07/06/2016 21:59:05
The problems I encountered were centered around the AlignedStream class. Trying to read saves without the AlignedStreams caused the engine to crash with an unknown error.
This is most surprising... Did you also remove AlignedStreams from writing saves? I think some save or load functions were shared between saves and game data loading routines, so that have to be investigated carefully.
Also, did you manage to make script global data increase? I suspect that to be more important for game patching than new characters (but I don't know what Wadget Eye does with their patches)

Regarding the whole save thing, there is also a problem I was considering: the items that are not found in the save should logically be reset to their initial game state, or they end up unchanged by loading the game. Of course, ideally their case should be fixed by script (hooks, as Snarky called the in the posts above). But resetting them as a temp solution would prevent bizzare issues, for example "new" characters standing where they stood before game restoration, and similar things.

Regarding save format, I would suggest to change the way save is loaded: instead of the game (engine) making expectations of every next piece of data, make save tell the engine what data follows. This may be achieved by splitting data into entity blocks, each having defined type, identifier and size written in the header. This way it will be easier for the engine to know which entities were read and which won't, and if there are "unknown" entities that don't belong to the game, and possibly pass this information to the script callbacks (hooks) to let game author deal with such occasions.

Of course it is not necessary to complete all of this in one turn, just to keep these points in mind.

Crimson Wizard

#10
I finally found time to write ideas down. The result is this ticket in the new issue tracker (hopefully not the last :tongue:):
http://adventuregamestudio.myjetbrains.com/youtrack/issue/AGS-4



NOTE: how to log into the YouTrack tracker?

You either create a free account specifically for YouTrack, or login using your -
* GitHub
* Yahoo
* Google
* Yandex
account. To do the latter you need to type in your credentials, then click on the corresponding system logo, instead of the "Submit" button.

Crimson Wizard

#11
Quote from: monkey0506 on Tue 07/06/2016 21:59:05
The problems I encountered were centered around the AlignedStream class. Trying to read saves without the AlignedStreams caused the engine to crash with an unknown error. Trying to add items like Characters or GUIs put things out of order somewhere though

I did not see your code changes, but looking around the save process - the most noticeable potential problem is that save format requires to know the exact number of characters BEFORE actually reading one from the savegame.

If you find "ReadMoveList_Aligned" function - that uses number of characters as a high limit in the reading loop, but is located before the number of characters is read from the save.

I suspect the GUI may have similar issue somewhere.

Also, - I think I must underline this, - one should read the number of characters from the save, but do not overwrite the one in the active game data, otherwise your game will get downgraded in terms of data (and loose consistency).

In any case, at least the save format (order in which pieces of data stored) must be changed to solve the problem I stated above. And there is a need to read some variables (mainly entity counts) not directly into the game data, but in some temporary struct to be used just for the time of reading the save.

SMF spam blocked by CleanTalk