Index: binaries/data/mods/public/gui/lobby/lobby.js =================================================================== --- binaries/data/mods/public/gui/lobby/lobby.js +++ binaries/data/mods/public/gui/lobby/lobby.js @@ -1289,7 +1289,7 @@ g_NetMessageTypes[msg.type][msg.level](msg); } - if (Engine.LobbyGuiPollPresenceStatusUpdate()) + if (Engine.LobbyGuiPollPlayerListUpdate()) updatePlayerList(); } Index: source/lobby/IXmppClient.h =================================================================== --- source/lobby/IXmppClient.h +++ source/lobby/IXmppClient.h @@ -54,7 +54,7 @@ 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 bool GuiPollPlayerListUpdate() = 0; virtual JS::Value GuiPollNewMessage(const ScriptInterface& scriptInterface) = 0; virtual JS::Value GuiPollHistoricMessages(const ScriptInterface& scriptInterface) = 0; virtual void SendMUCMessage(const std::string& message) = 0; Index: source/lobby/XmppClient.h =================================================================== --- source/lobby/XmppClient.h +++ source/lobby/XmppClient.h @@ -148,7 +148,7 @@ std::time_t ComputeTimestamp(const glooxwrapper::Message& msg) const; public: - bool GuiPollPresenceStatusUpdate(); + bool GuiPollPlayerListUpdate(); JS::Value GuiPollNewMessage(const ScriptInterface& scriptInterface); JS::Value GuiPollHistoricMessages(const ScriptInterface& scriptInterface); void SendMUCMessage(const std::string& message); @@ -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: source/lobby/XmppClient.cpp =================================================================== --- source/lobby/XmppClient.cpp +++ 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::GuiPollPlayerListUpdate() { - bool hasUpdate = m_PresenceUpdate; - m_PresenceUpdate = false; + bool hasUpdate = m_PlayerMapUpdate; + m_PlayerMapUpdate = false; return hasUpdate; } @@ -810,7 +811,7 @@ 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 +910,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: source/lobby/scripting/JSInterface_Lobby.h =================================================================== --- source/lobby/scripting/JSInterface_Lobby.h +++ source/lobby/scripting/JSInterface_Lobby.h @@ -48,7 +48,7 @@ JS::Value GetGameList(ScriptInterface::CxPrivate* pCxPrivate); JS::Value GetBoardList(ScriptInterface::CxPrivate* pCxPrivate); JS::Value GetProfile(ScriptInterface::CxPrivate* pCxPrivate); - bool LobbyGuiPollPresenceStatusUpdate(ScriptInterface::CxPrivate* pCxPrivate); + bool LobbyGuiPollPlayerListUpdate(ScriptInterface::CxPrivate* pCxPrivate); JS::Value LobbyGuiPollNewMessage(ScriptInterface::CxPrivate* pCxPrivate); JS::Value LobbyGuiPollHistoricMessages(ScriptInterface::CxPrivate* pCxPrivate); void LobbySendMessage(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& message); Index: source/lobby/scripting/JSInterface_Lobby.cpp =================================================================== --- source/lobby/scripting/JSInterface_Lobby.cpp +++ source/lobby/scripting/JSInterface_Lobby.cpp @@ -56,7 +56,7 @@ scriptInterface.RegisterFunction("GetGameList"); scriptInterface.RegisterFunction("GetBoardList"); scriptInterface.RegisterFunction("GetProfile"); - scriptInterface.RegisterFunction("LobbyGuiPollPresenceStatusUpdate"); + scriptInterface.RegisterFunction("LobbyGuiPollPlayerListUpdate"); scriptInterface.RegisterFunction("LobbyGuiPollNewMessage"); scriptInterface.RegisterFunction("LobbyGuiPollHistoricMessages"); scriptInterface.RegisterFunction("LobbySendMessage"); @@ -238,9 +238,9 @@ return profileFetch; } -bool JSI_Lobby::LobbyGuiPollPresenceStatusUpdate(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) +bool JSI_Lobby::LobbyGuiPollPlayerListUpdate(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) { - return g_XmppClient && g_XmppClient->GuiPollPresenceStatusUpdate(); + return g_XmppClient && g_XmppClient->GuiPollPlayerListUpdate(); } JS::Value JSI_Lobby::LobbyGuiPollNewMessage(ScriptInterface::CxPrivate* pCxPrivate)