mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 12:32:21 +00:00
fix: track desynced clients as live set instead of accumulating count
This commit is contained in:
@@ -104,11 +104,10 @@ export class GameManager {
|
||||
}
|
||||
|
||||
desyncCount(): number {
|
||||
let totalDesyncs = 0;
|
||||
this.games.forEach((game: GameServer) => {
|
||||
totalDesyncs += game.desyncCount;
|
||||
});
|
||||
return totalDesyncs;
|
||||
return [...this.games.values()].reduce(
|
||||
(acc, game) => acc + game.numDesyncedClients(),
|
||||
0,
|
||||
);
|
||||
}
|
||||
|
||||
tick() {
|
||||
|
||||
@@ -79,8 +79,6 @@ export class GameServer {
|
||||
|
||||
private _hasEnded = false;
|
||||
|
||||
public desyncCount = 0;
|
||||
|
||||
private lobbyInfoIntervalId: ReturnType<typeof setInterval> | null = null;
|
||||
|
||||
constructor(
|
||||
@@ -533,6 +531,10 @@ export class GameServer {
|
||||
return this.activeClients.length;
|
||||
}
|
||||
|
||||
public numDesyncedClients(): number {
|
||||
return this.outOfSyncClients.size;
|
||||
}
|
||||
|
||||
public prestart() {
|
||||
if (this.hasStarted()) {
|
||||
return;
|
||||
@@ -983,8 +985,6 @@ export class GameServer {
|
||||
const { mostCommonHash, outOfSyncClients } =
|
||||
this.findOutOfSyncClients(lastHashTurn);
|
||||
|
||||
this.desyncCount += outOfSyncClients.length;
|
||||
|
||||
if (outOfSyncClients.length === 0) {
|
||||
this.turns[lastHashTurn].hash = mostCommonHash;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user