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 8d1954dab05e888ce586d6eb4463233f4e2eb475..f359a2cbdfb406c6bf018873c7b14c5901397dfc 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 73887cd5b52e1270f52d3d38d9ebaf21eaa35c69..1d263b5a6b9c7587b3c6a877cf61b91d22633f0a 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 22a826c6ba4228341137d0345e0f56ade391c13b..69e3b69e864e690d61be49cfb46851178ca32dd7 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 *);