diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-07-24 12:04:57 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-08-10 22:34:33 +0200 |
commit | 1a90cb82b461568579e481f90b536e5cbd4fbf50 (patch) | |
tree | ea961cb16cee5cfc906db8920d9da9402745d047 | |
parent | 359e2c62ca54cf41d70635a994ca748fcca50f14 (diff) | |
download | server-1a90cb82b461568579e481f90b536e5cbd4fbf50.tar.gz |
Fix rematch button.
-rw-r--r-- | server.js | 2 | ||||
-rw-r--r-- | tools/undo.sh | 11 |
2 files changed, 9 insertions, 4 deletions
@@ -1121,7 +1121,7 @@ const SQL_DELETE_PLAYER_ROLE = SQL("DELETE FROM players WHERE game_id=? AND role const SQL_SELECT_OPEN_GAMES = SQL(`SELECT * FROM games WHERE status=${STATUS_OPEN}`) const SQL_COUNT_OPEN_GAMES = SQL(`SELECT COUNT(*) FROM games WHERE owner_id=? AND status=${STATUS_OPEN}`).pluck() -const SQL_SELECT_REMATCH = SQL(`SELECT game_id FROM games WHERE status = ${STATUS_FINISHED} AND notice=?`).pluck() +const SQL_SELECT_REMATCH = SQL(`SELECT game_id FROM games WHERE status < ${STATUS_FINISHED} AND notice=?`).pluck() const SQL_INSERT_REMATCH = SQL(` INSERT INTO games (owner_id, title_id, scenario, options, is_private, is_random, notice) diff --git a/tools/undo.sh b/tools/undo.sh index 889d6b8..b75182f 100644 --- a/tools/undo.sh +++ b/tools/undo.sh @@ -1,9 +1,14 @@ #!/bin/bash if [ -n "$1" ] then - COUNT=$(sqlite3 db "select coalesce(max(replay_id),0) from game_replay where game_id=$1") - echo Game has $COUNT actions. - sqlite3 db "delete from game_replay where game_id=$1 and replay_id=$COUNT" + if [ -n "$2" ] + then + COUNT=$2 + else + COUNT=$(sqlite3 db "select coalesce(max(replay_id),0) from game_replay where game_id=$1") + echo Game has $COUNT actions. + fi + sqlite3 db "delete from game_replay where game_id=$1 and replay_id>=$COUNT" node tools/patchgame.js $1 '{"validate_actions":false}' else echo "usage: bash tools/undo.sh GAME" |