forked from mirrors/0ad
Return the value from GuiPoll
This commit is contained in:
@@ -357,16 +357,15 @@ void CNetClient::CheckServerConnection()
|
||||
}
|
||||
}
|
||||
|
||||
void CNetClient::GuiPoll(const ScriptRequest& rq, JS::MutableHandleValue ret)
|
||||
JS::Value CNetClient::GuiPoll(const ScriptRequest& rq)
|
||||
{
|
||||
if (m_GuiMessageQueue.empty())
|
||||
{
|
||||
ret.setUndefined();
|
||||
return;
|
||||
}
|
||||
return JS::UndefinedValue();
|
||||
|
||||
Script::ReadStructuredClone(rq, m_GuiMessageQueue.front(), ret);
|
||||
JS::RootedValue ret{rq.cx};
|
||||
Script::ReadStructuredClone(rq, m_GuiMessageQueue.front(), &ret);
|
||||
m_GuiMessageQueue.pop_front();
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string CNetClient::TestReadGuiMessages()
|
||||
@@ -374,10 +373,9 @@ std::string CNetClient::TestReadGuiMessages()
|
||||
ScriptRequest rq(GetScriptInterface());
|
||||
|
||||
std::string r;
|
||||
JS::RootedValue msg(rq.cx);
|
||||
while (true)
|
||||
{
|
||||
GuiPoll(rq, &msg);
|
||||
JS::RootedValue msg{rq.cx, GuiPoll(rq)};
|
||||
if (msg.isUndefined())
|
||||
break;
|
||||
r += Script::ToString(rq, &msg) + "\n";
|
||||
|
||||
@@ -156,7 +156,7 @@ public:
|
||||
*
|
||||
* @return next message, or the value 'undefined' if the queue is empty
|
||||
*/
|
||||
void GuiPoll(const ScriptRequest& rq, JS::MutableHandleValue ret);
|
||||
JS::Value GuiPoll(const ScriptRequest& rq);
|
||||
|
||||
/**
|
||||
* Add a message to the queue, to be read by GuiPoll.
|
||||
|
||||
@@ -198,12 +198,7 @@ CStr GetPlayerGUID()
|
||||
|
||||
JS::Value PollNetworkClient(const ScriptRequest& rq)
|
||||
{
|
||||
if (!g_NetClient)
|
||||
return JS::UndefinedValue();
|
||||
|
||||
JS::RootedValue message{rq.cx};
|
||||
g_NetClient->GuiPoll(rq, &message);
|
||||
return message;
|
||||
return g_NetClient ? g_NetClient->GuiPoll(rq) : JS::UndefinedValue();
|
||||
}
|
||||
|
||||
void SendGameSetupMessage(const ScriptInterface& scriptInterface, JS::HandleValue attribs1)
|
||||
|
||||
Reference in New Issue
Block a user