1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-19 12:39:11 +00:00

(svn r15200) -Feature: give server admins a tool to combat profanity in nick names (based on patch by dihedral)

This commit is contained in:
rubidium
2009-01-21 23:07:11 +00:00
parent 0fa6e050e4
commit f2777cd02d
3 changed files with 55 additions and 0 deletions

View File

@@ -50,6 +50,7 @@ void NetworkServerYearlyLoop();
void NetworkServerChangeOwner(Owner current_owner, Owner new_owner);
void NetworkServerShowStatusToConsole();
bool NetworkServerStart();
bool NetworkServerChangeClientName(ClientID client_id, const char *new_name);
NetworkClientInfo *NetworkFindClientInfoFromIndex(ClientIndex index);
NetworkClientInfo *NetworkFindClientInfoFromClientID(ClientID client_id);

View File

@@ -1442,6 +1442,31 @@ bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH])
return found_name;
}
/**
* Change the client name of the given client
* @param client_id the client to change the name of
* @param new_name the new name for the client
* @return true iff the name was changed
*/
bool NetworkServerChangeClientName(ClientID client_id, const char *new_name)
{
NetworkClientInfo *ci;
/* Check if the name's already in use */
FOR_ALL_CLIENT_INFOS(ci) {
if (strcmp(ci->client_name, new_name) == 0) return false;
}
ci = NetworkFindClientInfoFromClientID(client_id);
if (ci == NULL) return false;
NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, true, ci->client_name, new_name);
strecpy(ci->client_name, new_name, lastof(ci->client_name));
NetworkUpdateClientInfo(client_id);
return true;
}
// Reads a packet from the stream
bool NetworkServer_ReadPackets(NetworkClientSocket *cs)
{