From 0781ff31ec85a8dd24f66b9c66f152a8dd057c55 Mon Sep 17 00:00:00 2001 From: p2r3 Date: Tue, 15 Oct 2024 20:46:11 +0000 Subject: [PATCH] fix(lobby): apply several small stability patches all of these have been tested in production, i think we're well past needing a pr --- defaults/live/main.js | 2 +- pages/live/lobby.js | 13 +++++++++---- util/lobbies.js | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/defaults/live/main.js b/defaults/live/main.js index d5a1392..93623b0 100644 --- a/defaults/live/main.js +++ b/defaults/live/main.js @@ -99,7 +99,7 @@ function processConsoleOutput () { } // Process map transition event - if (line.indexOf("DEFAULT_WRITE_PATH") !== -1 && line.indexOf(runMap) === -1) { + if (line.indexOf("DEFAULT_WRITE_PATH") !== -1 && line.indexOf(runMap.split("/").pop()) === -1) { // Notice that we don't actually request a new time report // Instead, we tell it to treat the last one (start of map load) as a map finish event expectReport = 3; diff --git a/pages/live/lobby.js b/pages/live/lobby.js index d4eb378..7a395f0 100644 --- a/pages/live/lobby.js +++ b/pages/live/lobby.js @@ -24,14 +24,19 @@ async function updatePlayerList () { const runA = leaderboard.find(c => c.steamid === a); const runB = leaderboard.find(c => c.steamid === b); - // In the event of a tie, prefer the lobby host - if (runA === runB) { + const runATime = runA && runA.time; + const runBTime = runB && runB.time; + + if (runATime === runBTime) { + // In the event of a tie, prefer the lobby host if (a === lobby.data.host) return -1; if (b === lobby.data.host) return 1; + // If neither player is host, sort by SteamID string + return a < b ? 1 : -1; } - if (!runA) return 1; - if (!runB) return -1; + if (!runATime) return 1; + if (!runBTime) return -1; return runA.time - runB.time; }); diff --git a/util/lobbies.js b/util/lobbies.js index 1707086..4a06539 100644 --- a/util/lobbies.js +++ b/util/lobbies.js @@ -234,8 +234,9 @@ module.exports = async function (args, context = epochtal) { break; } } - if (everyoneReady) { + if (everyoneReady && dataEntry.state !== LOBBY_INGAME) { dataEntry.state = LOBBY_INGAME; + const mapFile = dataEntry.context.data.map.file; await events(["send", eventName, { type: "lobby_start", map: mapFile }], context); }