45:e14a1d9aa91d | 46:4dcfb4c58b6d |
---|---|
273 } else if (strncmp(movestr, "remis", MOVESTR_BUFLEN) == 0) { | 273 } else if (strncmp(movestr, "remis", MOVESTR_BUFLEN) == 0) { |
274 if (!remisrejected) { | 274 if (!remisrejected) { |
275 net_send_code(opponent, NETCODE_REMIS); | 275 net_send_code(opponent, NETCODE_REMIS); |
276 printw("Remis offer sent - waiting for acceptance..."); | 276 printw("Remis offer sent - waiting for acceptance..."); |
277 refresh(); | 277 refresh(); |
278 if (net_recieve_code(opponent) == NETCODE_ACCEPT) { | 278 code = net_recieve_code(opponent); |
279 if (code == NETCODE_ACCEPT) { | |
279 printw("\rRemis accepted!"); | 280 printw("\rRemis accepted!"); |
281 clrtoeol(); | |
282 refresh(); | |
283 return 1; | |
284 } else if (code == NETCODE_CONNLOST) { | |
285 printw("\rYour opponent left the game."); | |
280 clrtoeol(); | 286 clrtoeol(); |
281 refresh(); | 287 refresh(); |
282 return 1; | 288 return 1; |
283 } else { | 289 } else { |
284 remisrejected = TRUE; | 290 remisrejected = TRUE; |
310 clrtoeol(); | 316 clrtoeol(); |
311 return 1; | 317 return 1; |
312 } else { | 318 } else { |
313 return 0; | 319 return 0; |
314 } | 320 } |
321 } else if (code == NETCODE_CONNLOST) { | |
322 printw("Your opponent left the game."); | |
323 return 1; | |
315 } else { | 324 } else { |
316 printw("Invalid network response."); | 325 printw("Invalid network response."); |
317 } | 326 } |
318 break; | 327 break; |
319 default: | 328 default: |
358 printw("\rYour opponent's time ran out - you win!"); | 367 printw("\rYour opponent's time ran out - you win!"); |
359 clrtoeol(); | 368 clrtoeol(); |
360 return 1; | 369 return 1; |
361 case NETCODE_RESIGN: | 370 case NETCODE_RESIGN: |
362 printw("\rYour opponent resigned!"); | 371 printw("\rYour opponent resigned!"); |
372 clrtoeol(); | |
373 return 1; | |
374 case NETCODE_CONNLOST: | |
375 printw("\rYour opponent has left the game."); | |
363 clrtoeol(); | 376 clrtoeol(); |
364 return 1; | 377 return 1; |
365 case NETCODE_REMIS: | 378 case NETCODE_REMIS: |
366 if (prompt_yesno( | 379 if (prompt_yesno( |
367 "\rYour opponent offers remis - do you accept")) { | 380 "\rYour opponent offers remis - do you accept")) { |
435 } while (running); | 448 } while (running); |
436 move(0,0); | 449 move(0,0); |
437 draw_board(&gamestate); | 450 draw_board(&gamestate); |
438 | 451 |
439 gamestate_cleanup(&gamestate); | 452 gamestate_cleanup(&gamestate); |
440 | |
441 mvaddstr(getmaxy(stdscr)-1, 0, | |
442 "Game has ended. Press any key to leave..."); | |
443 refresh(); | |
444 cbreak(); | |
445 flushinp(); | |
446 getch(); | |
447 } | 453 } |
448 | 454 |
449 void game_start(Settings *settings, int opponent) { | 455 void game_start(Settings *settings, int opponent) { |
450 inputy = getmaxy(stdscr) - 6; | 456 inputy = getmaxy(stdscr) - 6; |
451 | 457 |
471 | 477 |
472 move(0,0); | 478 move(0,0); |
473 draw_board(&gamestate); | 479 draw_board(&gamestate); |
474 | 480 |
475 gamestate_cleanup(&gamestate); | 481 gamestate_cleanup(&gamestate); |
476 | 482 } |
477 mvaddstr(getmaxy(stdscr)-1, 0, | |
478 "Game has ended. Press any key to leave..."); | |
479 refresh(); | |
480 cbreak(); | |
481 flushinp(); | |
482 getch(); | |
483 } |