src/game.c

changeset 126
d58b2abdd330
parent 124
08465aaec318
--- a/src/game.c	Wed May 20 15:52:17 2026 +0200
+++ b/src/game.c	Fri May 22 18:34:02 2026 +0200
@@ -224,7 +224,11 @@
         
         if (asyncgetnstr(movestr, &bufpos, MOVESTR_BUFLEN)) {
             if (strncmp(movestr, "resign", MOVESTR_BUFLEN) == 0) {
-                gamestate->resign = true;
+                if (curcolor == WHITE) {
+                    gamestate->wresign = true;
+                } else {
+                    gamestate->bresign = true;
+                }
                 return 1;
             } else if (strncmp(movestr, "remis", MOVESTR_BUFLEN) == 0) {
                 gamestate->remis = true;
@@ -311,7 +315,11 @@
                 resign_suggested = true;
                 break;
             case NETCODE_RESIGN:
-                gamestate->resign = true;
+                if (mycolor == WHITE) {
+                    gamestate->bresign = true;
+                } else {
+                    gamestate->wresign = true;
+                }
                 return 1;
             case NETCODE_CONNLOST:
                 gamestate->ragequit = true;
@@ -332,7 +340,11 @@
             bool was_premove = use_premove;
             use_premove = false;
             if (strncmp(movestr, "resign", MOVESTR_BUFLEN) == 0) {
-                gamestate->resign = true;
+                if (mycolor == WHITE) {
+                    gamestate->wresign = true;
+                } else {
+                    gamestate->bresign = true;
+                }
                 net_send_code(opponent, NETCODE_RESIGN);
                 return 1;
             } else if (strncmp(movestr, "savepgn", MOVESTR_BUFLEN) == 0) {
@@ -436,7 +448,11 @@
         /* allow the player to prepare a move */
         if (asyncgetnstr(movestr, &bufpos, MOVESTR_BUFLEN)) {
             if (strncmp(movestr, "resign", MOVESTR_BUFLEN) == 0) {
-                gamestate->resign = true;
+                if (mycolor == WHITE) {
+                    gamestate->wresign = true;
+                } else {
+                    gamestate->bresign = true;
+                }
                 net_send_code(opponent, NETCODE_RESIGN);
                 return 1;
             } else if (strncmp(movestr, "taunt", MOVESTR_BUFLEN) == 0) {
@@ -470,7 +486,11 @@
             timecontrol(gamestate, gameinfo);
             return 1;
         case NETCODE_RESIGN:
-            gamestate->resign = true;
+            if (mycolor == WHITE) {
+                gamestate->bresign = true;
+            } else {
+                gamestate->wresign = true;
+            }
             return 1;
         case NETCODE_CONNLOST:
             gamestate->ragequit = true;
@@ -547,16 +567,17 @@
             timecontrol(&viewedstate, gameinfo);
 
             move(getmaxy(stdscr)-5, 0);
-            const char *curcolorstr =
-                gamestate->movecount % 2 == 0 ? "White" : "Black";
-            if (gamestate->resign) {
-                printw("%s resigned.\n", curcolorstr);
+            if (gamestate->wresign) {
+                addstr("White resigned.\n");
+            } else if (gamestate->bresign) {
+                addstr("Black resigned.\n");
             } else if (gamestate->remis) {
                 addstr("The game ended remis.\n");
             } else if (gamestate->stalemate) {
                 addstr("The game ended in a stalemate.\n");
             } else if (gamestate->checkmate) {
-                printw("%s has lost the game.\n", curcolorstr);
+                printw("%s was checkmated.\n",
+                    gamestate->movecount % 2 == 0 ? "White" : "Black");
             } else if (gamestate->ragequit) {
                 printw("Your opponent disconnected.\n");
             }

mercurial