summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-06-04 10:33:38 +0200
committerPatric Stout <github@truebrain.nl>2021-06-10 19:18:24 +0200
commita2147d437e970b22da0290f6ac8e75c12ed6fe92 (patch)
tree6f3ea4de53ca8f052158d2b100372b60667d1035 /src
parentfba86f711fe091fa0802a65979df019f690e8827 (diff)
downloadopenttd-a2147d437e970b22da0290f6ac8e75c12ed6fe92.tar.xz
Codechange: use wrappers to get Var[Mem|File]Type, instead of GB()
Diffstat (limited to 'src')
-rw-r--r--src/saveload/saveload.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index c325c1ee5..40f631e31 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -587,17 +587,17 @@ static inline uint SlGetArrayLength(size_t length)
static inline uint SlCalcConvMemLen(VarType conv)
{
static const byte conv_mem_size[] = {1, 1, 1, 2, 2, 4, 4, 8, 8, 0};
- byte length = GB(conv, 4, 4);
- switch (length << 4) {
+ switch (GetVarMemType(conv)) {
case SLE_VAR_STRB:
case SLE_VAR_STR:
case SLE_VAR_STRQ:
return SlReadArrayLength();
default:
- assert(length < lengthof(conv_mem_size));
- return conv_mem_size[length];
+ uint8 type = GetVarMemType(conv) >> 4;
+ assert(type < lengthof(conv_mem_size));
+ return conv_mem_size[type];
}
}
@@ -610,9 +610,10 @@ static inline uint SlCalcConvMemLen(VarType conv)
static inline byte SlCalcConvFileLen(VarType conv)
{
static const byte conv_file_size[] = {1, 1, 2, 2, 4, 4, 8, 8, 2};
- byte length = GB(conv, 0, 4);
- assert(length < lengthof(conv_file_size));
- return conv_file_size[length];
+
+ uint8 type = GetVarFileType(conv);
+ assert(type < lengthof(conv_file_size));
+ return conv_file_size[type];
}
/** Return the size in bytes of a reference (pointer) */