Fix game timer: cycle-key tracking, wall-clock only, active gate
games_sp.log is not wiped on restart, so old J; lines from prior sessions were poisoning the anchor. Now the scanner walks the tail backward to the LATEST InitGame and only considers lines after it, returning an opaque cycle key (the first J; line) plus a state. The worker stamps game_started_at/ended_at with Date.now() at observation time instead of inferring from the log's own timestamps. Same-players game restarts produce a new key and cleanly re-anchor. When the server transitions to 0 players, game state is cleared server-side and the UI also gates the timer display on activeSince. Adds servers.game_cycle_key column with additive migration.
This commit is contained in:
@@ -42,7 +42,8 @@ const SERVERS_COLUMNS: Array<{ name: string; ddl: string }> = [
|
||||
{ name: 'active_since', ddl: 'ALTER TABLE servers ADD COLUMN active_since TEXT' },
|
||||
{ name: 'inactive_since', ddl: 'ALTER TABLE servers ADD COLUMN inactive_since TEXT' },
|
||||
{ name: 'game_started_at', ddl: 'ALTER TABLE servers ADD COLUMN game_started_at TEXT' },
|
||||
{ name: 'game_ended_at', ddl: 'ALTER TABLE servers ADD COLUMN game_ended_at TEXT' }
|
||||
{ name: 'game_ended_at', ddl: 'ALTER TABLE servers ADD COLUMN game_ended_at TEXT' },
|
||||
{ name: 'game_cycle_key', ddl: 'ALTER TABLE servers ADD COLUMN game_cycle_key TEXT' }
|
||||
];
|
||||
|
||||
function migrateServers(handle: Database.Database): void {
|
||||
|
||||
Reference in New Issue
Block a user