* 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
| 691 | * @return The entry on the game list. |
| 692 | */ |
| 693 | NetworkGame *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. |
no test coverage detected