src/train_cmd.cpp
changeset 8425 72a71d480c5f
parent 8424 4a488a90ccab
child 8427 143b0be22af1
equal deleted inserted replaced
8424:4a488a90ccab 8425:72a71d480c5f
   206 			if (rvi_v->pow_wag_power != 0 && rvi_u->railveh_type == RAILVEH_WAGON &&
   206 			if (rvi_v->pow_wag_power != 0 && rvi_u->railveh_type == RAILVEH_WAGON &&
   207 				UsesWagonOverride(u) && !HasBit(u->u.rail.cached_vis_effect, 7)) {
   207 				UsesWagonOverride(u) && !HasBit(u->u.rail.cached_vis_effect, 7)) {
   208 				/* wagon is powered */
   208 				/* wagon is powered */
   209 				SETBIT(u->u.rail.flags, VRF_POWEREDWAGON); // cache 'powered' status
   209 				SETBIT(u->u.rail.flags, VRF_POWEREDWAGON); // cache 'powered' status
   210 			} else {
   210 			} else {
   211 				CLRBIT(u->u.rail.flags, VRF_POWEREDWAGON);
   211 				ClrBit(u->u.rail.flags, VRF_POWEREDWAGON);
   212 			}
   212 			}
   213 
   213 
   214 			/* Do not count powered wagons for the compatible railtypes, as wagons always
   214 			/* Do not count powered wagons for the compatible railtypes, as wagons always
   215 			   have railtype normal */
   215 			   have railtype normal */
   216 			if (rvi_u->power > 0) {
   216 			if (rvi_u->power > 0) {
  1456 {
  1456 {
  1457 	byte flag1 = *swap_flag1;
  1457 	byte flag1 = *swap_flag1;
  1458 	byte flag2 = *swap_flag2;
  1458 	byte flag2 = *swap_flag2;
  1459 
  1459 
  1460 	/* Clear the flags */
  1460 	/* Clear the flags */
  1461 	CLRBIT(*swap_flag1, VRF_GOINGUP);
  1461 	ClrBit(*swap_flag1, VRF_GOINGUP);
  1462 	CLRBIT(*swap_flag1, VRF_GOINGDOWN);
  1462 	ClrBit(*swap_flag1, VRF_GOINGDOWN);
  1463 	CLRBIT(*swap_flag2, VRF_GOINGUP);
  1463 	ClrBit(*swap_flag2, VRF_GOINGUP);
  1464 	CLRBIT(*swap_flag2, VRF_GOINGDOWN);
  1464 	ClrBit(*swap_flag2, VRF_GOINGDOWN);
  1465 
  1465 
  1466 	/* Reverse the rail-flags (if needed) */
  1466 	/* Reverse the rail-flags (if needed) */
  1467 	if (HasBit(flag1, VRF_GOINGUP)) {
  1467 	if (HasBit(flag1, VRF_GOINGUP)) {
  1468 		SETBIT(*swap_flag2, VRF_GOINGDOWN);
  1468 		SETBIT(*swap_flag2, VRF_GOINGDOWN);
  1469 	} else if (HasBit(flag1, VRF_GOINGDOWN)) {
  1469 	} else if (HasBit(flag1, VRF_GOINGDOWN)) {
  1618 
  1618 
  1619 	if (IsTileDepotType(v->tile, TRANSPORT_RAIL)) {
  1619 	if (IsTileDepotType(v->tile, TRANSPORT_RAIL)) {
  1620 		InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
  1620 		InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
  1621 	}
  1621 	}
  1622 
  1622 
  1623 	CLRBIT(v->u.rail.flags, VRF_REVERSING);
  1623 	ClrBit(v->u.rail.flags, VRF_REVERSING);
  1624 }
  1624 }
  1625 
  1625 
  1626 /** Reverse train.
  1626 /** Reverse train.
  1627  * @param tile unused
  1627  * @param tile unused
  1628  * @param flags type of operation
  1628  * @param flags type of operation
  1905 		if (!!(p2 & DEPOT_SERVICE) == HasBit(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
  1905 		if (!!(p2 & DEPOT_SERVICE) == HasBit(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
  1906 			/* We called with a different DEPOT_SERVICE setting.
  1906 			/* We called with a different DEPOT_SERVICE setting.
  1907 			 * Now we change the setting to apply the new one and let the vehicle head for the same depot.
  1907 			 * Now we change the setting to apply the new one and let the vehicle head for the same depot.
  1908 			 * Note: the if is (true for requesting service == true for ordered to stop in depot)          */
  1908 			 * Note: the if is (true for requesting service == true for ordered to stop in depot)          */
  1909 			if (flags & DC_EXEC) {
  1909 			if (flags & DC_EXEC) {
  1910 				CLRBIT(v->current_order.flags, OFB_PART_OF_ORDERS);
  1910 				ClrBit(v->current_order.flags, OFB_PART_OF_ORDERS);
  1911 				TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
  1911 				TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
  1912 				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
  1912 				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
  1913 			}
  1913 			}
  1914 			return CommandCost();
  1914 			return CommandCost();
  1915 		}
  1915 		}
  2275 		}
  2275 		}
  2276 	} else {
  2276 	} else {
  2277 		/* route found, is the train marked with "path not found" flag? */
  2277 		/* route found, is the train marked with "path not found" flag? */
  2278 		if (HasBit(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION)) {
  2278 		if (HasBit(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION)) {
  2279 			/* clear the flag as the PF's problem was solved */
  2279 			/* clear the flag as the PF's problem was solved */
  2280 			CLRBIT(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION);
  2280 			ClrBit(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION);
  2281 			/* can we also delete the "News" item somehow? */
  2281 			/* can we also delete the "News" item somehow? */
  2282 		}
  2282 		}
  2283 	}
  2283 	}
  2284 
  2284 
  2285 #ifdef PF_BENCHMARK
  2285 #ifdef PF_BENCHMARK
  2551 {
  2551 {
  2552 	byte old_z = v->z_pos;
  2552 	byte old_z = v->z_pos;
  2553 	v->z_pos = GetSlopeZ(v->x_pos, v->y_pos);
  2553 	v->z_pos = GetSlopeZ(v->x_pos, v->y_pos);
  2554 
  2554 
  2555 	if (new_tile) {
  2555 	if (new_tile) {
  2556 		CLRBIT(v->u.rail.flags, VRF_GOINGUP);
  2556 		ClrBit(v->u.rail.flags, VRF_GOINGUP);
  2557 		CLRBIT(v->u.rail.flags, VRF_GOINGDOWN);
  2557 		ClrBit(v->u.rail.flags, VRF_GOINGDOWN);
  2558 
  2558 
  2559 		if (v->u.rail.track == TRACK_BIT_X || v->u.rail.track == TRACK_BIT_Y) {
  2559 		if (v->u.rail.track == TRACK_BIT_X || v->u.rail.track == TRACK_BIT_Y) {
  2560 			/* Any track that isn't TRACK_BIT_X or TRACK_BIT_Y cannot be sloped.
  2560 			/* Any track that isn't TRACK_BIT_X or TRACK_BIT_Y cannot be sloped.
  2561 			 * To check whether the current tile is sloped, and in which
  2561 			 * To check whether the current tile is sloped, and in which
  2562 			 * direction it is sloped, we get the 'z' at the center of
  2562 			 * direction it is sloped, we get the 'z' at the center of
  3536 				Vehicle *u = v;
  3536 				Vehicle *u = v;
  3537 
  3537 
  3538 				BEGIN_ENUM_WAGONS(u) {
  3538 				BEGIN_ENUM_WAGONS(u) {
  3539 					const RailVehicleInfo *rvi = RailVehInfo(u->engine_type);
  3539 					const RailVehicleInfo *rvi = RailVehInfo(u->engine_type);
  3540 
  3540 
  3541 					CLRBIT(u->subtype, 7);
  3541 					ClrBit(u->subtype, 7);
  3542 					switch (u->subtype) {
  3542 					switch (u->subtype) {
  3543 						case 0: /* TS_Front_Engine */
  3543 						case 0: /* TS_Front_Engine */
  3544 							if (rvi->railveh_type == RAILVEH_MULTIHEAD) SetMultiheaded(u);
  3544 							if (rvi->railveh_type == RAILVEH_MULTIHEAD) SetMultiheaded(u);
  3545 							SetFrontEngine(u);
  3545 							SetFrontEngine(u);
  3546 							SetTrainEngine(u);
  3546 							SetTrainEngine(u);