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

Function NetworkAddServer

src/network/network.cpp:693–712  ·  view source on GitHub ↗

* Validates an address entered as a string and adds the server to * the list. If you use this function, the games will be marked * as manually added. * @param connection_string The IP:port of the server to add. * @param manually Whether the enter should be marked as manual added. * @param never_expire Whether the entry can expire (removed when no longer found in the public listing). * @retur

Source from the content-addressed store, hash-verified

691 * @return The entry on the game list.
692 */
693NetworkGame *NetworkAddServer(std::string_view connection_string, bool manually, bool never_expire)
694{
695 if (connection_string.empty()) return nullptr;
696
697 /* Ensure the item already exists in the list */
698 NetworkGame *item = NetworkGameListAddItem(connection_string);
699 if (item->info.server_name.empty()) {
700 ClearGRFConfigList(item->info.grfconfig);
701 item->info.server_name = connection_string;
702
703 UpdateNetworkGameWindow();
704
705 NetworkQueryServer(connection_string);
706 }
707
708 if (manually) item->manually = true;
709 if (never_expire) item->version = INT32_MAX;
710
711 return item;
712}
713
714/**
715 * Get the addresses to bind to.

Callers 5

em_openttd_add_serverFunction · 0.85
NetworkGameWindowMethod · 0.85
OnQueryTextFinishedMethod · 0.85
ShowNetworkGameWindowFunction · 0.85

Calls 5

NetworkGameListAddItemFunction · 0.85
ClearGRFConfigListFunction · 0.85
UpdateNetworkGameWindowFunction · 0.85
NetworkQueryServerFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected