mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r10380) -Fix (r10364): when checking for unique names, only check vehicles that can have names, and skip inactive players.
This commit is contained in:
parent
42f0593b82
commit
b3c3171c1e
|
@ -201,6 +201,7 @@ static bool IsUniqueCompanyName(const char *name)
|
||||||
char buf[512];
|
char buf[512];
|
||||||
|
|
||||||
FOR_ALL_PLAYERS(p) {
|
FOR_ALL_PLAYERS(p) {
|
||||||
|
if (!p->is_active) continue;
|
||||||
SetDParam(0, p->index);
|
SetDParam(0, p->index);
|
||||||
GetString(buf, STR_COMPANY_NAME, lastof(buf));
|
GetString(buf, STR_COMPANY_NAME, lastof(buf));
|
||||||
if (strcmp(buf, name) == 0) return false;
|
if (strcmp(buf, name) == 0) return false;
|
||||||
|
@ -245,6 +246,7 @@ static bool IsUniquePresidentName(const char *name)
|
||||||
char buf[512];
|
char buf[512];
|
||||||
|
|
||||||
FOR_ALL_PLAYERS(p) {
|
FOR_ALL_PLAYERS(p) {
|
||||||
|
if (!p->is_active) continue;
|
||||||
SetDParam(0, p->index);
|
SetDParam(0, p->index);
|
||||||
GetString(buf, STR_PLAYER_NAME, lastof(buf));
|
GetString(buf, STR_PLAYER_NAME, lastof(buf));
|
||||||
if (strcmp(buf, name) == 0) return false;
|
if (strcmp(buf, name) == 0) return false;
|
||||||
|
|
|
@ -2405,17 +2405,26 @@ static bool IsUniqueVehicleName(const char *name)
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
switch (v->type) {
|
switch (v->type) {
|
||||||
case VEH_TRAIN:
|
case VEH_TRAIN:
|
||||||
|
if (!IsTrainEngine(v)) continue;
|
||||||
|
break;
|
||||||
|
|
||||||
case VEH_ROAD:
|
case VEH_ROAD:
|
||||||
|
break;
|
||||||
|
|
||||||
case VEH_AIRCRAFT:
|
case VEH_AIRCRAFT:
|
||||||
|
if (!IsNormalAircraft(v)) continue;
|
||||||
|
break;
|
||||||
|
|
||||||
case VEH_SHIP:
|
case VEH_SHIP:
|
||||||
SetDParam(0, v->index);
|
|
||||||
GetString(buf, STR_VEHICLE_NAME, lastof(buf));
|
|
||||||
if (strcmp(buf, name) == 0) return false;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetDParam(0, v->index);
|
||||||
|
GetString(buf, STR_VEHICLE_NAME, lastof(buf));
|
||||||
|
if (strcmp(buf, name) == 0) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue