summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2007-06-28 19:14:29 +0000
committerpeter1138 <peter1138@openttd.org>2007-06-28 19:14:29 +0000
commitb3c3171c1e801b0e52a720f741ac9a0cfbe17e66 (patch)
tree002a0bd36c3cde999cdf1ec36495b68bbe01111d /src
parent42f0593b82912f81dd1e92afb0223b78dc0eb363 (diff)
downloadopenttd-b3c3171c1e801b0e52a720f741ac9a0cfbe17e66.tar.xz
(svn r10380) -Fix (r10364): when checking for unique names, only check vehicles that can have names, and skip inactive players.
Diffstat (limited to 'src')
-rw-r--r--src/misc_cmd.cpp2
-rw-r--r--src/vehicle.cpp17
2 files changed, 15 insertions, 4 deletions
diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp
index 3a0448f84..830354c53 100644
--- a/src/misc_cmd.cpp
+++ b/src/misc_cmd.cpp
@@ -201,6 +201,7 @@ static bool IsUniqueCompanyName(const char *name)
char buf[512];
FOR_ALL_PLAYERS(p) {
+ if (!p->is_active) continue;
SetDParam(0, p->index);
GetString(buf, STR_COMPANY_NAME, lastof(buf));
if (strcmp(buf, name) == 0) return false;
@@ -245,6 +246,7 @@ static bool IsUniquePresidentName(const char *name)
char buf[512];
FOR_ALL_PLAYERS(p) {
+ if (!p->is_active) continue;
SetDParam(0, p->index);
GetString(buf, STR_PLAYER_NAME, lastof(buf));
if (strcmp(buf, name) == 0) return false;
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 45222cd69..775113536 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -2405,17 +2405,26 @@ static bool IsUniqueVehicleName(const char *name)
FOR_ALL_VEHICLES(v) {
switch (v->type) {
case VEH_TRAIN:
+ if (!IsTrainEngine(v)) continue;
+ break;
+
case VEH_ROAD:
+ break;
+
case VEH_AIRCRAFT:
+ if (!IsNormalAircraft(v)) continue;
+ break;
+
case VEH_SHIP:
- SetDParam(0, v->index);
- GetString(buf, STR_VEHICLE_NAME, lastof(buf));
- if (strcmp(buf, name) == 0) return false;
break;
default:
- break;
+ continue;
}
+
+ SetDParam(0, v->index);
+ GetString(buf, STR_VEHICLE_NAME, lastof(buf));
+ if (strcmp(buf, name) == 0) return false;
}
return true;