From 1e489124cb895e4c7f9c5d974ae846b760d1c6d8 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 31 Jan 2024 01:24:59 +0100 Subject: Store matching replay_id in game_snap. --- tools/patchgame.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'tools/patchgame.js') diff --git a/tools/patchgame.js b/tools/patchgame.js index b149460..3a21f67 100755 --- a/tools/patchgame.js +++ b/tools/patchgame.js @@ -11,7 +11,7 @@ let delete_replay = db.prepare("delete from game_replay where game_id=?") let insert_replay = db.prepare("insert into game_replay (game_id,replay_id,role,action,arguments) values (?,?,?,?,?)") let delete_snap = db.prepare("delete from game_snap where game_id=?") -let insert_snap = db.prepare("insert into game_snap(game_id,snap_id,state) values (?,?,?)") +let insert_snap = db.prepare("insert into game_snap(game_id,snap_id,replay_id,state) values (?,?,?,?)") let update_state = db.prepare("update game_state set state=? where game_id=?") let update_active = db.prepare("update games set active=? where game_id=?") @@ -162,10 +162,9 @@ function patch_game(game_id, {validate_actions=true, save_snaps=true, delete_und if (need_to_rewrite) { delete_replay.run(game_id) - let replay_id = 0 for (item of replay) if (!item.remove) - insert_replay.run(game_id, ++replay_id, item.role, item.action, item.arguments) + insert_replay.run(game_id, item.replay_id, item.role, item.action, item.arguments) } if (save_snaps) { @@ -173,7 +172,7 @@ function patch_game(game_id, {validate_actions=true, save_snaps=true, delete_und let snap_id = 0 for (item of replay) if (item.save) - insert_snap.run(game_id, ++snap_id, item.state) + insert_snap.run(game_id, ++snap_id, item.replay_id, item.state) } update_active.run(state.active, game_id) -- cgit v1.2.3