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

Function NetworkValidateClientName

src/network/network_client.cpp:1267–1274  ·  view source on GitHub ↗

* Trim the given client name in place, i.e. remove leading and trailing spaces. * After the trim check whether the client name is valid. A client name is valid * whenever the name is not empty and does not start with spaces. This check is * done via \c NetworkIsValidClientName. * When the client name is valid, this function returns true. * When the client name is not valid a GUI error message

Source from the content-addressed store, hash-verified

1265 * @return True iff the client name is valid.
1266 */
1267bool NetworkValidateClientName(std::string &client_name)
1268{
1269 StrTrimInPlace(client_name);
1270 if (NetworkIsValidClientName(client_name)) return true;
1271
1272 ShowErrorMessage(GetEncodedString(STR_NETWORK_ERROR_BAD_PLAYER_NAME), {}, WL_ERROR);
1273 return false;
1274}
1275
1276/**
1277 * Convenience method for NetworkValidateClientName on _settings_client.network.client_name.

Callers 1

Calls 4

StrTrimInPlaceFunction · 0.85
NetworkIsValidClientNameFunction · 0.85
ShowErrorMessageFunction · 0.85
GetEncodedStringFunction · 0.50

Tested by

no test coverage detected