Swap Duktape for quickjs-ng

Co-authored-by: Basssiiie <Basssiiie@users.noreply.github.com>
Co-authored-by: Tulio Leao <tupaschoal@gmail.com>
This commit is contained in:
committed 2026-04-01 02:18:36 +11:00
1 parent 69518538fd
commit 16cd1c07ff
143 files changed
+97493 -120975

No files matched your search

+24 -25
View File
@@ -1900,18 +1900,19 @@ namespace OpenRCT2::Network
auto ctx = GetContext()->GetScriptEngine().GetContext();
// Create event args object
DukObject eObj(ctx);
eObj.Set("name", name);
eObj.Set("publicKeyHash", publicKeyHash);
eObj.Set("ipAddress", connection.Socket->GetIpAddress());
eObj.Set("cancel", false);
auto e = eObj.Take();
JSValue obj = JS_NewObject(ctx);
JS_SetPropertyStr(ctx, obj, "name", JSFromStdString(ctx, name));
JS_SetPropertyStr(ctx, obj, "publicKeyHash", JSFromStdString(ctx, publicKeyHash));
JS_SetPropertyStr(ctx, obj, "ipAddress", JSFromStdString(ctx, connection.Socket->GetIpAddress()));
JS_SetPropertyStr(ctx, obj, "cancel", JS_NewBool(ctx, false));
// Call the subscriptions
hookEngine.Call(HookType::networkAuthenticate, e, false);
hookEngine.Call(HookType::networkAuthenticate, obj, false, true);
// Check if any hook has cancelled the join
if (AsOrDefault(e["cancel"], false))
const bool canceled = AsOrDefault(ctx, obj, "cancel", false);
JS_FreeValue(ctx, obj);
if (canceled)
{
return false;
}
@@ -1931,12 +1932,11 @@ namespace OpenRCT2::Network
auto ctx = GetContext()->GetScriptEngine().GetContext();
// Create event args object
DukObject eObj(ctx);
eObj.Set("player", playerId);
auto e = eObj.Take();
JSValue obj = JS_NewObject(ctx);
JS_SetPropertyStr(ctx, obj, "player", JS_NewInt32(ctx, playerId));
// Call the subscriptions
hookEngine.Call(HookType::networkJoin, e, false);
hookEngine.Call(HookType::networkJoin, obj, false);
}
#endif
}
@@ -1952,12 +1952,11 @@ namespace OpenRCT2::Network
auto ctx = GetContext()->GetScriptEngine().GetContext();
// Create event args object
DukObject eObj(ctx);
eObj.Set("player", playerId);
auto e = eObj.Take();
JSValue obj = JS_NewObject(ctx);
JS_SetPropertyStr(ctx, obj, "player", JS_NewInt32(ctx, playerId));
// Call the subscriptions
hookEngine.Call(HookType::networkLeave, e, false);
hookEngine.Call(HookType::networkJoin, obj, false);
}
#endif
}
@@ -2902,23 +2901,23 @@ namespace OpenRCT2::Network
auto ctx = GetContext()->GetScriptEngine().GetContext();
// Create event args object
auto objIdx = duk_push_object(ctx);
duk_push_number(ctx, playerId);
duk_put_prop_string(ctx, objIdx, "player");
duk_push_string(ctx, text.c_str());
duk_put_prop_string(ctx, objIdx, "message");
auto e = DukValue::take_from_stack(ctx);
JSValue obj = JS_NewObject(ctx);
JS_SetPropertyStr(ctx, obj, "player", JS_NewInt32(ctx, playerId));
JS_SetPropertyStr(ctx, obj, "message", Scripting::JSFromStdString(ctx, text));
// Call the subscriptions
hookEngine.Call(Scripting::HookType::networkChat, e, false);
hookEngine.Call(Scripting::HookType::networkChat, obj, false, true);
// Update text from object if subscriptions changed it
if (e["message"].type() != DukValue::Type::STRING)
auto message = Scripting::JSToOptionalStdString(ctx, obj, "message");
JS_FreeValue(ctx, obj);
if (!message.has_value())
{
// Subscription set text to non-string, do not relay message
return false;
}
text = e["message"].as_string();
text = message.value();
if (text.empty())
{
// Subscription set text to empty string, do not relay message