added being able to reconnect after network server was restarted
authorHolger Schemel <info@artsoft.org>
Tue, 3 Jul 2018 21:44:46 +0000 (23:44 +0200)
committerHolger Schemel <info@artsoft.org>
Tue, 3 Jul 2018 21:44:46 +0000 (23:44 +0200)
src/network.c

index e703da0cd8a25ef326488c17ef6c440c2923de61..657c796b7cfd30d7b5951ab686f82d3ba3f04a48 100644 (file)
@@ -462,6 +462,8 @@ static void Handle_OP_YOUR_NUMBER()
     Error(ERR_EXIT, "sorry, more than %d players not allowed", MAX_PLAYERS);
 
   Error(ERR_NETWORK_CLIENT, "you get client # %d", new_client_nr);
+
+  stored_player[new_index_nr].connected_network = TRUE;
 }
 
 static void Handle_OP_NUMBER_WANTED()
@@ -822,6 +824,17 @@ static char *HandleNetworkingPackets()
   return NULL;
 }
 
+static void FreeNetworkClientPlayerInfo(struct NetworkClientPlayerInfo *player)
+{
+  if (player == NULL)
+    return;
+
+  if (player->next)
+    FreeNetworkClientPlayerInfo(player->next);
+
+  checked_free(player);
+}
+
 static void HandleNetworkingDisconnect()
 {
   int i;
@@ -838,6 +851,11 @@ static void HandleNetworkingDisconnect()
 
   for (i = 0; i < MAX_PLAYERS; i++)
     stored_player[i].connected_network = FALSE;
+
+  FreeNetworkClientPlayerInfo(first_player.next);
+
+  first_player.nr = 0;
+  first_player.next = NULL;
 }
 
 void HandleNetworking()