diff --git a/src/openrct2-android/app/src/main/CMakeLists.txt b/src/openrct2-android/app/src/main/CMakeLists.txt index 28cfc374c4..a73bc8318d 100644 --- a/src/openrct2-android/app/src/main/CMakeLists.txt +++ b/src/openrct2-android/app/src/main/CMakeLists.txt @@ -264,4 +264,4 @@ target_include_directories(openrct2-cli PRIVATE "${ORCT2_ROOT}/src") target_include_directories(openrct2-cli SYSTEM PRIVATE "${ORCT2_ROOT}/src/thirdparty") target_include_directories(openrct2 PRIVATE "/opt/openrct2/include/nlohmann/../") -target_include_directories(openrct2-ui PRIVATE "/opt/openrct2/include/nlohmann/../") \ No newline at end of file +target_include_directories(openrct2-ui PRIVATE "/opt/openrct2/include/nlohmann/../") diff --git a/src/openrct2-ui/scripting/CustomImages.cpp b/src/openrct2-ui/scripting/CustomImages.cpp index 8abcab3b04..e4e0a56a9d 100644 --- a/src/openrct2-ui/scripting/CustomImages.cpp +++ b/src/openrct2-ui/scripting/CustomImages.cpp @@ -212,7 +212,7 @@ namespace OpenRCT2::Scripting JS_GetLength(ctx, data, &arrSz); if (arrSz > 0) { - result.resize(arrSz); + result.reserve(arrSz); JSIterateArray(ctx, data, [&result](JSContext* ctx2, JSValue val) { result.push_back(JSToInt(ctx2, val)); }); } } diff --git a/src/openrct2-ui/scripting/ScTitleSequence.hpp b/src/openrct2-ui/scripting/ScTitleSequence.hpp index 202f824410..c998877b57 100644 --- a/src/openrct2-ui/scripting/ScTitleSequence.hpp +++ b/src/openrct2-ui/scripting/ScTitleSequence.hpp @@ -244,6 +244,7 @@ namespace OpenRCT2::Scripting if (index) { TitleSequenceRenamePark(*seq, *index, valueStr.c_str()); + data->_fileName = valueStr; TitleSequenceSave(*seq); } } diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index 9daa234965..ac80e0a71d 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -1956,7 +1956,7 @@ namespace OpenRCT2::Network JS_SetPropertyStr(ctx, obj, "player", JS_NewInt32(ctx, playerId)); // Call the subscriptions - hookEngine.Call(HookType::networkJoin, obj, false); + hookEngine.Call(HookType::networkLeave, obj, false); } #endif } diff --git a/src/openrct2/scripting/ScriptEngine.cpp b/src/openrct2/scripting/ScriptEngine.cpp index 7555b6b470..e5a14c349f 100644 --- a/src/openrct2/scripting/ScriptEngine.cpp +++ b/src/openrct2/scripting/ScriptEngine.cpp @@ -1828,7 +1828,7 @@ std::pair, bool> ScriptEngine::CreateGa if (json.empty()) { JSValue emptyObj = JS_NewObject(ctx); - JSValue jsonVal = JS_JSONStringify(ctx, args, JS_UNDEFINED, JS_UNDEFINED); + JSValue jsonVal = JS_JSONStringify(ctx, emptyObj, JS_UNDEFINED, JS_UNDEFINED); json = JSToStdString(ctx, jsonVal); JS_FreeValue(ctx, emptyObj); JS_FreeValue(ctx, jsonVal); diff --git a/src/openrct2/scripting/ScriptUtil.hpp b/src/openrct2/scripting/ScriptUtil.hpp index c64a61a1fd..ca77f65ff7 100644 --- a/src/openrct2/scripting/ScriptUtil.hpp +++ b/src/openrct2/scripting/ScriptUtil.hpp @@ -588,27 +588,6 @@ namespace OpenRCT2::Scripting JS_ThrowTypeError(ctx, "Expected object"); \ return JS_EXCEPTION; \ } - - #define JS_UNPACK_COORDSXY(var, ctx, val) \ - CoordsXY var; \ - if (!JS_IsObject(var)) \ - { \ - JS_ThrowTypeError(ctx, "Expected CoordsXY"); \ - return JS_EXCEPTION; \ - } \ - { \ - auto x = JSToOptionalInt(ctx, position, "x"); \ - auto y = JSToOptionalInt(ctx, position, "y"); \ - if (x.has_value() && y.has_value()) \ - { \ - var = CoordsXY(x.value(), y.value()); \ - } \ - else \ - { \ - JS_ThrowTypeError(ctx, "Expected CoordsXY"); \ - return JS_EXCEPTION; \ - } \ - } } // namespace OpenRCT2::Scripting #endif diff --git a/src/openrct2/scripting/bindings/entity/ScMoneyEffect.cpp b/src/openrct2/scripting/bindings/entity/ScMoneyEffect.cpp index 0da7e23b8b..c9e4a45d21 100644 --- a/src/openrct2/scripting/bindings/entity/ScMoneyEffect.cpp +++ b/src/openrct2/scripting/bindings/entity/ScMoneyEffect.cpp @@ -39,7 +39,7 @@ namespace OpenRCT2::Scripting JSValue ScMoneyEffect::value_get(JSContext* ctx, JSValue thisVal) { auto moneyEffect = GetMoneyEffect(thisVal); - return JS_NewUint32(ctx, moneyEffect == nullptr ? 0 : moneyEffect->Value); + return JS_NewInt64(ctx, moneyEffect == nullptr ? 0 : moneyEffect->Value); } JSValue ScMoneyEffect::value_set(JSContext* ctx, JSValue thisVal, JSValue jsValue) diff --git a/src/openrct2/scripting/bindings/entity/ScPeep.hpp b/src/openrct2/scripting/bindings/entity/ScPeep.hpp index ca6305fd2c..8903860951 100644 --- a/src/openrct2/scripting/bindings/entity/ScPeep.hpp +++ b/src/openrct2/scripting/bindings/entity/ScPeep.hpp @@ -186,7 +186,7 @@ namespace OpenRCT2::Scripting auto peep = GetPeep(thisVal); if (peep != nullptr) { - value = std::clamp(static_cast(value), kPeepMinEnergy, kPeepMaxEnergy); + value = static_cast(std::clamp(value, kPeepMinEnergy, kPeepMaxEnergy)); peep->Energy = value; peep->Invalidate(); } @@ -205,7 +205,7 @@ namespace OpenRCT2::Scripting auto peep = GetPeep(thisVal); if (peep != nullptr) { - auto target = std::clamp(static_cast(value), kPeepMinEnergy, kPeepMaxEnergyTarget); + auto target = static_cast(std::clamp(value, kPeepMinEnergy, kPeepMaxEnergyTarget)); peep->EnergyTarget = target; } return JS_UNDEFINED; diff --git a/src/openrct2/scripting/bindings/entity/ScVehicle.cpp b/src/openrct2/scripting/bindings/entity/ScVehicle.cpp index c9ea754edf..73a28183bf 100644 --- a/src/openrct2/scripting/bindings/entity/ScVehicle.cpp +++ b/src/openrct2/scripting/bindings/entity/ScVehicle.cpp @@ -549,7 +549,7 @@ namespace OpenRCT2::Scripting // Set all peep slots between last valid peep and current to NULL (if there were any null peeps). for (size_t j = len; j < i; j++) { - JS_SetPropertyInt64(ctx, result, i, JS_NULL); + JS_SetPropertyInt64(ctx, result, j, JS_NULL); } JS_SetPropertyInt64(ctx, result, i, JS_NewUint32(ctx, peep.ToUnderlying()));