summaryrefslogtreecommitdiff
path: root/src/script/script_instance.cpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-06-12 14:49:51 +0200
committerPatric Stout <github@truebrain.nl>2021-06-15 16:45:04 +0200
commit97b94bdc9ab4ceeb589c5022d5c238442faf0454 (patch)
tree7d22a32f5bf2ac2a56467b7ce5f190fff9c8d09a /src/script/script_instance.cpp
parentf67af5cbe5cb754c3b64553b9cc03b5c18ca7e79 (diff)
downloadopenttd-97b94bdc9ab4ceeb589c5022d5c238442faf0454.tar.xz
Change: prefix SL_ARR with the length of the array
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.
Diffstat (limited to 'src/script/script_instance.cpp')
-rw-r--r--src/script/script_instance.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/script/script_instance.cpp b/src/script/script_instance.cpp
index 2d32b02e8..2665a8684 100644
--- a/src/script/script_instance.cpp
+++ b/src/script/script_instance.cpp
@@ -365,7 +365,7 @@ static const SaveLoad _script_byte[] = {
sq_getinteger(vm, index, &res);
if (!test) {
int value = (int)res;
- SlArray(&value, 1, SLE_INT32);
+ SlCopy(&value, 1, SLE_INT32);
}
return true;
}
@@ -385,7 +385,7 @@ static const SaveLoad _script_byte[] = {
if (!test) {
_script_sl_byte = (byte)len;
SlObject(nullptr, _script_byte);
- SlArray(const_cast<char *>(buf), len, SLE_CHAR);
+ SlCopy(const_cast<char *>(buf), len, SLE_CHAR);
}
return true;
}
@@ -565,7 +565,7 @@ bool ScriptInstance::IsPaused()
switch (_script_sl_byte) {
case SQSL_INT: {
int value;
- SlArray(&value, 1, SLE_INT32);
+ SlCopy(&value, 1, SLE_INT32);
if (vm != nullptr) sq_pushinteger(vm, (SQInteger)value);
return true;
}
@@ -573,7 +573,7 @@ bool ScriptInstance::IsPaused()
case SQSL_STRING: {
SlObject(nullptr, _script_byte);
static char buf[std::numeric_limits<decltype(_script_sl_byte)>::max()];
- SlArray(buf, _script_sl_byte, SLE_CHAR);
+ SlCopy(buf, _script_sl_byte, SLE_CHAR);
StrMakeValidInPlace(buf, buf + _script_sl_byte);
if (vm != nullptr) sq_pushstring(vm, buf, -1);
return true;