(svn r10380) -Fix (r10364): when checking for unique names, only check vehicles that can have names, and skip inactive players.
authorpeter1138
Thu, 28 Jun 2007 19:14:29 +0000
changeset 7604 bdf34754bb16
parent 7603 b79d8772d069
child 7605 5135b6db22bf
(svn r10380) -Fix (r10364): when checking for unique names, only check vehicles that can have names, and skip inactive players.
src/misc_cmd.cpp
src/vehicle.cpp
--- a/src/misc_cmd.cpp	Thu Jun 28 19:03:14 2007 +0000
+++ b/src/misc_cmd.cpp	Thu Jun 28 19:14:29 2007 +0000
@@ -201,6 +201,7 @@
 	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 @@
 	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;
--- a/src/vehicle.cpp	Thu Jun 28 19:03:14 2007 +0000
+++ b/src/vehicle.cpp	Thu Jun 28 19:14:29 2007 +0000
@@ -2405,17 +2405,26 @@
 	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;