Changeset View
Changeset View
Standalone View
Standalone View
source/lobby/scripting/JSInterface_Lobby.cpp
/* Copyright (C) 2014 Wildfire Games. | /* Copyright (C) 2017 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | #if CONFIG2_LOBBY // Allow the lobby to be disabled | ||||
scriptInterface.RegisterFunction<std::wstring, std::wstring, &JSI_Lobby::LobbyGetPlayerRole>("LobbyGetPlayerRole"); | scriptInterface.RegisterFunction<std::wstring, std::wstring, &JSI_Lobby::LobbyGetPlayerRole>("LobbyGetPlayerRole"); | ||||
scriptInterface.RegisterFunction<std::wstring, std::wstring, std::wstring, &JSI_Lobby::EncryptPassword>("EncryptPassword"); | scriptInterface.RegisterFunction<std::wstring, std::wstring, std::wstring, &JSI_Lobby::EncryptPassword>("EncryptPassword"); | ||||
scriptInterface.RegisterFunction<std::wstring, &JSI_Lobby::LobbyGetRoomSubject>("LobbyGetRoomSubject"); | scriptInterface.RegisterFunction<std::wstring, &JSI_Lobby::LobbyGetRoomSubject>("LobbyGetRoomSubject"); | ||||
#endif // CONFIG2_LOBBY | #endif // CONFIG2_LOBBY | ||||
} | } | ||||
bool JSI_Lobby::HasXmppClient(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) | bool JSI_Lobby::HasXmppClient(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) | ||||
{ | { | ||||
return (g_XmppClient ? true : false); | return g_XmppClient; | ||||
Sandarac: Is it possible that using a cast here might be (ever-so-slightly) slower? | |||||
} | } | ||||
bool JSI_Lobby::IsRankedGame(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) | bool JSI_Lobby::IsRankedGame(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) | ||||
{ | { | ||||
return g_rankedGame; | return g_rankedGame; | ||||
} | } | ||||
void JSI_Lobby::SetRankedGame(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), bool isRanked) | void JSI_Lobby::SetRankedGame(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), bool isRanked) | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | |||||
void JSI_Lobby::SendChangeStateGame(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& nbp, const std::wstring& players) | void JSI_Lobby::SendChangeStateGame(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& nbp, const std::wstring& players) | ||||
{ | { | ||||
if (!g_XmppClient) | if (!g_XmppClient) | ||||
return; | return; | ||||
g_XmppClient->SendIqChangeStateGame(utf8_from_wstring(nbp), utf8_from_wstring(players)); | g_XmppClient->SendIqChangeStateGame(utf8_from_wstring(nbp), utf8_from_wstring(players)); | ||||
} | } | ||||
JS::Value JSI_Lobby::GetPlayerList(ScriptInterface::CxPrivate* pCxPrivate) | JS::Value JSI_Lobby::GetPlayerList(ScriptInterface::CxPrivate* pCxPrivate) | ||||
{ | { | ||||
if (!g_XmppClient) | if (!g_XmppClient) | ||||
return JS::UndefinedValue(); | return JS::UndefinedValue(); | ||||
Not Done Inline ActionsDon't remove that. Imarok: Don't remove that. | |||||
Not Done Inline ActionsThis change is needed, as the JS code expects an array on disconnect elexis: This change is needed, as the JS code expects an array on disconnect | |||||
JSContext* cx = pCxPrivate->pScriptInterface->GetContext(); | JSContext* cx = pCxPrivate->pScriptInterface->GetContext(); | ||||
JSAutoRequest rq(cx); | JSAutoRequest rq(cx); | ||||
JS::RootedValue playerList(cx); | JS::RootedValue playerList(cx); | ||||
g_XmppClient->GUIGetPlayerList(*(pCxPrivate->pScriptInterface), &playerList); | g_XmppClient->GUIGetPlayerList(*(pCxPrivate->pScriptInterface), &playerList); | ||||
return playerList; | return playerList; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 187 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Is it possible that using a cast here might be (ever-so-slightly) slower?