Changeset - r8840:f5c2213cf909
[Not reviewed]
master
0 18 0
rubidium - 16 years ago 2008-04-06 07:48:51
rubidium@openttd.org
(svn r12588) -Codechange: do not access the destination of an order directly.
18 files changed with 116 insertions and 108 deletions:
0 comments (0 inline, 0 general)
src/ai/default/default.cpp
Show inline comments
 
@@ -260,14 +260,14 @@ static EngineID AiChooseAircraftToReplac
 
	/* determine forbidden aircraft bits */
 
	byte forbidden = 0;
 
	const Order *o;
 

	
 
	FOR_VEHICLE_ORDERS(v, o) {
 
		if (!o->IsValid()) continue;
 
		if (!IsValidStationID(o->dest)) continue;
 
		const Station *st = GetStation(o->dest);
 
		if (!IsValidStationID(o->GetDestination())) continue;
 
		const Station *st = GetStation(o->GetDestination());
 
		if (!(st->facilities & FACIL_AIRPORT)) continue;
 

	
 
		AirportFTAClass::Flags flags = st->Airport()->flags;
 
		if (!(flags & AirportFTAClass::AIRPLANES)) forbidden |= AIR_CTOL | AIR_FAST; // no planes for heliports / oil rigs
 
		if (flags & AirportFTAClass::SHORT_STRIP) forbidden |= AIR_FAST; // no fast planes for small airports
 
	}
 
