fixed bug with handling networking packets if request dialog is active
authorHolger Schemel <info@artsoft.org>
Fri, 12 Oct 2018 16:04:30 +0000 (18:04 +0200)
committerHolger Schemel <info@artsoft.org>
Fri, 12 Oct 2018 16:04:35 +0000 (18:04 +0200)
Before, it was possible for a network client to start a new game while
another client was still about answering a request dialog (like asking
if a tape for a solved level should be saved), causing synchronization
problems with network packet handling.

With this bugfix, handling network packets is paused during a request.

src/game.c
src/game.h
src/init.c
src/network.c
src/tools.c

index b80d8585b9fc63889a907efb28bc5163715ea823..c0fa1680b8c8ada252f5abe538d633499756930a 100644 (file)
@@ -4196,6 +4196,7 @@ void InitGame(void)
 
   game.restart_level = FALSE;
   game.restart_game_message = NULL;
 
   game.restart_level = FALSE;
   game.restart_game_message = NULL;
+  game.request_active = FALSE;
 
   if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
     InitGameActions_MM();
 
   if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
     InitGameActions_MM();
index 947d4662653923e0ea14e8ad15a06a9e72979c2e..3b79cb5d27e4ef817e13d9af119f34842e521d17 100644 (file)
@@ -208,6 +208,9 @@ struct GameInfo
   /* trigger message to ask for restarting the game */
   char *restart_game_message;
 
   /* trigger message to ask for restarting the game */
   char *restart_game_message;
 
+  /* values for special request dialog control */
+  boolean request_active;
+
   /* values for special game control */
   int centered_player_nr;
   int centered_player_nr_next;
   /* values for special game control */
   int centered_player_nr;
   int centered_player_nr_next;
index a7657670cc1ee8e72c9db46cf963186d6e33ea75..2167984b663649481289e4d4c0c5f14be1670312 100644 (file)
@@ -5113,6 +5113,7 @@ static void InitGameInfo(void)
 {
   game.restart_level = FALSE;
   game.restart_game_message = NULL;
 {
   game.restart_level = FALSE;
   game.restart_game_message = NULL;
+  game.request_active = FALSE;
 }
 
 static void InitPlayerInfo(void)
 }
 
 static void InitPlayerInfo(void)
index f67f819c0e98334277586611c669ae5995702657..73887cd5b52e1270f52d3d38d9ebaf21eaa35c69 100644 (file)
@@ -1049,6 +1049,10 @@ static void HandleNetworkingDisconnect(void)
 
 void HandleNetworking(void)
 {
 
 void HandleNetworking(void)
 {
+  /* do not handle any networking packets if request dialog is active */
+  if (game.request_active)
+    return;
+
   char *error_message = HandleNetworkingPackets();
 
   if (error_message != NULL)
   char *error_message = HandleNetworkingPackets();
 
   if (error_message != NULL)
index f89b2b250eeebc8a7d087043e05e344ce6fc2f0c..e9d11c13c2a1f29398e6b88a8e957781206ac372 100644 (file)
@@ -4243,6 +4243,8 @@ static int RequestHandleEvents(unsigned int req_state)
   int sx, sy;
   int result;
 
   int sx, sy;
   int result;
 
+  game.request_active = TRUE;
+
   setRequestPosition(&sx, &sy, FALSE);
 
   button_status = MB_RELEASED;
   setRequestPosition(&sx, &sy, FALSE);
 
   button_status = MB_RELEASED;
@@ -4543,6 +4545,8 @@ static int RequestHandleEvents(unsigned int req_state)
     BackToFront();
   }
 
     BackToFront();
   }
 
+  game.request_active = FALSE;
+
   return result;
 }
 
   return result;
 }