(svn r1568) made an enum of train subtypes to make the code more readable
authorbjarni
Wed, 19 Jan 2005 19:15:03 +0000
changeset 1067 3ba7987a004e
parent 1066 eaef1465d3ab
child 1068 b3abc3cebf53
(svn r1568) made an enum of train subtypes to make the code more readable
economy.c
main_gui.c
network_server.c
order_gui.c
player_gui.c
station_cmd.c
train_cmd.c
train_gui.c
tunnelbridge_cmd.c
vehicle.c
vehicle.h
vehicle_gui.c
--- a/economy.c	Wed Jan 19 13:31:46 2005 +0000
+++ b/economy.c	Wed Jan 19 19:15:03 2005 +0000
@@ -128,7 +128,7 @@
 		FOR_ALL_VEHICLES(v) {
 			if (v->owner != owner)
 				continue;
-			if ((v->type == VEH_Train && v->subtype == 0) ||
+			if ((v->type == VEH_Train && v->subtype == TS_Front_Engine) ||
 					v->type == VEH_Road ||
 					(v->type == VEH_Aircraft && v->subtype<=2) ||
 					v->type == VEH_Ship) {
@@ -310,7 +310,7 @@
 		// Determine Ids for the new vehicles
 		FOR_ALL_VEHICLES(v) {
 			if (v->owner == new_player) {
-				if (v->type == VEH_Train && v->subtype == 0)
+				if (v->type == VEH_Train && v->subtype == TS_Front_Engine)
 					num_train++;
 				else if (v->type == VEH_Road)
 					num_road++;
@@ -330,7 +330,7 @@
 					DeleteVehicle(v);
 				} else {
 					v->owner = new_player;
-					if (v->type == VEH_Train && v->subtype == 0)
+					if (v->type == VEH_Train && v->subtype == TS_Front_Engine)
 						v->unitnumber = ++num_train;
 					else if (v->type == VEH_Road)
 						v->unitnumber = ++num_road;
@@ -1297,7 +1297,7 @@
 	}
 
 	FOR_ALL_VEHICLES(x) {
-		if ((x->type != VEH_Train || x->subtype == 0) && // for all locs
+		if ((x->type != VEH_Train || x->subtype == TS_Front_Engine) && // for all locs
 				u->last_station_visited == x->last_station_visited && // at the same station
 				!(x->vehstatus & VS_STOPPED) && // not stopped
 				x->current_order.type == OT_LOADING && // loading
--- a/main_gui.c	Wed Jan 19 13:31:46 2005 +0000
+++ b/main_gui.c	Wed Jan 19 19:15:03 2005 +0000
@@ -810,7 +810,7 @@
 	Vehicle *v;
 	int dis = -1;
 	FOR_ALL_VEHICLES(v)
-		if (v->type == VEH_Train && v->subtype == 0) CLRBIT(dis, v->owner);
+		if (v->type == VEH_Train && v->subtype == TS_Front_Engine) CLRBIT(dis, v->owner);
 	PopupMainPlayerToolbMenu(w, 310, 13, dis);
 }
 
--- a/network_server.c	Wed Jan 19 13:31:46 2005 +0000
+++ b/network_server.c	Wed Jan 19 19:15:03 2005 +0000
@@ -1249,7 +1249,7 @@
 		if (v->owner < MAX_PLAYERS)
 			switch (v->type) {
 				case VEH_Train:
-					if (v->subtype == 0)
+					if (v->subtype == TS_Front_Engine)
 						_network_player_info[v->owner].num_vehicle[0]++;
 					break;
 				case VEH_Road:
--- a/order_gui.c	Wed Jan 19 13:31:46 2005 +0000
+++ b/order_gui.c	Wed Jan 19 19:15:03 2005 +0000
@@ -271,9 +271,9 @@
 	if (u->type != v->type)
 		return false;
 
-	if (u->type == VEH_Train && u->subtype != 0) {
+	if (u->type == VEH_Train && u->subtype != TS_Front_Engine) {
 		u = GetFirstVehicleInChain(u);
-		if (u->subtype != 0)
+		if (u->subtype != TS_Front_Engine)
 			return false;
 	}
 
--- a/player_gui.c	Wed Jan 19 13:31:46 2005 +0000
+++ b/player_gui.c	Wed Jan 19 19:15:03 2005 +0000
@@ -424,7 +424,7 @@
 	FOR_ALL_VEHICLES(v) {
 		if (v->owner == player) {
 			if (v->type == VEH_Train) {
-				if (v->subtype == 0)
+				if (v->subtype == TS_Front_Engine)
 					train++;
 			} else if (v->type == VEH_Road) {
 				road++;
--- a/station_cmd.c	Wed Jan 19 13:31:46 2005 +0000
+++ b/station_cmd.c	Wed Jan 19 19:15:03 2005 +0000
@@ -2188,7 +2188,7 @@
 	uint16 spd;
 
 	if (v->type == VEH_Train) {
-		if (IS_BYTE_INSIDE(_map5[tile], 0, 8) && v->subtype == 0 &&
+		if (IS_BYTE_INSIDE(_map5[tile], 0, 8) && v->subtype == TS_Front_Engine &&
 			!IsTrainStationTile(tile + TileOffsByDir(v->direction >> 1))) {
 
 			station_id = _map2[tile];
--- a/train_cmd.c	Wed Jan 19 13:31:46 2005 +0000
+++ b/train_cmd.c	Wed Jan 19 19:15:03 2005 +0000
@@ -39,7 +39,7 @@
 	uint acc, power=0, max_speed=5000, weight=0;
 	Vehicle *u = v;
 
-	assert(v->subtype == 0);
+	assert(v->subtype == TS_Front_Engine);
 
 	// compute stuff like max speed, power, and weight.
 	do {
@@ -92,7 +92,7 @@
 	float f = 0.0f, spd;
 	int curves = 0;
 
-	assert(v->subtype == 0);
+	assert(v->subtype == TS_Front_Engine);
 
 	// compute inclination force and number of curves.
 	do {
@@ -251,7 +251,7 @@
 
 			FOR_ALL_VEHICLES(w) {
 				if (w->type == VEH_Train && w->tile == (TileIndex)tile &&
-				    w->subtype == 4 && w->engine_type == engine) {
+				    w->subtype == TS_Free_Car && w->engine_type == engine) {
 					u = GetLastVehicleInChain(w);
 					break;
 				}
@@ -275,12 +275,12 @@
 			v->u.rail.track = 0x80;
 			v->vehstatus = VS_HIDDEN | VS_DEFPAL;
 
-			v->subtype = 4;
+			v->subtype = TS_Free_Car;
 			if (u != NULL) {
 				u->next = v;
-				v->subtype = 2;
+				v->subtype = TS_Not_First;
 				v->u.rail.first_engine = u->u.rail.first_engine;
-				if (v->u.rail.first_engine == 0xffff && u->subtype == 0)
+				if (v->u.rail.first_engine == 0xffff && u->subtype == TS_Front_Engine )
 					v->u.rail.first_engine = u->engine_type;
 			} else {
 				v->u.rail.first_engine = 0xffff;
@@ -314,7 +314,7 @@
 {
 	Vehicle *v;
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_Train && v->subtype==4 &&
+		if (v->type == VEH_Train && v->subtype == TS_Free_Car &&
 				v->tile == u->tile &&
 				v->u.rail.track == 0x80) {
 			if (DoCommandByTile(0,v->index | (u->index<<16), 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE) == CMD_ERROR)
@@ -377,7 +377,7 @@
 	u->u.rail.track = 0x80;
 	v->u.rail.first_engine = 0xffff;
 	u->vehstatus = v->vehstatus & ~VS_STOPPED;
-	u->subtype = 2;
+	u->subtype = TS_Not_First;
 	u->spritenum = v->spritenum + 1;
 	u->cargo_type = v->cargo_type;
 	u->cargo_cap = v->cargo_cap;
@@ -517,7 +517,7 @@
 	do {
 		count++;
 		if (v->u.rail.track != 0x80 || v->tile != (TileIndex)tile ||
-				(v->subtype==0 && !(v->vehstatus&VS_STOPPED)))
+				(v->subtype == TS_Front_Engine && !(v->vehstatus&VS_STOPPED)))
 			goto errmsg;
 	} while ( (v=v->next) != NULL);
 
@@ -534,7 +534,7 @@
 		Vehicle *u;
 		if ((v=v->next) == NULL) return NULL;
 		for (u=v; u; u=u->next) u->u.rail.first_engine = v->engine_type;
-		v->subtype = 4;
+		v->subtype = TS_Free_Car;
 		return v;
 	} else {
 		Vehicle *u;
@@ -551,7 +551,7 @@
 	TileIndex tile = src->tile;
 
 	FOR_ALL_VEHICLES(dst) {
-		if (dst->type==VEH_Train && dst->subtype==4 && dst->tile==tile) {
+		if (dst->type == VEH_Train && dst->subtype == TS_Free_Car && dst->tile==tile) {
 			// check so all vehicles in the line have the same engine.
 			Vehicle *v = dst;
 			while (v->engine_type == eng) {
@@ -611,7 +611,7 @@
 		if (num < 0)
 			return CMD_ERROR;
 
-		if (num > (_patches.mammoth_trains ? 100 : 9) && dst_head->subtype==0)
+		if (num > (_patches.mammoth_trains ? 100 : 9) && dst_head->subtype == TS_Front_Engine )
 			return_cmd_error(STR_8819_TRAIN_TOO_LONG);
 
 		// if it's a multiheaded vehicle we're dragging to, drag to the vehicle before..
@@ -630,7 +630,7 @@
 		return 0;
 
 	// moving a loco to a new line?, then we need to assign a unitnumber.
-	if (dst == NULL && src->subtype != 0 && is_loco) {
+	if (dst == NULL && src->subtype != TS_Front_Engine && is_loco) {
 		uint unit_num = GetFreeUnitNumber(VEH_Train);
 		if (unit_num > _patches.max_trains)
 			return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
@@ -658,30 +658,30 @@
 		if (dst == NULL) {
 			// move the train to an empty line. for locomotives, we set the type to 0. for wagons, 4.
 			if (is_loco) {
-				if (src->subtype != 0) {
+				if (src->subtype != TS_Front_Engine) {
 					// setting the type to 0 also involves setting up the orders field.
-					src->subtype = 0;
+					src->subtype = TS_Front_Engine;
 					assert(src->orders == NULL);
 					src->num_orders = 0;
 				}
 				dst_head = src;
 			} else {
-				src->subtype = 4;
+				src->subtype = TS_Free_Car;
 			}
 			src->u.rail.first_engine = 0xffff;
 		} else {
-			if (src->subtype == 0) {
+			if (src->subtype == TS_Front_Engine) {
 				// the vehicle was previously a loco. need to free the order list and delete vehicle windows etc.
 				DeleteWindowById(WC_VEHICLE_VIEW, src->index);
 				DeleteVehicleOrders(src);
 			}
 
-			src->subtype = 2;
+			src->subtype = TS_Not_First;
 			src->unitnumber = 0; // doesn't occupy a unitnumber anymore.
 
 			// setup first_engine
 			src->u.rail.first_engine = dst->u.rail.first_engine;
-			if (src->u.rail.first_engine == 0xffff && dst->subtype == 0)
+			if (src->u.rail.first_engine == 0xffff && dst->subtype == TS_Front_Engine)
 				src->u.rail.first_engine = dst->engine_type;
 
 			// link in the wagon(s) in the chain.
@@ -696,12 +696,12 @@
 			dst->next = src;
 		}
 
-		if (src_head->subtype == 0)
+		if (src_head->subtype == TS_Front_Engine)
 			UpdateTrainAcceleration(src_head);
 		InvalidateWindow(WC_VEHICLE_DETAILS, src_head->index);
 
 		if (dst_head) {
-			if (dst_head->subtype == 0)
+			if (dst_head->subtype == TS_Front_Engine)
 				UpdateTrainAcceleration(dst_head);
 			InvalidateWindow(WC_VEHICLE_DETAILS, dst_head->index);
 		}
@@ -751,7 +751,7 @@
 
 	// get first vehicle in chain
 	first = v;
-	if (first->subtype != 0) {
+	if (first->subtype != TS_Front_Engine) {
 		first = GetFirstVehicleInChain(first);
 		last = GetLastVehicleInChain(first);
 		//now if:
@@ -761,7 +761,7 @@
 		// 4) the first and the last vehicle of the chain are not identical
 		// 5) and of "engine" type (i.e. not a carriage)
 		// then let the last vehicle live
-		if ( (p2 == 1) && (v != last) && ( last->engine_type == first->engine_type ) && (last != first) && (first->subtype == 0) )
+		if ( (p2 == 1) && (v != last) && ( last->engine_type == first->engine_type ) && (last != first) && (first->subtype == TS_Front_Engine) )
 			last = GetPrevVehicleInChain(last);
 		else
 			last = NULL;
@@ -785,11 +785,11 @@
 	if (flags & DC_EXEC) {
 		// always redraw the depot. maybe redraw train list
 		InvalidateWindow(WC_VEHICLE_DEPOT, first->tile);
-		if (first->subtype == 0) {
+		if (first->subtype == TS_Front_Engine) {
 			RebuildVehicleLists();
 		}
 		// when selling an attached locomotive. we need to delete its window.
-		if (v->subtype == 0) {
+		if (v->subtype == TS_Front_Engine) {
 			DeleteWindowById(WC_VEHICLE_VIEW, v->index);
 
 			// rearrange all vehicles that follow to separate lines.
@@ -829,7 +829,7 @@
 		}
 
 		// an attached train changed?
-		if (first && first->subtype == 0) {
+		if (first && first->subtype == TS_Front_Engine) {
 			UpdateTrainAcceleration(first);
 			InvalidateWindow(WC_VEHICLE_DETAILS, first->index);
 		}
@@ -1920,7 +1920,7 @@
 			// tracks over roads, do owner check of tracks (_map_owner[tile])
 			return
 				_map_owner[tile] == v->owner &&
-				(v->subtype != 0 || (_map3_hi[tile] & 0xF) == v->u.rail.railtype);
+				(v->subtype != TS_Front_Engine || (_map3_hi[tile] & 0xF) == v->u.rail.railtype);
 
 		default:
 			return true;
@@ -1928,7 +1928,7 @@
 
 	return
 		_map_owner[tile] == v->owner &&
-		(v->subtype != 0 || (_map3_lo[tile] & 0xF) == v->u.rail.railtype);
+		(v->subtype != TS_Front_Engine || (_map3_lo[tile] & 0xF) == v->u.rail.railtype);
 }
 
 typedef struct {
@@ -2028,14 +2028,14 @@
 {
 	int num = 0;
 	BEGIN_ENUM_WAGONS(v)
-		if (v->cargo_type == 0) num += v->cargo_count;
+		if (v->cargo_type == CT_PASSENGERS) num += v->cargo_count;
 	END_ENUM_WAGONS(v)
 	return num;
 }
 
 /*
  * Checks whether the specified tried has a collision with another vehicle. If
- * so, destroys this vehicle, and the other vehicle if its subtype is 0 (?).
+ * so, destroys this vehicle, and the other vehicle if its subtype is 0 (TS_Front_Engine).
  * Reports the incident in a flashy news item, modifies station ratings and
  * plays a sound.
  */
@@ -2074,7 +2074,7 @@
 		num += 2 + CountPassengersInTrain(coll);
 
 	SetVehicleCrashed(v);
-	if (coll->subtype == 0)
+	if (coll->subtype == TS_Front_Engine)
 		SetVehicleCrashed(coll);
 
 
@@ -2093,7 +2093,7 @@
 {
 	uint32 d = (uint32)data;
 
-	if (v->type == VEH_Train && v->subtype == 0 && v->tile == (TileIndex)(d >> 8)) {
+	if (v->type == VEH_Train && v->subtype == TS_Front_Engine && v->tile == (TileIndex)(d >> 8)) {
 		byte diff = (v->direction - (byte)d + 2) & 7;
 		if (diff == 2 || (v->cur_speed <= 5 && diff <= 4))
 			return (void*)1;
@@ -2196,14 +2196,14 @@
 				if (r&0x8)
 					goto invalid_rail;
 
-				if (v->subtype == 0) v->load_unload_time_rem = 0;
+				if (v->subtype == TS_Front_Engine) v->load_unload_time_rem = 0;
 
 				if (!(r&0x4)) {
 					v->tile = gp.new_tile;
 					v->u.rail.track = chosen_track;
 				}
 
-				if (v->subtype == 0)
+				if (v->subtype == TS_Front_Engine)
 					TrainMovedChangeSignals(gp.new_tile, dir>>1);
 
 				/* Signals can only change when the first
@@ -2606,11 +2606,11 @@
 
 	v->tick_counter++;
 
-	if (v->subtype == 0) {
+	if (v->subtype == TS_Front_Engine) {
 		TrainLocoHandler(v, false);
 
 		// make sure vehicle wasn't deleted.
-		if (v->type == VEH_Train && v->subtype == 0)
+		if (v->type == VEH_Train && v->subtype == TS_Front_Engine)
 			TrainLocoHandler(v, true);
 	}
 }
@@ -2629,7 +2629,7 @@
 {
 	SetSignalsOnBothDir(tile, _depot_track_ind[_map5[tile]&3]);
 
-	if (v->subtype != 0)
+	if (v->subtype != TS_Front_Engine)
 		v = GetFirstVehicleInChain(v);
 
 	VehicleServiceInDepot(v);
@@ -2741,7 +2741,7 @@
 	if ((++v->day_counter & 7) == 0)
 		DecreaseVehicleValue(v);
 
-	if (v->subtype == 0) {
+	if (v->subtype == TS_Front_Engine) {
 		CheckVehicleBreakdown(v);
 		AgeVehicle(v);
 
@@ -2785,7 +2785,7 @@
 	Vehicle *v;
 
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_Train && v->subtype == 0) {
+		if (v->type == VEH_Train && v->subtype == TS_Front_Engine) {
 
 			// show warning if train is not generating enough income last 2 years (corresponds to a red icon in the vehicle list)
 			if (_patches.train_income_warn && v->owner == _local_player && v->age >= 730 && v->profit_this_year < 0) {
@@ -2809,7 +2809,7 @@
 
 void HandleClickOnTrain(Vehicle *v)
 {
-	if (v->subtype != 0) v = GetFirstVehicleInChain(v);
+	if (v->subtype != TS_Front_Engine) v = GetFirstVehicleInChain(v);
 	ShowTrainViewWindow(v);
 }
 
--- a/train_gui.c	Wed Jan 19 13:31:46 2005 +0000
+++ b/train_gui.c	Wed Jan 19 19:15:03 2005 +0000
@@ -65,7 +65,7 @@
 	// find a locomotive in the depot.
 	found = NULL;
 	FOR_ALL_VEHICLES(v) {
-		if (v->type == VEH_Train && v->subtype==0 &&
+		if (v->type == VEH_Train && v->subtype == TS_Front_Engine &&
 				v->tile == tile &&
 				v->u.rail.track == 0x80) {
 			if (found != NULL) // must be exactly one.
@@ -314,12 +314,12 @@
 	hnum = 1;
 	FOR_ALL_VEHICLES(v) {
 		if (v->type == VEH_Train &&
-				  (v->subtype == 0 || v->subtype == 4) &&
+				  (v->subtype == TS_Front_Engine || v->subtype == TS_Free_Car) &&
 				v->tile == (TileIndex)tile &&
 				v->u.rail.track == 0x80) {
 					num++;
 					// determine number of items in the X direction.
-					if (v->subtype == 0) {
+					if (v->subtype == TS_Front_Engine) {
 						i = 0;
 						u = v;
 						do i++; while ( (u=u->next) != NULL);
@@ -349,7 +349,7 @@
 	// draw all trains
 	FOR_ALL_VEHICLES(v) {
 		if (v->type == VEH_Train &&
-				v->subtype == 0 &&
+				v->subtype == TS_Front_Engine &&
 				v->tile == (TileIndex)tile &&
 				v->u.rail.track == 0x80 &&
 				--num < 0 && num >= -w->vscroll.cap) {
@@ -377,7 +377,7 @@
 	// draw all remaining vehicles
 	FOR_ALL_VEHICLES(v) {
 		if (v->type == VEH_Train &&
-				v->subtype == 4 &&
+				v->subtype == TS_Free_Car &&
 				v->tile == (TileIndex)tile &&
 				v->u.rail.track == 0x80 &&
 				--num < 0 && num >= -w->vscroll.cap) {
@@ -424,7 +424,7 @@
 	/* go through all the locomotives */
 	FOR_ALL_VEHICLES(v) {
 		if (v->type == VEH_Train &&
-				v->subtype == 0 &&
+				v->subtype == TS_Front_Engine &&
 				v->tile == w->window_number &&
 				v->u.rail.track == 0x80 &&
 				--row < 0) {
@@ -438,7 +438,7 @@
 	/* and then the list of free wagons */
 	FOR_ALL_VEHICLES(v) {
 		if (v->type == VEH_Train &&
-				v->subtype == 4 &&
+				v->subtype == TS_Free_Car &&
 				v->tile == w->window_number &&
 				v->u.rail.track == 0x80 &&
 				--row < 0)
@@ -455,7 +455,7 @@
 	d->head = d->wagon = v;
 
 	/* either pressed the flag or the number, but only when it's a loco */
-	if (area_x < 0 && v->subtype==0)
+	if (area_x < 0 && v->subtype == TS_Front_Engine)
 		return area_x;
 
 	/* find the vehicle in this row that was clicked */
@@ -475,7 +475,7 @@
 
 	v = GetVehicle(sel);
 
-	if (/*v->subtype == 0 ||*/ v == wagon)
+	if (/*v->subtype == TS_Front_Engine ||*/ v == wagon)
 		return;
 
 	if (wagon == NULL) {
@@ -576,7 +576,7 @@
 
 			sell_cmd = (e->click.widget == 5 || _ctrl_pressed) ? 1 : 0;
 
-			if (v->subtype != 0) {
+			if (v->subtype != TS_Front_Engine) {
 				DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE));
 			} else {
 				_backup_orders_tile = v->tile;
@@ -597,7 +597,7 @@
 						sel != INVALID_VEHICLE) {
 					if (gdvp.wagon == NULL || gdvp.wagon->index != sel) {
 						TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
-					} else if (gdvp.head != NULL && gdvp.head->subtype==0) {
+					} else if (gdvp.head != NULL && gdvp.head->subtype == TS_Front_Engine) {
 						ShowTrainViewWindow(gdvp.head);
 					}
 				}
@@ -1365,7 +1365,7 @@
 
 				v = GetVehicle(vl->sort_list[id_v].index);
 
-				assert(v->type == VEH_Train && v->subtype == 0 && v->owner == owner);
+				assert(v->type == VEH_Train && v->subtype == TS_Front_Engine && v->owner == owner);
 
 				ShowTrainViewWindow(v);
 			}
--- a/tunnelbridge_cmd.c	Wed Jan 19 13:31:46 2005 +0000
+++ b/tunnelbridge_cmd.c	Wed Jan 19 19:15:03 2005 +0000
@@ -1413,7 +1413,7 @@
 			vdir = v->direction >> 1;
 
 			if (v->u.rail.track != 0x40 && dir == vdir) {
-				if (v->subtype == 0 && fc == _tunnel_fractcoord_1[dir]) {
+				if (v->subtype == TS_Front_Engine && fc == _tunnel_fractcoord_1[dir]) {
 					if (v->spritenum < 4)
 						SndPlayVehicleFx(SND_05_TRAIN_THROUGH_TUNNEL, v);
 					return 0;
@@ -1465,7 +1465,7 @@
 			}
 		}
 	} else if (_map5[tile] & 0x80) {
-		if (v->type == VEH_Road || (v->type == VEH_Train && v->subtype == 0)) {
+		if (v->type == VEH_Road || (v->type == VEH_Train && v->subtype == TS_Front_Engine)) {
 			if (GetTileSlope(tile, &h) != 0)
 				h += 8; // Compensate for possible foundation
 			if (!(_map5[tile] & 0x40) || // start/end tile of bridge
--- a/vehicle.c	Wed Jan 19 13:31:46 2005 +0000
+++ b/vehicle.c	Wed Jan 19 19:15:03 2005 +0000
@@ -159,7 +159,7 @@
 			VehiclePositionChanged(v);
 
 			if (v->type == VEH_Train) {
-				if (v->subtype == 0)
+				if (v->subtype == TS_Front_Engine)
 					UpdateTrainAcceleration(v);
 			}
 		}
@@ -2012,7 +2012,7 @@
 	FOR_ALL_VEHICLES(v) {
 		Vehicle *w;
 
-		if (v->type != VEH_Train || v->subtype != 0)
+		if (v->type != VEH_Train || v->subtype != TS_Front_Engine)
 			continue;
 
 		for (w = v->next; w; w = w->next)
--- a/vehicle.h	Wed Jan 19 13:31:46 2005 +0000
+++ b/vehicle.h	Wed Jan 19 19:15:03 2005 +0000
@@ -229,7 +229,12 @@
 	VS_CRASHED = 0x80,
 };
 
-
+// 1 and 3 do not appear to be used
+enum TrainSubtype {
+	TS_Front_Engine = 0,
+	TS_Not_First = 2,
+	TS_Free_Car = 4,
+};
 
 /* Effect vehicle types */
 enum {
--- a/vehicle_gui.c	Wed Jan 19 13:31:46 2005 +0000
+++ b/vehicle_gui.c	Wed Jan 19 19:15:03 2005 +0000
@@ -72,7 +72,7 @@
 
 void BuildVehicleList(vehiclelist_d *vl, int type, int owner, int station)
 {
-	int subtype = (type != VEH_Aircraft) ? 0 : 2;
+	int subtype = (type != VEH_Aircraft) ? TS_Front_Engine : 2;
 	int n = 0;
 	int i;