Fix 39e90ec: Integers for scripts are 64bit, but saved as 32bit (#9415)

(cherry picked from commit ddafc0de05)
pull/332/head
Loïc Guilloux 3 years ago committed by Jonathan G Rennison
parent fb8020916a
commit a84feb3444

@ -157,6 +157,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
{ XSLFI_DEPOT_ORDER_EXTRA_FLAGS,XSCF_IGNORABLE_UNKNOWN, 1, 1, "depot_order_extra_flags", nullptr, nullptr, nullptr },
{ XSLFI_EXTRA_SIGNAL_TYPES, XSCF_NULL, 1, 1, "extra_signal_types", nullptr, nullptr, nullptr },
{ XSLFI_BANKRUPTCY_EXTRA, XSCF_NULL, 1, 1, "bankruptcy_extra", nullptr, nullptr, nullptr },
{ XSLFI_SCRIPT_INT64, XSCF_NULL, 1, 1, "script_int64", nullptr, nullptr, nullptr },
{ XSLFI_NULL, XSCF_NULL, 0, 0, nullptr, nullptr, nullptr, nullptr },// This is the end marker
};

@ -111,6 +111,7 @@ enum SlXvFeatureIndex {
XSLFI_DEPOT_ORDER_EXTRA_FLAGS, ///< Depot order extra flags
XSLFI_EXTRA_SIGNAL_TYPES, ///< Extra signal types
XSLFI_BANKRUPTCY_EXTRA, ///< Extra company bankruptcy fields
XSLFI_SCRIPT_INT64, ///< See: SLV_SCRIPT_INT64
XSLFI_RIFF_HEADER_60_BIT, ///< Size field in RIFF chunk header is 60 bit
XSLFI_HEIGHT_8_BIT, ///< Map tile height is 8 bit instead of 4 bit, but savegame version may be before this became true in trunk

@ -39,7 +39,7 @@
* data from the loaded game.
* - Finally, #Start is called to start execution of the script.
*
* See also http://wiki.openttd.org/AI:Save/Load for more details.
* See also https://wiki.openttd.org/en/Development/Script/Save%20and%20Load for more details.
*
* @api ai game
*/
@ -91,7 +91,7 @@ public:
* notified of the call. To avoid race-conditions between #Save and the
* other script code, change variables directly after a #Sleep, it is
* very unlikely, to get interrupted at that point in the execution.
* See also http://wiki.openttd.org/AI:Save/Load for more details.
* See also https://wiki.openttd.org/en/Development/Script/Save%20and%20Load for more details.
*
* @note No other information is saved than the table returned by #Save.
* For example all pending events are lost as soon as the game is loaded.

@ -388,8 +388,8 @@ static const SaveLoad _script_byte[] = {
SQInteger res;
sq_getinteger(vm, index, &res);
if (!test) {
int value = (int)res;
SlArray(&value, 1, SLE_INT32);
int64 value = (int64)res;
SlArray(&value, 1, SLE_INT64);
}
return true;
}
@ -588,8 +588,8 @@ bool ScriptInstance::IsPaused()
SlObject(nullptr, _script_byte);
switch (_script_sl_byte) {
case SQSL_INT: {
int value;
SlArray(&value, 1, SLE_INT32);
int64 value;
SlArray(&value, 1, (IsSavegameVersionBefore(SLV_SCRIPT_INT64) && SlXvIsFeatureMissing(XSLFI_SCRIPT_INT64)) ? SLE_FILE_I32 | SLE_VAR_I64 : SLE_INT64);
if (vm != nullptr) sq_pushinteger(vm, (SQInteger)value);
return true;
}

Loading…
Cancel
Save