summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-06-18 13:27:59 +0200
committerPatric Stout <github@truebrain.nl>2021-07-02 22:21:58 +0200
commit4e645ce749904f736ccf2b5b9d400240ea420833 (patch)
tree48263c271be7db4fb1bc00f1046be616d8cea909 /src/saveload
parent9643a1b80ac9d5c2e3b2781e7536de874ee3f2bb (diff)
downloadopenttd-4e645ce749904f736ccf2b5b9d400240ea420833.tar.xz
Codechange: using "until" in function names can be confusing
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.
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/afterload.cpp2
-rw-r--r--src/saveload/saveload.h20
2 files changed, 11 insertions, 11 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 83f3c6fc6..df1b4e44f 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -3106,7 +3106,7 @@ bool AfterLoadGame()
}
}
- if (IsSavegameVersionUntil(SLV_ENDING_YEAR)) {
+ if (IsSavegameVersionBeforeOrAt(SLV_ENDING_YEAR)) {
/* Update station docking tiles. Was only needed for pre-SLV_MULTITLE_DOCKS
* savegames, but a bug in docking tiles touched all savegames between
* SLV_MULTITILE_DOCKS and SLV_ENDING_YEAR. */
diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h
index 77588a9f8..e4318c011 100644
--- a/src/saveload/saveload.h
+++ b/src/saveload/saveload.h
@@ -618,14 +618,14 @@ typedef void *SaveLoadAddrProc(void *base, size_t extra);
/** SaveLoad type struct. Do NOT use this directly but use the SLE_ macros defined just below! */
struct SaveLoad {
std::string name; ///< Name of this field (optional, used for tables).
- SaveLoadType cmd; ///< the action to take with the saved/loaded type, All types need different action
- VarType conv; ///< type of the variable to be saved, int
- uint16 length; ///< (conditional) length of the variable (eg. arrays) (max array size is 65536 elements)
- SaveLoadVersion version_from; ///< save/load the variable starting from this savegame version
- SaveLoadVersion version_to; ///< save/load the variable until this savegame version
- size_t size; ///< the sizeof size.
- SaveLoadAddrProc *address_proc; ///< callback proc the get the actual variable address in memory
- size_t extra_data; ///< extra data for the callback proc
+ SaveLoadType cmd; ///< The action to take with the saved/loaded type, All types need different action.
+ VarType conv; ///< Type of the variable to be saved; this field combines both FileVarType and MemVarType.
+ uint16 length; ///< (Conditional) length of the variable (eg. arrays) (max array size is 65536 elements).
+ SaveLoadVersion version_from; ///< Save/load the variable starting from this savegame version.
+ SaveLoadVersion version_to; ///< Save/load the variable before this savegame version.
+ size_t size; ///< The sizeof size.
+ SaveLoadAddrProc *address_proc; ///< Callback proc the get the actual variable address in memory.
+ size_t extra_data; ///< Extra data for the callback proc.
std::shared_ptr<SaveLoadHandler> handler; ///< Custom handler for Save/Load procs.
};
@@ -641,7 +641,7 @@ struct SaveLoadCompat {
std::string name; ///< Name of the field.
uint16 length; ///< Length of the NULL field.
SaveLoadVersion version_from; ///< Save/load the variable starting from this savegame version.
- SaveLoadVersion version_to; ///< Save/load the variable until this savegame version.
+ SaveLoadVersion version_to; ///< Save/load the variable before this savegame version.
};
/**
@@ -1001,7 +1001,7 @@ static inline bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor = 0
* @param major Major number of the version to check against.
* @return Savegame version is at most the specified version.
*/
-static inline bool IsSavegameVersionUntil(SaveLoadVersion major)
+static inline bool IsSavegameVersionBeforeOrAt(SaveLoadVersion major)
{
extern SaveLoadVersion _sl_version;
return _sl_version <= major;