Changeset - r25726:96b4fe65dab7
[Not reviewed]
master
0 4 0
rubidium42 - 3 years ago 2021-06-21 16:29:21
rubidium@openttd.org
Codechange: [Network] Remove overload on NetworkValidateClientName

Rename the zero-parameter NetworkValidateClientName to NetworkValidateOurClientName to make it clearer it is performed on our client name, and to make it a non-overloaded function to aid with the variant being added a few commits later
4 files changed with 5 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/network/network.cpp
Show inline comments
 
@@ -792,13 +792,13 @@ public:
 
bool NetworkClientConnectGame(const std::string &connection_string, CompanyID default_company, const std::string &join_server_password, const std::string &join_company_password)
 
{
 
	CompanyID join_as = default_company;
 
	std::string resolved_connection_string = ParseGameConnectionString(connection_string, NETWORK_DEFAULT_PORT, &join_as).GetAddressAsString(false);
 

	
 
	if (!_network_available) return false;
 
	if (!NetworkValidateClientName()) return false;
 
	if (!NetworkValidateOurClientName()) return false;
 

	
 
	_network_join.connection_string = resolved_connection_string;
 
	_network_join.company = join_as;
 
	_network_join.server_password = join_server_password;
 
	_network_join.company_password = join_company_password;
 

	
src/network/network_client.cpp
Show inline comments
 
@@ -1335,13 +1335,13 @@ bool NetworkValidateClientName(std::stri
 
 * Convenience method for NetworkValidateClientName on _settings_client.network.client_name.
 
 * It trims the client name and checks whether it is empty. When it is empty
 
 * an error message is shown to the GUI user.
 
 * See \c NetworkValidateClientName(char*) for details about the functionality.
 
 * @return True iff the client name is valid.
 
 */
 
bool NetworkValidateClientName()
 
bool NetworkValidateOurClientName()
 
{
 
	return NetworkValidateClientName(_settings_client.network.client_name);
 
}
 

	
 
/**
 
 * Send the server our name as callback from the setting.
src/network/network_func.h
Show inline comments
 
@@ -33,13 +33,13 @@ extern uint8 _network_reconnect;
 
extern StringList _network_bind_list;
 
extern StringList _network_host_list;
 
extern StringList _network_ban_list;
 

	
 
byte NetworkSpectatorCount();
 
bool NetworkIsValidClientName(const std::string_view client_name);
 
bool NetworkValidateClientName();
 
bool NetworkValidateOurClientName();
 
bool NetworkValidateClientName(std::string &client_name);
 
bool NetworkValidateServerName(std::string &server_name);
 
void NetworkUpdateClientName(const std::string &client_name);
 
bool NetworkCompanyHasClients(CompanyID company);
 
std::string NetworkChangeCompanyPassword(CompanyID company_id, std::string password);
 
void NetworkReboot();
src/network/network_gui.cpp
Show inline comments
 
@@ -1260,13 +1260,13 @@ static WindowDesc _network_start_server_
 
	0,
 
	_nested_network_start_server_window_widgets, lengthof(_nested_network_start_server_window_widgets)
 
);
 

	
 
static void ShowNetworkStartServerWindow()
 
{
 
	if (!NetworkValidateClientName()) return;
 
	if (!NetworkValidateOurClientName()) return;
 

	
 
	CloseWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME);
 
	CloseWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_LOBBY);
 

	
 
	new NetworkStartServerWindow(&_network_start_server_window_desc);
 
}
 
@@ -1554,13 +1554,13 @@ static WindowDesc _network_lobby_window_
 
/**
 
 * Show the networklobbywindow with the selected server.
 
 * @param ngl Selected game pointer which is passed to the new window.
 
 */
 
static void ShowNetworkLobbyWindow(NetworkGameList *ngl)
 
{
 
	if (!NetworkValidateClientName()) return;
 
	if (!NetworkValidateOurClientName()) return;
 

	
 
	CloseWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_START);
 
	CloseWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME);
 

	
 
	_settings_client.network.last_joined = ngl->connection_string;
 

	
0 comments (0 inline, 0 general)