summaryrefslogtreecommitdiff
path: root/src/saveload
AgeCommit message (Collapse)Author
2021-07-17Feature: Persistant rotation of numbered auto/netsave after restart (#9397)Loïc Guilloux
It was always starting from 0 on openttd restart. Now the most recent auto/netsave number will be used as a base to generate the next filename.
2021-07-09Codechange: use the name string in SaveLoad for the name of the Setting as wellRubidium
2021-07-09Codechange: access the name of a setting via an accessor functionRubidium
2021-07-09Codechange: name a few unnamed settings as to not to have to check for that ↵Rubidium
being empty
2021-07-09Add #9188: netsave now keeps multiple version around, similar to autosave ↵Stephan
(#9395)
2021-07-09Codechange: split settings.ini over several files (#9421)Patric Stout
This reduced the load on compilers, as currently for example MacOS doesn't like the huge settings-tables. Additionally, nobody can find settings, as the list is massive and unordered. By splitting it, it becomes a little bit more sensible.
2021-07-08Fix: reduce the amount of debug messages on -dsl=2 (#9420)Patric Stout
LoadCheck makes it sound like something is really broken while loading savegames, while it really is perfectly normal, as most chunks do not implement LoadCheck.
2021-07-06Codechange: Use a common sub-class for NewGRFMapping chunksglx22
2021-07-06Cleanup: Remove now unneeded ChunkHandler membersglx22
2021-07-06Codechange: Use ChunkHandlers sub-classesglx22
2021-07-06Codechange: Use static array of references to ChunkHandlerglx22
2021-07-06Codechange: Preparation for ChunkHandler subclassingglx22
2021-07-06Codechange: split off the settings saveload code from the main settings ↵Rubidium
handling logic
2021-07-06Fix 39e90ec: Integers for scripts are 64bit, but saved as 32bit (#9415)Loïc Guilloux
2021-07-03Fix cdb3dd049: GOAL chunk was not using the header for loading (#9409)Loïc Guilloux
2021-07-02Codechange: make savegame-version checks more obvious in SlCompanyLiveries::LoadPatric Stout
num_liveries indirectly contained the same information, but this makes reading these things pretty difficult. So use IsSavegameVersionBefore() like everywhere else instead.
2021-07-02Codechange: using "until" in function names can be confusingPatric Stout
IsSavegameVersionUntil() did a [0, N] check, not [0, N) as the name suggests. Until can be a confusing word, where people consider it to be including the upperbound. Dictionary states it means "before", excluding the upperbound. There are long debates about who is right. So, simply remove away from this ambiguity, and call it "before" and "before or at". This makes the world easier for everyone.
2021-07-02Cleanup: remove SLE_NULL and friendsPatric Stout
We no longer need them. If you want to remove a field .. just remove it! Because of the headers in the savegame, on loading, it will do the right thing and skip the field. Do remember to bump the savegame version, as otherwise older clients can still load the game, but will reset the field you have removed .. that might be unintentially.
2021-07-02Add: store headers for chunks with SL_STRUCTLISTPatric Stout
2021-07-02Add: store headers for most savegame chunksPatric Stout
When a header is added, the chunk changes from CH_ARRAY type to CH_TABLE type.
2021-07-02Feature: framework to make savegames self-descriptivePatric Stout
We won't be able to make it fully self-descriptive (looking at you MAP-chunks), but anything else can. With this framework, we can add headers for each chunk explaining how each chunk looks like in detail. They also will all be tables, making it a lot easier to read in external tooling, and opening the way to consider a database (like SQLite) to use as savegame format. Lastly, with the headers in the savegame, you can freely add fields without needing a savegame version bump; older versions of OpenTTD will simply ignore the new field. This also means we can remove all the SLE_CONDNULL, as they are irrelevant. The next few commits will start using this framework.
2021-06-26Codechange: instead of "naked" initializer lists, declare the type in the ↵rubidium42
saveload macros This to help variant's constructor to be able to resolve the constructor of the setting
2021-06-17Cleanup: simplify some boolean expressionsRubidium
2021-06-17Cleanup: use true/false instead of 1/0 where applicableRubidium
2021-06-15Codechange: mark chunks that are not stored as CH_READONLYPatric Stout
This makes it easier to spot chunks that have a save_proc that is a nullptr, but also prevents confusion, where it looks like the CH_ type of a chunk has influence on how it is being read. It is not, it is only used for saving.
2021-06-15Change: rework GLOG chunk to be more like the restPatric Stout
Basically it is very similar to Vehicles, where there first is a type field, followed by data of that type. So this commit makes it looks like how Vehicles solved that. This removes a lot of custom "keeping track of length" stuff.
2021-06-15Change: rework several CH_RIFF chunks to use CH_ARRAY insteadPatric Stout
This adds two byte extra to those chunks, and might feel a bit silly at first. But in later changes we will prefix CH_ARRAY with a table header, and then this change shines. Without this, we could still add headers to these chunks, but any external reader wouldn't know if the CH_RIFF has them or not. This way is much more practical, as they are now more like any other chunk.
2021-06-15Codechange: add the ability to save/load a std::vectorPatric Stout
std::vector<bool> is not possible, as .. that is a nice special case in C++. This new type will be used in next commit.
2021-06-15Change: prefix SL_ARR with the length of the arrayPatric Stout
This means that during loading we can validate that what is saved is also that what is expected. Additionally, this makes all list types similar to how they are stored on disk: First a gamma to indicate length, followed by the data. The size still depends on the type.
2021-06-15Codechange: make it more obvious SlArray supports SLE_VAR_NULLPatric Stout
In the end, the code was already doing the right thing, but a few functions deep, and not really obvious. When validating what objects can handle SLE_VAR_NULL, it is nicer to just have this obvious.
2021-06-15Codechange: use SL_NULL if you want to store null-bytes or load to nothingPatric Stout
Using SL_ARR for this gives us a bit of trouble later on, where we add a length-field to SL_ARR. This of course is not the intention of SLE_CONDNULL. So better seperate it.
2021-06-15Change: switch SL_DEQUE and SL_REFLIST length field to a gammaPatric Stout
The current SaveLoad is a bit inconsistent how long a length field is. Sometimes it is a 32bit, sometimes a gamma. Make it consistent across the board by making them all gammas.
2021-06-15Change: indicate in the savegame if a SL_STRUCT contains any dataPatric Stout
This helps external tooling to understand if a SL_STRUCT should be skipped when reading. Basically, this transforms an SL_STRUCT into a SL_STRUCTLIST with either 0 or 1 length.
2021-06-15Change: store length of SL_STRUCTLIST in the savegamePatric Stout
This wasn't consistently done, and often variables were used that were read by an earlier blob. By moving it next to the struct itself, the code becomes a bit more self-contained and easier to read. Additionally, this allows for external tooling to know how many structs to expect, instead of having to know where to find the length-field or a hard-coded value that can change at any moment.
2021-06-14Codechange: use SLE_STRUCT(LIST) for Linkgraph chunksPatric Stout
2021-06-14Codechange: move Save/Load functions of same chunk next to each otherPatric Stout
2021-06-14Codechange: use SLE_STRUCT(LIST) for GameScript chunksPatric Stout
2021-06-14Codechange: use as much of STNN code for STNS as possiblePatric Stout
There was a lot of code duplication for no real reason. Now with SLEG_STRUCT support, we can just re-use the code, hopefully making it easier for future-us to make changes to this, without breaking everything for old games.
2021-06-14Codechange: use SLE_STRUCT(LIST) for Station chunksPatric Stout
2021-06-14Codechange: use SLE_STRUCT(LIST) for Company chunksPatric Stout
2021-06-14Codechange: use SLE_STRUCT(LIST) for Town chunksPatric Stout
2021-06-14Codechange: remove the special station/vehicle code from SaveLoadPatric Stout
With the new SLEG_STRUCT it is much easier to embed a struct in a struct, where the sub-struct has limitations on when it is being used. This makes both the code easier to read (less magic) and avoids the SaveLoad needing to know all these things about Stations and Vehicles.
2021-06-14Codechange: ability to store structs and list of structs in savegamesPatric Stout
The commits following this will use this new functionality. Currently, a few places do this manually. This has as drawback that the Save() and Load() code need to be in sync, and that any change can result in (old) savegames no longer loading. In general, it is annoying code to maintain. By putting everything in a description table, and use that for both Save() and Load(), it becomes easier to see what is going on, and hopefully less likely for people to make mistakes.
2021-06-13Fix 81062163: for (really) old games, station bus/truck station cache was ↵Patric Stout
not updated (#9366)
2021-06-13Codechange: convert printf DEBUG statements to fmt Debug statementsrubidium42
2021-06-10Feature: Configurable subsidy durationTyler Trahan
2021-06-10Codechange: rework CHTS-chunk save/load to be more like the othersPatric Stout
2021-06-10Codechange: rename SL_LST to SL_REFLIST to highlight the "reference" partPatric Stout
You can easily mistake SlList / SL_LST to be a list of SL_VAR, but it is a list of SL_REF. With this rename, it hopefully saves a few people from "wtf?" moments.
2021-06-10Codechange: refactor SlList to use SlStorageHelperPatric Stout
2021-06-10Codechange: refactor SlDequeueHelper to work with unsigned and be more genericPatric Stout
Future additions will start using it for std::list too.