(svn r3150) Unify some code duplication in HandleLocomotiveSmokeCloud()
authorpeter1138
Mon, 07 Nov 2005 13:02:33 +0000
changeset 2612 744aef3af72f
parent 2611 65b5313bc525
child 2613 b008d366ed8a
(svn r3150) Unify some code duplication in HandleLocomotiveSmokeCloud()
train_cmd.c
--- a/train_cmd.c	Sun Nov 06 13:42:26 2005 +0000
+++ b/train_cmd.c	Mon Nov 07 13:02:33 2005 +0000
@@ -1876,6 +1876,10 @@
 				(v->vehstatus & VS_HIDDEN) || (v->u.rail.track & 0xC0))
 			continue;
 
+		// No smoke in depots or tunnels
+		if (IsTileDepotType(v->tile, TRANSPORT_RAIL) || IsTunnelTile(v->tile))
+			continue;
+
 		if (effect_type == 0) {
 			// Use default effect type for engine class.
 			effect_type = RailVehInfo(engtype)->engclass;
@@ -1889,21 +1893,21 @@
 		switch (effect_type) {
 		case 0:
 			// steam smoke.
-			if ( (v->tick_counter&0xF) == 0 && !IsTileDepotType(v->tile, TRANSPORT_RAIL) && !IsTunnelTile(v->tile)) {
+			if (GB(v->tick_counter, 0, 4) == 0) {
 				CreateEffectVehicleRel(v, x, y, 10, EV_STEAM_SMOKE);
 			}
 			break;
 
 		case 1:
 			// diesel smoke
-			if (u->cur_speed <= 40 && !IsTileDepotType(v->tile, TRANSPORT_RAIL) && !IsTunnelTile(v->tile) && GB(Random(), 0, 16) <= 0x1E00) {
+			if (u->cur_speed <= 40 && GB(Random(), 0, 16) <= 0x1E00) {
 				CreateEffectVehicleRel(v, 0, 0, 10, EV_DIESEL_SMOKE);
 			}
 			break;
 
 		case 2:
 			// blue spark
-			if (GB(v->tick_counter, 0, 2) == 0 && !IsTileDepotType(v->tile, TRANSPORT_RAIL) && !IsTunnelTile(v->tile) && GB(Random(), 0, 16) <= 0x5B0) {
+			if (GB(v->tick_counter, 0, 2) == 0 && GB(Random(), 0, 16) <= 0x5B0) {
 				CreateEffectVehicleRel(v, 0, 0, 10, EV_ELECTRIC_SPARK);
 			}
 			break;