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 @@ -91,6 +91,11 @@ var g_GameList = {}; /** + * All games where buddy joined. + */ +var g_GamesBuddy = undefined; + +/** * Used to restore the selection after updating the playerlist. */ var g_SelectedPlayer = ""; @@ -908,6 +913,9 @@ g_SelectedGamePort = g_GameList[gamesBox.selected].port; } + if (g_GamesBuddy) + g_GamesBuddy.aliveCompare = !g_GamesBuddy.aliveCompare; + g_GameList = Engine.GetGameList().map(game => { game.hasBuddies = 0; @@ -915,6 +923,14 @@ // Compute average rating of participating players let playerRatings = []; + let initGamesBuddy = !g_GamesBuddy; + if (initGamesBuddy) + g_GamesBuddy = {"games": [], "aliveCompare": true}; + if (!g_GamesBuddy.games[game]) + g_GamesBuddy.games[game] = {"alive": g_GamesBuddy.aliveCompare, "buddies": []}; + else + g_GamesBuddy.games[game].alive = g_GamesBuddy.aliveCompare; + for (let player of stringifiedTeamListToPlayerData(game.players)) { let [nick, rating] = splitRatingFromNick(player.Name); @@ -922,6 +938,20 @@ if (player.Team != "observer") playerRatings.push(rating || g_DefaultLobbyRating); + if (g_Buddies.indexOf(nick) != -1) + if (g_GamesBuddy.games[game].buddies.indexOf(nick) == -1) + { + g_GamesBuddy.games[game].buddies.push(nick); + if (!initGamesBuddy) + addChatMessage({ + "from": "info", + "text": sprintf( + translate("Buddy %(buddy)s has joined game %(game)s."), + {"buddy": g_BuddySymbol + " " + nick, "game": g_BuddySymbol + " " + game.name} + )} + ); + } + // Sort games with playing buddies above games with spectating buddies if (game.hasBuddies < 2 && g_Buddies.indexOf(nick) != -1) game.hasBuddies = player.Team == "observer" ? 1 : 2; @@ -965,6 +995,11 @@ return 0; }); + if (g_GamesBuddy) + for (let game of Object.keys(g_GamesBuddy.games)) + if (g_GamesBuddy.games[game].alive != g_GamesBuddy.aliveCompare) + delete g_GamesBuddy.games[game]; + let list_buddy = []; let list_name = []; let list_mapName = [];