fixed asking all network clients to "play again" after unsolved game end
authorHolger Schemel <info@artsoft.org>
Fri, 12 Oct 2018 22:37:26 +0000 (00:37 +0200)
committerHolger Schemel <info@artsoft.org>
Fri, 12 Oct 2018 22:37:26 +0000 (00:37 +0200)
Before, all network clients were asked to play again after a game was
lost, which could cause problems (or at least confusion) when starting
a new network game from different network clients at the same time.

Now, only the network client which started the network game is asked
to play again, while all other clients only confirm that the game is
over and return to the main menu.

src/game.c
src/network.c
src/network.h

index 8d1954d..f359a2c 100644 (file)
@@ -14938,7 +14938,10 @@ void RequestRestartGame(char *message)
 {
   game.restart_game_message = NULL;
 
-  if (Request(message, REQ_ASK | REQ_STAY_CLOSED))
+  boolean has_started_game = hasStartedNetworkGame();
+  int request_mode = (has_started_game ? REQ_ASK : REQ_CONFIRM);
+
+  if (Request(message, request_mode | REQ_STAY_CLOSED) && has_started_game)
   {
     StartGameActions(network.enabled, setup.autorecord, level.random_seed);
   }
@@ -14977,7 +14980,9 @@ void CheckGameOver(void)
   }
 
   if (last_game_over != game_over)
-    game.restart_game_message = "Game over! Play it again?";
+    game.restart_game_message = (hasStartedNetworkGame() ?
+                                "Game over! Play it again?" :
+                                "Game over!");
 
   last_game_over = game_over;
 }
index 73887cd..1d263b5 100644 (file)
@@ -173,6 +173,11 @@ char *getNetworkPlayerName(int player_nr)
   return(EMPTY_PLAYER_NAME);
 }
 
+boolean hasStartedNetworkGame(void)
+{
+  return !network_level.use_network_level_files;
+}
+
 static boolean hasPathSeparator(char *s)
 {
   return (strchr(s, '/') != NULL);
index 22a826c..69e3b69 100644 (file)
@@ -18,6 +18,7 @@
 #define NETWORK_STOP_BY_ERROR          1
 
 char *getNetworkPlayerName(int);
+boolean hasStartedNetworkGame(void);
 
 boolean ConnectToServer(char *, int);
 void SendToServer_PlayerName(char *);