From 0fa974b6c752ef68e72476c03a5a466e95f01c44 Mon Sep 17 00:00:00 2001 From: Darshan Shaligram Date: Sat, 19 Mar 2016 19:46:59 -0400 Subject: [PATCH] Fix display game index for -random (amalloy) --- src/sqlhelper.rb | 4 +--- tests/testcmd.txt | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sqlhelper.rb b/src/sqlhelper.rb index c3a0f4fd..067e7bcd 100644 --- a/src/sqlhelper.rb +++ b/src/sqlhelper.rb @@ -119,7 +119,6 @@ def sql_find_game(default_nick, args) end def sql_show_game(default_nick, args) - original_args = args.dup query_group = sql_parse_query(default_nick, args) query_group.with_context do q = query_group.primary_query @@ -168,7 +167,6 @@ def sql_exec_query(num, q, lastcount=nil) return sql_random_row(q) if q.random_game? origindex = num - dbh = sql_db_handle # -1 is the natural index 0, -2 = 1, etc. num = -num - 1 @@ -229,7 +227,7 @@ def sql_random_row(q) end return Sql::ResultSet.empty(q) unless index q.with_contexts { - return sql_game_by_id(id, index, count, q) + return sql_game_by_id(id, index + 1, count, q) } end diff --git a/tests/testcmd.txt b/tests/testcmd.txt index 07b274b9..90d4e505 100644 --- a/tests/testcmd.txt +++ b/tests/testcmd.txt @@ -30,6 +30,9 @@ $ rm dat/user_commands.db !lg . win !win ::= No games for hyperbolic (win !win). +# Random game number test: +!lg * gid=meneril:cdo:20071006235624S -random ::~ 1. meneril the Footpad + !help badcommand ::~ Unknown command !nick ivowin (win) Ivo