src/game.c

changeset 46
4dcfb4c58b6d
parent 45
e14a1d9aa91d
child 47
d726e4b46c33
--- a/src/game.c	Thu Apr 17 11:55:36 2014 +0200
+++ b/src/game.c	Thu Apr 17 12:16:14 2014 +0200
@@ -275,11 +275,17 @@
                     net_send_code(opponent, NETCODE_REMIS);
                     printw("Remis offer sent - waiting for acceptance...");
                     refresh();
-                    if (net_recieve_code(opponent) == NETCODE_ACCEPT) {
+                    code = net_recieve_code(opponent);
+                    if (code == NETCODE_ACCEPT) {
                         printw("\rRemis accepted!");
                         clrtoeol();
                         refresh();
                         return 1;
+                    } else if (code == NETCODE_CONNLOST) {
+                        printw("\rYour opponent left the game.");
+                        clrtoeol();
+                        refresh();
+                        return 1;
                     } else {
                         remisrejected = TRUE;
                     }
@@ -312,6 +318,9 @@
                         } else {
                             return 0;
                         }
+                    } else if (code == NETCODE_CONNLOST) {
+                        printw("Your opponent left the game.");
+                        return 1;
                     } else {
                         printw("Invalid network response.");
                     }
@@ -362,6 +371,10 @@
                 printw("\rYour opponent resigned!");
                 clrtoeol();
                 return 1;
+            case NETCODE_CONNLOST:
+                printw("\rYour opponent has left the game.");
+                clrtoeol();
+                return 1;
             case NETCODE_REMIS:
                 if (prompt_yesno(
                     "\rYour opponent offers remis - do you accept")) {
@@ -437,13 +450,6 @@
     draw_board(&gamestate);
     
     gamestate_cleanup(&gamestate);
-    
-    mvaddstr(getmaxy(stdscr)-1, 0,
-        "Game has ended. Press any key to leave...");
-    refresh();
-    cbreak();
-    flushinp();
-    getch();
 }
 
 void game_start(Settings *settings, int opponent) {
@@ -473,11 +479,4 @@
     draw_board(&gamestate);
     
     gamestate_cleanup(&gamestate);
-    
-    mvaddstr(getmaxy(stdscr)-1, 0,
-        "Game has ended. Press any key to leave...");
-    refresh();
-    cbreak();
-    flushinp();
-    getch();
 }

mercurial