Index: ps/trunk/binaries/data/mods/public/gui/lobby/lobby.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/lobby/lobby.js +++ ps/trunk/binaries/data/mods/public/gui/lobby/lobby.js @@ -1289,7 +1289,7 @@ g_NetMessageTypes[msg.type][msg.level](msg); } - if (Engine.LobbyGuiPollPresenceStatusUpdate()) + if (Engine.LobbyGuiPollHasPlayerListUpdate()) updatePlayerList(); } Index: ps/trunk/source/lobby/IXmppClient.h =================================================================== --- ps/trunk/source/lobby/IXmppClient.h +++ ps/trunk/source/lobby/IXmppClient.h @@ -54,9 +54,11 @@ virtual void GUIGetGameList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0; virtual void GUIGetBoardList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0; virtual void GUIGetProfile(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret) = 0; - virtual bool GuiPollPresenceStatusUpdate() = 0; + virtual JS::Value GuiPollNewMessage(const ScriptInterface& scriptInterface) = 0; virtual JS::Value GuiPollHistoricMessages(const ScriptInterface& scriptInterface) = 0; + virtual bool GuiPollHasPlayerListUpdate() = 0; + virtual void SendMUCMessage(const std::string& message) = 0; virtual void SendStunEndpointToHost(const StunClient::StunEndpoint& stunEndpoint, const std::string& hostJID) = 0; }; Index: ps/trunk/source/lobby/XmppClient.h =================================================================== --- ps/trunk/source/lobby/XmppClient.h +++ ps/trunk/source/lobby/XmppClient.h @@ -148,9 +148,9 @@ std::time_t ComputeTimestamp(const glooxwrapper::Message& msg) const; public: - bool GuiPollPresenceStatusUpdate(); JS::Value GuiPollNewMessage(const ScriptInterface& scriptInterface); JS::Value GuiPollHistoricMessages(const ScriptInterface& scriptInterface); + bool GuiPollHasPlayerListUpdate(); void SendMUCMessage(const std::string& message); protected: @@ -164,6 +164,8 @@ private: /// Map of players std::map > m_PlayerMap; + /// Whether or not the playermap has changed since the last time the GUI checked. + bool m_PlayerMapUpdate; /// List of games std::vector m_GameList; /// List of rankings @@ -178,8 +180,6 @@ std::vector > m_HistoricGuiMessages; /// Current room subject/topic. std::string m_Subject; - /// Whether or not a player has changed the presence status since the last time the GUI checked. - bool m_PresenceUpdate; }; #endif // XMPPCLIENT_H Index: ps/trunk/source/lobby/XmppClient.cpp =================================================================== --- ps/trunk/source/lobby/XmppClient.cpp +++ ps/trunk/source/lobby/XmppClient.cpp @@ -91,7 +91,7 @@ m_isConnected(false), m_sessionManager(nullptr), m_certStatus(gloox::CertStatus::CertOk), - m_PresenceUpdate(false) + m_PlayerMapUpdate(false) { if (m_ScriptInterface) JS_AddExtraGCRootsTracer(m_ScriptInterface->GetJSRuntime(), XmppClient::Trace, this); @@ -275,10 +275,11 @@ m_BoardList.clear(); m_GameList.clear(); m_PlayerMap.clear(); + m_PlayerMapUpdate = true; m_Profile.clear(); m_HistoricGuiMessages.clear(); - m_isConnected = false; + CreateGUIMessage( "system", "disconnected", @@ -681,10 +682,10 @@ m_GuiMessageQueue.push_back(JS::Heap(message)); } -bool XmppClient::GuiPollPresenceStatusUpdate() +bool XmppClient::GuiPollHasPlayerListUpdate() { - bool hasUpdate = m_PresenceUpdate; - m_PresenceUpdate = false; + bool hasUpdate = m_PlayerMapUpdate; + m_PlayerMapUpdate = false; return hasUpdate; } @@ -808,9 +809,11 @@ { std::string name = t->findAttribute("name").to_string(); if (m_PlayerMap.find(name) != m_PlayerMap.end()) + { m_PlayerMap[name][1] = t->findAttribute("rating").to_string(); + m_PlayerMapUpdate = true; + } } - CreateGUIMessage("game", "ratinglist", std::time(nullptr)); } } @@ -909,16 +912,19 @@ else if (m_PlayerMap[nick][2] != roleString) CreateGUIMessage("chat", "role", std::time(nullptr), "nick", nick, "oldrole", m_PlayerMap[nick][2], "newrole", roleString); else + { // Don't create a GUI message for regular presence changes, because // several hundreds of them accumulate during a match, impacting performance terribly and // the only way they are used is to determine whether to update the playerlist. - m_PresenceUpdate = true; + } DbgXMPP(nick << " is in the room, presence : " << (int)presenceType); m_PlayerMap[nick].resize(3); m_PlayerMap[nick][0] = presenceString; m_PlayerMap[nick][2] = roleString; } + + m_PlayerMapUpdate = true; } /** Index: ps/trunk/source/lobby/scripting/JSInterface_Lobby.h =================================================================== --- ps/trunk/source/lobby/scripting/JSInterface_Lobby.h +++ ps/trunk/source/lobby/scripting/JSInterface_Lobby.h @@ -48,9 +48,9 @@ JS::Value GetGameList(ScriptInterface::CxPrivate* pCxPrivate); JS::Value GetBoardList(ScriptInterface::CxPrivate* pCxPrivate); JS::Value GetProfile(ScriptInterface::CxPrivate* pCxPrivate); - bool LobbyGuiPollPresenceStatusUpdate(ScriptInterface::CxPrivate* pCxPrivate); JS::Value LobbyGuiPollNewMessage(ScriptInterface::CxPrivate* pCxPrivate); JS::Value LobbyGuiPollHistoricMessages(ScriptInterface::CxPrivate* pCxPrivate); + bool LobbyGuiPollHasPlayerListUpdate(ScriptInterface::CxPrivate* pCxPrivate); void LobbySendMessage(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& message); void LobbySetPlayerPresence(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& presence); void LobbySetNick(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nick); Index: ps/trunk/source/lobby/scripting/JSInterface_Lobby.cpp =================================================================== --- ps/trunk/source/lobby/scripting/JSInterface_Lobby.cpp +++ ps/trunk/source/lobby/scripting/JSInterface_Lobby.cpp @@ -56,9 +56,9 @@ scriptInterface.RegisterFunction("GetGameList"); scriptInterface.RegisterFunction("GetBoardList"); scriptInterface.RegisterFunction("GetProfile"); - scriptInterface.RegisterFunction("LobbyGuiPollPresenceStatusUpdate"); scriptInterface.RegisterFunction("LobbyGuiPollNewMessage"); scriptInterface.RegisterFunction("LobbyGuiPollHistoricMessages"); + scriptInterface.RegisterFunction("LobbyGuiPollHasPlayerListUpdate"); scriptInterface.RegisterFunction("LobbySendMessage"); scriptInterface.RegisterFunction("LobbySetPlayerPresence"); scriptInterface.RegisterFunction("LobbySetNick"); @@ -238,9 +238,9 @@ return profileFetch; } -bool JSI_Lobby::LobbyGuiPollPresenceStatusUpdate(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) +bool JSI_Lobby::LobbyGuiPollHasPlayerListUpdate(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) { - return g_XmppClient && g_XmppClient->GuiPollPresenceStatusUpdate(); + return g_XmppClient && g_XmppClient->GuiPollHasPlayerListUpdate(); } JS::Value JSI_Lobby::LobbyGuiPollNewMessage(ScriptInterface::CxPrivate* pCxPrivate)