fixed bug where an invalid network response lead to an accepted move

Wed, 16 Apr 2014 21:57:53 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 16 Apr 2014 21:57:53 +0200
changeset 42
21cb830efe91
parent 41
a8346dcf7bbf
child 43
12141136a0da

fixed bug where an invalid network response lead to an accepted move

src/game.c file | annotate | diff | comparison | revisions
--- a/src/game.c	Wed Apr 16 21:46:34 2014 +0200
+++ b/src/game.c	Wed Apr 16 21:57:53 2014 +0200
@@ -296,7 +296,10 @@
                     gamestate->stalemate = code == NETCODE_STALEMATE;
                     if (code == NETCODE_DECLINE) {
                         printw("Invalid move.");
-                    } else {
+                    } else if (code == NETCODE_ACCEPT
+                            || code == NETCODE_CHECK
+                            || code == NETCODE_CHECKMATE
+                            || code == NETCODE_STALEMATE) {
                         apply_move(gamestate, &move);
                         if (gamestate->checkmate) {
                             printw("Checkmate!");
@@ -309,6 +312,8 @@
                         } else {
                             return 0;
                         }
+                    } else {
+                        printw("Invalid network response.");
                     }
                     break;
                 default:

mercurial