Why AGS produces huge save game files?

Started by Windenwart, Sat 19/04/2025 16:39:01

Previous topic - Next topic

Windenwart

At the moment I play the AGS game "Rosewater". The savegame files are bigger than 17...20 MB, although it is a very linear game. Why is that? A look at the savegame file with a hex editor shows that it consists of 90% zeros. What's going wrong here? Why is such a file not compressed if there is no other way?

Crimson Wizard

#1
AGS built-in save system creates saves that keep full state of a game, meaning they contain a dump of all game objects properties and script data, both statically and dynamically allocated. This includes states of all visited rooms too. This is done regardless of whether this is actually necessary or not, because the engine does not know what has to be saved. There's currently no way how a game developer may instruct AGS to exclude particular objects or script data from saving, or save only chosen data. Therefore, the size of saves does not depend on game's linearity or complexity of its story logic, it depends only on the number of things in game overall.

The only way around that for the game developer is to write their own save system that only tracks story progression. But very little people bother with that, it seems. There's also a feature that allows to skip certain types of data, but it's only available in the newest version of the engine, and has restrictions to how it may be used.

Normally, the total sizes of game objects in save should take maybe hundreds of kilobytes (unless the game has absurd amount of content). If the save is tens of megabytes large, that usually means that something big is allocated in script. Sometimes this may be an indication of leftover dynamic data created for one scene and never deleted; in which case it may be fixed. There may be other ways to reduce it. But, in any case, this is something that game author should be addressing. One would have to investigate the contents of the save, or what the game does, in order to find out what causes this exactly. 

Why the standard saves are not compressed - that is a good question, I suppose they could be, but this was never implemented.
I thought about doing this many years ago, but kept forgetting. I'm not very good at planning and prioritizing tasks. Unfortunately, users did not give much feedback about this problem either.

Crimson Wizard

#2
I opened an experimental PR that introduces an optional save contents compression, and non-optional screenshot compression (in save's header).
https://github.com/adventuregamestudio/ags/pull/2721

Haven't tried this with the "Rosewater" yet (planning to), but in the recently released "Old Skies" this reduces save file made on game start from 17.8 MB to 3.2 MB (so down to ~18%).

Engine download link:
https://cirrus-ci.com/task/5485984655081472
Compression is enabled in them setup (or config file) as:
Code: ags
[misc]
compress_saves=1
setup program may be run for the engine executable as "acwin.exe --setup".

Crimson Wizard

Quote from: Windenwart on Sat 19/04/2025 16:39:01The savegame files are bigger than 17...20 MB

I am only able to try the beginning of the game, and the saves are around 1.3 MB there, so it's difficult to judge.
Anyway, the experimental build mentioned above compresses them down to 120 KB, practically 10 times.

SMF spam blocked by CleanTalk