diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/network/network_gamelist.cpp | 9 | ||||
-rw-r--r-- | src/network/network_gamelist.h | 17 | ||||
-rw-r--r-- | src/network/network_udp.cpp | 4 |
3 files changed, 15 insertions, 15 deletions
diff --git a/src/network/network_gamelist.cpp b/src/network/network_gamelist.cpp index 1edbafc32..e4e2d1741 100644 --- a/src/network/network_gamelist.cpp +++ b/src/network/network_gamelist.cpp @@ -57,7 +57,7 @@ static void NetworkGameListHandleDelayedInsert() if (item->manually) NetworkRebuildHostList(); UpdateNetworkGameWindow(); } - free(ins_item); + delete ins_item; } } @@ -80,9 +80,7 @@ NetworkGameList *NetworkGameListAddItem(const std::string &connection_string) prev_item = item; } - item = CallocT<NetworkGameList>(1); - item->next = nullptr; - item->connection_string = resolved_connection_string; + item = new NetworkGameList(resolved_connection_string); if (prev_item == nullptr) { _network_game_list = item; @@ -112,8 +110,7 @@ void NetworkGameListRemoveItem(NetworkGameList *remove) /* Remove GRFConfig information */ ClearGRFConfigList(&remove->info.grfconfig); - free(remove); - remove = nullptr; + delete remove; DEBUG(net, 4, "[gamelist] removed server from list"); NetworkRebuildHostList(); diff --git a/src/network/network_gamelist.h b/src/network/network_gamelist.h index 31b3bc3e6..6ef9d8e41 100644 --- a/src/network/network_gamelist.h +++ b/src/network/network_gamelist.h @@ -16,12 +16,17 @@ /** Structure with information shown in the game list (GUI) */ struct NetworkGameList { - NetworkGameInfo info; ///< The game information of this server - std::string connection_string; ///< Address of the server - bool online; ///< False if the server did not respond (default status) - bool manually; ///< True if the server was added manually - uint8 retries; ///< Number of retries (to stop requerying) - NetworkGameList *next; ///< Next pointer to make a linked game list + NetworkGameList(const std::string &connection_string, bool manually = false) : + connection_string(connection_string), manually(manually) + { + } + + NetworkGameInfo info = {}; ///< The game information of this server + std::string connection_string; ///< Address of the server + bool online = false; ///< False if the server did not respond (default status) + bool manually = false; ///< True if the server was added manually + uint8 retries = 0; ///< Number of retries (to stop requerying) + NetworkGameList *next = nullptr; ///< Next pointer to make a linked game list }; /** Game list of this client */ diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp index 558b51f99..4e4f4a37e 100644 --- a/src/network/network_udp.cpp +++ b/src/network/network_udp.cpp @@ -90,10 +90,8 @@ static UDPSocket _udp_master("Master"); ///< udp master socket static void DoNetworkUDPQueryServer(const std::string &connection_string, bool needs_mutex, bool manually) { /* Clear item in gamelist */ - NetworkGameList *item = CallocT<NetworkGameList>(1); + NetworkGameList *item = new NetworkGameList(connection_string, manually); strecpy(item->info.server_name, connection_string.c_str(), lastof(item->info.server_name)); - item->connection_string = connection_string; - item->manually = manually; NetworkGameListAddItemDelayed(item); std::unique_lock<std::mutex> lock(_udp_client.mutex, std::defer_lock); |