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

Function NetworkValidateServerName

src/network/network.cpp:859–866  ·  view source on GitHub ↗

* Trim the given server name in place, i.e. remove leading and trailing spaces. * After the trim check whether the server name is not empty. * When the server name is empty a GUI error message is shown telling the * user to set the servername and this function returns false. * * @param server_name The server name to validate. It will be trimmed of leading * and trailing sp

Source from the content-addressed store, hash-verified

857 * @return True iff the server name is valid.
858 */
859bool NetworkValidateServerName(std::string &server_name)
860{
861 StrTrimInPlace(server_name);
862 if (!server_name.empty()) return true;
863
864 ShowErrorMessage(GetEncodedString(STR_NETWORK_ERROR_BAD_SERVER_NAME), {}, WL_ERROR);
865 return false;
866}
867
868/**
869 * Check whether the client and server name are set, for a dedicated server and if not set them to some default

Callers 1

CheckServerNameMethod · 0.85

Calls 4

StrTrimInPlaceFunction · 0.85
ShowErrorMessageFunction · 0.85
GetEncodedStringFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected