From: Holger Schemel Date: Fri, 12 Oct 2018 22:37:26 +0000 (+0200) Subject: fixed asking all network clients to "play again" after unsolved game end X-Git-Tag: 4.1.2.0~131 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=4848f0bcd25bee8a7a4e48ae7d2a670bbc4e278d;p=rocksndiamonds.git fixed asking all network clients to "play again" after unsolved game end 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. --- diff --git a/src/game.c b/src/game.c index 8d1954da..f359a2cb 100644 --- a/src/game.c +++ b/src/game.c @@ -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; } diff --git a/src/network.c b/src/network.c index 73887cd5..1d263b5a 100644 --- a/src/network.c +++ b/src/network.c @@ -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); diff --git a/src/network.h b/src/network.h index 22a826c6..69e3b69e 100644 --- a/src/network.h +++ b/src/network.h @@ -18,6 +18,7 @@ #define NETWORK_STOP_BY_ERROR 1 char *getNetworkPlayerName(int); +boolean hasStartedNetworkGame(void); boolean ConnectToServer(char *, int); void SendToServer_PlayerName(char *);