forked from mirror/OpenTTD
Codechange: Use vector/unique_ptr to manage network game information. (#13902)
Replaces linked list with manual memory management.
This commit is contained in:
@@ -650,7 +650,7 @@ public:
|
||||
{
|
||||
Debug(net, 9, "Query::OnFailure(): connection_string={}", this->connection_string);
|
||||
|
||||
NetworkGameList *item = NetworkGameListAddItem(connection_string);
|
||||
NetworkGame *item = NetworkGameListAddItem(connection_string);
|
||||
item->status = NGLS_OFFLINE;
|
||||
item->refreshing = false;
|
||||
|
||||
@@ -676,7 +676,7 @@ void NetworkQueryServer(const std::string &connection_string)
|
||||
Debug(net, 9, "NetworkQueryServer(): connection_string={}", connection_string);
|
||||
|
||||
/* Mark the entry as refreshing, so the GUI can show the refresh is pending. */
|
||||
NetworkGameList *item = NetworkGameListAddItem(connection_string);
|
||||
NetworkGame *item = NetworkGameListAddItem(connection_string);
|
||||
item->refreshing = true;
|
||||
|
||||
TCPConnecter::Create<TCPQueryConnecter>(connection_string);
|
||||
@@ -691,12 +691,12 @@ void NetworkQueryServer(const std::string &connection_string)
|
||||
* @param never_expire Whether the entry can expire (removed when no longer found in the public listing).
|
||||
* @return The entry on the game list.
|
||||
*/
|
||||
NetworkGameList *NetworkAddServer(const std::string &connection_string, bool manually, bool never_expire)
|
||||
NetworkGame *NetworkAddServer(const std::string &connection_string, bool manually, bool never_expire)
|
||||
{
|
||||
if (connection_string.empty()) return nullptr;
|
||||
|
||||
/* Ensure the item already exists in the list */
|
||||
NetworkGameList *item = NetworkGameListAddItem(connection_string);
|
||||
NetworkGame *item = NetworkGameListAddItem(connection_string);
|
||||
if (item->info.server_name.empty()) {
|
||||
ClearGRFConfigList(item->info.grfconfig);
|
||||
item->info.server_name = connection_string;
|
||||
@@ -729,14 +729,14 @@ void GetBindAddresses(NetworkAddressList *addresses, uint16_t port)
|
||||
}
|
||||
}
|
||||
|
||||
/* Generates the list of manually added hosts from NetworkGameList and
|
||||
/* Generates the list of manually added hosts from NetworkGame and
|
||||
* dumps them into the array _network_host_list. This array is needed
|
||||
* by the function that generates the config file. */
|
||||
void NetworkRebuildHostList()
|
||||
{
|
||||
_network_host_list.clear();
|
||||
|
||||
for (NetworkGameList *item = _network_game_list; item != nullptr; item = item->next) {
|
||||
for (const auto &item : _network_game_list) {
|
||||
if (item->manually) _network_host_list.emplace_back(item->connection_string);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user