Changeset 5454:2ab8612a9401 in roaraudio
- Timestamp:
- 03/25/12 20:24:36 (11 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/universal/tic-tac-toe.c
r5450 r5454 37 37 "\n" \ 38 38 "Game board: IDs:\n" \ 39 " %c | %c | %c 0 | 1 | 2\n" \39 " %c | %c | %c 7 | 8 | 9\n" \ 40 40 "---+---+--- ---+---+---\n" \ 41 " %c | %c | %c 3 | 4 | 5\n" \41 " %c | %c | %c 4 | 5 | 7\n" \ 42 42 "---+---+--- ---+---+---\n" \ 43 " %c | %c | %c 6 | 7 | 8\n" \43 " %c | %c | %c 1 | 2 | 3\n" \ 44 44 "\n" \ 45 45 "%s\n" … … 231 231 } 232 232 233 static char input2id(char c) { 234 if ( c > '9' ) 235 return c; 236 if ( c >= '7' ) 237 return c - 7; 238 if ( c >= '4' ) 239 return c - 1; 240 if ( c >= '1' ) 241 return c + 5; 242 return c; 243 } 244 233 245 static int check_client(int client, struct roar_vio_calls * vio) { 234 246 struct roar_client_server * cs; … … 239 251 char won; 240 252 int player_move = -1; 253 char c; 241 254 242 255 ROAR_DBG("check_client(client=%i, vio=%p) = ?", client, vio); … … 266 279 267 280 for (i = 0; i < len; i++) { 268 switch (buf[i]) { 281 c = input2id(buf[i]); 282 switch (c) { 269 283 case 'q': 270 284 clients_delete(client); … … 273 287 case '0': case '1': case '2': case '3': case '4': 274 288 case '5': case '6': case '7': case '8': 275 if ( try_put(cs->protoinst, buf[i]- '0', _PLAYER) == -1 ) {289 if ( try_put(cs->protoinst, c - '0', _PLAYER) == -1 ) { 276 290 msg = MSG__CANNOT_PUT_HERE; 277 291 draw_game(client, cs->protoinst, msg); … … 280 294 msg = MSG__YOUR_TURN; 281 295 i = len; // end the loop. 282 player_move = buf[i]- '0';296 player_move = c - '0'; 283 297 } 284 298 break;
Note: See TracChangeset
for help on using the changeset viewer.