added clearing network players from main menu screen if server disconnects
authorHolger Schemel <info@artsoft.org>
Tue, 3 Jul 2018 06:44:05 +0000 (08:44 +0200)
committerHolger Schemel <info@artsoft.org>
Tue, 3 Jul 2018 06:44:05 +0000 (08:44 +0200)
src/network.c
src/tools.c
src/tools.h

index 6f06d610392aa6d6d3b36c11b2af5315254b6381..e703da0cd8a25ef326488c17ef6c440c2923de61 100644 (file)
@@ -859,6 +859,9 @@ void HandleNetworking()
     else
     {
       Request(error_message, REQ_CONFIRM);
+
+      if (game_status == GAME_MODE_MAIN)
+       ClearNetworkPlayers();
     }
   }
 }
index b0773082c16981783208ab5c7c815a2b2790ea6e..ec52e93e56816447bdf7d8d31c162c231f47f448 100644 (file)
@@ -3530,9 +3530,12 @@ static void DrawNetworkPlayer(int x, int y, int player_nr, int tile_size,
   DrawText(x + xoffset_text, y + yoffset_text, player_name, font_nr);
 }
 
-void DrawNetworkPlayers()
+void DrawNetworkPlayersExt(boolean force)
 {
-  if (!network.enabled || !network.connected)
+  if (game_status != GAME_MODE_MAIN)
+    return;
+
+  if (!network.connected && !force)
     return;
 
   int num_players = 0;
@@ -3564,7 +3567,8 @@ void DrawNetworkPlayers()
   /* first draw local network player ... */
   for (i = 0; i < MAX_PLAYERS; i++)
   {
-    if (stored_player[i].connected_locally)
+    if (stored_player[i].connected_network &&
+       stored_player[i].connected_locally)
     {
       char *player_name = getNetworkPlayerName(i + 1);
       int player_width = xoffset_text + getTextWidth(player_name, font_nr);
@@ -3593,6 +3597,16 @@ void DrawNetworkPlayers()
   }
 }
 
+void DrawNetworkPlayers()
+{
+  DrawNetworkPlayersExt(FALSE);
+}
+
+void ClearNetworkPlayers()
+{
+  DrawNetworkPlayersExt(TRUE);
+}
+
 inline static void DrawGraphicAnimationExt(DrawBuffer *dst_bitmap, int x, int y,
                                           int graphic, int sync_frame,
                                           int mask_mode)
index 61541f370287d7bf5ebb9f4a85706aa055642e99..a5e348a698888c0c22a9de1cf213cf5d9a57d67b 100644 (file)
@@ -198,6 +198,7 @@ void DrawPreviewLevelInitial(void);
 void DrawPreviewLevelAnimation(void);
 
 void DrawNetworkPlayers(void);
+void ClearNetworkPlayers(void);
 
 void WaitForEventToContinue(void);
 boolean Request(char *, unsigned int);