Save seems however a good starting point to get an understanding of what is involved in storing a game to a file.
Basically, the game state needs to be serialized onto a file. With save there is only one version you can save, namely the current one. (If you want to be able to load a file in an older version of the game, you need to be able to write older serializations too, but to me it does not seem useful enough to support.)
The next question is what to save exactly. A simple but non-feasible answer is "everything". A memory dump would obviously work. However, it does not seem the right solution, since that also means all data structures must stay the same, and get restored at the exact same place in memory. Further evolution would be tricky at least.
So what to save then? Do we save the set of windows opened at the game interface? Do we save that the user was buying a shop, and had just placed it? I don't know whether we should, but as a starting point, I would think just the current simulation engine state is enough.
Opened windows, loaded RCD files, and their sprites and other data is not saved.
A scenario save is more difficult. To save a game, you save all game state. For a large part, game state depends on the RCD data available at the time of the save, eg a shop of type X in the game. X and its behavior is defined in an RCD file. If you ensure the same RCD file is available during loading, you can continue the game.
A scenario however can be seen as a template. Some of the things are pre-defined, but other things are still free. One thing I expect to happen is that users will want to play with their favorite set of RCD files. Loading such a scenario thus has to be able to load the saved state, yet allow the user to add/modify some aspects.
Loading has the problem that you don't know what you got until you load it. Since I would like to support old versions (otherwise all saved games and all scenarios would stop working with each new release), the loader has to be ready for loading an old version.
Thus it may get file data about concepts that has changed a lot in the mean time, or parts of the game state are missing entirely (when we introduce something new).
Secondly, the file may need RCD files that are not at the system or (more likely) a more modern version exists. (Off-topic, but a reliable way to detect RCD file version is thus needed, experience shows that a manually maintained version number will not work.)
Save seems however a good starting point to get an understanding of what is involved in storing a game to a file.
Basically, the game state needs to be serialized onto a file. With save there is only one version you can save, namely the current one. (If you want to be able to load a file in an older version of the game, you need to be able to write older serializations too, but to me it does not seem useful enough to support.)There is absolutely no need for saving in old formats. The game is free, so everyone can keep it up to date.
So what to save then? Do we save the set of windows opened at the game interface? Do we save that the user was buying a shop, and had just placed it? I don't know whether we should, but as a starting point, I would think just the current simulation engine state is enough.
Opened windows, loaded RCD files, and their sprites and other data is not saved.Everything that can't be calculated or loaded from files (sprites, terrain data) and represents the game's current state.
Windows should be saved.
There isn't to much to save anyways (window). You just save the list of opened windows and their screen position, the data displayed in window is part of the selected object (shop, ride, person) anyways.
For shops, I would only save it's location and current values (price, sales, position...). I don't see any point in saving if a shop was bought - can you explain how you meant it?
A scenario save is more difficult. To save a game, you save all game state. For a large part, game state depends on the RCD data available at the time of the save, eg a shop of type X in the game. X and its behavior is defined in an RCD file. If you ensure the same RCD file is available during loading, you can continue the game.
A scenario however can be seen as a template. Some of the things are pre-defined, but other things are still free. One thing I expect to happen is that users will want to play with their favorite set of RCD files. Loading such a scenario thus has to be able to load the saved state, yet allow the user to add/modify some aspects.A scenario save doesn't seem that very much different to me. It has everything that a save game has, except some additional parameters (like goals or limits) that define the way how the game is played. A scenario can contain already built rides or shops. It can also have already visitors. The only thing that I see right now that a scenario doesn't need to contain and a save game must, is history data (sales stats, ratings, guests) - my opinion is that a game should always start from year 1, without any history, even if there are rides already built.
Loading has the problem that you don't know what you got until you load it. Since I would like to support old versions (otherwise all saved games and all scenarios would stop working with each new release), the loader has to be ready for loading an old version.
Thus it may get file data about concepts that has changed a lot in the mean time, or parts of the game state are missing entirely (when we introduce something new).
Secondly, the file may need RCD files that are not at the system or (more likely) a more modern version exists. (Off-topic, but a reliable way to detect RCD file version is thus needed, experience shows that a manually maintained version number will not work.)A compatibility list can be made. It should specify which file versions can be loaded with specified game version. If those two are not compatible, the saved game cannot be loaded. Until features are added (a
shop gets a new item to sell), this shouldn't be the case, but if you make a change like remove a shop (won't happen, is just an example :)), it changes the direction of the gameplay, so it can't/shouldn't be loaded. It could also occur that a scenario would change. In this case, the save game and the scenario wouldn't be compatible to.
Pressed buttons, toggle switches? Position of scrollbars? Selected tab in the window? Tbh I don't see much value in saving this data, it's easy enough to open the window again.
The path and shop (and coaster) windows have state. You have to select what to buy, place it in the window, and press some button to actually buy it. So you have to store you selected X shop, were busy placing it, and had the mouse at position (x,y,z), or whatever.
I would like to aim for loading all versions. Adding a new feature is not a problem, old games simply don't have that (but once loaded they do). Removing a feature is also doable, just delete the feature from the file (or rather, just ignore it while loading). Changing a feature means you have to also define how an old game is loaded in that case. A bad solution (but it always works) is to see it as removal of the old version of the feature, and adding of the new version of the feature.
Having such cuts is bad for continuity. It means all scenarios and savegames that exist become unusable.
Users can throw away all their saved data. Bug reports with savegames becomes unsolvable. Scenario authors have to start over from scratch.
What's worse, it also means you can never even retrieve the contents of the old data anymore. That rollercoaster design you worked at for 4 months, or that beautiful landscape, and that tricky three rollercoasters with paths completely intertwined with each other.... all gone.
Old file data that needs to be updated to the current version
About the savedata version, it is very important to keep it in the header or in a special node of the XML file, otherwise, we will have serious trouble loading old savedatas on newer game versions.
What do you mean with "an object changes size"?
As for the data format, I think XML is overrated as storage format. I'd prefer a binary format.
We do not need to be compatible with other systems, or exchange savegames with them.
Judging by openttd savegames, which can be 6MB heavily compressed binary data
What do you mean with "an object changes size"?Sorry about the imprecision, I meant the room that an object needs. For example a toboggan had a size of 2x2, and you decide that finally, 2x2 is really too small for a toboggan and thus you change its size to 3x3.
As for the data format, I think XML is overrated as storage format. I'd prefer a binary format.I agree with you.
We do not need to be compatible with other systems, or exchange savegames with them.That pops a question in my mind, do you think there will be some kind of Roller Coaster Tycoon savedata importing tool at some point?
Judging by openttd savegames, which can be 6MB heavily compressed binary dataI don't remind the size of Roller Coaster Tycoon savedata, and I don't have a copy of this game right now. Can you please give me some size examples?
I think you'll have a hard time to find out all properties.
Something like that will also happen in FreeRCT. I don't see 128*128 as enough for all users (even though it would be nice if it was).
I think you'll have a hard time to find out all properties.Yes, I think it would need a great time to reverse the whole savedata system (maybe we could ask Chris Sawyer to hand us some documentation about it?)
If you really want to realize this, maybe the best solution is to write a converter to the FreeRCT savegame file format (which currently is non-existent) ?