src/game.c

changeset 46
4dcfb4c58b6d
parent 45
e14a1d9aa91d
child 47
d726e4b46c33
     1.1 --- a/src/game.c	Thu Apr 17 11:55:36 2014 +0200
     1.2 +++ b/src/game.c	Thu Apr 17 12:16:14 2014 +0200
     1.3 @@ -275,11 +275,17 @@
     1.4                      net_send_code(opponent, NETCODE_REMIS);
     1.5                      printw("Remis offer sent - waiting for acceptance...");
     1.6                      refresh();
     1.7 -                    if (net_recieve_code(opponent) == NETCODE_ACCEPT) {
     1.8 +                    code = net_recieve_code(opponent);
     1.9 +                    if (code == NETCODE_ACCEPT) {
    1.10                          printw("\rRemis accepted!");
    1.11                          clrtoeol();
    1.12                          refresh();
    1.13                          return 1;
    1.14 +                    } else if (code == NETCODE_CONNLOST) {
    1.15 +                        printw("\rYour opponent left the game.");
    1.16 +                        clrtoeol();
    1.17 +                        refresh();
    1.18 +                        return 1;
    1.19                      } else {
    1.20                          remisrejected = TRUE;
    1.21                      }
    1.22 @@ -312,6 +318,9 @@
    1.23                          } else {
    1.24                              return 0;
    1.25                          }
    1.26 +                    } else if (code == NETCODE_CONNLOST) {
    1.27 +                        printw("Your opponent left the game.");
    1.28 +                        return 1;
    1.29                      } else {
    1.30                          printw("Invalid network response.");
    1.31                      }
    1.32 @@ -362,6 +371,10 @@
    1.33                  printw("\rYour opponent resigned!");
    1.34                  clrtoeol();
    1.35                  return 1;
    1.36 +            case NETCODE_CONNLOST:
    1.37 +                printw("\rYour opponent has left the game.");
    1.38 +                clrtoeol();
    1.39 +                return 1;
    1.40              case NETCODE_REMIS:
    1.41                  if (prompt_yesno(
    1.42                      "\rYour opponent offers remis - do you accept")) {
    1.43 @@ -437,13 +450,6 @@
    1.44      draw_board(&gamestate);
    1.45      
    1.46      gamestate_cleanup(&gamestate);
    1.47 -    
    1.48 -    mvaddstr(getmaxy(stdscr)-1, 0,
    1.49 -        "Game has ended. Press any key to leave...");
    1.50 -    refresh();
    1.51 -    cbreak();
    1.52 -    flushinp();
    1.53 -    getch();
    1.54  }
    1.55  
    1.56  void game_start(Settings *settings, int opponent) {
    1.57 @@ -473,11 +479,4 @@
    1.58      draw_board(&gamestate);
    1.59      
    1.60      gamestate_cleanup(&gamestate);
    1.61 -    
    1.62 -    mvaddstr(getmaxy(stdscr)-1, 0,
    1.63 -        "Game has ended. Press any key to leave...");
    1.64 -    refresh();
    1.65 -    cbreak();
    1.66 -    flushinp();
    1.67 -    getch();
    1.68  }

mercurial