@@ -3659,13 +3659,13 @@ static void AiStateRemoveStation(Player 
 
	_players_ai[p->index].state = AIS_1;
 

	
 
	// Get a list of all stations that are in use by a vehicle
 
	byte *in_use = MallocT<byte>(GetMaxStationIndex() + 1);
 
	memset(in_use, 0, GetMaxStationIndex() + 1);
 
	FOR_ALL_ORDERS(ord) {
 
		if (ord->IsType(OT_GOTO_STATION)) in_use[ord->dest] = 1;
 
		if (ord->IsType(OT_GOTO_STATION)) in_use[ord->GetDestination()] = 1;
 
	}
 

	
 
	// Go through all stations and delete those that aren't in use
 
	FOR_ALL_STATIONS(st) {
 
		if (st->owner == _current_player && !in_use[st->index] &&
 
				( (st->bus_stops != NULL && (tile = st->bus_stops->xy) != 0) ||
src/ai/trolly/trolly.cpp
Show inline comments
 
@@ -550,13 +550,13 @@ static bool AiNew_CheckVehicleStation(Pl
 
	// Also check if we don't have already a lot of busses to this city...
 
	FOR_ALL_VEHICLES(v) {
 
		if (v->owner == _current_player) {
 
			const Order *order;
 

	
 
			FOR_VEHICLE_ORDERS(v, order) {
 
				if (order->IsType(OT_GOTO_STATION) && GetStation(order->dest) == st) {
 
				if (order->IsType(OT_GOTO_STATION) && GetStation(order->GetDestination()) == st) {
 
					// This vehicle has this city in its list
 
					count++;
 
				}
 
			}
 
		}
 
	}
src/aircraft_cmd.cpp
Show inline comments
 
@@ -702,13 +702,13 @@ static void CheckIfAircraftNeedsService(
 
	if (_patches.servint_aircraft == 0 || !VehicleNeedsService(v)) return;
 
	if (v->IsInDepot()) {
 
		VehicleServiceInDepot(v);
 
		return;
 
	}
 

	
 
	const Station *st = GetStation(v->current_order.dest);
 
	const Station *st = GetStation(v->current_order.GetDestination());
 
	/* only goto depot if the target airport has terminals (eg. it is airport) */
 
	if (st->IsValid() && st->airport_tile != 0 && st->Airport()->terminals != NULL) {
 
//		printf("targetairport = %d, st->index = %d\n", v->u.air.targetairport, st->index);
 
//		v->u.air.targetairport = st->index;
 
		v->current_order.MakeGoToDepot(INVALID_STATION, false);
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
@@ -1051,13 +1051,13 @@ static bool AircraftController(Vehicle *
 
	if (tile == 0) {
 
		tile = st->xy;
 

	
 
		/* Jump into our "holding pattern" state machine if possible */
 
		if (v->u.air.pos >= afc->nofelements) {
 
			v->u.air.pos = v->u.air.previous_pos = AircraftGetEntryPoint(v, afc);
 
		} else if (v->u.air.targetairport != v->current_order.dest) {
 
		} else if (v->u.air.targetairport != v->current_order.GetDestination()) {
 
			/* If not possible, just get out of here fast */
 
			v->u.air.state = FLYING;
 
			UpdateAircraftCache(v);
 
			AircraftNextAirportPos_and_Order(v);
 
			/* get aircraft back on running altitude */
 
			SetAircraftPosition(v, v->x_pos, v->y_pos, GetAircraftFlyingAltitude(v));
 
@@ -1498,13 +1498,13 @@ static void AircraftLandAirplane(Vehicle
 

	
 
/** set the right pos when heading to other airports after takeoff */
 
static void AircraftNextAirportPos_and_Order(Vehicle *v)
 
{
 
	if (v->current_order.IsType(OT_GOTO_STATION) ||
 
			v->current_order.IsType(OT_GOTO_DEPOT))
 
		v->u.air.targetairport = v->current_order.dest;
 
		v->u.air.targetairport = v->current_order.GetDestination();
 

	
 
	const AirportFTAClass *apc = GetStation(v->u.air.targetairport)->Airport();
 
	v->u.air.pos = v->u.air.previous_pos = AircraftGetEntryPoint(v, apc);
 
}
 

	
 
static void AircraftLeaveHangar(Vehicle *v)
 
@@ -1607,13 +1607,13 @@ static void AircraftEventHandler_InHanga
 
		return;
 

	
 
	/* if the block of the next position is busy, stay put */
 
	if (AirportHasBlock(v, &apc->layout[v->u.air.pos], apc)) return;
 

	
 
	/* We are already at the target airport, we need to find a terminal */
 
	if (v->current_order.dest == v->u.air.targetairport) {
 
	if (v->current_order.GetDestination() == v->u.air.targetairport) {
 
		/* FindFreeTerminal:
 
		 * 1. Find a free terminal, 2. Occupy it, 3. Set the vehicle's state to that terminal */
 
		if (v->subtype == AIR_HELICOPTER) {
 
			if (!AirportFindFreeHelipad(v, apc)) return; // helicopter
 
		} else {
 
			if (!AirportFindFreeTerminal(v, apc)) return; // airplane
 
@@ -1657,13 +1657,13 @@ static void AircraftEventHandler_AtTermi
 
	switch (v->current_order.GetType()) {
 
		case OT_GOTO_STATION: // ready to fly to another airport
 
			/* airplane goto state takeoff, helicopter to helitakeoff */
 
			v->u.air.state = (v->subtype == AIR_HELICOPTER) ? HELITAKEOFF : TAKEOFF;
 
			break;
 
		case OT_GOTO_DEPOT:   // visit hangar for serivicing, sale, etc.
 
			if (v->current_order.dest == v->u.air.targetairport) {
 
			if (v->current_order.GetDestination() == v->u.air.targetairport) {
 
				v->u.air.state = HANGAR;
 
			} else {
 
				v->u.air.state = (v->subtype == AIR_HELICOPTER) ? HELITAKEOFF : TAKEOFF;
 
			}
 
			break;
 
		default:  // orders have been deleted (no orders), goto depot and don't bother us
src/disaster_cmd.cpp
Show inline comments
 
@@ -203,35 +203,35 @@ static void DisasterTick_Zeppeliner(Vehi
 
	int x, y;
 
	byte z;
 
	TileIndex tile;
 

	
 
	v->tick_counter++;
 

	
 
	if (v->current_order.dest < 2) {
 
	if (v->current_order.GetDestination() < 2) {
 
		if (HasBit(v->tick_counter, 0)) return;
 

	
 
		GetNewVehiclePosResult gp = GetNewVehiclePos(v);
 

	
 
		SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
 

	
 
		if (v->current_order.dest == 1) {
 
		if (v->current_order.GetDestination() == 1) {
 
			if (++v->age == 38) {
 
				v->current_order.dest = 2;
 
				v->current_order.SetDestination(2);
 
				v->age = 0;
 
			}
 

	
 
			if (GB(v->tick_counter, 0, 3) == 0) CreateEffectVehicleRel(v, 0, -17, 2, EV_SMOKE);
 

	
 
		} else if (v->current_order.dest == 0) {
 
		} else if (v->current_order.GetDestination() == 0) {
 
			tile = v->tile;
 

	
 
			if (IsValidTile(tile) &&
 
					IsTileType(tile, MP_STATION) &&
 
					IsAirport(tile) &&
 
					IsHumanPlayer(GetTileOwner(tile))) {
 
				v->current_order.dest = 1;
 
				v->current_order.SetDestination(1);
 
				v->age = 0;
 

	
 
				SetDParam(0, GetStationIndex(tile));
 
				AddNewsItem(STR_B000_ZEPPELIN_DISASTER_AT,
 
					NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, DNC_NONE,
 
					v->index,
 
@@ -240,13 +240,13 @@ static void DisasterTick_Zeppeliner(Vehi
 
		}
 

	
 
		if (v->y_pos >= ((int)MapSizeY() + 9) * TILE_SIZE - 1) DeleteDisasterVeh(v);
 
		return;
 
	}
 

	
 
	if (v->current_order.dest > 2) {
 
	if (v->current_order.GetDestination() > 2) {
 
		if (++v->age <= 13320) return;
 

	
 
		tile = v->tile;
 

	
 
		if (IsValidTile(tile) &&
 
				IsTileType(tile, MP_STATION) &&
 
@@ -281,13 +281,13 @@ static void DisasterTick_Zeppeliner(Vehi
 
				GB(r, 0, 4) - 7,
 
				GB(r, 4, 4) - 7,
 
				GB(r, 8, 3) + 5,
 
				EV_EXPLOSION_SMALL);
 
		}
 
	} else if (v->age == 350) {
 
		v->current_order.dest = 3;
 
		v->current_order.SetDestination(3);
 
		v->age = 0;
 
	}
 

	
 
	tile = v->tile;
 
	if (IsValidTile(tile) &&
 
			IsTileType(tile, MP_STATION) &&
 
@@ -309,13 +309,13 @@ static void DisasterTick_Ufo(Vehicle *v)
 
	Vehicle *u;
 
	uint dist;
 
	byte z;
 

	
 
	v->u.disaster.image_override = (HasBit(++v->tick_counter, 3)) ? SPR_UFO_SMALL_SCOUT_DARKER : SPR_UFO_SMALL_SCOUT;
 

	
 
	if (v->current_order.dest == 0) {
 
	if (v->current_order.GetDestination() == 0) {
 
		/* Fly around randomly */
 
		int x = TileX(v->dest_tile) * TILE_SIZE;
 
		int y = TileY(v->dest_tile) * TILE_SIZE;
 
		if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= TILE_SIZE) {
 
			v->direction = GetDirectionTowards(v, x, y);
 
			GetNewVehiclePosResult gp = GetNewVehiclePos(v);
 
@@ -323,13 +323,13 @@ static void DisasterTick_Ufo(Vehicle *v)
 
			return;
 
		}
 
		if (++v->age < 6) {
 
			v->dest_tile = RandomTile();
 
			return;
 
		}
 
		v->current_order.dest = 1;
 
		v->current_order.SetDestination(1);
 

	
 
		FOR_ALL_VEHICLES(u) {
 
			if (u->type == VEH_ROAD && IsHumanPlayer(u->owner)) {
 
				v->dest_tile = u->index;
 
				v->age = 0;
 
				return;
 
@@ -402,52 +402,52 @@ static void DestructIndustry(Industry *i
 
 * If the industry was removed in the meantime just fly to the end of the map
 
 */
 
static void DisasterTick_Airplane(Vehicle *v)
 
{
 
	v->tick_counter++;
 
	v->u.disaster.image_override =
 
		(v->current_order.dest == 1 && HasBit(v->tick_counter, 2)) ? SPR_F_15_FIRING : 0;
 
		(v->current_order.GetDestination() == 1 && HasBit(v->tick_counter, 2)) ? SPR_F_15_FIRING : 0;
 

	
 
	GetNewVehiclePosResult gp = GetNewVehiclePos(v);
 
	SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
 

	
 
	if (gp.x < (-10 * TILE_SIZE)) {
 
		DeleteDisasterVeh(v);
 
		return;
 
	}
 

	
 
	if (v->current_order.dest == 2) {
 
	if (v->current_order.GetDestination() == 2) {
 
		if (GB(v->tick_counter, 0, 2) == 0) {
 
			Industry *i = GetIndustry(v->dest_tile);
 
			int x = TileX(i->xy) * TILE_SIZE;
 
			int y = TileY(i->xy) * TILE_SIZE;
 
			uint32 r = Random();
 

	
 
			CreateEffectVehicleAbove(
 
				GB(r,  0, 6) + x,
 
				GB(r,  6, 6) + y,
 
				GB(r, 12, 4),
 
				EV_EXPLOSION_SMALL);
 

	
 
			if (++v->age >= 55) v->current_order.dest = 3;
 
			if (++v->age >= 55) v->current_order.SetDestination(3);
 
		}
 
	} else if (v->current_order.dest == 1) {
 
	} else if (v->current_order.GetDestination() == 1) {
 
		if (++v->age == 112) {
 
			Industry *i;
 

	
 
			v->current_order.dest = 2;
 
			v->current_order.SetDestination(2);
 
			v->age = 0;
 

	
 
			i = GetIndustry(v->dest_tile);
 
			DestructIndustry(i);
 

	
 
			SetDParam(0, i->town->index);
 
			AddNewsItem(STR_B002_OIL_REFINERY_EXPLOSION, NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, DNC_NONE, i->xy, 0);
 
			SndPlayTileFx(SND_12_EXPLOSION, i->xy);
 
		}
 
	} else if (v->current_order.dest == 0) {
 
	} else if (v->current_order.GetDestination() == 0) {
 
		int x, y;
 
		TileIndex tile;
 
		uint ind;
 

	
 
		x = v->x_pos - (15 * TILE_SIZE);
 
		y = v->y_pos;
 
@@ -458,13 +458,13 @@ static void DisasterTick_Airplane(Vehicl
 
		if (!IsTileType(tile, MP_INDUSTRY)) return;
 

	
 
		ind = GetIndustryIndex(tile);
 
		v->dest_tile = ind;
 

	
 
		if (GetIndustrySpec(GetIndustry(ind)->type)->behaviour & INDUSTRYBEH_AIRPLANE_ATTACKS) {
 
			v->current_order.dest = 1;
 
			v->current_order.SetDestination(1);
 
			v->age = 0;
 
		}
 
	}
 
}
 

	
 
/**
 
@@ -475,52 +475,52 @@ static void DisasterTick_Airplane(Vehicl
 
 * 3: Fly out of the map
 
 */
 
static void DisasterTick_Helicopter(Vehicle *v)
 
{
 
	v->tick_counter++;
 
	v->u.disaster.image_override =
 
		(v->current_order.dest == 1 && HasBit(v->tick_counter, 2)) ? SPR_AH_64A_FIRING : 0;
 
		(v->current_order.GetDestination() == 1 && HasBit(v->tick_counter, 2)) ? SPR_AH_64A_FIRING : 0;
 

	
 
	GetNewVehiclePosResult gp = GetNewVehiclePos(v);
 
	SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
 

	
 
	if (gp.x > (int)MapSizeX() * TILE_SIZE + 9 * TILE_SIZE - 1) {
 
		DeleteDisasterVeh(v);
 
		return;
 
	}
 

	
 
	if (v->current_order.dest == 2) {
 
	if (v->current_order.GetDestination() == 2) {
 
		if (GB(v->tick_counter, 0, 2) == 0) {
 
			Industry *i = GetIndustry(v->dest_tile);
 
			int x = TileX(i->xy) * TILE_SIZE;
 
			int y = TileY(i->xy) * TILE_SIZE;
 
			uint32 r = Random();
 

	
 
			CreateEffectVehicleAbove(
 
				GB(r,  0, 6) + x,
 
				GB(r,  6, 6) + y,
 
				GB(r, 12, 4),
 
				EV_EXPLOSION_SMALL);
 

	
 
			if (++v->age >= 55) v->current_order.dest = 3;
 
			if (++v->age >= 55) v->current_order.SetDestination(3);
 
		}
 
	} else if (v->current_order.dest == 1) {
 
	} else if (v->current_order.GetDestination() == 1) {
 
		if (++v->age == 112) {
 
			Industry *i;
 

	
 
			v->current_order.dest = 2;
 
			v->current_order.SetDestination(2);
 
			v->age = 0;
 

	
 
			i = GetIndustry(v->dest_tile);
 
			DestructIndustry(i);
 

	
 
			SetDParam(0, i->town->index);
 
			AddNewsItem(STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS, NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, DNC_NONE, i->xy, 0);
 
			SndPlayTileFx(SND_12_EXPLOSION, i->xy);
 
		}
 
	} else if (v->current_order.dest == 0) {
 
	} else if (v->current_order.GetDestination() == 0) {
 
		int x, y;
 
		TileIndex tile;
 
		uint ind;
 

	
 
		x = v->x_pos + (15 * TILE_SIZE);
 
		y = v->y_pos;
 
@@ -531,13 +531,13 @@ static void DisasterTick_Helicopter(Vehi
 
		if (!IsTileType(tile, MP_INDUSTRY)) return;
 

	
 
		ind = GetIndustryIndex(tile);
 
		v->dest_tile = ind;
 

	
 
		if (GetIndustrySpec(GetIndustry(ind)->type)->behaviour & INDUSTRYBEH_CHOPPER_ATTACKS) {
 
			v->current_order.dest = 1;
 
			v->current_order.SetDestination(1);
 
			v->age = 0;
 
		}
 
	}
 
}
 

	
 
/** Helicopter rotor blades; keep these spinning */
 
@@ -565,13 +565,13 @@ static void DisasterTick_Big_Ufo(Vehicle
 
	Town *t;
 
	TileIndex tile;
 
	TileIndex tile_org;
 

	
 
	v->tick_counter++;
 

	
 
	if (v->current_order.dest == 1) {
 
	if (v->current_order.GetDestination() == 1) {
 
		int x = TileX(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2;
 
		int y = TileY(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2;
 
		if (Delta(v->x_pos, x) + Delta(v->y_pos, y) >= 8) {
 
			v->direction = GetDirectionTowards(v, x, y);
 

	
 
			GetNewVehiclePosResult gp = GetNewVehiclePos(v);
 
@@ -582,13 +582,13 @@ static void DisasterTick_Big_Ufo(Vehicle
 
		z = GetSlopeZ(v->x_pos, v->y_pos);
 
		if (z < v->z_pos) {
 
			SetDisasterVehiclePos(v, v->x_pos, v->y_pos, v->z_pos - 1);
 
			return;
 
		}
 

	
 
		v->current_order.dest = 2;
 
		v->current_order.SetDestination(2);
 

	
 
		FOR_ALL_VEHICLES(u) {
 
			if (u->type == VEH_TRAIN || u->type == VEH_ROAD) {
 
				if (Delta(u->x_pos, v->x_pos) + Delta(u->y_pos, v->y_pos) <= 12 * TILE_SIZE) {
 
					u->breakdown_ctr = 5;
 
					u->breakdown_delay = 0xF0;
 
@@ -615,13 +615,13 @@ static void DisasterTick_Big_Ufo(Vehicle
 
		w = new DisasterVehicle();
 
		if (w == NULL) return;
 

	
 
		u->SetNext(w);
 
		InitializeDisasterVehicle(w, -6 * TILE_SIZE, v->y_pos, 0, DIR_SW, ST_Big_Ufo_Destroyer_Shadow);
 
		w->vehstatus |= VS_SHADOW;
 
	} else if (v->current_order.dest == 0) {
 
	} else if (v->current_order.GetDestination() == 0) {
 
		int x = TileX(v->dest_tile) * TILE_SIZE;
 
		int y = TileY(v->dest_tile) * TILE_SIZE;
 
		if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= TILE_SIZE) {
 
			v->direction = GetDirectionTowards(v, x, y);
 
			GetNewVehiclePosResult gp = GetNewVehiclePos(v);
 
			SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
 
@@ -629,13 +629,13 @@ static void DisasterTick_Big_Ufo(Vehicle
 
		}
 

	
 
		if (++v->age < 6) {
 
			v->dest_tile = RandomTile();
 
			return;
 
		}
 
		v->current_order.dest = 1;
 
		v->current_order.SetDestination(1);
 

	
 
		tile_org = tile = RandomTile();
 
		do {
 
			if (IsTileType(tile, MP_RAILWAY) &&
 
					IsPlainRailTile(tile) &&
 
					IsHumanPlayer(GetTileOwner(tile))) {
 
@@ -666,16 +666,16 @@ static void DisasterTick_Big_Ufo_Destroy
 

	
 
	if (gp.x > (int)MapSizeX() * TILE_SIZE + 9 * TILE_SIZE - 1) {
 
		DeleteDisasterVeh(v);
 
		return;
 
	}
 

	
 
	if (v->current_order.dest == 0) {
 
	if (v->current_order.GetDestination() == 0) {
 
		u = GetVehicle(v->u.disaster.big_ufo_destroyer_target);
 
		if (Delta(v->x_pos, u->x_pos) > TILE_SIZE) return;
 
		v->current_order.dest = 1;
 
		v->current_order.SetDestination(1);
 

	
 
		CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE);
 
		SndPlayVehicleFx(SND_12_EXPLOSION, u);
 

	
 
		DeleteDisasterVeh(u);
 

	
src/industry_cmd.cpp
Show inline comments
 
@@ -1966,13 +1966,13 @@ int WhoCanServiceIndustry(Industry* ind)
 
		 * may have a different cargo type.
 
		 */
 
		const Order *o;
 
		FOR_VEHICLE_ORDERS(v, o) {
 
			if (o->IsType(OT_GOTO_STATION) && !HasBit(o->flags, OF_TRANSFER)) {
 
				/* Vehicle visits a station to load or unload */
 
				Station *st = GetStation(o->dest);
 
				Station *st = GetStation(o->GetDestination());
 
				if (!st->IsValid()) continue;
 

	
 
				/* Same cargo produced by industry is dropped here => not serviced by vehicle v */
 
				if (HasBit(o->flags, OF_UNLOAD) && !c_accepts) break;
 

	
 
				if (stations.find(st) != stations.end()) {
src/npf.cpp
Show inline comments
 
@@ -978,14 +978,14 @@ void NPFFillWithOrderData(NPFFindStation
 
	 * save the station id for ships. For roadvehs we don't store it either,
 
	 * because multistop depends on vehicles actually reaching the exact
 
	 * dest_tile, not just any stop of that station.
 
	 * So only for train orders to stations we fill fstd->station_index, for all
 
	 * others only dest_coords */
 
	if (v->current_order.IsType(OT_GOTO_STATION) && v->type == VEH_TRAIN) {
 
		fstd->station_index = v->current_order.dest;
 
		fstd->station_index = v->current_order.GetDestination();
 
		/* Let's take the closest tile of the station as our target for trains */
 
		fstd->dest_coords = CalcClosestStationTile(v->current_order.dest, v->tile);
 
		fstd->dest_coords = CalcClosestStationTile(fstd->station_index, v->tile);
 
	} else {
 
		fstd->dest_coords = v->dest_tile;
 
		fstd->station_index = INVALID_STATION;
 
	}
 
}
src/openttd.cpp
Show inline comments
 
@@ -2302,13 +2302,13 @@ bool AfterLoadGame()
 
	}
 

	
 
	if (CheckSavegameVersion(84)) {
 
		/* Update go to buoy orders because they are just waypoints */
 
		Order *order;
 
		FOR_ALL_ORDERS(order) {
 
			if (order->IsType(OT_GOTO_STATION) && GetStation(order->dest)->IsBuoy()) {
 
			if (order->IsType(OT_GOTO_STATION) && GetStation(order->GetDestination())->IsBuoy()) {
 
				order->flags = 0;
 
			}
 
		}
 

	
 
		/* Set all share owners to PLAYER_SPECTATOR for
 
		 * 1) all inactive players
src/order_base.h
Show inline comments
 
@@ -25,21 +25,21 @@ struct Order : PoolItem<Order, OrderID, 
 
private:
 
	friend const struct SaveLoad *GetVehicleDescription(VehicleType vt); ///< Saving and loading the current order of vehicles.
 
	friend void Load_VEHS();                                             ///< Loading of ancient vehicles.
 
	friend const struct SaveLoad *GetOrderDescription();                 ///< Saving and loading of orders.
 

	
 
	OrderTypeByte type;   ///< The type of order
 
	DestinationID dest;   ///< The destination of the order.
 

	
 
	CargoID refit_cargo;  ///< Refit CargoID
 
	byte refit_subtype;   ///< Refit subtype
 

	
 
public:
 
	Order *next;          ///< Pointer to next order. If NULL, end of list
 

	
 
	uint8  flags;
 
	DestinationID dest;   ///< The destionation of the order.
 

	
 
	uint16 wait_time;    ///< How long in ticks to wait at the destination.
 
	uint16 travel_time;  ///< How long in ticks the journey to this destination should take.
 

	
 
	Order() : refit_cargo(CT_NO_REFIT) {}
 
	~Order() { this->type = OT_NOTHING; }
 
@@ -115,12 +115,26 @@ public:
 
	 * Free a complete order chain.
 
	 * @note do not use on "current_order" vehicle orders!
 
	 */
 
	void FreeChain();
 

	
 
	/**
 
	 * Gets the destination of this order.
 
	 * @pre IsType(OT_GOTO_WAYPOINT) || IsType(OT_GOTO_DEPOT) || IsType(OT_GOTO_STATION).
 
	 * @return the destination of the order.
 
	 */
 
	inline DestinationID GetDestination() const { return this->dest; }
 

	
 
	/**
 
	 * Sets the destination of this order.
 
	 * @param destination the new destination of the order.
 
	 * @pre IsType(OT_GOTO_WAYPOINT) || IsType(OT_GOTO_DEPOT) || IsType(OT_GOTO_STATION).
 
	 */
 
	inline void SetDestination(DestinationID destination) { this->dest = destination; }
 

	
 
	/**
 
	 * Is this order a refit order.
 
	 * @pre IsType(OT_GOTO_DEPOT)
 
	 * @return true if a refit should happen.
 
	 */
 
	inline bool IsRefit() const { return this->refit_cargo < NUM_CARGO; }
 

	
src/order_cmd.cpp
Show inline comments
 
@@ -157,13 +157,13 @@ Order UnpackOldOrder(uint16 packed)
 
	Order order = UnpackVersion4Order(packed);
 

	
 
	/*
 
	 * Sanity check
 
	 * TTD stores invalid orders as OT_NOTHING with non-zero flags/station
 
	 */
 
	if (!order.IsValid() && (order.flags != 0 || order.dest != 0)) {
 
	if (!order.IsValid() && (order.flags != 0 || order.GetDestination() != 0)) {
 
		order.MakeDummy();
 
	}
 

	
 
	return order;
 
}
 

	
 
@@ -231,14 +231,14 @@ static void DeleteOrderWarnings(const Ve
 

	
 

	
 
static TileIndex GetOrderLocation(const Order& o)
 
{
 
	switch (o.GetType()) {
 
		default: NOT_REACHED();
 
		case OT_GOTO_STATION: return GetStation(o.dest)->xy;
 
		case OT_GOTO_DEPOT:   return GetDepot(o.dest)->xy;
 
		case OT_GOTO_STATION: return GetStation(o.GetDestination())->xy;
 
		case OT_GOTO_DEPOT:   return GetDepot(o.GetDestination())->xy;
 
	}
 
}
 

	
 

	
 
/** Add an order to the orderlist of a vehicle.
 
 * @param tile unused
 
@@ -264,16 +264,15 @@ CommandCost CmdInsertOrder(TileIndex til
 
	if (!CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
	/* Check if the inserted order is to the correct destination (owner, type),
 
	 * and has the correct flags if any */
 
	switch (new_order.GetType()) {
 
		case OT_GOTO_STATION: {
 
			const Station *st;
 
			if (!IsValidStationID(new_order.GetDestination())) return CMD_ERROR;
 

	
 
			if (!IsValidStationID(new_order.dest)) return CMD_ERROR;
 
			st = GetStation(new_order.dest);
 
			const Station *st = GetStation(new_order.GetDestination());
 

	
 
			if (st->owner != OWNER_NONE && !CheckOwnership(st->owner)) {
 
				return CMD_ERROR;
 
			}
 

	
 
			switch (v->type) {
 
@@ -327,28 +326,26 @@ CommandCost CmdInsertOrder(TileIndex til
 
			}
 
			break;
 
		}
 

	
 
		case OT_GOTO_DEPOT: {
 
			if (v->type == VEH_AIRCRAFT) {
 
				const Station* st;
 
				if (!IsValidStationID(new_order.GetDestination())) return CMD_ERROR;
 

	
 
				if (!IsValidStationID(new_order.dest)) return CMD_ERROR;
 
				st = GetStation(new_order.dest);
 
				const Station *st = GetStation(new_order.GetDestination());
 

	
 
				if (!CheckOwnership(st->owner) ||
 
						!(st->facilities & FACIL_AIRPORT) ||
 
						st->Airport()->nof_depots == 0 ||
 
						!CanAircraftUseStation(v->engine_type, st)) {
 
					return CMD_ERROR;
 
				}
 
			} else {
 
				const Depot* dp;
 
				if (!IsValidDepotID(new_order.GetDestination())) return CMD_ERROR;
 

	
 
				if (!IsValidDepotID(new_order.dest)) return CMD_ERROR;
 
				dp = GetDepot(new_order.dest);
 
				const Depot *dp = GetDepot(new_order.GetDestination());
 

	
 
				if (!CheckOwnership(GetTileOwner(dp->xy))) return CMD_ERROR;
 

	
 
				switch (v->type) {
 
					case VEH_TRAIN:
 
						if (!IsTileDepotType(dp->xy, TRANSPORT_RAIL)) return CMD_ERROR;
 
@@ -382,18 +379,17 @@ CommandCost CmdInsertOrder(TileIndex til
 
				default: return CMD_ERROR;
 
			}
 
			break;
 
		}
 

	
 
		case OT_GOTO_WAYPOINT: {
 
			const Waypoint* wp;
 

	
 
			if (v->type != VEH_TRAIN) return CMD_ERROR;
 

	
 
			if (!IsValidWaypointID(new_order.dest)) return CMD_ERROR;
 
			wp = GetWaypoint(new_order.dest);
 
			if (!IsValidWaypointID(new_order.GetDestination())) return CMD_ERROR;
 
			const Waypoint *wp = GetWaypoint(new_order.GetDestination());
 

	
 
			if (!CheckOwnership(GetTileOwner(wp->xy))) return CMD_ERROR;
 

	
 
			/* Order flags can be any of the following for waypoints:
 
			 * [non-stop]
 
			 * non-stop orders (if any) are only valid for trains */
 
@@ -766,13 +762,13 @@ CommandCost CmdModifyOrder(TileIndex til
 
	if (!CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
	/* Is it a valid order? */
 
	if (sel_ord >= v->num_orders) return CMD_ERROR;
 

	
 
	order = GetVehicleOrder(v, sel_ord);
 
	if ((!order->IsType(OT_GOTO_STATION)  || GetStation(order->dest)->IsBuoy()) &&
 
	if ((!order->IsType(OT_GOTO_STATION)  || GetStation(order->GetDestination())->IsBuoy()) &&
 
			(!order->IsType(OT_GOTO_DEPOT)    || p2 == OF_UNLOAD) &&
 
			(!order->IsType(OT_GOTO_WAYPOINT) || p2 != OF_NON_STOP)) {
 
		return CMD_ERROR;
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
@@ -906,13 +902,13 @@ CommandCost CmdCloneOrder(TileIndex tile
 
			if (src->type == VEH_ROAD) {
 
				const Order *order;
 
				TileIndex required_dst = INVALID_TILE;
 

	
 
				FOR_VEHICLE_ORDERS(src, order) {
 
					if (order->IsType(OT_GOTO_STATION)) {
 
						const Station *st = GetStation(order->dest);
 
						const Station *st = GetStation(order->GetDestination());
 
						if (IsCargoInClass(dst->cargo_type, CC_PASSENGERS)) {
 
							if (st->bus_stops != NULL) required_dst = st->bus_stops->xy;
 
						} else {
 
							if (st->truck_stops != NULL) required_dst = st->truck_stops->xy;
 
						}
 
						/* This station has not the correct road-bay, so we can't copy! */
 
@@ -1187,13 +1183,13 @@ void CheckOrders(const Vehicle* v)
 
			if (order->IsType(OT_DUMMY)) {
 
				problem_type = 1;
 
				break;
 
			}
 
			/* Does station have a load-bay for this vehicle? */
 
			if (order->IsType(OT_GOTO_STATION)) {
 
				const Station* st = GetStation(order->dest);
 
				const Station* st = GetStation(order->GetDestination());
 
				TileIndex required_tile = GetStationTileForVehicle(v, st);
 

	
 
				n_st++;
 
				if (required_tile == 0) problem_type = 3;
 
			}
 
		}
 
@@ -1248,22 +1244,22 @@ void RemoveOrderFromAllVehicles(OrderTyp
 
		if (v->last_station_visited == destination && type == OT_GOTO_STATION) {
 
			v->last_station_visited = INVALID_STATION;
 
		}
 

	
 
		order = &v->current_order;
 
		if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) ? OT_GOTO_STATION : order->GetType()) == type &&
 
				v->current_order.dest == destination) {
 
				v->current_order.GetDestination() == destination) {
 
			order->MakeDummy();
 
			InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
		}
 

	
 
		/* Clear the order from the order-list */
 
		invalidate = false;
 
		FOR_VEHICLE_ORDERS(v, order) {
 
			if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) ? OT_GOTO_STATION : order->GetType()) == type &&
 
					order->dest == destination) {
 
					order->GetDestination() == destination) {
 
				order->MakeDummy();
 
				invalidate = true;
 
			}
 
		}
 

	
 
		/* Only invalidate once, and if needed */
 
@@ -1411,14 +1407,14 @@ bool ProcessOrders(Vehicle *v)
 
	}
 

	
 
	/* Check if we've reached a non-stop station while TTDPatch nonstop is enabled.. */
 
	if (_patches.new_nonstop &&
 
			v->current_order.flags & OFB_NON_STOP &&
 
			IsTileType(v->tile, MP_STATION) &&
 
			v->current_order.dest == GetStationIndex(v->tile)) {
 
		v->last_station_visited = v->current_order.dest;
 
			v->current_order.GetDestination() == GetStationIndex(v->tile)) {
 
		v->last_station_visited = v->current_order.GetDestination();
 
		UpdateVehicleTimetable(v, true);
 
		v->cur_order_index++;
 
	}
 

	
 
	/* Get the current order */
 
	if (v->cur_order_index >= v->num_orders) v->cur_order_index = 0;
 
@@ -1439,13 +1435,13 @@ bool ProcessOrders(Vehicle *v)
 
		if (v->type == VEH_ROAD) ClearSlot(v);
 
		return false;
 
	}
 

	
 
	/* If it is unchanged, keep it. */
 
	if (order->Equals(v->current_order) &&
 
			(v->type != VEH_SHIP || !order->IsType(OT_GOTO_STATION) || GetStation(order->dest)->dock_tile != 0)) {
 
			(v->type != VEH_SHIP || !order->IsType(OT_GOTO_STATION) || GetStation(order->GetDestination())->dock_tile != 0)) {
 
		return false;
 
	}
 

	
 
	/* Otherwise set it, and determine the destination tile. */
 
	v->current_order = *order;
 

	
 
@@ -1463,21 +1459,21 @@ bool ProcessOrders(Vehicle *v)
 
			InvalidateWindowClasses(v->GetVehicleListWindowClass());
 
			break;
 
	}
 

	
 
	switch (order->GetType()) {
 
		case OT_GOTO_STATION:
 
			v->dest_tile = v->GetOrderStationLocation(order->dest);
 
			v->dest_tile = v->GetOrderStationLocation(order->GetDestination());
 
			break;
 

	
 
		case OT_GOTO_DEPOT:
 
			if (v->type != VEH_AIRCRAFT) v->dest_tile = GetDepot(order->dest)->xy;
 
			if (v->type != VEH_AIRCRAFT) v->dest_tile = GetDepot(order->GetDestination())->xy;
 
			break;
 

	
 
		case OT_GOTO_WAYPOINT:
 
			v->dest_tile = GetWaypoint(order->dest)->xy;
 
			v->dest_tile = GetWaypoint(order->GetDestination())->xy;
 
			break;
 

	
 
		default:
 
			v->dest_tile = 0;
 
			return false;
 
	}
src/order_gui.cpp
Show inline comments
 
@@ -152,13 +152,13 @@ static void DrawOrdersWindow(Window *w)
 

	
 
	w->ShowWidget(ORDER_WIDGET_UNLOAD); // Unload
 

	
 
	if (order != NULL) {
 
		switch (order->GetType()) {
 
			case OT_GOTO_STATION:
 
				if (!GetStation(order->dest)->IsBuoy()) break;
 
				if (!GetStation(order->GetDestination())->IsBuoy()) break;
 
				/* Fall-through */
 

	
 
			case OT_GOTO_WAYPOINT:
 
				w->DisableWidget(ORDER_WIDGET_FULL_LOAD);
 
				w->DisableWidget(ORDER_WIDGET_UNLOAD);
 
				w->DisableWidget(ORDER_WIDGET_TRANSFER);
 
@@ -194,28 +194,28 @@ static void DrawOrdersWindow(Window *w)
 
		if (i - w->vscroll.pos < w->vscroll.cap) {
 
			SetDParam(1, 6);
 

	
 
			switch (order->GetType()) {
 
				case OT_DUMMY:
 
					SetDParam(1, STR_INVALID_ORDER);
 
					SetDParam(2, order->dest);
 
					SetDParam(2, order->GetDestination());
 
					break;
 

	
 
				case OT_GOTO_STATION:
 
					SetDParam(1, StationOrderStrings[order->flags]);
 
					SetDParam(2, order->dest);
 
					SetDParam(2, order->GetDestination());
 
					break;
 

	
 
				case OT_GOTO_DEPOT: {
 
					StringID s = STR_NULL;
 

	
 
					if (v->type == VEH_AIRCRAFT) {
 
						s = STR_GO_TO_AIRPORT_HANGAR;
 
						SetDParam(2, order->dest);
 
						SetDParam(2, order->GetDestination());
 
					} else {
 
						SetDParam(2, GetDepot(order->dest)->town_index);
 
						SetDParam(2, GetDepot(order->GetDestination())->town_index);
 

	
 
						switch (v->type) {
 
							case VEH_TRAIN: s = (order->flags & OFB_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break;
 
							case VEH_ROAD:  s = STR_GO_TO_ROADVEH_DEPOT; break;
 
							case VEH_SHIP:  s = STR_GO_TO_SHIP_DEPOT; break;
 
							default: break;
 
@@ -233,13 +233,13 @@ static void DrawOrdersWindow(Window *w)
 
					}
 
					break;
 
				}
 

	
 
				case OT_GOTO_WAYPOINT:
 
					SetDParam(1, (order->flags & OFB_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
 
					SetDParam(2, order->dest);
 
					SetDParam(2, order->GetDestination());
 
					break;
 

	
 
				default: break;
 
			}
 

	
 
			SetDParam(0, i + 1);
 
@@ -332,13 +332,12 @@ static Order GetOrderCmdFromTile(const V
 
			}
 
		}
 
	}
 

	
 
	// not found
 
	order.Free();
 
	order.dest = INVALID_STATION;
 
	return order;
 
}
 

	
 
static bool HandleOrderVehClick(const Vehicle *v, const Vehicle *u, Window *w)
 
{
 
	if (u->type != v->type) return false;
 
@@ -560,15 +559,15 @@ static void OrdersWndProc(Window *w, Win
 

	
 
			if (_ctrl_pressed && sel < v->num_orders) {
 
				const Order *ord = GetVehicleOrder(v, sel);
 
				TileIndex xy;
 

	
 
				switch (ord->GetType()) {
 
					case OT_GOTO_STATION:  xy = GetStation(ord->dest)->xy ; break;
 
					case OT_GOTO_DEPOT:    xy = (v->type == VEH_AIRCRAFT) ?  GetStation(ord->dest)->xy : GetDepot(ord->dest)->xy;    break;
 
					case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->dest)->xy; break;
 
					case OT_GOTO_STATION:  xy = GetStation(ord->GetDestination())->xy ; break;
 
					case OT_GOTO_DEPOT:    xy = (v->type == VEH_AIRCRAFT) ?  GetStation(ord->GetDestination())->xy : GetDepot(ord->GetDestination())->xy;    break;
 
					case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->GetDestination())->xy; break;
 
					default:               xy = 0; break;
 
				}
 

	
 
				if (xy != 0) ScrollMainWindowToTile(xy);
 
				return;
 
			} else {
src/roadveh_cmd.cpp
Show inline comments
 
@@ -1740,13 +1740,13 @@ again:
 
	 * and it's the correct type of stop (bus or truck) and the frame equals the stop frame...
 
	 * (the station test and stop type test ensure that other vehicles, using the road stop as
 
	 * a through route, do not stop) */
 
	if (IsRoadVehFront(v) && ((IsInsideMM(v->u.road.state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END) &&
 
			_road_veh_data_1[v->u.road.state - RVSB_IN_ROAD_STOP + (_opt.road_side << RVS_DRIVE_SIDE)] == v->u.road.frame) ||
 
			(IsInsideMM(v->u.road.state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) &&
 
			v->current_order.dest == GetStationIndex(v->tile) &&
 
			v->current_order.GetDestination() == GetStationIndex(v->tile) &&
 
			GetRoadStopType(v->tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK) &&
 
			v->u.road.frame == RVC_DRIVE_THROUGH_STOP_FRAME))) {
 

	
 
		RoadStop *rs = GetRoadStopByTile(v->tile, GetRoadStopType(v->tile));
 
		Station* st = GetStationByTile(v->tile);
 

	
 
@@ -1817,15 +1817,15 @@ again:
 
			if (v->dest_tile != v->u.road.slot->xy) {
 
				DEBUG(ms, 2, " stop tile 0x%X is not destination tile 0x%X. Multistop desync", v->u.road.slot->xy, v->dest_tile);
 
			}
 
			if (!v->current_order.IsType(OT_GOTO_STATION)) {
 
				DEBUG(ms, 2, " current order type (%d) is not OT_GOTO_STATION", v->current_order.GetType());
 
			} else {
 
				if (v->current_order.dest != st->index)
 
				if (v->current_order.GetDestination() != st->index)
 
					DEBUG(ms, 2, " current station %d is not target station in current_order.station (%d)",
 
							st->index, v->current_order.dest);
 
							st->index, v->current_order.GetDestination());
 
			}
 

	
 
			DEBUG(ms, 2, " force a slot clearing");
 
			ClearSlot(v);
 
		}
 

	
 
@@ -1960,13 +1960,13 @@ void RoadVehicle::OnNewDay()
 
			this->unitnumber, this->index, this->u.road.slot->xy);
 
		ClearSlot(this);
 
	}
 

	
 
	/* update destination */
 
	if (!(this->vehstatus & VS_STOPPED) && this->current_order.IsType(OT_GOTO_STATION) && this->u.road.slot == NULL && !(this->vehstatus & VS_CRASHED)) {
 
		Station *st = GetStation(this->current_order.dest);
 
		Station *st = GetStation(this->current_order.GetDestination());
 
		RoadStop *rs = st->GetPrimaryRoadStop(this);
 
		RoadStop *best = NULL;
 

	
 
		if (rs != NULL) {
 
			/* We try to obtain a slot if:
 
			 * 1) we're reasonably close to the primary road stop
src/ship_cmd.cpp
Show inline comments
 
@@ -642,16 +642,16 @@ static void ShipController(Vehicle *v)
 
						if (v->current_order.IsType(OT_GOTO_DEPOT)) {
 
							if ((gp.x & 0xF) == 8 && (gp.y & 0xF) == 8) {
 
								VehicleEnterDepot(v);
 
								return;
 
							}
 
						} else if (v->current_order.IsType(OT_GOTO_STATION)) {
 
							v->last_station_visited = v->current_order.dest;
 
							v->last_station_visited = v->current_order.GetDestination();
 

	
 
							/* Process station in the orderlist. */
 
							Station *st = GetStation(v->current_order.dest);
 
							Station *st = GetStation(v->current_order.GetDestination());
 
							if (st->facilities & FACIL_DOCK) { // ugly, ugly workaround for problem with ships able to drop off cargo at wrong stations
 
								ShipArrivesAt(v, st);
 
								v->BeginLoading();
 
							} else { // leave stations without docks right aways
 
								v->current_order.MakeLeaveStation();
 
								v->cur_order_index++;
src/station_cmd.cpp
Show inline comments
 
@@ -1895,13 +1895,13 @@ bool HasStationInUse(StationID station, 
 
{
 
	const Vehicle *v;
 
	FOR_ALL_VEHICLES(v) {
 
		if (player == INVALID_PLAYER || v->owner == player) {
 
			const Order *order;
 
			FOR_VEHICLE_ORDERS(v, order) {
 
				if (order->IsType(OT_GOTO_STATION) && order->dest == station) {
 
				if (order->IsType(OT_GOTO_STATION) && order->GetDestination() == station) {
 
					return true;
 
				}
 
			}
 
		}
 
	}
 
	return false;
 
@@ -2434,13 +2434,13 @@ static VehicleEnterTileStatus VehicleEnt
 
					byte side = ((DirToDiagDir(v->direction) == ReverseDiagDir(GetRoadStopDir(tile))) == (v->u.road.overtaking == 0)) ? 0 : 1;
 

	
 
					if (!rs->IsFreeBay(side)) return VETSB_CANNOT_ENTER;
 

	
 
					/* Check if the vehicle is stopping at this road stop */
 
					if (GetRoadStopType(tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK) &&
 
							v->current_order.dest == GetStationIndex(tile)) {
 
							v->current_order.GetDestination() == GetStationIndex(tile)) {
 
						SetBit(v->u.road.state, RVS_IS_STOPPING);
 
						rs->AllocateDriveThroughBay(side);
 
					}
 

	
 
					/* Indicate if vehicle is using second bay. */
 
					if (side == 1) SetBit(v->u.road.state, RVS_USING_SECOND_BAY);
src/timetable_gui.cpp
Show inline comments
 
@@ -117,13 +117,13 @@ static void DrawTimetableWindow(Window *
 
				case OT_DUMMY:
 
					SetDParam(0, STR_INVALID_ORDER);
 
					break;
 

	
 
				case OT_GOTO_STATION:
 
					SetDParam(0, (order->flags & OFB_NON_STOP) ? STR_880A_GO_NON_STOP_TO : STR_8806_GO_TO);
 
					SetDParam(1, order->dest);
 
					SetDParam(1, order->GetDestination());
 

	
 
					if (order->wait_time > 0) {
 
						SetDParam(2, STR_TIMETABLE_STAY_FOR);
 
						SetTimetableParams(3, 4, order->wait_time);
 
					}
 

	
 
@@ -131,15 +131,15 @@ static void DrawTimetableWindow(Window *
 

	
 
				case OT_GOTO_DEPOT: {
 
					StringID string = STR_EMPTY;
 

	
 
					if (v->type == VEH_AIRCRAFT) {
 
						string = STR_GO_TO_AIRPORT_HANGAR;
 
						SetDParam(1, order->dest);
 
						SetDParam(1, order->GetDestination());
 
					} else {
 
						SetDParam(1, GetDepot(order->dest)->town_index);
 
						SetDParam(1, GetDepot(order->GetDestination())->town_index);
 

	
 
						switch (v->type) {
 
							case VEH_TRAIN: string = (order->flags & OFB_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break;
 
							case VEH_ROAD:  string = STR_GO_TO_ROADVEH_DEPOT; break;
 
							case VEH_SHIP:  string = STR_GO_TO_SHIP_DEPOT; break;
 
							default: break;
 
@@ -150,13 +150,13 @@ static void DrawTimetableWindow(Window *
 

	
 
					SetDParam(0, string);
 
				} break;
 

	
 
				case OT_GOTO_WAYPOINT:
 
					SetDParam(0, (order->flags & OFB_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
 
					SetDParam(1, order->dest);
 
					SetDParam(1, order->GetDestination());
 
					break;
 

	
 
				default: break;
 
			}
 

	
 
			DrawString(2, y, STR_TIMETABLE_GO_TO, (i == selected) ? TC_WHITE : TC_BLACK);
src/train_cmd.cpp
Show inline comments
 
@@ -2339,13 +2339,13 @@ static bool NtpCallbFindStation(TileInde
 
	}
 
}
 

	
 
static void FillWithStationData(TrainTrackFollowerData* fd, const Vehicle* v)
 
{
 
	fd->dest_coords = v->dest_tile;
 
	fd->station_index = v->current_order.IsType(OT_GOTO_STATION) ? v->current_order.dest : INVALID_STATION;
 
	fd->station_index = v->current_order.IsType(OT_GOTO_STATION) ? v->current_order.GetDestination() : INVALID_STATION;
 
}
 

	
 
static const byte _initial_tile_subcoord[6][4][3] = {
 
{{ 15, 8, 1 }, { 0, 0, 0 }, { 0, 8, 5 }, { 0,  0, 0 }},
 
{{  0, 0, 0 }, { 8, 0, 3 }, { 0, 0, 0 }, { 8, 15, 7 }},
 
{{  0, 0, 0 }, { 7, 0, 2 }, { 0, 7, 6 }, { 0,  0, 0 }},
 
@@ -2655,13 +2655,12 @@ static void TrainEnterStation(Vehicle *v
 
			v->index,
 
			0
 
		);
 
	}
 

	
 
	v->BeginLoading();
 
	v->current_order.dest = 0;
 
}
 

	
 
static byte AfterSetTrainPos(Vehicle *v, bool new_tile)
 
{
 
	byte old_z = v->z_pos;
 
	v->z_pos = GetSlopeZ(v->x_pos, v->y_pos);
 
@@ -3556,13 +3555,13 @@ static void CheckIfTrainNeedsService(Veh
 
		return;
 
	}
 

	
 
	const Depot* depot = GetDepotByTile(tfdd.tile);
 

	
 
	if (v->current_order.IsType(OT_GOTO_DEPOT) &&
 
			v->current_order.dest != depot->index &&
 
			v->current_order.GetDestination() != depot->index &&
 
			!Chance16(3, 16)) {
 
		return;
 
	}
 

	
 
	v->current_order.MakeGoToDepot(depot->index, false);
 
	v->dest_tile = tfdd.tile;
 
@@ -3580,13 +3579,13 @@ void Train::OnNewDay()
 
		CheckIfTrainNeedsService(this);
 

	
 
		CheckOrders(this);
 

	
 
		/* update destination */
 
		if (this->current_order.IsType(OT_GOTO_STATION)) {
 
			TileIndex tile = GetStation(this->current_order.dest)->train_tile;
 
			TileIndex tile = GetStation(this->current_order.GetDestination())->train_tile;
 
			if (tile != 0) this->dest_tile = tile;
 
		}
 

	
 
		if (this->running_ticks != 0) {
 
			/* running costs */
 
			CommandCost cost(EXPENSES_TRAIN_RUN, this->GetRunningCost() * this->running_ticks / (364 * DAY_TICKS));
src/vehicle.cpp
Show inline comments
 
@@ -2030,13 +2030,13 @@ uint GenerateVehicleSortList(const Vehic
 
		case VLW_STATION_LIST: {
 
			FOR_ALL_VEHICLES(v) {
 
				if (v->type == type && v->IsPrimaryVehicle()) {
 
					const Order *order;
 

	
 
					FOR_VEHICLE_ORDERS(v, order) {
 
						if (order->IsType(OT_GOTO_STATION) && order->dest == index) {
 
						if (order->IsType(OT_GOTO_STATION) && order->GetDestination() == index) {
 
							if (n == *length_of_array) ExtendVehicleListSize(sort_list, length_of_array, 50);
 
							(*sort_list)[n++] = v;
 
							break;
 
						}
 
					}
 
				}
 
@@ -2074,13 +2074,13 @@ uint GenerateVehicleSortList(const Vehic
 
		case VLW_DEPOT_LIST: {
 
			FOR_ALL_VEHICLES(v) {
 
				if (v->type == type && v->IsPrimaryVehicle()) {
 
					const Order *order;
 

	
 
					FOR_VEHICLE_ORDERS(v, order) {
 
						if (order->IsType(OT_GOTO_DEPOT) && order->dest == index) {
 
						if (order->IsType(OT_GOTO_DEPOT) && order->GetDestination() == index) {
 
							if (n == *length_of_array) ExtendVehicleListSize(sort_list, length_of_array, 25);
 
							(*sort_list)[n++] = v;
 
							break;
 
						}
 
					}
 
				}
 
@@ -3128,13 +3128,13 @@ extern const ChunkHandler _veh_chunk_han
 

	
 
void Vehicle::BeginLoading()
 
{
 
	assert(IsTileType(tile, MP_STATION) || type == VEH_SHIP);
 

	
 
	if (this->current_order.IsType(OT_GOTO_STATION) &&
 
			this->current_order.dest == this->last_station_visited) {
 
			this->current_order.GetDestination() == this->last_station_visited) {
 
		/* Arriving at the ordered station.
 
		 * Keep the load/unload flags, as we (obviously) still need them. */
 
		this->current_order.flags &= OFB_FULL_LOAD | OFB_UNLOAD | OFB_TRANSFER;
 

	
 
		/* Furthermore add the Non Stop flag to mark that this station
 
		 * is the actual destination of the vehicle, which is (for example)
src/vehicle_gui.cpp
Show inline comments
 
@@ -915,15 +915,15 @@ void DrawSmallOrderList(const Vehicle *v
 

	
 
	FOR_VEHICLE_ORDERS(v, order) {
 
		if (sel == 0) DrawString(x - 6, y, STR_SMALL_RIGHT_ARROW, TC_BLACK);
 
		sel--;
 

	
 
		if (order->IsType(OT_GOTO_STATION)) {
 
			if (v->type == VEH_SHIP && GetStation(order->dest)->IsBuoy()) continue;
 
			if (v->type == VEH_SHIP && GetStation(order->GetDestination())->IsBuoy()) continue;
 

	
 
			SetDParam(0, order->dest);
 
			SetDParam(0, order->GetDestination());
 
			DrawString(x, y, STR_A036, TC_FROMSTRING);
 

	
 
			y += 6;
 
			if (++i == 4) break;
 
		}
 
	}
 
@@ -1951,24 +1951,24 @@ static void DrawVehicleViewWindow(Window
 
		} else { // no train
 
			str = STR_8861_STOPPED;
 
		}
 
	} else { // vehicle is in a "normal" state, show current order
 
		switch (v->current_order.GetType()) {
 
			case OT_GOTO_STATION: {
 
				SetDParam(0, v->current_order.dest);
 
				SetDParam(0, v->current_order.GetDestination());
 
				SetDParam(1, v->GetDisplaySpeed());
 
				str = STR_HEADING_FOR_STATION + _patches.vehicle_speed;
 
			} break;
 

	
 
			case OT_GOTO_DEPOT: {
 
				if (v->type == VEH_AIRCRAFT) {
 
					/* Aircrafts always go to a station, even if you say depot */
 
					SetDParam(0, v->current_order.dest);
 
					SetDParam(0, v->current_order.GetDestination());
 
					SetDParam(1, v->GetDisplaySpeed());
 
				} else {
 
					Depot *depot = GetDepot(v->current_order.dest);
 
					Depot *depot = GetDepot(v->current_order.GetDestination());
 
					SetDParam(0, depot->town_index);
 
					SetDParam(1, v->GetDisplaySpeed());
 
				}
 
				if (HasBit(v->current_order.flags, OF_HALT_IN_DEPOT) && !HasBit(v->current_order.flags, OF_PART_OF_ORDERS)) {
 
					str = _heading_for_depot_strings[v->type] + _patches.vehicle_speed;
 
				} else {
 
@@ -1979,13 +1979,13 @@ static void DrawVehicleViewWindow(Window
 
			case OT_LOADING:
 
				str = STR_882F_LOADING_UNLOADING;
 
				break;
 

	
 
			case OT_GOTO_WAYPOINT: {
 
				assert(v->type == VEH_TRAIN);
 
				SetDParam(0, v->current_order.dest);
 
				SetDParam(0, v->current_order.GetDestination());
 
				str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed;
 
				SetDParam(1, v->GetDisplaySpeed());
 
				break;
 
			}
 

	
 
			case OT_LEAVESTATION:
src/yapf/yapf_destrail.hpp
Show inline comments
 
@@ -85,22 +85,22 @@ protected:
 

	
 
public:
 
	void SetDestination(Vehicle* v)
 
	{
 
		switch (v->current_order.GetType()) {
 
			case OT_GOTO_STATION:
 
				m_destTile = CalcStationCenterTile(v->current_order.dest);
 
				m_dest_station_id = v->current_order.dest;
 
				m_destTile = CalcStationCenterTile(v->current_order.GetDestination());
 
				m_dest_station_id = v->current_order.GetDestination();
 
				m_destTrackdirs = INVALID_TRACKDIR_BIT;
 
				break;
 

	
 
			case OT_GOTO_WAYPOINT: {
 
				Waypoint *wp = GetWaypoint(v->current_order.dest);
 
				Waypoint *wp = GetWaypoint(v->current_order.GetDestination());
 
				if (wp == NULL) {
 
					/* Invalid waypoint in orders! */
 
					DEBUG(yapf, 0, "Invalid waypoint in orders == 0x%04X (train %d, player %d)", v->current_order.dest, v->unitnumber, (PlayerID)v->owner);
 
					DEBUG(yapf, 0, "Invalid waypoint in orders == 0x%04X (train %d, player %d)", v->current_order.GetDestination(), v->unitnumber, (PlayerID)v->owner);
 
					break;
 
				}
 
				m_destTile = wp->xy;
 
				if (m_destTile != v->dest_tile) {
 
					/* Something is wrong with orders! */
 
					DEBUG(yapf, 0, "Invalid v->dest_tile == 0x%04X (train %d, player %d)", v->dest_tile, v->unitnumber, (PlayerID)v->owner);
0 comments (0 inline, 0 general)