(svn r6142) -Codechange: added WaypointID (sorry DV, couldn't splits it anymore)

-Codechange: introduced DestinationID, which is in fact an union of several types
  Used in Order struct, so no longer StationID is abused for all targets.
  Hangars are a big exception, as they use a station-id with GOTO_DEPOT (go figure)
This commit is contained in:
truelight 2006-08-26 16:34:03 +00:00
parent f73a2829f3
commit db8dfcd6e9
23 changed files with 172 additions and 157 deletions

View File

@ -2453,7 +2453,7 @@ handle_nocash:
order.type = OT_GOTO_STATION; order.type = OT_GOTO_STATION;
order.flags = 0; order.flags = 0;
order.station = AiGetStationIdByDef(aib->use_tile, aib->cur_building_rule); order.dest.station = AiGetStationIdByDef(aib->use_tile, aib->cur_building_rule);
if (!is_pass && i == 1) order.flags |= OF_UNLOAD; if (!is_pass && i == 1) order.flags |= OF_UNLOAD;
if (p->ai.num_want_fullload != 0 && (is_pass || i == 0)) if (p->ai.num_want_fullload != 0 && (is_pass || i == 0))
@ -3185,7 +3185,7 @@ static void AiStateBuildRoadVehicles(Player *p)
order.type = OT_GOTO_STATION; order.type = OT_GOTO_STATION;
order.flags = 0; order.flags = 0;
order.station = AiGetStationIdFromRoadBlock(aib->use_tile, aib->cur_building_rule); order.dest.station = AiGetStationIdFromRoadBlock(aib->use_tile, aib->cur_building_rule);
if (!is_pass && i == 1) order.flags |= OF_UNLOAD; if (!is_pass && i == 1) order.flags |= OF_UNLOAD;
if (p->ai.num_want_fullload != 0 && (is_pass || i == 0)) if (p->ai.num_want_fullload != 0 && (is_pass || i == 0))
@ -3464,7 +3464,7 @@ static void AiStateBuildAircraftVehicles(Player *p)
order.type = OT_GOTO_STATION; order.type = OT_GOTO_STATION;
order.flags = 0; order.flags = 0;
order.station = AiGetStationIdFromAircraftBlock(aib->use_tile, aib->cur_building_rule); order.dest.station = AiGetStationIdFromAircraftBlock(aib->use_tile, aib->cur_building_rule);
if (!is_pass && i == 1) order.flags |= OF_UNLOAD; if (!is_pass && i == 1) order.flags |= OF_UNLOAD;
if (p->ai.num_want_fullload != 0 && (is_pass || i == 0)) if (p->ai.num_want_fullload != 0 && (is_pass || i == 0))
@ -3567,7 +3567,7 @@ static void AiStateRemoveStation(Player *p)
in_use = malloc(GetStationArraySize()); in_use = malloc(GetStationArraySize());
memset(in_use, 0, GetStationArraySize()); memset(in_use, 0, GetStationArraySize());
FOR_ALL_ORDERS(ord) { FOR_ALL_ORDERS(ord) {
if (ord->type == OT_GOTO_STATION) in_use[ord->station] = 1; if (ord->type == OT_GOTO_STATION) in_use[ord->dest.station] = 1;
} }
// Go through all stations and delete those that aren't in use // Go through all stations and delete those that aren't in use

View File

@ -555,7 +555,7 @@ static bool AiNew_CheckVehicleStation(Player *p, Station *st)
const Order *order; const Order *order;
FOR_VEHICLE_ORDERS(v, order) { FOR_VEHICLE_ORDERS(v, order) {
if (order->type == OT_GOTO_STATION && GetStation(order->station) == st) { if (order->type == OT_GOTO_STATION && GetStation(order->dest.station) == st) {
// This vehicle has this city in its list // This vehicle has this city in its list
count++; count++;
} }
@ -1192,14 +1192,14 @@ static void AiNew_State_GiveOrders(Player *p)
idx = 0; idx = 0;
order.type = OT_GOTO_DEPOT; order.type = OT_GOTO_DEPOT;
order.flags = OF_UNLOAD; order.flags = OF_UNLOAD;
order.station = GetDepotByTile(p->ainew.depot_tile)->index; order.dest.depot = GetDepotByTile(p->ainew.depot_tile)->index;
AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER); AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
} }
idx = 0; idx = 0;
order.type = OT_GOTO_STATION; order.type = OT_GOTO_STATION;
order.flags = 0; order.flags = 0;
order.station = GetStationIndex(p->ainew.to_tile); order.dest.station = GetStationIndex(p->ainew.to_tile);
if (p->ainew.tbt == AI_TRUCK && p->ainew.to_deliver) if (p->ainew.tbt == AI_TRUCK && p->ainew.to_deliver)
order.flags |= OF_FULL_LOAD; order.flags |= OF_FULL_LOAD;
AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER); AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
@ -1207,7 +1207,7 @@ static void AiNew_State_GiveOrders(Player *p)
idx = 0; idx = 0;
order.type = OT_GOTO_STATION; order.type = OT_GOTO_STATION;
order.flags = 0; order.flags = 0;
order.station = GetStationIndex(p->ainew.from_tile); order.dest.station = GetStationIndex(p->ainew.from_tile);
if (p->ainew.tbt == AI_TRUCK && p->ainew.from_deliver) if (p->ainew.tbt == AI_TRUCK && p->ainew.from_deliver)
order.flags |= OF_FULL_LOAD; order.flags |= OF_FULL_LOAD;
AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER); AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);

View File

