diff options
Diffstat (limited to 'FICS/gameproc.c')
-rw-r--r-- | FICS/gameproc.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/FICS/gameproc.c b/FICS/gameproc.c index b4a538e..cd6398e 100644 --- a/FICS/gameproc.c +++ b/FICS/gameproc.c @@ -30,6 +30,7 @@ Markus Uhlin 24/04/13 Added usage of msnprintf(), mstrlcpy() and mstrlcat(). Markus Uhlin 24/05/05 Added usage of reallocarray(). + Markus Uhlin 25/03/09 Calc string length once */ #include "stdinclude.h" @@ -848,18 +849,23 @@ CheckRepetition(int p, int g) char *pos; int flag1 = 1, flag2 = 1; int move_num; + size_t len[3]; if (garray[g].numHalfMoves < 8) // Can't have three repeats any quicker. return 0; + len[0] = strlen(pos1); + len[1] = strlen(pos2); + for (move_num = garray[g].game_state.lastIrreversable; move_num < garray[g].numHalfMoves - 1; move_num++) { pos = GetFENpos(g, move_num); + len[2] = strlen(pos); - if (strlen(pos1) == strlen(pos) && !strcmp(pos1, pos)) + if (len[0] == len[2] && !strcmp(pos1, pos)) flag1++; - if (strlen(pos2) == strlen(pos) && !strcmp(pos2, pos)) + if (len[1] == len[2] && !strcmp(pos2, pos)) flag2++; } @@ -1828,7 +1834,11 @@ com_goboard(int p, param_list param) } on = parray[p].simul_info.onBoard; - g = parray[p].simul_info.boards[on]; + + if ((g = parray[p].simul_info.boards[on]) < 0) { + pprintf(p, "Internal error! Unexpected negative value!\n"); + return COM_OK; + } if (p1 == garray[g].black) { pprintf(p, "You are already at that board!\n"); |