1.1 --- a/src/game.c Thu Apr 10 11:44:55 2014 +0200 1.2 +++ b/src/game.c Thu Apr 10 12:10:09 2014 +0200 1.3 @@ -172,11 +172,12 @@ 1.4 } 1.5 } 1.6 1.7 +#define MOVESTR_BUFLEN 8 1.8 static int domove_singlemachine(GameState *gamestate, GameInfo *gameinfo) { 1.9 1.10 - const size_t buflen = 8; 1.11 + 1.12 size_t bufpos = 0; 1.13 - char movestr[buflen]; 1.14 + char movestr[MOVESTR_BUFLEN]; 1.15 1.16 flushinp(); 1.17 while (1) { 1.18 @@ -191,14 +192,14 @@ 1.19 "Type your move: "); 1.20 clrtoeol(); 1.21 1.22 - if (asyncgetnstr(movestr, &bufpos, buflen)) { 1.23 - if (strncmp(movestr, "surr", buflen) == 0) { 1.24 + if (asyncgetnstr(movestr, &bufpos, MOVESTR_BUFLEN)) { 1.25 + if (strncmp(movestr, "surr", MOVESTR_BUFLEN) == 0) { 1.26 printw("%s surrendered!", 1.27 gamestate->mycolor==WHITE?"White":"Black"); 1.28 clrtoeol(); 1.29 refresh(); 1.30 return 1; 1.31 - } else if (strncmp(movestr, "remis", buflen) == 0) { 1.32 + } else if (strncmp(movestr, "remis", MOVESTR_BUFLEN) == 0) { 1.33 printw("Game ends remis."); 1.34 clrtoeol(); 1.35 refresh(); 1.36 @@ -236,9 +237,8 @@ 1.37 1.38 static int sendmove(GameState *gamestate, GameInfo *gameinfo, int opponent) { 1.39 1.40 - const size_t buflen = 8; 1.41 size_t bufpos = 0; 1.42 - char movestr[buflen]; 1.43 + char movestr[MOVESTR_BUFLEN]; 1.44 _Bool remisrejected = FALSE; 1.45 uint8_t code; 1.46 1.47 @@ -263,14 +263,14 @@ 1.48 } 1.49 clrtoeol(); 1.50 1.51 - if (asyncgetnstr(movestr, &bufpos, buflen)) { 1.52 - if (strncmp(movestr, "surr", buflen) == 0) { 1.53 + if (asyncgetnstr(movestr, &bufpos, MOVESTR_BUFLEN)) { 1.54 + if (strncmp(movestr, "surr", MOVESTR_BUFLEN) == 0) { 1.55 printw("You surrendered!"); 1.56 clrtoeol(); 1.57 refresh(); 1.58 net_send_code(opponent, NETCODE_SURRENDER); 1.59 return 1; 1.60 - } else if (strncmp(movestr, "remis", buflen) == 0) { 1.61 + } else if (strncmp(movestr, "remis", MOVESTR_BUFLEN) == 0) { 1.62 if (!remisrejected) { 1.63 net_send_code(opponent, NETCODE_REMIS); 1.64 printw("Remis offer sent - waiting for acceptance...");