@ -537,7 +537,7 @@ int32 CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
v->current_order.type = OT_GOTO_DEPOT; v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = HASBIT(p2, 16) ? 0 : OF_NON_STOP | OF_FULL_LOAD; v->current_order.flags = HASBIT(p2, 16) ? 0 : OF_NON_STOP | OF_FULL_LOAD;
v->current_order.station = next_airport_index; v->current_order.dest.station = next_airport_index;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
if (HASBIT(p2, 17) || (p2 == 0 && v->u.air.state == FLYING && !next_airport_has_hangar)) { if (HASBIT(p2, 17) || (p2 == 0 && v->u.air.state == FLYING && !next_airport_has_hangar)) {
// the aircraft is now heading for a different hangar than the next in the orders // the aircraft is now heading for a different hangar than the next in the orders
@ -650,7 +650,7 @@ static void CheckIfAircraftNeedsService(Vehicle *v)
if (_patches.gotodepot && VehicleHasDepotOrders(v)) return; if (_patches.gotodepot && VehicleHasDepotOrders(v)) return;
st = GetStation(v->current_order.station); st = GetStation(v->current_order.dest.station);
// only goto depot if the target airport has terminals (eg. it is airport) // only goto depot if the target airport has terminals (eg. it is airport)
if (IsValidStation(st) && st->airport_tile != 0 && GetAirport(st->airport_type)->terminals != NULL) { if (IsValidStation(st) && st->airport_tile != 0 && GetAirport(st->airport_type)->terminals != NULL) {
// printf("targetairport = %d, st->index = %d\n", v->u.air.targetairport, st->index); // printf("targetairport = %d, st->index = %d\n", v->u.air.targetairport, st->index);
@ -1195,9 +1195,9 @@ static void ProcessAircraftOrder(Vehicle *v)
if (order->type == OT_DUMMY && !CheckForValidOrders(v)) CrashAirplane(v); if (order->type == OT_DUMMY && !CheckForValidOrders(v)) CrashAirplane(v);
if (order->type == v->current_order.type && if (order->type == v->current_order.type &&
order->flags == v->current_order.flags && order->flags == v->current_order.flags &&
order->station == v->current_order.station) order->dest.station == v->current_order.dest.station)
return; return;
v->current_order = *order; v->current_order = *order;
@ -1205,7 +1205,7 @@ static void ProcessAircraftOrder(Vehicle *v)
// orders are changed in flight, ensure going to the right station // orders are changed in flight, ensure going to the right station
if (order->type == OT_GOTO_STATION && v->u.air.state == FLYING) { if (order->type == OT_GOTO_STATION && v->u.air.state == FLYING) {
AircraftNextAirportPos_and_Order(v); AircraftNextAirportPos_and_Order(v);
v->u.air.targetairport = order->station; v->u.air.targetairport = order->dest.station;
} }
InvalidateVehicleOrder(v); InvalidateVehicleOrder(v);
@ -1347,7 +1347,7 @@ static void AircraftEntersTerminal(Vehicle *v)
v->current_order.flags = 0; v->current_order.flags = 0;
if (old_order.type == OT_GOTO_STATION && if (old_order.type == OT_GOTO_STATION &&
v->current_order.station == v->last_station_visited) { v->current_order.dest.station == v->last_station_visited) {
v->current_order.flags = v->current_order.flags =
(old_order.flags & (OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER)) | OF_NON_STOP; (old_order.flags & (OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER)) | OF_NON_STOP;
} }
@ -1415,7 +1415,7 @@ static void AircraftNextAirportPos_and_Order(Vehicle *v)
if (v->current_order.type == OT_GOTO_STATION || if (v->current_order.type == OT_GOTO_STATION ||
v->current_order.type == OT_GOTO_DEPOT) v->current_order.type == OT_GOTO_DEPOT)
v->u.air.targetairport = v->current_order.station; v->u.air.targetairport = v->current_order.dest.station;
st = GetStation(v->u.air.targetairport); st = GetStation(v->u.air.targetairport);
Airport = GetAirport(st->airport_type); Airport = GetAirport(st->airport_type);
@ -1487,7 +1487,7 @@ static void AircraftEventHandler_InHangar(Vehicle *v, const AirportFTAClass *Air
if (AirportHasBlock(v, &Airport->layout[v->u.air.pos], Airport)) return; if (AirportHasBlock(v, &Airport->layout[v->u.air.pos], Airport)) return;
// We are already at the target airport, we need to find a terminal // We are already at the target airport, we need to find a terminal
if (v->current_order.station == v->u.air.targetairport) { if (v->current_order.dest.station == v->u.air.targetairport) {
// FindFreeTerminal: // FindFreeTerminal:
// 1. Find a free terminal, 2. Occupy it, 3. Set the vehicle's state to that terminal // 1. Find a free terminal, 2. Occupy it, 3. Set the vehicle's state to that terminal
if (v->subtype != 0) { if (v->subtype != 0) {
@ -1539,7 +1539,7 @@ static void AircraftEventHandler_AtTerminal(Vehicle *v, const AirportFTAClass *A
v->u.air.state = (v->subtype != 0) ? TAKEOFF : HELITAKEOFF; v->u.air.state = (v->subtype != 0) ? TAKEOFF : HELITAKEOFF;
break; break;
case OT_GOTO_DEPOT: // visit hangar for serivicing, sale, etc. case OT_GOTO_DEPOT: // visit hangar for serivicing, sale, etc.
if (v->current_order.station == v->u.air.targetairport) { if (v->current_order.dest.station == v->u.air.targetairport) {
v->u.air.state = HANGAR; v->u.air.state = HANGAR;
} else { } else {
v->u.air.state = (v->subtype != 0) ? TAKEOFF : HELITAKEOFF; v->u.air.state = (v->subtype != 0) ? TAKEOFF : HELITAKEOFF;

View File

@ -548,13 +548,14 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e)
} else { } else {
switch (v->current_order.type) { switch (v->current_order.type) {
case OT_GOTO_STATION: { case OT_GOTO_STATION: {
SetDParam(0, v->current_order.station); SetDParam(0, v->current_order.dest.station);
SetDParam(1, v->cur_speed * 128 / 10); SetDParam(1, v->cur_speed * 128 / 10);
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; str = STR_HEADING_FOR_STATION + _patches.vehicle_speed;
} break; } break;
case OT_GOTO_DEPOT: { case OT_GOTO_DEPOT: {
SetDParam(0, v->current_order.station); /* Aircrafts always go to a station, even if you say depot */
SetDParam(0, v->current_order.dest.station);
SetDParam(1, v->cur_speed * 128 / 10); SetDParam(1, v->cur_speed * 128 / 10);
str = STR_HEADING_FOR_HANGAR + _patches.vehicle_speed; str = STR_HEADING_FOR_HANGAR + _patches.vehicle_speed;
} break; } break;
@ -960,7 +961,7 @@ static void DrawSmallOrderList(const Vehicle *v, int x, int y)
sel--; sel--;
if (order->type == OT_GOTO_STATION) { if (order->type == OT_GOTO_STATION) {
SetDParam(0, order->station); SetDParam(0, order->dest.station);
DrawString(x, y, STR_A036, 0); DrawString(x, y, STR_A036, 0);
y += 6; y += 6;

View File

@ -83,7 +83,7 @@ void DestroyDepot(Depot *depot)
DoClearSquare(depot->xy); DoClearSquare(depot->xy);
/* Clear the depot from all order-lists */ /* Clear the depot from all order-lists */
RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, depot->index); RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, (DestinationID)depot->index);
/* Delete the depot-window */ /* Delete the depot-window */
DeleteWindowById(WC_VEHICLE_DEPOT, depot->xy); DeleteWindowById(WC_VEHICLE_DEPOT, depot->xy);

View File

@ -101,7 +101,7 @@ static void InitializeDisasterVehicle(Vehicle* v, int x, int y, byte z, Directio
v->u.disaster.image_override = 0; v->u.disaster.image_override = 0;
v->current_order.type = OT_NOTHING; v->current_order.type = OT_NOTHING;
v->current_order.flags = 0; v->current_order.flags = 0;
v->current_order.station = 0; v->current_order.dest.station = 0;
DisasterVehicleUpdateImage(v); DisasterVehicleUpdateImage(v);
VehiclePositionChanged(v); VehiclePositionChanged(v);
@ -165,7 +165,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
++v->tick_counter; ++v->tick_counter;
if (v->current_order.station < 2) { if (v->current_order.dest.disaster < 2) {
if (v->tick_counter&1) if (v->tick_counter&1)
return; return;
@ -173,23 +173,23 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
if (v->current_order.station == 1) { if (v->current_order.dest.disaster == 1) {
if (++v->age == 38) { if (++v->age == 38) {
v->current_order.station = 2; v->current_order.dest.disaster = 2;
v->age = 0; v->age = 0;
} }
if ((v->tick_counter&7)==0) { if ((v->tick_counter&7)==0) {
CreateEffectVehicleRel(v, 0, -17, 2, EV_SMOKE); CreateEffectVehicleRel(v, 0, -17, 2, EV_SMOKE);
} }
} else if (v->current_order.station == 0) { } else if (v->current_order.dest.disaster == 0) {
tile = v->tile; /**/ tile = v->tile; /**/
if (IsValidTile(tile) && if (IsValidTile(tile) &&
IsTileType(tile, MP_STATION) && IsTileType(tile, MP_STATION) &&
IsAirport(tile) && IsAirport(tile) &&
IS_HUMAN_PLAYER(GetTileOwner(tile))) { IS_HUMAN_PLAYER(GetTileOwner(tile))) {
v->current_order.station = 1; v->current_order.dest.disaster = 1;
v->age = 0; v->age = 0;
SetDParam(0, GetStationIndex(tile)); SetDParam(0, GetStationIndex(tile));
@ -204,7 +204,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
return; return;
} }
if (v->current_order.station > 2) { if (v->current_order.dest.disaster > 2) {
if (++v->age <= 13320) if (++v->age <= 13320)
return; return;
@ -247,7 +247,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
EV_EXPLOSION_SMALL); EV_EXPLOSION_SMALL);
} }
} else if (v->age == 350) { } else if (v->age == 350) {
v->current_order.station = 3; v->current_order.dest.disaster = 3;
v->age = 0; v->age = 0;
} }
@ -272,7 +272,7 @@ static void DisasterTick_UFO(Vehicle *v)
v->u.disaster.image_override = (++v->tick_counter & 8) ? SPR_UFO_SMALL_SCOUT_DARKER : SPR_UFO_SMALL_SCOUT; v->u.disaster.image_override = (++v->tick_counter & 8) ? SPR_UFO_SMALL_SCOUT_DARKER : SPR_UFO_SMALL_SCOUT;
if (v->current_order.station == 0) { if (v->current_order.dest.disaster == 0) {
// fly around randomly // fly around randomly
int x = TileX(v->dest_tile) * TILE_SIZE; int x = TileX(v->dest_tile) * TILE_SIZE;
int y = TileY(v->dest_tile) * TILE_SIZE; int y = TileY(v->dest_tile) * TILE_SIZE;
@ -286,7 +286,7 @@ static void DisasterTick_UFO(Vehicle *v)
v->dest_tile = RandomTile(); v->dest_tile = RandomTile();
return; return;
} }
v->current_order.station = 1; v->current_order.dest.disaster = 1;
FOR_ALL_VEHICLES(u) { FOR_ALL_VEHICLES(u) {
if (u->type == VEH_Road && IS_HUMAN_PLAYER(u->owner)) { if (u->type == VEH_Road && IS_HUMAN_PLAYER(u->owner)) {
@ -360,7 +360,7 @@ static void DisasterTick_2(Vehicle *v)
v->tick_counter++; v->tick_counter++;
v->u.disaster.image_override = v->u.disaster.image_override =
(v->current_order.station == 1 && v->tick_counter & 4) ? SPR_F_15_FIRING : 0; (v->current_order.dest.disaster == 1 && v->tick_counter & 4) ? SPR_F_15_FIRING : 0;
GetNewVehiclePos(v, &gp); GetNewVehiclePos(v, &gp);
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
@ -370,7 +370,7 @@ static void DisasterTick_2(Vehicle *v)
return; return;
} }
if (v->current_order.station == 2) { if (v->current_order.dest.disaster == 2) {
if (!(v->tick_counter&3)) { if (!(v->tick_counter&3)) {
Industry *i = GetIndustry(v->dest_tile); Industry *i = GetIndustry(v->dest_tile);
int x = TileX(i->xy) * TILE_SIZE; int x = TileX(i->xy) * TILE_SIZE;
@ -384,13 +384,13 @@ static void DisasterTick_2(Vehicle *v)
EV_EXPLOSION_SMALL); EV_EXPLOSION_SMALL);
if (++v->age >= 55) if (++v->age >= 55)
v->current_order.station = 3; v->current_order.dest.disaster = 3;
} }
} else if (v->current_order.station == 1) { } else if (v->current_order.dest.disaster == 1) {
if (++v->age == 112) { if (++v->age == 112) {
Industry *i; Industry *i;
v->current_order.station = 2; v->current_order.dest.disaster = 2;
v->age = 0; v->age = 0;
i = GetIndustry(v->dest_tile); i = GetIndustry(v->dest_tile);
@ -400,7 +400,7 @@ static void DisasterTick_2(Vehicle *v)
AddNewsItem(STR_B002_OIL_REFINERY_EXPLOSION, NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy, 0); AddNewsItem(STR_B002_OIL_REFINERY_EXPLOSION, NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy, 0);
SndPlayTileFx(SND_12_EXPLOSION, i->xy); SndPlayTileFx(SND_12_EXPLOSION, i->xy);
} }
} else if (v->current_order.station == 0) { } else if (v->current_order.dest.disaster == 0) {
int x,y; int x,y;
TileIndex tile; TileIndex tile;
uint ind; uint ind;
@ -419,7 +419,7 @@ static void DisasterTick_2(Vehicle *v)
v->dest_tile = ind; v->dest_tile = ind;
if (GetIndustry(ind)->type == IT_OIL_REFINERY) { if (GetIndustry(ind)->type == IT_OIL_REFINERY) {
v->current_order.station = 1; v->current_order.dest.disaster = 1;
v->age = 0; v->age = 0;
} }
} }
@ -432,7 +432,7 @@ static void DisasterTick_3(Vehicle *v)
v->tick_counter++; v->tick_counter++;
v->u.disaster.image_override = v->u.disaster.image_override =
(v->current_order.station == 1 && v->tick_counter & 4) ? SPR_AH_64A_FIRING : 0; (v->current_order.dest.disaster == 1 && v->tick_counter & 4) ? SPR_AH_64A_FIRING : 0;
GetNewVehiclePos(v, &gp); GetNewVehiclePos(v, &gp);
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
@ -442,7 +442,7 @@ static void DisasterTick_3(Vehicle *v)
return; return;
} }
if (v->current_order.station == 2) { if (v->current_order.dest.disaster == 2) {
if (!(v->tick_counter&3)) { if (!(v->tick_counter&3)) {
Industry *i = GetIndustry(v->dest_tile); Industry *i = GetIndustry(v->dest_tile);
int x = TileX(i->xy) * TILE_SIZE; int x = TileX(i->xy) * TILE_SIZE;
@ -456,13 +456,13 @@ static void DisasterTick_3(Vehicle *v)
EV_EXPLOSION_SMALL); EV_EXPLOSION_SMALL);
if (++v->age >= 55) if (++v->age >= 55)
v->current_order.station = 3; v->current_order.dest.disaster = 3;
} }
} else if (v->current_order.station == 1) { } else if (v->current_order.dest.disaster == 1) {
if (++v->age == 112) { if (++v->age == 112) {
Industry *i; Industry *i;
v->current_order.station = 2; v->current_order.dest.disaster = 2;
v->age = 0; v->age = 0;
i = GetIndustry(v->dest_tile); i = GetIndustry(v->dest_tile);
@ -472,7 +472,7 @@ static void DisasterTick_3(Vehicle *v)
AddNewsItem(STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS, NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy, 0); AddNewsItem(STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS, NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy, 0);
SndPlayTileFx(SND_12_EXPLOSION, i->xy); SndPlayTileFx(SND_12_EXPLOSION, i->xy);
} }
} else if (v->current_order.station == 0) { } else if (v->current_order.dest.disaster == 0) {
int x,y; int x,y;
TileIndex tile; TileIndex tile;
uint ind; uint ind;
@ -491,7 +491,7 @@ static void DisasterTick_3(Vehicle *v)
v->dest_tile = ind; v->dest_tile = ind;
if (GetIndustry(ind)->type == IT_FACTORY) { if (GetIndustry(ind)->type == IT_FACTORY) {
v->current_order.station = 1; v->current_order.dest.disaster = 1;
v->age = 0; v->age = 0;
} }
} }
@ -523,7 +523,7 @@ static void DisasterTick_4(Vehicle *v)
v->tick_counter++; v->tick_counter++;
if (v->current_order.station == 1) { if (v->current_order.dest.disaster == 1) {
int x = TileX(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2; int x = TileX(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2;
int y = TileY(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2; int y = TileY(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2;
if (abs(v->x_pos - x) + abs(v->y_pos - y) >= 8) { if (abs(v->x_pos - x) + abs(v->y_pos - y) >= 8) {
@ -540,7 +540,7 @@ static void DisasterTick_4(Vehicle *v)
return; return;
} }
v->current_order.station = 2; v->current_order.dest.disaster = 2;
FOR_ALL_VEHICLES(u) { FOR_ALL_VEHICLES(u) {
if (u->type == VEH_Train || u->type == VEH_Road) { if (u->type == VEH_Train || u->type == VEH_Road) {
@ -574,7 +574,7 @@ static void DisasterTick_4(Vehicle *v)
u->next = w; u->next = w;
InitializeDisasterVehicle(w, -6 * TILE_SIZE, v->y_pos, 0, DIR_SW, 12); InitializeDisasterVehicle(w, -6 * TILE_SIZE, v->y_pos, 0, DIR_SW, 12);
w->vehstatus |= VS_SHADOW; w->vehstatus |= VS_SHADOW;
} else if (v->current_order.station < 1) { } else if (v->current_order.dest.disaster < 1) {
int x = TileX(v->dest_tile) * TILE_SIZE; int x = TileX(v->dest_tile) * TILE_SIZE;
int y = TileY(v->dest_tile) * TILE_SIZE; int y = TileY(v->dest_tile) * TILE_SIZE;
@ -589,7 +589,7 @@ static void DisasterTick_4(Vehicle *v)
v->dest_tile = RandomTile(); v->dest_tile = RandomTile();
return; return;
} }
v->current_order.station = 1; v->current_order.dest.disaster = 1;
tile_org = tile = RandomTile(); tile_org = tile = RandomTile();
do { do {
@ -624,11 +624,11 @@ static void DisasterTick_4b(Vehicle *v)
return; return;
} }
if (v->current_order.station == 0) { if (v->current_order.dest.disaster == 0) {
u = GetVehicle(v->u.disaster.unk2); u = GetVehicle(v->u.disaster.unk2);
if (abs(v->x_pos - u->x_pos) > TILE_SIZE) if (abs(v->x_pos - u->x_pos) > TILE_SIZE)
return; return;
v->current_order.station = 1; v->current_order.dest.disaster = 1;
CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE); CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE);
SndPlayVehicleFx(SND_12_EXPLOSION, u); SndPlayVehicleFx(SND_12_EXPLOSION, u);

4
npf.c
View File

@ -886,9 +886,9 @@ void NPFFillWithOrderData(NPFFindStationOrTileData* fstd, Vehicle* v)
* So only for train orders to stations we fill fstd->station_index, for all * So only for train orders to stations we fill fstd->station_index, for all
* others only dest_coords */ * others only dest_coords */
if (v->current_order.type == OT_GOTO_STATION && v->type == VEH_Train) { if (v->current_order.type == OT_GOTO_STATION && v->type == VEH_Train) {
fstd->station_index = v->current_order.station; fstd->station_index = v->current_order.dest.station;
/* Let's take the closest tile of the station as our target for trains */ /* Let's take the closest tile of the station as our target for trains */
fstd->dest_coords = CalcClosestStationTile(v->current_order.station, v->tile); fstd->dest_coords = CalcClosestStationTile(v->current_order.dest.station, v->tile);
} else { } else {
fstd->dest_coords = v->dest_tile; fstd->dest_coords = v->dest_tile;
fstd->station_index = INVALID_STATION; fstd->station_index = INVALID_STATION;

View File

@ -40,18 +40,33 @@ typedef uint16 StationID;
typedef uint16 TownID; typedef uint16 TownID;
typedef uint16 IndustryID; typedef uint16 IndustryID;
typedef uint16 DepotID; typedef uint16 DepotID;
typedef uint16 WaypointID;
typedef byte PlayerID; typedef byte PlayerID;
typedef byte OrderID; typedef byte OrderID;
typedef byte CargoID; typedef byte CargoID;
typedef byte LandscapeID; typedef byte LandscapeID;
typedef uint16 StringID; typedef uint16 StringID;
typedef uint32 SpriteID; ///< The number of a sprite, without mapping bits and colortables typedef uint32 SpriteID; ///< The number of a sprite, without mapping bits and colortables
typedef uint32 PalSpriteID; ///< The number of a sprite plus all the mapping bits and colortables typedef uint32 PalSpriteID; ///< The number of a sprite plus all the mapping bits and colortables
typedef uint32 CursorID; typedef uint32 CursorID;
typedef uint16 EngineID; ///< All enginenumbers should be of this type typedef uint16 EngineID;
typedef uint16 EngineRenewID; typedef uint16 EngineRenewID;
typedef uint16 SignID; typedef uint16 SignID;
typedef uint16 UnitID; ///< All unitnumber stuff is of this type (or anyway, should be) typedef uint16 UnitID;
typedef union DestinationID {
StationID station;
DepotID depot;
WaypointID waypoint;
uint16 disaster; ///< Please don't ask about it, but disasters uses orders to store stuff...
} DestinationID;
/* All items of DestionationID has to be of the same size, because some part
* of the code depends on the fact that DestionationID is the same for all
* items inside DestionationID. Check PackOrder() */
assert_compile(sizeof(StationID) == sizeof(DepotID));
assert_compile(sizeof(StationID) == sizeof(WaypointID));
assert_compile(sizeof(StationID) == sizeof(uint16));
typedef uint32 WindowNumber; typedef uint32 WindowNumber;
typedef byte WindowClass; typedef byte WindowClass;

View File

@ -70,7 +70,6 @@ enum {
CO_UNSHARE = 2 CO_UNSHARE = 2
}; };
/* If you change this, keep in mind that it is saved on 3 places: /* If you change this, keep in mind that it is saved on 3 places:
* - Load_ORDR, all the global orders * - Load_ORDR, all the global orders
* - Vehicle -> current_order * - Vehicle -> current_order
@ -79,7 +78,7 @@ enum {
typedef struct Order { typedef struct Order {
OrderType type; OrderType type;
uint8 flags; uint8 flags;
StationID station; DestinationID dest; ///< The destionation of the order.
struct Order *next; ///< Pointer to next order. If NULL, end of list struct Order *next; ///< Pointer to next order. If NULL, end of list
@ -172,7 +171,7 @@ static inline bool IsOrderPoolFull(void)
static inline uint32 PackOrder(const Order *order) static inline uint32 PackOrder(const Order *order)
{ {
return order->station << 16 | order->flags << 8 | order->type; return order->dest.station << 16 | order->flags << 8 | order->type;
} }
static inline Order UnpackOrder(uint32 packed) static inline Order UnpackOrder(uint32 packed)
@ -180,7 +179,7 @@ static inline Order UnpackOrder(uint32 packed)
Order order; Order order;
order.type = (OrderType)GB(packed, 0, 8); order.type = (OrderType)GB(packed, 0, 8);
order.flags = GB(packed, 8, 8); order.flags = GB(packed, 8, 8);
order.station = GB(packed, 16, 16); order.dest.station = GB(packed, 16, 16);
order.next = NULL; order.next = NULL;
order.index = 0; // avoid compiler warning order.index = 0; // avoid compiler warning
return order; return order;
@ -189,7 +188,7 @@ static inline Order UnpackOrder(uint32 packed)
/* Functions */ /* Functions */
void BackupVehicleOrders(const Vehicle *v, BackuppedOrders *order); void BackupVehicleOrders(const Vehicle *v, BackuppedOrders *order);
void RestoreVehicleOrders(const Vehicle* v, const BackuppedOrders* order); void RestoreVehicleOrders(const Vehicle* v, const BackuppedOrders* order);
void RemoveOrderFromAllVehicles(OrderType type, StationID destination); void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination);
void InvalidateVehicleOrder(const Vehicle *v); void InvalidateVehicleOrder(const Vehicle *v);
bool VehicleHasDepotOrders(const Vehicle *v); bool VehicleHasDepotOrders(const Vehicle *v);
void CheckOrders(const Vehicle*); void CheckOrders(const Vehicle*);

View File

@ -47,12 +47,12 @@ Order UnpackOldOrder(uint16 packed)
Order order; Order order;
order.type = GB(packed, 0, 4); order.type = GB(packed, 0, 4);
order.flags = GB(packed, 4, 4); order.flags = GB(packed, 4, 4);
order.station = GB(packed, 8, 8); order.dest.station = GB(packed, 8, 8);
order.next = NULL; order.next = NULL;
// Sanity check // Sanity check
// TTD stores invalid orders as OT_NOTHING with non-zero flags/station // TTD stores invalid orders as OT_NOTHING with non-zero flags/station
if (order.type == OT_NOTHING && (order.flags != 0 || order.station != 0)) { if (order.type == OT_NOTHING && (order.flags != 0 || order.dest.station != 0)) {
order.type = OT_DUMMY; order.type = OT_DUMMY;
order.flags = 0; order.flags = 0;
} }
@ -70,7 +70,7 @@ static Order UnpackVersion4Order(uint16 packed)
Order order; Order order;
order.type = GB(packed, 0, 4); order.type = GB(packed, 0, 4);
order.flags = GB(packed, 4, 4); order.flags = GB(packed, 4, 4);
order.station = GB(packed, 8, 8); order.dest.station = GB(packed, 8, 8);
order.next = NULL; order.next = NULL;
order.index = 0; // avoid compiler warning order.index = 0; // avoid compiler warning
return order; return order;
@ -144,7 +144,7 @@ void AssignOrder(Order *order, Order data)
{ {
order->type = data.type; order->type = data.type;
order->flags = data.flags; order->flags = data.flags;
order->station = data.station; order->dest.station = data.dest.station;
} }
@ -191,8 +191,8 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
case OT_GOTO_STATION: { case OT_GOTO_STATION: {
const Station *st; const Station *st;
if (!IsValidStationID(new_order.station)) return CMD_ERROR; if (!IsValidStationID(new_order.dest.station)) return CMD_ERROR;
st = GetStation(new_order.station); st = GetStation(new_order.dest.station);
if (st->airport_type != AT_OILRIG && !IsBuoy(st) && !CheckOwnership(st->owner)) { if (st->airport_type != AT_OILRIG && !IsBuoy(st) && !CheckOwnership(st->owner)) {
return CMD_ERROR; return CMD_ERROR;
@ -252,8 +252,8 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (v->type == VEH_Aircraft) { if (v->type == VEH_Aircraft) {
const Station* st; const Station* st;
if (!IsValidStationID(new_order.station)) return CMD_ERROR; if (!IsValidStationID(new_order.dest.station)) return CMD_ERROR;
st = GetStation(new_order.station); st = GetStation(new_order.dest.station);
if ((st->airport_type != AT_OILRIG && !CheckOwnership(st->owner)) || if ((st->airport_type != AT_OILRIG && !CheckOwnership(st->owner)) ||
!(st->facilities & FACIL_AIRPORT) || !(st->facilities & FACIL_AIRPORT) ||
@ -263,8 +263,8 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
} else { } else {
const Depot* dp; const Depot* dp;
if (!IsValidDepotID(new_order.station)) return CMD_ERROR; if (!IsValidDepotID(new_order.dest.depot)) return CMD_ERROR;
dp = GetDepot(new_order.station); dp = GetDepot(new_order.dest.depot);
if (!CheckOwnership(GetTileOwner(dp->xy))) return CMD_ERROR; if (!CheckOwnership(GetTileOwner(dp->xy))) return CMD_ERROR;
@ -308,8 +308,8 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (v->type != VEH_Train) return CMD_ERROR; if (v->type != VEH_Train) return CMD_ERROR;
if (!IsValidWaypointID(new_order.station)) return CMD_ERROR; if (!IsValidWaypointID(new_order.dest.waypoint)) return CMD_ERROR;
wp = GetWaypoint(new_order.station); wp = GetWaypoint(new_order.dest.waypoint);
if (!CheckOwnership(GetTileOwner(wp->xy))) return CMD_ERROR; if (!CheckOwnership(GetTileOwner(wp->xy))) return CMD_ERROR;
@ -346,8 +346,8 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
&& !_patches.new_pathfinding_all) { && !_patches.new_pathfinding_all) {
int dist = DistanceManhattan( int dist = DistanceManhattan(
GetStation(GetVehicleOrder(v, sel_ord - 1)->station)->xy, GetStation(GetVehicleOrder(v, sel_ord - 1)->dest.station)->xy,
GetStation(new_order.station)->xy // XXX type != OT_GOTO_STATION? GetStation(new_order.dest.station)->xy // XXX type != OT_GOTO_STATION?
); );
if (dist >= 130) if (dist >= 130)
return_cmd_error(STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO); return_cmd_error(STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO);
@ -704,7 +704,7 @@ int32 CmdCloneOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
FOR_VEHICLE_ORDERS(src, order) { FOR_VEHICLE_ORDERS(src, order) {
if (order->type == OT_GOTO_STATION) { if (order->type == OT_GOTO_STATION) {
const Station *st = GetStation(order->station); const Station *st = GetStation(order->dest.station);
if (dst->cargo_type == CT_PASSENGERS) { if (dst->cargo_type == CT_PASSENGERS) {
if (st->bus_stops != NULL) required_dst = st->bus_stops->xy; if (st->bus_stops != NULL) required_dst = st->bus_stops->xy;
} else { } else {
@ -919,7 +919,7 @@ void CheckOrders(const Vehicle* v)
} }
/* Does station have a load-bay for this vehicle? */ /* Does station have a load-bay for this vehicle? */
if (order->type == OT_GOTO_STATION) { if (order->type == OT_GOTO_STATION) {
const Station* st = GetStation(order->station); const Station* st = GetStation(order->dest.station);
TileIndex required_tile = GetStationTileForVehicle(v, st); TileIndex required_tile = GetStationTileForVehicle(v, st);
n_st++; n_st++;
@ -933,7 +933,7 @@ void CheckOrders(const Vehicle* v)
if (v->orders->type == last->type && if (v->orders->type == last->type &&
v->orders->flags == last->flags && v->orders->flags == last->flags &&
v->orders->station == last->station) { v->orders->dest.station == last->dest.station) {
problem_type = 2; problem_type = 2;
} }
} }
@ -962,7 +962,7 @@ void CheckOrders(const Vehicle* v)
* @param type The type of the order (OT_GOTO_[STATION|DEPOT|WAYPOINT]). * @param type The type of the order (OT_GOTO_[STATION|DEPOT|WAYPOINT]).
* @param destination The destination. Can be a StationID, DepotID or WaypointID. * @param destination The destination. Can be a StationID, DepotID or WaypointID.
*/ */
void RemoveOrderFromAllVehicles(OrderType type, StationID destination) void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
{ {
Vehicle *v; Vehicle *v;
Order *order; Order *order;
@ -973,11 +973,11 @@ void RemoveOrderFromAllVehicles(OrderType type, StationID destination)
if (v->orders == NULL) continue; if (v->orders == NULL) continue;
/* Forget about this station if this station is removed */ /* Forget about this station if this station is removed */
if (v->last_station_visited == destination && type == OT_GOTO_STATION) if (v->last_station_visited == destination.station && type == OT_GOTO_STATION)
v->last_station_visited = INVALID_STATION; v->last_station_visited = INVALID_STATION;
/* Check the current order */ /* Check the current order */
if (v->current_order.type == type && v->current_order.station == destination) { if (v->current_order.type == type && v->current_order.dest.station == destination.station) {
/* Mark the order as DUMMY */ /* Mark the order as DUMMY */
v->current_order.type = OT_DUMMY; v->current_order.type = OT_DUMMY;
v->current_order.flags = 0; v->current_order.flags = 0;
@ -987,7 +987,7 @@ void RemoveOrderFromAllVehicles(OrderType type, StationID destination)
/* Clear the order from the order-list */ /* Clear the order from the order-list */
need_invalidate = false; need_invalidate = false;
FOR_VEHICLE_ORDERS(v, order) { FOR_VEHICLE_ORDERS(v, order) {
if (order->type == type && order->station == destination) { if (order->type == type && order->dest.station == destination.station) {
/* Mark the order as DUMMY */ /* Mark the order as DUMMY */
order->type = OT_DUMMY; order->type = OT_DUMMY;
order->flags = 0; order->flags = 0;
@ -1112,7 +1112,7 @@ void InitializeOrders(void)
static const SaveLoad _order_desc[] = { static const SaveLoad _order_desc[] = {
SLE_VAR(Order, type, SLE_UINT8), SLE_VAR(Order, type, SLE_UINT8),
SLE_VAR(Order, flags, SLE_UINT8), SLE_VAR(Order, flags, SLE_UINT8),
SLE_VAR(Order, station, SLE_UINT16), SLE_VAR(Order, dest.station, SLE_UINT16), // Saving one of the union is enough, they all share the same memory
SLE_REF(Order, next, REF_ORDER), SLE_REF(Order, next, REF_ORDER),
// reserve extra space in savegame here. (currently 10 bytes) // reserve extra space in savegame here. (currently 10 bytes)

View File

@ -134,7 +134,7 @@ static void DrawOrdersWindow(Window *w)
switch (order->type) { switch (order->type) {
case OT_GOTO_STATION: case OT_GOTO_STATION:
SetDParam(1, StationOrderStrings[order->flags]); SetDParam(1, StationOrderStrings[order->flags]);
SetDParam(2, order->station); SetDParam(2, order->dest.station);
break; break;
case OT_GOTO_DEPOT: { case OT_GOTO_DEPOT: {
@ -142,9 +142,9 @@ static void DrawOrdersWindow(Window *w)
if (v->type == VEH_Aircraft) { if (v->type == VEH_Aircraft) {
s = STR_GO_TO_AIRPORT_HANGAR; s = STR_GO_TO_AIRPORT_HANGAR;
SetDParam(2, order->station); SetDParam(2, order->dest.depot);
} else { } else {
SetDParam(2, GetDepot(order->station)->town_index); SetDParam(2, GetDepot(order->dest.depot)->town_index);
switch (v->type) { switch (v->type) {
case VEH_Train: s = (order->flags & OF_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break; case VEH_Train: s = (order->flags & OF_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break;
@ -162,7 +162,7 @@ static void DrawOrdersWindow(Window *w)
case OT_GOTO_WAYPOINT: case OT_GOTO_WAYPOINT:
SetDParam(1, (order->flags & OF_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT); SetDParam(1, (order->flags & OF_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
SetDParam(2, order->station); SetDParam(2, order->dest.waypoint);
break; break;
default: break; default: break;
@ -174,7 +174,7 @@ static void DrawOrdersWindow(Window *w)
DrawString(2, y, str, color); DrawString(2, y, str, color);
} else { } else {
SetDParam(1, STR_INVALID_ORDER); SetDParam(1, STR_INVALID_ORDER);
SetDParam(2, order->station); SetDParam(2, order->dest.station);
DrawString(2, y, str, color); DrawString(2, y, str, color);
} }
y += 10; y += 10;
@ -205,7 +205,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
if (IsRailDepot(tile)) { if (IsRailDepot(tile)) {
order.type = OT_GOTO_DEPOT; order.type = OT_GOTO_DEPOT;
order.flags = OF_PART_OF_ORDERS; order.flags = OF_PART_OF_ORDERS;
order.station = GetDepotByTile(tile)->index; order.dest.depot = GetDepotByTile(tile)->index;
return order; return order;
} }
} }
@ -215,7 +215,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
if (GetRoadTileType(tile) == ROAD_TILE_DEPOT && v->type == VEH_Road && IsTileOwner(tile, _local_player)) { if (GetRoadTileType(tile) == ROAD_TILE_DEPOT && v->type == VEH_Road && IsTileOwner(tile, _local_player)) {
order.type = OT_GOTO_DEPOT; order.type = OT_GOTO_DEPOT;
order.flags = OF_PART_OF_ORDERS; order.flags = OF_PART_OF_ORDERS;
order.station = GetDepotByTile(tile)->index; order.dest.depot = GetDepotByTile(tile)->index;
return order; return order;
} }
break; break;
@ -225,7 +225,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
if (IsHangar(tile) && IsTileOwner(tile, _local_player)) { if (IsHangar(tile) && IsTileOwner(tile, _local_player)) {
order.type = OT_GOTO_DEPOT; order.type = OT_GOTO_DEPOT;
order.flags = OF_PART_OF_ORDERS; order.flags = OF_PART_OF_ORDERS;
order.station = GetStationIndex(tile); order.dest.station = GetStationIndex(tile);
return order; return order;
} }
break; break;
@ -238,7 +238,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
order.type = OT_GOTO_DEPOT; order.type = OT_GOTO_DEPOT;
order.flags = OF_PART_OF_ORDERS; order.flags = OF_PART_OF_ORDERS;
order.station = GetDepotByTile(tile < tile2 ? tile : tile2)->index; order.dest.depot = GetDepotByTile(tile < tile2 ? tile : tile2)->index;
return order; return order;
} }
@ -254,7 +254,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
IsRailWaypoint(tile)) { IsRailWaypoint(tile)) {
order.type = OT_GOTO_WAYPOINT; order.type = OT_GOTO_WAYPOINT;
order.flags = 0; order.flags = 0;
order.station = GetWaypointByTile(tile)->index; order.dest.waypoint = GetWaypointByTile(tile)->index;
return order; return order;
} }
@ -272,7 +272,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
if (st->facilities & facil) { if (st->facilities & facil) {
order.type = OT_GOTO_STATION; order.type = OT_GOTO_STATION;
order.flags = 0; order.flags = 0;
order.station = st_index; order.dest.station = st_index;
return order; return order;
} }
} }
@ -281,7 +281,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
// not found // not found
order.type = OT_NOTHING; order.type = OT_NOTHING;
order.flags = 0; order.flags = 0;
order.station = INVALID_STATION; order.dest.station = INVALID_STATION;
return order; return order;
} }
@ -410,9 +410,9 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
TileIndex xy; TileIndex xy;
switch (ord->type) { switch (ord->type) {
case OT_GOTO_STATION: xy = GetStation(ord->station)->xy ; break; case OT_GOTO_STATION: xy = GetStation(ord->dest.station)->xy ; break;
case OT_GOTO_DEPOT: xy = GetDepot(ord->station)->xy; break; case OT_GOTO_DEPOT: xy = GetDepot(ord->dest.depot)->xy; break;
case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->station)->xy; break; case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->dest.waypoint)->xy; break;
default: xy = 0; break; default: xy = 0; break;
} }

View File

@ -394,7 +394,7 @@ int32 CmdSendRoadVehToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
ClearSlot(v); ClearSlot(v);
v->current_order.type = OT_GOTO_DEPOT; v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP | OF_HALT_IN_DEPOT; v->current_order.flags = OF_NON_STOP | OF_HALT_IN_DEPOT;
v->current_order.station = dep->index; v->current_order.dest.depot = dep->index;
v->dest_tile = dep->xy; v->dest_tile = dep->xy;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
} }
@ -649,7 +649,7 @@ static void ProcessRoadVehOrder(Vehicle *v)
if (order->type == v->current_order.type && if (order->type == v->current_order.type &&
order->flags == v->current_order.flags && order->flags == v->current_order.flags &&
order->station == v->current_order.station) { order->dest.station == v->current_order.dest.station) {
return; return;
} }
@ -659,12 +659,12 @@ static void ProcessRoadVehOrder(Vehicle *v)
case OT_GOTO_STATION: { case OT_GOTO_STATION: {
const RoadStop* rs; const RoadStop* rs;
if (order->station == v->last_station_visited) { if (order->dest.station == v->last_station_visited) {
v->last_station_visited = INVALID_STATION; v->last_station_visited = INVALID_STATION;
} }
rs = GetPrimaryRoadStop( rs = GetPrimaryRoadStop(
GetStation(order->station), GetStation(order->dest.station),
v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK
); );
@ -690,7 +690,7 @@ static void ProcessRoadVehOrder(Vehicle *v)
} }
case OT_GOTO_DEPOT: case OT_GOTO_DEPOT:
v->dest_tile = GetDepot(order->station)->xy; v->dest_tile = GetDepot(order->dest.depot)->xy;
break; break;
default: default:
@ -1478,7 +1478,7 @@ again:
v->current_order.flags = 0; v->current_order.flags = 0;
if (old_order.type == OT_GOTO_STATION && if (old_order.type == OT_GOTO_STATION &&
v->current_order.station == v->last_station_visited) { v->current_order.dest.station == v->last_station_visited) {
v->current_order.flags = v->current_order.flags =
(old_order.flags & (OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER)) | OF_NON_STOP; (old_order.flags & (OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER)) | OF_NON_STOP;
} }
@ -1520,9 +1520,9 @@ again:
if (v->current_order.type != OT_GOTO_STATION) { if (v->current_order.type != OT_GOTO_STATION) {
DEBUG(ms, 0) ("Multistop: -- Current order type (%d) is not OT_GOTO_STATION.", v->current_order.type); DEBUG(ms, 0) ("Multistop: -- Current order type (%d) is not OT_GOTO_STATION.", v->current_order.type);
} else { } else {
if (v->current_order.station != st->index) if (v->current_order.dest.station != st->index)
DEBUG(ms, 0) ("Multistop: -- Current station %d is not target station in current_order.station (%d).", DEBUG(ms, 0) ("Multistop: -- Current station %d is not target station in current_order.station (%d).",
st->index, v->current_order.station); st->index, v->current_order.dest.station);
} }
DEBUG(ms, 0) (" -- Force a slot clearing."); DEBUG(ms, 0) (" -- Force a slot clearing.");
@ -1637,7 +1637,7 @@ static void CheckIfRoadVehNeedsService(Vehicle *v)
v->current_order.type = OT_GOTO_DEPOT; v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP; v->current_order.flags = OF_NON_STOP;
v->current_order.station = depot->index; v->current_order.dest.depot = depot->index;
v->dest_tile = depot->xy; v->dest_tile = depot->xy;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
} }
@ -1665,7 +1665,7 @@ void OnNewDay_RoadVeh(Vehicle *v)
/* update destination */ /* update destination */
if (v->current_order.type == OT_GOTO_STATION && v->u.road.slot == NULL && !(v->vehstatus & VS_CRASHED)) { if (v->current_order.type == OT_GOTO_STATION && v->u.road.slot == NULL && !(v->vehstatus & VS_CRASHED)) {
Station* st = GetStation(v->current_order.station); Station* st = GetStation(v->current_order.dest.station);
RoadStop* rs = GetPrimaryRoadStop(st, v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK); RoadStop* rs = GetPrimaryRoadStop(st, v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK);
RoadStop* best = NULL; RoadStop* best = NULL;

View File

@ -334,13 +334,13 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e)
} else { } else {
switch (v->current_order.type) { switch (v->current_order.type) {
case OT_GOTO_STATION: { case OT_GOTO_STATION: {
SetDParam(0, v->current_order.station); SetDParam(0, v->current_order.dest.station);
SetDParam(1, v->cur_speed / 2); SetDParam(1, v->cur_speed / 2);
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; str = STR_HEADING_FOR_STATION + _patches.vehicle_speed;
} break; } break;
case OT_GOTO_DEPOT: { case OT_GOTO_DEPOT: {
Depot *depot = GetDepot(v->current_order.station); Depot *depot = GetDepot(v->current_order.dest.depot);
SetDParam(0, depot->town_index); SetDParam(0, depot->town_index);
SetDParam(1, v->cur_speed / 2); SetDParam(1, v->cur_speed / 2);
str = STR_HEADING_FOR_ROAD_DEPOT + _patches.vehicle_speed; str = STR_HEADING_FOR_ROAD_DEPOT + _patches.vehicle_speed;

View File

@ -125,7 +125,7 @@ static void CheckIfShipNeedsService(Vehicle *v)
v->current_order.type = OT_GOTO_DEPOT; v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP; v->current_order.flags = OF_NON_STOP;
v->current_order.station = depot->index; v->current_order.dest.depot = depot->index;
v->dest_tile = depot->xy; v->dest_tile = depot->xy;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
} }
@ -229,7 +229,7 @@ static void ProcessShipOrder(Vehicle *v)
if (order->type == v->current_order.type && if (order->type == v->current_order.type &&
order->flags == v->current_order.flags && order->flags == v->current_order.flags &&
order->station == v->current_order.station) order->dest.station == v->current_order.dest.station)
return; return;
v->current_order = *order; v->current_order = *order;
@ -237,15 +237,15 @@ static void ProcessShipOrder(Vehicle *v)
if (order->type == OT_GOTO_STATION) { if (order->type == OT_GOTO_STATION) {
const Station *st; const Station *st;
if (order->station == v->last_station_visited) if (order->dest.station == v->last_station_visited)
v->last_station_visited = INVALID_STATION; v->last_station_visited = INVALID_STATION;
st = GetStation(order->station); st = GetStation(order->dest.station);
if (st->dock_tile != 0) { if (st->dock_tile != 0) {
v->dest_tile = TILE_ADD(st->dock_tile, ToTileIndexDiff(GetDockOffset(st->dock_tile))); v->dest_tile = TILE_ADD(st->dock_tile, ToTileIndexDiff(GetDockOffset(st->dock_tile)));
} }
} else if (order->type == OT_GOTO_DEPOT) { } else if (order->type == OT_GOTO_DEPOT) {
v->dest_tile = GetDepot(order->station)->xy; v->dest_tile = GetDepot(order->dest.depot)->xy;
} else { } else {
v->dest_tile = 0; v->dest_tile = 0;
} }
@ -722,10 +722,10 @@ static void ShipController(Vehicle *v)
} else if (v->current_order.type == OT_GOTO_STATION) { } else if (v->current_order.type == OT_GOTO_STATION) {
Station *st; Station *st;
v->last_station_visited = v->current_order.station; v->last_station_visited = v->current_order.dest.station;
/* Process station in the orderlist. */ /* Process station in the orderlist. */
st = GetStation(v->current_order.station); st = GetStation(v->current_order.dest.station);
if (st->facilities & FACIL_DOCK) { /* ugly, ugly workaround for problem with ships able to drop off cargo at wrong stations */ if (st->facilities & FACIL_DOCK) { /* ugly, ugly workaround for problem with ships able to drop off cargo at wrong stations */
v->current_order.type = OT_LOADING; v->current_order.type = OT_LOADING;
v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER; v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER;
@ -1033,7 +1033,7 @@ int32 CmdSendShipToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->dest_tile = dep->xy; v->dest_tile = dep->xy;
v->current_order.type = OT_GOTO_DEPOT; v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP | OF_HALT_IN_DEPOT; v->current_order.flags = OF_NON_STOP | OF_HALT_IN_DEPOT;
v->current_order.station = dep->index; v->current_order.dest.depot = dep->index;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
} }

View File

@ -481,13 +481,13 @@ static void ShipViewWndProc(Window *w, WindowEvent *e)
} else { } else {
switch (v->current_order.type) { switch (v->current_order.type) {
case OT_GOTO_STATION: { case OT_GOTO_STATION: {
SetDParam(0, v->current_order.station); SetDParam(0, v->current_order.dest.station);
SetDParam(1, v->cur_speed / 2); SetDParam(1, v->cur_speed / 2);
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; str = STR_HEADING_FOR_STATION + _patches.vehicle_speed;
} break; } break;
case OT_GOTO_DEPOT: { case OT_GOTO_DEPOT: {
Depot *depot = GetDepot(v->current_order.station); Depot *depot = GetDepot(v->current_order.dest.depot);
SetDParam(0, depot->town_index); SetDParam(0, depot->town_index);
SetDParam(1, v->cur_speed / 2); SetDParam(1, v->cur_speed / 2);
str = STR_HEADING_FOR_SHIP_DEPOT + _patches.vehicle_speed; str = STR_HEADING_FOR_SHIP_DEPOT + _patches.vehicle_speed;
@ -906,8 +906,8 @@ static void DrawSmallOrderList(const Vehicle *v, int x, int y)
sel--; sel--;
if (order->type == OT_GOTO_STATION) { if (order->type == OT_GOTO_STATION) {
if (!IsBuoy(GetStation(order->station))){ if (!IsBuoy(GetStation(order->dest.station))){
SetDParam(0, order->station); SetDParam(0, order->dest.station);
DrawString(x, y, STR_A036, 0); DrawString(x, y, STR_A036, 0);
y += 6; y += 6;

View File

@ -1863,7 +1863,7 @@ static bool CheckShipsOnBuoy(Station *st)
if (v->type == VEH_Ship) { if (v->type == VEH_Ship) {
const Order *order; const Order *order;
FOR_VEHICLE_ORDERS(v, order) { FOR_VEHICLE_ORDERS(v, order) {
if (order->type == OT_GOTO_STATION && order->station == st->index) { if (order->type == OT_GOTO_STATION && order->dest.station == st->index) {
return true; return true;
} }
} }
@ -2333,7 +2333,7 @@ static uint32 VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
StationID station_id = GetStationIndex(tile); StationID station_id = GetStationIndex(tile);
if ((!(v->current_order.flags & OF_NON_STOP) && !_patches.new_nonstop) || if ((!(v->current_order.flags & OF_NON_STOP) && !_patches.new_nonstop) ||
(v->current_order.type == OT_GOTO_STATION && v->current_order.station == station_id)) { (v->current_order.type == OT_GOTO_STATION && v->current_order.dest.station == station_id)) {
if (!(_patches.new_nonstop && v->current_order.flags & OF_NON_STOP) && if (!(_patches.new_nonstop && v->current_order.flags & OF_NON_STOP) &&
v->current_order.type != OT_LEAVESTATION && v->current_order.type != OT_LEAVESTATION &&
v->last_station_visited != station_id) { v->last_station_visited != station_id) {
@ -2412,7 +2412,7 @@ static void DeleteStation(Station *st)
DeleteWindowById(WC_STATION_VIEW, index); DeleteWindowById(WC_STATION_VIEW, index);
/* Now delete all orders that go to the station */ /* Now delete all orders that go to the station */
RemoveOrderFromAllVehicles(OT_GOTO_STATION, index); RemoveOrderFromAllVehicles(OT_GOTO_STATION, (DestinationID)index);
//And do the same with aircraft that have the station as a hangar-stop //And do the same with aircraft that have the station as a hangar-stop
FOR_ALL_VEHICLES(v) { FOR_ALL_VEHICLES(v) {
@ -2420,7 +2420,7 @@ static void DeleteStation(Station *st)
if (v->type == VEH_Aircraft) { if (v->type == VEH_Aircraft) {
Order *order; Order *order;
FOR_VEHICLE_ORDERS(v, order) { FOR_VEHICLE_ORDERS(v, order) {
if (order->type == OT_GOTO_DEPOT && order->station == index) { if (order->type == OT_GOTO_DEPOT && order->dest.station == index) {
order->type = OT_DUMMY; order->type = OT_DUMMY;
order->flags = 0; order->flags = 0;
invalidate = true; invalidate = true;

View File

@ -254,13 +254,13 @@ static bool TrainShouldStop(const Vehicle* v, TileIndex tile)
assert(v->type == VEH_Train); assert(v->type == VEH_Train);
//When does a train drive through a station //When does a train drive through a station
//first we deal with the "new nonstop handling" //first we deal with the "new nonstop handling"
if (_patches.new_nonstop && o->flags & OF_NON_STOP && sid == o->station) { if (_patches.new_nonstop && o->flags & OF_NON_STOP && sid == o->dest.station) {
return false; return false;
} }
if (v->last_station_visited == sid) return false; if (v->last_station_visited == sid) return false;
if (sid != o->station && (o->flags & OF_NON_STOP || _patches.new_nonstop)) { if (sid != o->dest.station && (o->flags & OF_NON_STOP || _patches.new_nonstop)) {
return false; return false;
} }
@ -1960,7 +1960,7 @@ int32 CmdSendTrainToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->dest_tile = tfdd.tile; v->dest_tile = tfdd.tile;
v->current_order.type = OT_GOTO_DEPOT; v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP | OF_FULL_LOAD; v->current_order.flags = OF_NON_STOP | OF_FULL_LOAD;
v->current_order.station = GetDepotByTile(tfdd.tile)->index; v->current_order.dest.depot = GetDepotByTile(tfdd.tile)->index;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
/* If there is no depot in front, reverse automatically */ /* If there is no depot in front, reverse automatically */
if (tfdd.reverse) if (tfdd.reverse)
@ -2164,7 +2164,7 @@ static void FillWithStationData(TrainTrackFollowerData* fd, const Vehicle* v)
{ {
fd->dest_coords = v->dest_tile; fd->dest_coords = v->dest_tile;
if (v->current_order.type == OT_GOTO_STATION) { if (v->current_order.type == OT_GOTO_STATION) {
fd->station_index = v->current_order.station; fd->station_index = v->current_order.dest.station;
} else { } else {
fd->station_index = INVALID_STATION; fd->station_index = INVALID_STATION;
} }
@ -2411,7 +2411,7 @@ static bool ProcessTrainOrder(Vehicle *v)
if (_patches.new_nonstop && if (_patches.new_nonstop &&
v->current_order.flags & OF_NON_STOP && v->current_order.flags & OF_NON_STOP &&
IsTileType(v->tile, MP_STATION) && IsTileType(v->tile, MP_STATION) &&
v->current_order.station == GetStationIndex(v->tile)) { v->current_order.dest.station == GetStationIndex(v->tile)) {
v->cur_order_index++; v->cur_order_index++;
} }
@ -2431,7 +2431,7 @@ static bool ProcessTrainOrder(Vehicle *v)
// If it is unchanged, keep it. // If it is unchanged, keep it.
if (order->type == v->current_order.type && if (order->type == v->current_order.type &&
order->flags == v->current_order.flags && order->flags == v->current_order.flags &&
order->station == v->current_order.station) order->dest.station == v->current_order.dest.station)
return false; return false;
// Otherwise set it, and determine the destination tile. // Otherwise set it, and determine the destination tile.
@ -2443,17 +2443,17 @@ static bool ProcessTrainOrder(Vehicle *v)
switch (order->type) { switch (order->type) {
case OT_GOTO_STATION: case OT_GOTO_STATION:
if (order->station == v->last_station_visited) if (order->dest.station == v->last_station_visited)
v->last_station_visited = INVALID_STATION; v->last_station_visited = INVALID_STATION;
v->dest_tile = GetStation(order->station)->xy; v->dest_tile = GetStation(order->dest.station)->xy;
break; break;
case OT_GOTO_DEPOT: case OT_GOTO_DEPOT:
v->dest_tile = GetDepot(order->station)->xy; v->dest_tile = GetDepot(order->dest.depot)->xy;
break; break;
case OT_GOTO_WAYPOINT: case OT_GOTO_WAYPOINT:
v->dest_tile = GetWaypoint(order->station)->xy; v->dest_tile = GetWaypoint(order->dest.waypoint)->xy;
break; break;
default: default:
@ -2574,7 +2574,7 @@ static void TrainEnterStation(Vehicle *v, StationID station)
// Did we reach the final destination? // Did we reach the final destination?
if (v->current_order.type == OT_GOTO_STATION && if (v->current_order.type == OT_GOTO_STATION &&
v->current_order.station == station) { v->current_order.dest.station == station) {
// Yeah, keep the load/unload flags // Yeah, keep the load/unload flags
// Non Stop now means if the order should be increased. // Non Stop now means if the order should be increased.
v->current_order.type = OT_LOADING; v->current_order.type = OT_LOADING;
@ -2585,7 +2585,7 @@ static void TrainEnterStation(Vehicle *v, StationID station)
v->current_order.type = OT_LOADING; v->current_order.type = OT_LOADING;
v->current_order.flags = 0; v->current_order.flags = 0;
} }
v->current_order.station = 0; v->current_order.dest.station = 0;
SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC); SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC);
if (LoadUnloadVehicle(v) != 0) { if (LoadUnloadVehicle(v) != 0) {
@ -3503,14 +3503,14 @@ static void CheckIfTrainNeedsService(Vehicle *v)
depot = GetDepotByTile(tfdd.tile); depot = GetDepotByTile(tfdd.tile);
if (v->current_order.type == OT_GOTO_DEPOT && if (v->current_order.type == OT_GOTO_DEPOT &&
v->current_order.station != depot->index && v->current_order.dest.depot != depot->index &&
!CHANCE16(3, 16)) { !CHANCE16(3, 16)) {
return; return;
} }
v->current_order.type = OT_GOTO_DEPOT; v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP; v->current_order.flags = OF_NON_STOP;
v->current_order.station = depot->index; v->current_order.dest.depot = depot->index;
v->dest_tile = tfdd.tile; v->dest_tile = tfdd.tile;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
} }
@ -3555,7 +3555,7 @@ void OnNewDay_Train(Vehicle *v)
/* update destination */ /* update destination */
if (v->current_order.type == OT_GOTO_STATION && if (v->current_order.type == OT_GOTO_STATION &&
(tile = GetStation(v->current_order.station)->train_tile) != 0) { (tile = GetStation(v->current_order.dest.station)->train_tile) != 0) {
v->dest_tile = tile; v->dest_tile = tile;
} }

View File

@ -968,12 +968,12 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
switch (v->current_order.type) { switch (v->current_order.type) {
case OT_GOTO_STATION: { case OT_GOTO_STATION: {
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; str = STR_HEADING_FOR_STATION + _patches.vehicle_speed;
SetDParam(0, v->current_order.station); SetDParam(0, v->current_order.dest.station);
SetDParam(1, v->u.rail.last_speed); SetDParam(1, v->u.rail.last_speed);
} break; } break;
case OT_GOTO_DEPOT: { case OT_GOTO_DEPOT: {
Depot *dep = GetDepot(v->current_order.station); Depot *dep = GetDepot(v->current_order.dest.depot);
SetDParam(0, dep->town_index); SetDParam(0, dep->town_index);
str = STR_HEADING_FOR_TRAIN_DEPOT + _patches.vehicle_speed; str = STR_HEADING_FOR_TRAIN_DEPOT + _patches.vehicle_speed;
SetDParam(1, v->u.rail.last_speed); SetDParam(1, v->u.rail.last_speed);
@ -985,7 +985,7 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
break; break;
case OT_GOTO_WAYPOINT: { case OT_GOTO_WAYPOINT: {
SetDParam(0, v->current_order.station); SetDParam(0, v->current_order.dest.waypoint);
str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed; str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed;
SetDParam(1, v->u.rail.last_speed); SetDParam(1, v->u.rail.last_speed);
break; break;

View File

@ -2193,12 +2193,12 @@ const SaveLoad _common_veh_desc[] = {
type and flags (which were both 4 bits) into type. Later on this is type and flags (which were both 4 bits) into type. Later on this is
converted correctly */ converted correctly */
SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, type), SLE_UINT8, 0, 4), SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, type), SLE_UINT8, 0, 4),
SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station), SLE_FILE_U8 | SLE_VAR_U16, 0, 4), SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest.station), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
/* Orders for version 5 and on */ /* Orders for version 5 and on */
SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, type), SLE_UINT8, 5, SL_MAX_VERSION), SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, type), SLE_UINT8, 5, SL_MAX_VERSION),
SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, flags), SLE_UINT8, 5, SL_MAX_VERSION), SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, flags), SLE_UINT8, 5, SL_MAX_VERSION),
SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station), SLE_UINT16, 5, SL_MAX_VERSION), SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest.station), SLE_UINT16, 5, SL_MAX_VERSION),
SLE_REF(Vehicle, orders, REF_ORDER), SLE_REF(Vehicle, orders, REF_ORDER),
@ -2363,8 +2363,8 @@ static const SaveLoad _disaster_desc[] = {
SLE_VAR(Vehicle, z_height, SLE_UINT8), SLE_VAR(Vehicle, z_height, SLE_UINT8),
SLE_VAR(Vehicle, owner, SLE_UINT8), SLE_VAR(Vehicle, owner, SLE_UINT8),
SLE_VAR(Vehicle, vehstatus, SLE_UINT8), SLE_VAR(Vehicle, vehstatus, SLE_UINT8),
SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station), SLE_FILE_U8 | SLE_VAR_U16, 0, 4), SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest.station), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, station), SLE_UINT16, 5, SL_MAX_VERSION), SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest.station), SLE_UINT16, 5, SL_MAX_VERSION),
SLE_VAR(Vehicle, cur_image, SLE_UINT16), SLE_VAR(Vehicle, cur_image, SLE_UINT16),
SLE_CONDVAR(Vehicle, age, SLE_FILE_U16 | SLE_VAR_I32, 0, 30), SLE_CONDVAR(Vehicle, age, SLE_FILE_U16 | SLE_VAR_I32, 0, 30),

View File

@ -142,7 +142,7 @@ void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID sta
const Order *order; const Order *order;
FOR_VEHICLE_ORDERS(v, order) { FOR_VEHICLE_ORDERS(v, order) {
if (order->type == OT_GOTO_STATION && order->station == station) { if (order->type == OT_GOTO_STATION && order->dest.station == station) {
sort_list[n++] = v; sort_list[n++] = v;
break; break;
} }

View File

@ -249,7 +249,7 @@ static void DoDeleteWaypoint(Waypoint *wp)
{ {
wp->xy = 0; wp->xy = 0;
RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, wp->index); RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, (DestinationID)wp->index);
if (wp->string != STR_NULL) DeleteName(wp->string); if (wp->string != STR_NULL) DeleteName(wp->string);

View File

@ -8,7 +8,7 @@
struct Waypoint { struct Waypoint {
TileIndex xy; ///< Tile of waypoint TileIndex xy; ///< Tile of waypoint
StationID index; ///< Index of waypoint WaypointID index; ///< Index of waypoint
TownID town_index; ///< Town associated with the waypoint TownID town_index; ///< Town associated with the waypoint
byte town_cn; ///< The Nth waypoint for this town (consecutive number) byte town_cn; ///< The Nth waypoint for this town (consecutive number)
@ -29,7 +29,7 @@ extern MemoryPool _waypoint_pool;
/** /**
* Get the pointer to the waypoint with index 'index' * Get the pointer to the waypoint with index 'index'
*/ */
static inline Waypoint *GetWaypoint(uint index) static inline Waypoint *GetWaypoint(WaypointID index)
{ {
return (Waypoint*)GetItemFromPool(&_waypoint_pool, index); return (Waypoint*)GetItemFromPool(&_waypoint_pool, index);
} }
@ -50,7 +50,7 @@ static inline bool IsValidWaypoint(const Waypoint *wp)
return wp->xy != 0; return wp->xy != 0;
} }
static inline bool IsValidWaypointID(uint index) static inline bool IsValidWaypointID(WaypointID index)
{ {
return index < GetWaypointPoolSize() && IsValidWaypoint(GetWaypoint(index)); return index < GetWaypointPoolSize() && IsValidWaypoint(GetWaypoint(index));
} }

View File

@ -85,8 +85,8 @@ public:
void SetDestination(Vehicle* v) void SetDestination(Vehicle* v)
{ {
if (v->current_order.type == OT_GOTO_STATION) { if (v->current_order.type == OT_GOTO_STATION) {
m_destTile = CalcStationCenterTile(v->current_order.station); m_destTile = CalcStationCenterTile(v->current_order.dest.station);
m_dest_station_id = v->current_order.station; m_dest_station_id = v->current_order.dest.station;
m_destTrackdirs = INVALID_TRACKDIR_BIT; m_destTrackdirs = INVALID_TRACKDIR_BIT;
} else { } else {
m_destTile = v->dest_tile; m_destTile = v->dest_tile;