summaryrefslogtreecommitdiff
path: root/src/settings_type.h
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-03-01 13:12:17 +0100
committerPatric Stout <github@truebrain.nl>2021-03-01 23:17:47 +0100
commit74aa934441351334e40d8963900b8a2fbc9bc9cd (patch)
tree1257efebb69111b35c5026d59c0504088faff0d8 /src/settings_type.h
parentd7a70c67bacef7453ae56e9136c9c16e4b19c314 (diff)
downloadopenttd-74aa934441351334e40d8963900b8a2fbc9bc9cd.tar.xz
Codechange: validate that "max" value of settings fit in their storage
This is an easy mistake to make, so protect us against making such mistakes, by validating it doesn't happen.
Diffstat (limited to 'src/settings_type.h')
-rw-r--r--src/settings_type.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/settings_type.h b/src/settings_type.h
index f2c591f64..433e8d535 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -21,6 +21,15 @@
#include "zoom_type.h"
#include "openttd.h"
+/* Used to validate sizes of "max" value in settings. */
+const size_t MAX_SLE_UINT8 = UINT8_MAX;
+const size_t MAX_SLE_UINT16 = UINT16_MAX;
+const size_t MAX_SLE_UINT32 = UINT32_MAX;
+const size_t MAX_SLE_UINT = UINT_MAX;
+const size_t MAX_SLE_INT8 = INT8_MAX;
+const size_t MAX_SLE_INT16 = INT16_MAX;
+const size_t MAX_SLE_INT32 = INT32_MAX;
+const size_t MAX_SLE_INT = INT_MAX;
/** Settings profiles and highscore tables. */
enum SettingsProfile {