summaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-09-10 15:54:09 +0200
committerTor Andersson <tor@ccxvii.net>2024-09-10 15:58:35 +0200
commitcb8c881b2792579d5b85e4b7a395e40eba1d3fc5 (patch)
tree1e5e8191894663bb8d9a862eb1cf45ac3cb16042 /server.js
parent66a395d7a2dfdb6a627fe04ec06a7a7a921a739b (diff)
downloadserver-cb8c881b2792579d5b85e4b7a395e40eba1d3fc5.tar.gz
Add clock time when admin rewinds a game and time is low.
Diffstat (limited to 'server.js')
-rw-r--r--server.js2
1 files changed, 2 insertions, 0 deletions
diff --git a/server.js b/server.js
index 07b9827..90261a3 100644
--- a/server.js
+++ b/server.js
@@ -1296,6 +1296,7 @@ const SQL_FINISH_GAME = SQL(`
game_id = ?
`)
+const SQL_REWIND_GAME_CLOCK = SQL("update players set clock=1 where game_id=? and clock < 1")
const SQL_REWIND_GAME = SQL("update games set status=1,moves=?,active=?,mtime=datetime() where game_id=?")
const SQL_SELECT_REWIND = SQL("select snap_id, state->>'$.active' as active, state->>'$.state' as state from game_snap where game_id=? order by snap_id desc")
@@ -2159,6 +2160,7 @@ function rewind_game_to_snap(game_id, snap_id, res) {
SQL_INSERT_GAME_STATE.run(game_id, JSON.stringify(snap_state))
SQL_REWIND_GAME.run(snap_id - 1, snap_state.active, game_id)
+ SQL_REWIND_GAME_CLOCK.run(game_id)
update_join_clients(game_id)
if (game_clients[game_id])