From 1a90cb82b461568579e481f90b536e5cbd4fbf50 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 24 Jul 2023 12:04:57 +0200 Subject: Fix rematch button. --- tools/undo.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'tools') 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" -- cgit v1.2.3