Merge commit from fork

This commit is contained in:
Alex Pickett
2026-04-20 11:18:02 -07:00
committed by GitHub
parent c3d7d0373e
commit 328b8859d3
3 changed files with 20 additions and 4 deletions
+6 -1
View File
@@ -59,7 +59,12 @@ export class GameManager {
creatorPersistentID?: string,
startsAt?: number,
publicGameType?: PublicGameType,
) {
): GameServer | null {
if (this.games.has(id)) {
this.log.warn("cannot create game, id already exists", { gameID: id });
return null;
}
const game = new GameServer(
id,
this.log,
+8 -1
View File
@@ -200,6 +200,10 @@ export async function startWorker() {
// Pass creatorPersistentID to createGame
const game = gm.createGame(id, gc, creatorPersistentID);
if (game === null) {
log.warn(`cannot create game, id ${id} already exists`);
return res.status(409).json({ error: "Game ID already exists" });
}
log.info(
`Worker ${workerId}: IP ${ipAnonymize(clientIP)} creating ${game.isPublic() ? GameType.Public : GameType.Private}${gc?.gameMode ? ` ${gc.gameMode}` : ""} game with id ${id}${creatorPersistentID ? `, creator: ${creatorPersistentID.substring(0, 8)}...` : ""}`,
@@ -599,12 +603,15 @@ async function startMatchmakingPolling(gm: GameManager) {
log.info(`Lobby poll successful:`, data);
if (data.assignment) {
gm.createGame(
const game = gm.createGame(
gameId,
playlist.get1v1Config(),
undefined,
Date.now() + 7000,
);
if (game === null) {
log.warn(`Failed to create matchmaking game ${gameId}`);
}
}
} catch (error) {
if (error instanceof Error && error.name === "AbortError") {
+6 -2
View File
@@ -44,20 +44,24 @@ export class WorkerLobbyService {
// Update master with my lobby info
this.sendMyLobbiesToMaster();
break;
case "createGame":
case "createGame": {
if (this.gm.game(msg.gameID) !== null) {
this.log.warn(`Game ${msg.gameID} already exists, skipping create`);
return;
}
this.log.info(`Creating public game ${msg.gameID} from master`);
this.gm.createGame(
const game = this.gm.createGame(
msg.gameID,
msg.gameConfig,
undefined,
undefined,
msg.publicGameType,
);
if (game === null) {
this.log.warn(`Game ${msg.gameID} already exists, skipping create`);
}
break;
}
case "updateLobby": {
const game = this.gm.game(msg.gameID);
if (!game) {