diff options
author | Patric Stout <truebrain@openttd.org> | 2021-06-06 16:03:56 +0200 |
---|---|---|
committer | Patric Stout <github@truebrain.nl> | 2021-06-14 21:58:05 +0200 |
commit | 4e4720f2178c9e0faf7233e55bec71e6ae19f9ad (patch) | |
tree | af474483110fca7fd7c617e052d1d381991e1179 /src/saveload/saveload.h | |
parent | 4600d289b5d12389137d36e57bfda09c26ed6caf (diff) | |
download | openttd-4e4720f2178c9e0faf7233e55bec71e6ae19f9ad.tar.xz |
Codechange: remove the special station/vehicle code from SaveLoad
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.
Diffstat (limited to 'src/saveload/saveload.h')
-rw-r--r-- | src/saveload/saveload.h | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index ff0982569..7b0127709 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -570,10 +570,7 @@ enum SaveLoadType : byte { SL_STDSTR = 6, ///< Save/load a \c std::string. SL_STRUCT = 7, ///< Save/load a struct. SL_STRUCTLIST = 8, ///< Save/load a list of structs. - /* non-normal save-load types */ - SL_WRITEBYTE = 9, - SL_VEH_INCLUDE = 10, - SL_ST_INCLUDE = 11, + SL_SAVEBYTE = 9, ///< Save (but not load) a byte. }; typedef void *SaveLoadAddrProc(void *base, size_t extra); @@ -740,11 +737,17 @@ struct SaveLoad { */ #define SLE_CONDNULL(length, from, to) {SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL, length, from, to, 0, nullptr, 0, nullptr} -/** Translate values ingame to different values in the savegame and vv. */ -#define SLE_WRITEBYTE(base, variable) SLE_GENERAL(SL_WRITEBYTE, base, variable, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, 0) - -#define SLE_VEH_INCLUDE() {SL_VEH_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, 0, [] (void *b, size_t) { return b; }, 0, nullptr} -#define SLE_ST_INCLUDE() {SL_ST_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, 0, [] (void *b, size_t) { return b; }, 0, nullptr} +/** + * Only write byte during saving; never read it during loading. + * When using SLE_SAVEBYTE you will have to read this byte before the table + * this is in is read. This also means SLE_SAVEBYTE can only be used at the + * top of a chunk. + * This is intended to be used to indicate what type of entry this is in a + * list of entries. + * @param base Name of the class or struct containing the variable. + * @param variable Name of the variable in the class or struct referenced by \a base. + */ +#define SLE_SAVEBYTE(base, variable) SLE_GENERAL(SL_SAVEBYTE, base, variable, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, 0) /** * Storage of global simple variables, references (pointers), and arrays. |