Skip to content

Commit

Permalink
Fix display game index for -random (amalloy)
Browse files Browse the repository at this point in the history
  • Loading branch information
greensnark committed Mar 19, 2016
1 parent cbb0c72 commit 0fa974b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/sqlhelper.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions tests/testcmd.txt
Expand Up @@ -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
Expand Down

0 comments on commit 0fa974b

Please sign in to comment.