mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-27 22:52:04 +00:00
Provide ScriptInterface CreateObject and CreateArray functions to replace Eval calls following 7c2e9027c2, 1c0536bf08 and later.
Differential Revision: https://code.wildfiregames.com/D2080 Previous version reviewed By: Krinkle Comments By: historic_bruno, wraitii This was SVN commit r22528.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2018 Wildfire Games.
|
||||
/* Copyright (C) 2019 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -295,11 +295,14 @@ void CNetClient::PostPlayerAssignmentsToScript()
|
||||
for (const std::pair<CStr, PlayerAssignment>& p : m_PlayerAssignments)
|
||||
{
|
||||
JS::RootedValue assignment(cx);
|
||||
GetScriptInterface().Eval("({})", &assignment);
|
||||
GetScriptInterface().SetProperty(assignment, "name", CStrW(p.second.m_Name), false);
|
||||
GetScriptInterface().SetProperty(assignment, "player", p.second.m_PlayerID, false);
|
||||
GetScriptInterface().SetProperty(assignment, "status", p.second.m_Status, false);
|
||||
GetScriptInterface().SetProperty(newAssignments, p.first.c_str(), assignment, false);
|
||||
|
||||
GetScriptInterface().CreateObject(
|
||||
&assignment,
|
||||
"name", CStrW(p.second.m_Name),
|
||||
"player", p.second.m_PlayerID,
|
||||
"status", p.second.m_Status);
|
||||
|
||||
GetScriptInterface().SetProperty(newAssignments, p.first.c_str(), assignment);
|
||||
}
|
||||
|
||||
PushGuiMessage(msg);
|
||||
@@ -760,10 +763,12 @@ bool CNetClient::OnKicked(void *context, CFsmEvent* event)
|
||||
CKickedMessage* message = (CKickedMessage*)event->GetParamRef();
|
||||
JS::RootedValue msg(cx);
|
||||
|
||||
client->GetScriptInterface().Eval("({})", &msg);
|
||||
client->GetScriptInterface().SetProperty(msg, "username", message->m_Name);
|
||||
client->GetScriptInterface().SetProperty(msg, "type", CStr("kicked"));
|
||||
client->GetScriptInterface().SetProperty(msg, "banned", message->m_Ban != 0);
|
||||
client->GetScriptInterface().CreateObject(
|
||||
&msg,
|
||||
"username", message->m_Name,
|
||||
"type", CStr("kicked"),
|
||||
"banned", message->m_Ban != 0);
|
||||
|
||||
client->PushGuiMessage(msg);
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user