Skip to content

Commit

Permalink
fix(lobby): apply several small stability patches
Browse files Browse the repository at this point in the history
all of these have been tested in production, i think we're well past needing a pr
  • Loading branch information
p2r3 committed Oct 15, 2024
1 parent cada477 commit 0781ff3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion defaults/live/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 9 additions & 4 deletions pages/live/lobby.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

});
Expand Down
3 changes: 2 additions & 1 deletion util/lobbies.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 0781ff3

Please sign in to comment.