Jibble

Author Topic: Loading saves after game update  (Read 2472 times)

Snarky

  • Global Moderator
  • Global Moderator
  • Mittens Lord
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Loading saves after game update
« on: 03 May 2016, 11:03 »
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

Re: Loading saves after game update
« Reply #1 on: 03 May 2016, 13:39 »
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.
« Last Edit: 03 May 2016, 13:47 by Crimson Wizard »

Snarky

  • Global Moderator
  • Global Moderator
  • Mittens Lord
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Re: Loading saves after game update
« Reply #2 on: 03 May 2016, 15:51 »
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

  • Mittens Vassal
  • Cavefish
  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
    • Monsieur OUXX worked on one or more games that won an AGS Award!
    •  
    • Monsieur OUXX worked on one or more games that was nominated for an AGS Award!
Re: Loading saves after game update
« Reply #3 on: 04 May 2016, 10:15 »
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.
« Last Edit: 04 May 2016, 10:19 by Monsieur OUXX »
 

Ponch

  • AGS Baker
  • Sweatin' to the Oldies
    • Lifetime Achievement Award Winner
    • Ponch worked on one or more games that won an AGS Award!
    •  
    • Ponch worked on one or more games that was nominated for an AGS Award!
Re: Loading saves after game update
« Reply #4 on: 07 May 2016, 13:49 »
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

  • AGS Baker
  • Rottwheelers
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
Re: Loading saves after game update
« Reply #5 on: 09 May 2016, 09:24 »
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.
No more military army stuff. I'm alive and back.

JanetC

  • Mittens Serf
    • JanetC worked on one or more games that won an AGS Award!
    •  
    • JanetC worked on one or more games that was nominated for an AGS Award!
Re: Loading saves after game update
« Reply #6 on: 17 May 2016, 18:27 »
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 :(

Re: Loading saves after game update
« Reply #7 on: 22 May 2016, 11:29 »
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.
« Last Edit: 22 May 2016, 11:31 by Crimson Wizard »

monkey0506

  • SEND PIZZA.
    • Best Innovation Award Winner 2017, for his work to help AGS games reach the widest possible audience - through popular distribution platforms (Steam, Galaxy) as well as other operating systems (Android, Linux)
    • monkey0506 worked on one or more games that won an AGS Award!
    •  
    • monkey0506 worked on one or more games that was nominated for an AGS Award!
Re: Loading saves after game update
« Reply #8 on: 07 Jun 2016, 21:59 »
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.

Re: Loading saves after game update
« Reply #9 on: 07 Jun 2016, 22:33 »
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.
« Last Edit: 07 Jun 2016, 22:35 by Crimson Wizard »

Re: Loading saves after game update
« Reply #10 on: 08 Jun 2016, 19:45 »
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.
« Last Edit: 08 Jun 2016, 21:00 by Crimson Wizard »

Re: Loading saves after game update
« Reply #11 on: 09 Jun 2016, 19:27 »
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.
« Last Edit: 09 Jun 2016, 19:36 by Crimson Wizard »