From: Holger Schemel Date: Tue, 3 Jul 2018 21:44:46 +0000 (+0200) Subject: added being able to reconnect after network server was restarted X-Git-Tag: 4.1.1.0~88 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=80a611519cc20b404bce7fc5dc6d321b082f99d2;p=rocksndiamonds.git added being able to reconnect after network server was restarted --- diff --git a/src/network.c b/src/network.c index e703da0c..657c796b 100644 --- a/src/network.c +++ b/src/network.c @@ -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()