src/server.c

changeset 122
e65d9b5e9324
parent 98
9cb41383540f
--- a/src/server.c	Tue May 19 17:59:24 2026 +0200
+++ b/src/server.c	Tue May 19 18:03:06 2026 +0200
@@ -147,28 +147,28 @@
     addstr("\rClient connected - awaiting challenge acceptance...");
     refresh();
     int code = net_recieve_code(fd);
+    int exitcode = 0;
     if (code == NETCODE_ACCEPT) {
         addstr("\rClient connected - challenge accepted.");
         clrtoeol();
         game_play(settings, &gamestate, fd);
         net_destroy(&server);
         game_review(settings, &gamestate);
-        return 0;
     } else if (code == NETCODE_DECLINE) {
         addstr("\rClient connected - challenge declined.");
         clrtoeol();
         net_destroy(&server);
-        return 0;
     } else if (code == NETCODE_CONNLOST) {
         addstr("\rClient connected - but gave no response.");
         clrtoeol();
         net_destroy(&server);
-        return 0;
     } else {
         addstr("\rInvalid client response");
         clrtoeol();
         
         net_destroy(&server);
-        return 1;
+        exitcode = 1;
     }
+    gamestate_cleanup(&gamestate);
+    return exitcode;
 }

mercurial