Review fixes

This commit is contained in:
Michael Bernardi committed 2026-04-01 02:19:02 +11:00
1 parent e924c00a0d
commit 7aa5a067d1
9 files changed
+9 -29

No files matched your search

@@ -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/../")
target_include_directories(openrct2-ui PRIVATE "/opt/openrct2/include/nlohmann/../")
+1 -1
View File
@@ -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)); });
}
}
@@ -244,6 +244,7 @@ namespace OpenRCT2::Scripting
if (index)
{
TitleSequenceRenamePark(*seq, *index, valueStr.c_str());
data->_fileName = valueStr;
TitleSequenceSave(*seq);
}
}
+1 -1
View File
@@ -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
}
+1 -1
View File
@@ -1828,7 +1828,7 @@ std::pair<std::unique_ptr<GameActions::GameAction>, 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);
-21
View File
@@ -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
@@ -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)
@@ -186,7 +186,7 @@ namespace OpenRCT2::Scripting
auto peep = GetPeep(thisVal);
if (peep != nullptr)
{
value = std::clamp(static_cast<uint8_t>(value), kPeepMinEnergy, kPeepMaxEnergy);
value = static_cast<uint8_t>(std::clamp<uint32_t>(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<uint8_t>(value), kPeepMinEnergy, kPeepMaxEnergyTarget);
auto target = static_cast<uint8_t>(std::clamp<uint32_t>(value, kPeepMinEnergy, kPeepMaxEnergyTarget));
peep->EnergyTarget = target;
}
return JS_UNDEFINED;
@@ -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()));