Skip to content

Commit

Permalink
bump version number; fix: game never starts after a player joins & le…
Browse files Browse the repository at this point in the history
…aves; edge case causing "Game in progress" to appear; enhance: improve gas debug mode
  • Loading branch information
hsanger committed Jul 4, 2023
1 parent a8de6a1 commit c220a2e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "suroi",
"version": "0.6.2",
"version": "0.6.3",
"description": "An open-source 2D battle royale game inspired by surviv.io",
"private": true,
"scripts": {
Expand Down
16 changes: 9 additions & 7 deletions server/src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,10 @@ export class Game {
// End the game in 1 second
this.allowJoin = false;
this.over = true;
setTimeout(() => endGame(this.id), 1000);

// Create a new game
const id = this.id === 0 ? 1 : 0;
createNewGame(id);
setTimeout(() => {
endGame(this.id); // End this game
createNewGame(this.id); // Create a new game
}, 1000);
}

// Record performance and start the next tick
Expand Down Expand Up @@ -524,7 +523,10 @@ export class Game {
console.error("Error destroying player body. Details: ", e);
}
}
if (this.aliveCount < 2) clearTimeout(this.startTimeoutID);
if (this.aliveCount < 2) {
clearTimeout(this.startTimeoutID);
this.startTimeoutID = undefined;
}
try {
player.socket.close();
} catch (e) { }
Expand Down Expand Up @@ -607,7 +609,7 @@ export class Game {
if (currentStage.state === GasState.Waiting) {
this.gas.oldPosition = vClone(this.gas.newPosition);
if (currentStage.newRadius !== 0) {
this.gas.newPosition = randomPointInsideCircle(this.gas.oldPosition, currentStage.oldRadius - currentStage.newRadius);
this.gas.newPosition = Config.gas.mode !== GasMode.Debug ? randomPointInsideCircle(this.gas.oldPosition, currentStage.oldRadius - currentStage.newRadius) : v(360, 360);
} else {
this.gas.newPosition = vClone(this.gas.oldPosition);
}
Expand Down

0 comments on commit c220a2e

Please sign in to comment.