Ticket #3171: t3171_clear_muc_messages_v6_16795.patch
File t3171_clear_muc_messages_v6_16795.patch, 4.5 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/lobby/lobby.js
12 12 var g_mapSizes = {}; 13 13 const g_mapTypesText = [translateWithContext("map", "Skirmish"), translateWithContext("map", "Random"), translate("Scenario")]; 14 14 const g_mapTypes = ["skirmish", "random", "scenario"]; 15 15 var g_userRating = ""; // Rating of user, defaults to Unrated 16 16 var g_modPrefix = "@"; 17 var g_joined = false;18 17 // Block spammers for 30 seconds. 19 18 var SPAM_BLOCK_LENGTH = 30; 20 19 21 20 //////////////////////////////////////////////////////////////////////////////////////////////// 22 21 … … 697 696 var ratingList = playersBox.list_rating; 698 697 var nickIndex = nickList.indexOf(nick); 699 698 switch(message.level) 700 699 { 701 700 case "join": 702 if (nick == g_Name) 703 { 704 // We just joined, we need to get the full player list 705 [playerList, presenceList, nickList, ratingList] = updatePlayerList(); 706 // Don't display any joins until our join request bounces back 707 // Our join message should be the last one as we just got added to the stack 708 g_joined = true; 709 break; 710 } 711 else if (g_joined) 712 { 713 var [name, status, rating] = formatPlayerListEntry(nick, presence, "-"); 714 playerList.push(name); 715 presenceList.push(status); 716 nickList.push(nick); 717 ratingList.push(String(rating)); 718 Engine.SendGetRatingList(); 719 addChatMessage({ "text": "/special " + sprintf(translate("%(nick)s has joined."), { nick: nick }), "key": g_specialKey }); 720 } 701 var [name, status, rating] = formatPlayerListEntry(nick, presence, "-"); 702 playerList.push(name); 703 presenceList.push(status); 704 nickList.push(nick); 705 ratingList.push(String(rating)); 706 Engine.SendGetRatingList(); 707 addChatMessage({ "text": "/special " + sprintf(translate("%(nick)s has joined."), { nick: nick }), "key": g_specialKey }); 721 708 break; 722 709 case "leave": 723 710 if (nickIndex == -1) // Left, but not present (TODO: warn about this?) 724 711 break; 725 712 playerList.splice(nickIndex, 1); -
source/lobby/XmppClient.cpp
77 77 78 78 m_xpartamuppId = sXpartamupp + "@" + sServer + "/CC"; 79 79 glooxwrapper::JID clientJid(sUsername + "@" + sServer + "/0ad"); 80 80 glooxwrapper::JID roomJid(sRoom + "@conference." + sServer + "/" + sNick); 81 81 82 m_bouncedBack = false; 83 82 84 // If we are connecting, use the full jid and a password 83 85 // If we are registering, only use the server name 84 86 if(!regOpt) 85 87 m_client = new glooxwrapper::Client(clientJid, sPassword); 86 88 else … … 492 494 * 493 495 * @return A JS array containing all known players and their presences 494 496 */ 495 497 void XmppClient::GUIGetPlayerList(ScriptInterface& scriptInterface, JS::MutableHandleValue ret) 496 498 { 499 // Clear outdated presence updates 500 std::remove_if(m_GuiMessageQueue.begin(), m_GuiMessageQueue.end(), 501 [](XmppClient::GUIMessage& message) 502 { 503 return message.type == L"muc"; 504 } 505 ); 506 497 507 JSContext* cx = scriptInterface.GetContext(); 498 508 JSAutoRequest rq(cx); 499 509 500 510 scriptInterface.Eval("([])", ret); 501 511 … … 800 810 m_PlayerMap.erase(nick); 801 811 } 802 812 else 803 813 { 804 814 if (m_PlayerMap.find(nick) == m_PlayerMap.end()) 805 CreateSimpleMessage("muc", nick, "join"); 815 { 816 if (nick == m_mucRoom->nick().to_string()) 817 m_bouncedBack = true; 818 819 // Don't display any joins until our join request bounces back 820 if (m_bouncedBack) 821 CreateSimpleMessage("muc", nick, "join"); 822 } 806 823 else 807 824 CreateSimpleMessage("muc", nick, "presence"); 808 825 809 826 DbgXMPP(nick << " is in the room, presence : " << (int)presenceType); 810 827 m_PlayerMap[nick].resize(3); -
source/lobby/XmppClient.h
138 138 protected: 139 139 void PushGuiMessage(XmppClient::GUIMessage message); 140 140 void CreateSimpleMessage(const std::string& type, const std::string& text, const std::string& level = "standard", const std::string& data = ""); 141 141 142 142 private: 143 // Whether or not we have successfully joined the lobby 144 bool m_bouncedBack; 143 145 /// Map of players 144 146 std::map<std::string, std::vector<std::string> > m_PlayerMap; 145 147 /// List of games 146 148 std::vector<const glooxwrapper::Tag*> m_GameList; 147 149 /// List of rankings