(svn r11844) -Fix: road vehicle count was incorrect in network lobby window
authorglx
Sun, 13 Jan 2008 22:27:06 +0000
changeset 8280 bb1cd1c23f4b
parent 8279 b8b1e11e175c
child 8281 c4b8951e7aa9
(svn r11844) -Fix: road vehicle count was incorrect in network lobby window
src/network/network_server.cpp
--- a/src/network/network_server.cpp	Sun Jan 13 22:12:39 2008 +0000
+++ b/src/network/network_server.cpp	Sun Jan 13 22:27:06 2008 +0000
@@ -8,8 +8,8 @@
 #include "../strings_func.h"
 #include "network_data.h"
 #include "core/tcp.h"
-#include "../train.h"
-#include "../aircraft.h"
+#include "../vehicle_base.h"
+#include "../vehicle_func.h"
 #include "../date_func.h"
 #include "network_server.h"
 #include "network_udp.h"
@@ -1302,30 +1302,15 @@
 	// Go through all vehicles and count the type of vehicles
 	FOR_ALL_VEHICLES(v) {
 		if (!IsValidPlayer(v->owner)) continue;
-
+		byte type = 0;
 		switch (v->type) {
-			case VEH_TRAIN:
-				if (IsFrontEngine(v)) _network_player_info[v->owner].num_vehicle[0]++;
-				break;
-
-			case VEH_ROAD:
-				if (v->cargo_type != CT_PASSENGERS) {
-					_network_player_info[v->owner].num_vehicle[1]++;
-				} else {
-					_network_player_info[v->owner].num_vehicle[2]++;
-				}
-				break;
-
-			case VEH_AIRCRAFT:
-				if (IsNormalAircraft(v)) _network_player_info[v->owner].num_vehicle[3]++;
-				break;
-
-			case VEH_SHIP:
-				_network_player_info[v->owner].num_vehicle[4]++;
-				break;
-
-			default: break;
+			case VEH_TRAIN: type = 0; break;
+			case VEH_ROAD: type = (v->cargo_type != CT_PASSENGERS) ? 1 : 2; break;
+			case VEH_AIRCRAFT: type = 3; break;
+			case VEH_SHIP: type = 4; break;
+			default: continue;
 		}
+		if (IsEngineCountable(v)) _network_player_info[v->owner].num_vehicle[type]++;
 	}
 
 	// Go through all stations and count the types of stations