diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-01-31 01:24:59 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-02-07 20:55:56 +0100 |
commit | 1e489124cb895e4c7f9c5d974ae846b760d1c6d8 (patch) | |
tree | 299ea5a24a8a184c11e1c79649cea210f6bac007 /tools/patchgame.js | |
parent | 8da3c4a8fedd7a26d4a323822146eb3a91d39cd1 (diff) | |
download | server-1e489124cb895e4c7f9c5d974ae846b760d1c6d8.tar.gz |
Store matching replay_id in game_snap.
Diffstat (limited to 'tools/patchgame.js')
-rwxr-xr-x | tools/patchgame.js | 7 |
1 files changed, 3 insertions, 4 deletions
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) |