mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-02 09:40:35 +00:00
(svn r14727) -Codechange: replace some magic numbers with a constant.
This commit is contained in:
parent
fb7ccc6820
commit
bc8984a9bb
@ -1414,10 +1414,10 @@ static void NetworkAutoCleanCompanies()
|
|||||||
bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH])
|
bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH])
|
||||||
{
|
{
|
||||||
bool found_name = false;
|
bool found_name = false;
|
||||||
byte number = 0;
|
uint number = 0;
|
||||||
char original_name[NETWORK_CLIENT_NAME_LENGTH];
|
char original_name[NETWORK_CLIENT_NAME_LENGTH];
|
||||||
|
|
||||||
// We use NETWORK_CLIENT_NAME_LENGTH in here, because new_name is really a pointer
|
/* We use NETWORK_CLIENT_NAME_LENGTH in here, because new_name is really a pointer */
|
||||||
ttd_strlcpy(original_name, new_name, NETWORK_CLIENT_NAME_LENGTH);
|
ttd_strlcpy(original_name, new_name, NETWORK_CLIENT_NAME_LENGTH);
|
||||||
|
|
||||||
while (!found_name) {
|
while (!found_name) {
|
||||||
@ -1426,22 +1426,22 @@ bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH])
|
|||||||
found_name = true;
|
found_name = true;
|
||||||
FOR_ALL_CLIENT_INFOS(ci) {
|
FOR_ALL_CLIENT_INFOS(ci) {
|
||||||
if (strcmp(ci->client_name, new_name) == 0) {
|
if (strcmp(ci->client_name, new_name) == 0) {
|
||||||
// Name already in use
|
/* Name already in use */
|
||||||
found_name = false;
|
found_name = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check if it is the same as the server-name
|
/* Check if it is the same as the server-name */
|
||||||
ci = NetworkFindClientInfoFromClientID(CLIENT_ID_SERVER);
|
ci = NetworkFindClientInfoFromClientID(CLIENT_ID_SERVER);
|
||||||
if (ci != NULL) {
|
if (ci != NULL) {
|
||||||
if (strcmp(ci->client_name, new_name) == 0) found_name = false; // name already in use
|
if (strcmp(ci->client_name, new_name) == 0) found_name = false; // name already in use
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found_name) {
|
if (!found_name) {
|
||||||
// Try a new name (<name> #1, <name> #2, and so on)
|
/* Try a new name (<name> #1, <name> #2, and so on) */
|
||||||
|
|
||||||
// Stop if we tried for more than 50 times..
|
/* Something's really wrong when there're more names than clients */
|
||||||
if (number++ > 50) break;
|
if (number++ > MAX_CLIENTS) break;
|
||||||
snprintf(new_name, NETWORK_CLIENT_NAME_LENGTH, "%s #%d", original_name, number);
|
snprintf(new_name, NETWORK_CLIENT_NAME_LENGTH, "%s #%d", original_name, number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1487,7 +1487,7 @@ const SettingDesc _patch_settings[] = {
|
|||||||
SDTC_VAR(network.max_clients, SLE_UINT8, S, NO, 10, 2, MAX_CLIENTS, 0, STR_NULL, NULL),
|
SDTC_VAR(network.max_clients, SLE_UINT8, S, NO, 10, 2, MAX_CLIENTS, 0, STR_NULL, NULL),
|
||||||
SDTC_VAR(network.max_spectators, SLE_UINT8, S, NO, 10, 0, MAX_CLIENTS, 0, STR_NULL, NULL),
|
SDTC_VAR(network.max_spectators, SLE_UINT8, S, NO, 10, 0, MAX_CLIENTS, 0, STR_NULL, NULL),
|
||||||
SDTC_VAR(network.restart_game_year, SLE_INT32, S,D0|NO|NC,0, MIN_YEAR, MAX_YEAR, 1, STR_NULL, NULL),
|
SDTC_VAR(network.restart_game_year, SLE_INT32, S,D0|NO|NC,0, MIN_YEAR, MAX_YEAR, 1, STR_NULL, NULL),
|
||||||
SDTC_VAR(network.min_active_clients, SLE_UINT8, S, NO, 0, 0, 10, 0, STR_NULL, UpdateMinActiveClients),
|
SDTC_VAR(network.min_active_clients, SLE_UINT8, S, NO, 0, 0, MAX_CLIENTS, 0, STR_NULL, UpdateMinActiveClients),
|
||||||
SDTC_OMANY(network.server_lang, SLE_UINT8, S, NO, 0, 35, "ANY|ENGLISH|GERMAN|FRENCH|BRAZILIAN|BULGARIAN|CHINESE|CZECH|DANISH|DUTCH|ESPERANTO|FINNISH|HUNGARIAN|ICELANDIC|ITALIAN|JAPANESE|KOREAN|LITHUANIAN|NORWEGIAN|POLISH|PORTUGUESE|ROMANIAN|RUSSIAN|SLOVAK|SLOVENIAN|SPANISH|SWEDISH|TURKISH|UKRAINIAN|AFRIKAANS|CROATIAN|CATALAN|ESTONIAN|GALICIAN|GREEK|LATVIAN", STR_NULL, NULL),
|
SDTC_OMANY(network.server_lang, SLE_UINT8, S, NO, 0, 35, "ANY|ENGLISH|GERMAN|FRENCH|BRAZILIAN|BULGARIAN|CHINESE|CZECH|DANISH|DUTCH|ESPERANTO|FINNISH|HUNGARIAN|ICELANDIC|ITALIAN|JAPANESE|KOREAN|LITHUANIAN|NORWEGIAN|POLISH|PORTUGUESE|ROMANIAN|RUSSIAN|SLOVAK|SLOVENIAN|SPANISH|SWEDISH|TURKISH|UKRAINIAN|AFRIKAANS|CROATIAN|CATALAN|ESTONIAN|GALICIAN|GREEK|LATVIAN", STR_NULL, NULL),
|
||||||
SDTC_BOOL(network.reload_cfg, S, NO, false, STR_NULL, NULL),
|
SDTC_BOOL(network.reload_cfg, S, NO, false, STR_NULL, NULL),
|
||||||
SDTC_STR(network.last_host, SLE_STRB, S, 0, "0.0.0.0", STR_NULL, NULL),
|
SDTC_STR(network.last_host, SLE_STRB, S, 0, "0.0.0.0", STR_NULL, NULL),
|
||||||
|
Loading…
Reference in New Issue
Block a user