MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / NetworkGameListAddItem

Function NetworkGameListAddItem

src/network/network_gamelist.cpp:30–46  ·  view source on GitHub ↗

* Add a new item to the linked gamelist. If the IP and Port match * return the existing item instead of adding it again * @param connection_string the address of the to-be added item * @return a point to the newly added or already existing item */

Source from the content-addressed store, hash-verified

28 * @return a point to the newly added or already existing item
29 */
30NetworkGame *NetworkGameListAddItem(std::string_view connection_string)
31{
32 /* Parse the connection string to ensure the default port is there. */
33 const std::string resolved_connection_string = ServerAddress::Parse(connection_string, NETWORK_DEFAULT_PORT).connection_string;
34
35 /* Check if it's already added. */
36 auto it = std::ranges::find(_network_game_list, resolved_connection_string, &NetworkGame::connection_string);
37 if (it != std::end(_network_game_list)) return it->get();
38
39 auto &item = _network_game_list.emplace_back(std::make_unique<NetworkGame>(resolved_connection_string));
40 item->info.gamescript_version = -1;
41 item->version = _network_game_list_version;
42
43 UpdateNetworkGameWindow();
44
45 return item.get();
46}
47
48/**
49 * Remove an item from the gamelist linked list

Callers 10

CloseConnectionMethod · 0.85
Receive_SERVER_FULLMethod · 0.85
Receive_SERVER_BANNEDMethod · 0.85
Receive_SERVER_ERRORMethod · 0.85
Receive_GC_ERRORMethod · 0.85
Receive_GC_LISTINGMethod · 0.85
OnFailureMethod · 0.85
NetworkQueryServerFunction · 0.85
NetworkAddServerFunction · 0.85

Calls 4

UpdateNetworkGameWindowFunction · 0.85
findFunction · 0.50
endFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected