mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:10:42 +00:00
archive full game on crash (#251)
This commit is contained in:
@@ -193,7 +193,7 @@ export class ClientGameRunner {
|
||||
this.lobby.gameID,
|
||||
this.lobby.clientID,
|
||||
);
|
||||
this.stop();
|
||||
this.stop(true);
|
||||
return;
|
||||
}
|
||||
gu.updates[GameUpdateType.Hash].forEach((hu: HashUpdate) => {
|
||||
@@ -265,10 +265,10 @@ export class ClientGameRunner {
|
||||
this.transport.connect(onconnect, onmessage);
|
||||
}
|
||||
|
||||
public stop() {
|
||||
public stop(saveFullGame: boolean = false) {
|
||||
this.worker.cleanup();
|
||||
this.isActive = false;
|
||||
this.transport.leaveGame();
|
||||
this.transport.leaveGame(saveFullGame);
|
||||
}
|
||||
|
||||
private inputEvent(event: MouseUpEvent) {
|
||||
|
||||
@@ -144,7 +144,7 @@ export class LocalServer {
|
||||
});
|
||||
}
|
||||
|
||||
public endGame() {
|
||||
public endGame(saveFullGame: boolean = false) {
|
||||
consolex.log("local server ending game");
|
||||
clearInterval(this.endTurnIntervalID);
|
||||
const players: PlayerRecord[] = [
|
||||
@@ -165,8 +165,10 @@ export class LocalServer {
|
||||
this.winner,
|
||||
this.allPlayersStats,
|
||||
);
|
||||
// Clear turns because beacon only supports up to 64kb
|
||||
record.turns = [];
|
||||
if (!saveFullGame) {
|
||||
// Clear turns because beacon only supports up to 64kb
|
||||
record.turns = [];
|
||||
}
|
||||
// For unload events, sendBeacon is the only reliable method
|
||||
const blob = new Blob([JSON.stringify(GameRecordSchema.parse(record))], {
|
||||
type: "application/json",
|
||||
|
||||
@@ -319,9 +319,9 @@ export class Transport {
|
||||
);
|
||||
}
|
||||
|
||||
leaveGame() {
|
||||
leaveGame(saveFullGame: boolean = false) {
|
||||
if (this.isLocal) {
|
||||
this.localServer.endGame();
|
||||
this.localServer.endGame(saveFullGame);
|
||||
return;
|
||||
}
|
||||
this.stopPing();
|
||||
|
||||
Reference in New Issue
Block a user