(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold

DestinationID being a union of these types is just hassle without benefit and cannot be handled correctly everywhere because of local lack of information
This commit is contained in:
tron 2006-09-03 08:25:27 +00:00
parent 302772883c
commit 1c21c645ae
21 changed files with 173 additions and 187 deletions

View File

@ -2453,7 +2453,7 @@ handle_nocash:
order.type = OT_GOTO_STATION;
order.flags = 0;
order.dest.station = AiGetStationIdByDef(aib->use_tile, aib->cur_building_rule);
order.dest = AiGetStationIdByDef(aib->use_tile, aib->cur_building_rule);
if (!is_pass && i == 1) order.flags |= OF_UNLOAD;
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.flags = 0;
order.dest.station = AiGetStationIdFromRoadBlock(aib->use_tile, aib->cur_building_rule);
order.dest = AiGetStationIdFromRoadBlock(aib->use_tile, aib->cur_building_rule);
if (!is_pass && i == 1) order.flags |= OF_UNLOAD;
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.flags = 0;
order.dest.station = AiGetStationIdFromAircraftBlock(aib->use_tile, aib->cur_building_rule);
order.dest = AiGetStationIdFromAircraftBlock(aib->use_tile, aib->cur_building_rule);
if (!is_pass && i == 1) order.flags |= OF_UNLOAD;
if (p->ai.num_want_fullload != 0 && (is_pass || i == 0))
@ -3567,7 +3567,7 @@ static void AiStateRemoveStation(Player *p)
in_use = malloc(GetStationArraySize());
memset(in_use, 0, GetStationArraySize());
FOR_ALL_ORDERS(ord) {
if (ord->type == OT_GOTO_STATION) in_use[ord->dest.station] = 1;
if (ord->type == OT_GOTO_STATION) in_use[ord->dest] = 1;
}
// 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;
FOR_VEHICLE_ORDERS(v, order) {
if (order->type == OT_GOTO_STATION && GetStation(order->dest.station) == st) {
if (order->type == OT_GOTO_STATION && GetStation(order->dest) == st) {
// This vehicle has this city in its list
count++;
}
@ -1192,14 +1192,14 @@ static void AiNew_State_GiveOrders(Player *p)
idx = 0;
order.type = OT_GOTO_DEPOT;
order.flags = OF_UNLOAD;
order.dest.depot = GetDepotByTile(p->ainew.depot_tile)->index;
order.dest = GetDepotByTile(p->ainew.depot_tile)->index;
AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
}
idx = 0;
order.type = OT_GOTO_STATION;
order.flags = 0;
order.dest.station = GetStationIndex(p->ainew.to_tile);
order.dest = GetStationIndex(p->ainew.to_tile);
if (p->ainew.tbt == AI_TRUCK && p->ainew.to_deliver)
order.flags |= OF_FULL_LOAD;
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;
order.type = OT_GOTO_STATION;
order.flags = 0;
order.dest.station = GetStationIndex(p->ainew.from_tile);
order.dest = GetStationIndex(p->ainew.from_tile);
if (p->ainew.tbt == AI_TRUCK && p->ainew.from_deliver)
order.flags |= OF_FULL_LOAD;
AI_DoCommand(0, p->ainew.veh_id + (idx << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);

View File

@ -554,7 +554,7 @@ int32 CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP;
if (!(p1 & DEPOT_SERVICE)) SETBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
v->current_order.dest.station = next_airport_index;
v->current_order.dest = next_airport_index;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
if (p2 & DEPOT_LOCATE_HANGAR || (p2 & DEPOT_SERVICE && v->u.air.state == FLYING && !next_airport_has_hangar)) {
/* The aircraft is now heading for a different hangar than the next in the orders */
@ -667,7 +667,7 @@ static void CheckIfAircraftNeedsService(Vehicle *v)
if (_patches.gotodepot && VehicleHasDepotOrders(v)) return;
st = GetStation(v->current_order.dest.station);
st = GetStation(v->current_order.dest);
// 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) {
// printf("targetairport = %d, st->index = %d\n", v->u.air.targetairport, st->index);
@ -1212,9 +1212,9 @@ static void ProcessAircraftOrder(Vehicle *v)
if (order->type == OT_DUMMY && !CheckForValidOrders(v)) CrashAirplane(v);
if (order->type == v->current_order.type &&
order->flags == v->current_order.flags &&
order->dest.station == v->current_order.dest.station)
if (order->type == v->current_order.type &&
order->flags == v->current_order.flags &&
order->dest == v->current_order.dest)
return;
v->current_order = *order;
@ -1222,7 +1222,7 @@ static void ProcessAircraftOrder(Vehicle *v)
// orders are changed in flight, ensure going to the right station
if (order->type == OT_GOTO_STATION && v->u.air.state == FLYING) {
AircraftNextAirportPos_and_Order(v);
v->u.air.targetairport = order->dest.station;
v->u.air.targetairport = order->dest;
}
InvalidateVehicleOrder(v);
@ -1364,7 +1364,7 @@ static void AircraftEntersTerminal(Vehicle *v)
v->current_order.flags = 0;
if (old_order.type == OT_GOTO_STATION &&
v->current_order.dest.station == v->last_station_visited) {
v->current_order.dest == v->last_station_visited) {
v->current_order.flags =
(old_order.flags & (OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER)) | OF_NON_STOP;
}
@ -1432,7 +1432,7 @@ static void AircraftNextAirportPos_and_Order(Vehicle *v)
if (v->current_order.type == OT_GOTO_STATION ||
v->current_order.type == OT_GOTO_DEPOT)
v->u.air.targetairport = v->current_order.dest.station;
v->u.air.targetairport = v->current_order.dest;
st = GetStation(v->u.air.targetairport);
Airport = GetAirport(st->airport_type);
@ -1504,7 +1504,7 @@ static void AircraftEventHandler_InHangar(Vehicle *v, const AirportFTAClass *Air
if (AirportHasBlock(v, &Airport->layout[v->u.air.pos], Airport)) return;
// We are already at the target airport, we need to find a terminal
if (v->current_order.dest.station == v->u.air.targetairport) {
if (v->current_order.dest == 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 != 0) {
@ -1556,7 +1556,7 @@ static void AircraftEventHandler_AtTerminal(Vehicle *v, const AirportFTAClass *A
v->u.air.state = (v->subtype != 0) ? TAKEOFF : HELITAKEOFF;
break;
case OT_GOTO_DEPOT: // visit hangar for serivicing, sale, etc.
if (v->current_order.dest.station == v->u.air.targetairport) {
if (v->current_order.dest == v->u.air.targetairport) {
v->u.air.state = HANGAR;
} else {
v->u.air.state = (v->subtype != 0) ? TAKEOFF : HELITAKEOFF;

View File

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

View File

@ -79,14 +79,11 @@ Depot *AllocateDepot(void)
*/
void DestroyDepot(Depot *depot)
{
DestinationID dest;
/* Clear the tile */
DoClearSquare(depot->xy);
/* Clear the depot from all order-lists */
dest.depot = depot->index;
RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, dest);
RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, depot->index);
/* Delete the depot-window */
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->current_order.type = OT_NOTHING;
v->current_order.flags = 0;
v->current_order.dest.station = 0;
v->current_order.dest = 0;
DisasterVehicleUpdateImage(v);
VehiclePositionChanged(v);
@ -165,7 +165,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
++v->tick_counter;
if (v->current_order.dest.disaster < 2) {
if (v->current_order.dest < 2) {
if (v->tick_counter&1)
return;
@ -173,23 +173,23 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
if (v->current_order.dest.disaster == 1) {
if (v->current_order.dest == 1) {
if (++v->age == 38) {
v->current_order.dest.disaster = 2;
v->current_order.dest = 2;
v->age = 0;
}
if ((v->tick_counter&7)==0) {
CreateEffectVehicleRel(v, 0, -17, 2, EV_SMOKE);
}
} else if (v->current_order.dest.disaster == 0) {
} else if (v->current_order.dest == 0) {
tile = v->tile; /**/
if (IsValidTile(tile) &&
IsTileType(tile, MP_STATION) &&
IsAirport(tile) &&
IS_HUMAN_PLAYER(GetTileOwner(tile))) {
v->current_order.dest.disaster = 1;
v->current_order.dest = 1;
v->age = 0;
SetDParam(0, GetStationIndex(tile));
@ -204,7 +204,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
return;
}
if (v->current_order.dest.disaster > 2) {
if (v->current_order.dest > 2) {
if (++v->age <= 13320)
return;
@ -247,7 +247,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
EV_EXPLOSION_SMALL);
}
} else if (v->age == 350) {
v->current_order.dest.disaster = 3;
v->current_order.dest = 3;
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;
if (v->current_order.dest.disaster == 0) {
if (v->current_order.dest == 0) {
// fly around randomly
int x = TileX(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();
return;
}
v->current_order.dest.disaster = 1;
v->current_order.dest = 1;
FOR_ALL_VEHICLES(u) {
if (u->type == VEH_Road && IS_HUMAN_PLAYER(u->owner)) {
@ -360,7 +360,7 @@ static void DisasterTick_2(Vehicle *v)
v->tick_counter++;
v->u.disaster.image_override =
(v->current_order.dest.disaster == 1 && v->tick_counter & 4) ? SPR_F_15_FIRING : 0;
(v->current_order.dest == 1 && v->tick_counter & 4) ? SPR_F_15_FIRING : 0;
GetNewVehiclePos(v, &gp);
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
@ -370,7 +370,7 @@ static void DisasterTick_2(Vehicle *v)
return;
}
if (v->current_order.dest.disaster == 2) {
if (v->current_order.dest == 2) {
if (!(v->tick_counter&3)) {
Industry *i = GetIndustry(v->dest_tile);
int x = TileX(i->xy) * TILE_SIZE;
@ -384,13 +384,13 @@ static void DisasterTick_2(Vehicle *v)
EV_EXPLOSION_SMALL);
if (++v->age >= 55)
v->current_order.dest.disaster = 3;
v->current_order.dest = 3;
}
} else if (v->current_order.dest.disaster == 1) {
} else if (v->current_order.dest == 1) {
if (++v->age == 112) {
Industry *i;
v->current_order.dest.disaster = 2;
v->current_order.dest = 2;
v->age = 0;
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);
SndPlayTileFx(SND_12_EXPLOSION, i->xy);
}
} else if (v->current_order.dest.disaster == 0) {
} else if (v->current_order.dest == 0) {
int x,y;
TileIndex tile;
uint ind;
@ -419,7 +419,7 @@ static void DisasterTick_2(Vehicle *v)
v->dest_tile = ind;
if (GetIndustry(ind)->type == IT_OIL_REFINERY) {
v->current_order.dest.disaster = 1;
v->current_order.dest = 1;
v->age = 0;
}
}
@ -432,7 +432,7 @@ static void DisasterTick_3(Vehicle *v)
v->tick_counter++;
v->u.disaster.image_override =
(v->current_order.dest.disaster == 1 && v->tick_counter & 4) ? SPR_AH_64A_FIRING : 0;
(v->current_order.dest == 1 && v->tick_counter & 4) ? SPR_AH_64A_FIRING : 0;
GetNewVehiclePos(v, &gp);
SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos);
@ -442,7 +442,7 @@ static void DisasterTick_3(Vehicle *v)
return;
}
if (v->current_order.dest.disaster == 2) {
if (v->current_order.dest == 2) {
if (!(v->tick_counter&3)) {
Industry *i = GetIndustry(v->dest_tile);
int x = TileX(i->xy) * TILE_SIZE;
@ -456,13 +456,13 @@ static void DisasterTick_3(Vehicle *v)
EV_EXPLOSION_SMALL);
if (++v->age >= 55)
v->current_order.dest.disaster = 3;
v->current_order.dest = 3;
}
} else if (v->current_order.dest.disaster == 1) {
} else if (v->current_order.dest == 1) {
if (++v->age == 112) {
Industry *i;
v->current_order.dest.disaster = 2;
v->current_order.dest = 2;
v->age = 0;
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);
SndPlayTileFx(SND_12_EXPLOSION, i->xy);
}
} else if (v->current_order.dest.disaster == 0) {
} else if (v->current_order.dest == 0) {
int x,y;
TileIndex tile;
uint ind;
@ -491,7 +491,7 @@ static void DisasterTick_3(Vehicle *v)
v->dest_tile = ind;
if (GetIndustry(ind)->type == IT_FACTORY) {
v->current_order.dest.disaster = 1;
v->current_order.dest = 1;
v->age = 0;
}
}
@ -523,7 +523,7 @@ static void DisasterTick_4(Vehicle *v)
v->tick_counter++;
if (v->current_order.dest.disaster == 1) {
if (v->current_order.dest == 1) {
int x = TileX(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) {
@ -540,7 +540,7 @@ static void DisasterTick_4(Vehicle *v)
return;
}
v->current_order.dest.disaster = 2;
v->current_order.dest = 2;
FOR_ALL_VEHICLES(u) {
if (u->type == VEH_Train || u->type == VEH_Road) {
@ -574,7 +574,7 @@ static void DisasterTick_4(Vehicle *v)
u->next = w;
InitializeDisasterVehicle(w, -6 * TILE_SIZE, v->y_pos, 0, DIR_SW, 12);
w->vehstatus |= VS_SHADOW;
} else if (v->current_order.dest.disaster < 1) {
} else if (v->current_order.dest < 1) {
int x = TileX(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();
return;
}
v->current_order.dest.disaster = 1;
v->current_order.dest = 1;
tile_org = tile = RandomTile();
do {
@ -624,11 +624,11 @@ static void DisasterTick_4b(Vehicle *v)
return;
}
if (v->current_order.dest.disaster == 0) {
if (v->current_order.dest == 0) {
u = GetVehicle(v->u.disaster.unk2);
if (abs(v->x_pos - u->x_pos) > TILE_SIZE)
return;
v->current_order.dest.disaster = 1;
v->current_order.dest = 1;
CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE);
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
* others only dest_coords */
if (v->current_order.type == OT_GOTO_STATION && v->type == VEH_Train) {
fstd->station_index = v->current_order.dest.station;
fstd->station_index = v->current_order.dest;
/* Let's take the closest tile of the station as our target for trains */
fstd->dest_coords = CalcClosestStationTile(v->current_order.dest.station, v->tile);
fstd->dest_coords = CalcClosestStationTile(v->current_order.dest, v->tile);
} else {
fstd->dest_coords = v->dest_tile;
fstd->station_index = INVALID_STATION;

View File

@ -57,20 +57,14 @@ typedef uint16 WaypointID;
typedef uint16 OrderID;
typedef uint16 SignID;
typedef uint16 EngineRenewID;
typedef uint16 DestinationID;
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 DestinationID has to be of the same size, because some part
* of the code depends on the fact that DestinationID is the same for all
* items inside DestinationID. Check PackOrder() */
assert_compile(sizeof(StationID) == sizeof(DepotID));
assert_compile(sizeof(StationID) == sizeof(WaypointID));
assert_compile(sizeof(StationID) == sizeof(uint16));
/* DestinationID must be at least as large as every these below, because it can
* be any of them
*/
assert_compile(sizeof(DestinationID) == sizeof(DepotID));
assert_compile(sizeof(DestinationID) == sizeof(WaypointID));
assert_compile(sizeof(DestinationID) == sizeof(StationID));
typedef uint32 WindowNumber;
typedef byte WindowClass;

View File

@ -177,7 +177,7 @@ static inline bool IsOrderPoolFull(void)
static inline uint32 PackOrder(const Order *order)
{
return order->dest.station << 16 | order->flags << 8 | order->type;
return order->dest << 16 | order->flags << 8 | order->type;
}
static inline Order UnpackOrder(uint32 packed)
@ -185,7 +185,7 @@ static inline Order UnpackOrder(uint32 packed)
Order order;
order.type = (OrderType)GB(packed, 0, 8);
order.flags = GB(packed, 8, 8);
order.dest.station = GB(packed, 16, 16);
order.dest = GB(packed, 16, 16);
order.next = NULL;
order.index = 0; // avoid compiler warning
return order;

View File

@ -47,12 +47,12 @@ Order UnpackOldOrder(uint16 packed)
Order order;
order.type = GB(packed, 0, 4);
order.flags = GB(packed, 4, 4);
order.dest.station = GB(packed, 8, 8);
order.dest = GB(packed, 8, 8);
order.next = NULL;
// Sanity check
// TTD stores invalid orders as OT_NOTHING with non-zero flags/station
if (order.type == OT_NOTHING && (order.flags != 0 || order.dest.station != 0)) {
if (order.type == OT_NOTHING && (order.flags != 0 || order.dest != 0)) {
order.type = OT_DUMMY;
order.flags = 0;
}
@ -68,11 +68,11 @@ Order UnpackOldOrder(uint16 packed)
static Order UnpackVersion4Order(uint16 packed)
{
Order order;
order.type = GB(packed, 0, 4);
order.flags = GB(packed, 4, 4);
order.dest.station = GB(packed, 8, 8);
order.next = NULL;
order.index = 0; // avoid compiler warning
order.type = GB(packed, 0, 4);
order.flags = GB(packed, 4, 4);
order.dest = GB(packed, 8, 8);
order.next = NULL;
order.index = 0; // avoid compiler warning
return order;
}
@ -142,9 +142,9 @@ static Order *AllocateOrder(void)
*/
void AssignOrder(Order *order, Order data)
{
order->type = data.type;
order->flags = data.flags;
order->dest.station = data.dest.station;
order->type = data.type;
order->flags = data.flags;
order->dest = data.dest;
}
@ -191,8 +191,8 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
case OT_GOTO_STATION: {
const Station *st;
if (!IsValidStationID(new_order.dest.station)) return CMD_ERROR;
st = GetStation(new_order.dest.station);
if (!IsValidStationID(new_order.dest)) return CMD_ERROR;
st = GetStation(new_order.dest);
if (st->airport_type != AT_OILRIG && !IsBuoy(st) && !CheckOwnership(st->owner)) {
return CMD_ERROR;
@ -252,8 +252,8 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (v->type == VEH_Aircraft) {
const Station* st;
if (!IsValidStationID(new_order.dest.station)) return CMD_ERROR;
st = GetStation(new_order.dest.station);
if (!IsValidStationID(new_order.dest)) return CMD_ERROR;
st = GetStation(new_order.dest);
if ((st->airport_type != AT_OILRIG && !CheckOwnership(st->owner)) ||
!(st->facilities & FACIL_AIRPORT) ||
@ -263,8 +263,8 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
} else {
const Depot* dp;
if (!IsValidDepotID(new_order.dest.depot)) return CMD_ERROR;
dp = GetDepot(new_order.dest.depot);
if (!IsValidDepotID(new_order.dest)) return CMD_ERROR;
dp = GetDepot(new_order.dest);
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 (!IsValidWaypointID(new_order.dest.waypoint)) return CMD_ERROR;
wp = GetWaypoint(new_order.dest.waypoint);
if (!IsValidWaypointID(new_order.dest)) return CMD_ERROR;
wp = GetWaypoint(new_order.dest);
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) {
int dist = DistanceManhattan(
GetStation(GetVehicleOrder(v, sel_ord - 1)->dest.station)->xy,
GetStation(new_order.dest.station)->xy // XXX type != OT_GOTO_STATION?
GetStation(GetVehicleOrder(v, sel_ord - 1)->dest)->xy,
GetStation(new_order.dest)->xy // XXX type != OT_GOTO_STATION?
);
if (dist >= 130)
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) {
if (order->type == OT_GOTO_STATION) {
const Station *st = GetStation(order->dest.station);
const Station *st = GetStation(order->dest);
if (dst->cargo_type == CT_PASSENGERS) {
if (st->bus_stops != NULL) required_dst = st->bus_stops->xy;
} else {
@ -919,7 +919,7 @@ void CheckOrders(const Vehicle* v)
}
/* Does station have a load-bay for this vehicle? */
if (order->type == OT_GOTO_STATION) {
const Station* st = GetStation(order->dest.station);
const Station* st = GetStation(order->dest);
TileIndex required_tile = GetStationTileForVehicle(v, st);
n_st++;
@ -931,9 +931,9 @@ void CheckOrders(const Vehicle* v)
if (v->num_orders > 1) {
const Order* last = GetLastVehicleOrder(v);
if (v->orders->type == last->type &&
v->orders->flags == last->flags &&
v->orders->dest.station == last->dest.station) {
if (v->orders->type == last->type &&
v->orders->flags == last->flags &&
v->orders->dest == last->dest) {
problem_type = 2;
}
}
@ -973,11 +973,11 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
if (v->orders == NULL) continue;
/* Forget about this station if this station is removed */
if (v->last_station_visited == destination.station && type == OT_GOTO_STATION)
if (v->last_station_visited == destination && type == OT_GOTO_STATION)
v->last_station_visited = INVALID_STATION;
/* Check the current order */
if (v->current_order.type == type && v->current_order.dest.station == destination.station) {
if (v->current_order.type == type && v->current_order.dest == destination) {
/* Mark the order as DUMMY */
v->current_order.type = OT_DUMMY;
v->current_order.flags = 0;
@ -987,7 +987,7 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
/* Clear the order from the order-list */
need_invalidate = false;
FOR_VEHICLE_ORDERS(v, order) {
if (order->type == type && order->dest.station == destination.station) {
if (order->type == type && order->dest == destination) {
/* Mark the order as DUMMY */
order->type = OT_DUMMY;
order->flags = 0;
@ -1110,10 +1110,10 @@ void InitializeOrders(void)
}
static const SaveLoad _order_desc[] = {
SLE_VAR(Order, type, SLE_UINT8),
SLE_VAR(Order, flags, SLE_UINT8),
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_VAR(Order, type, SLE_UINT8),
SLE_VAR(Order, flags, SLE_UINT8),
SLE_VAR(Order, dest, SLE_UINT16),
SLE_REF(Order, next, REF_ORDER),
// reserve extra space in savegame here. (currently 10 bytes)
SLE_CONDNULL(10, 5, SL_MAX_VERSION),

View File

@ -145,7 +145,7 @@ static void DrawOrdersWindow(Window *w)
switch (order->type) {
case OT_GOTO_STATION:
SetDParam(1, StationOrderStrings[order->flags]);
SetDParam(2, order->dest.station);
SetDParam(2, order->dest);
break;
case OT_GOTO_DEPOT: {
@ -153,9 +153,9 @@ static void DrawOrdersWindow(Window *w)
if (v->type == VEH_Aircraft) {
s = STR_GO_TO_AIRPORT_HANGAR;
SetDParam(2, order->dest.depot);
SetDParam(2, order->dest);
} else {
SetDParam(2, GetDepot(order->dest.depot)->town_index);
SetDParam(2, GetDepot(order->dest)->town_index);
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;
@ -173,7 +173,7 @@ static void DrawOrdersWindow(Window *w)
case OT_GOTO_WAYPOINT:
SetDParam(1, (order->flags & OF_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
SetDParam(2, order->dest.waypoint);
SetDParam(2, order->dest);
break;
default: break;
@ -185,7 +185,7 @@ static void DrawOrdersWindow(Window *w)
DrawString(2, y, str, color);
} else {
SetDParam(1, STR_INVALID_ORDER);
SetDParam(2, order->dest.station);
SetDParam(2, order->dest);
DrawString(2, y, str, color);
}
y += 10;
@ -216,7 +216,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
if (IsRailDepot(tile)) {
order.type = OT_GOTO_DEPOT;
order.flags = OF_PART_OF_ORDERS;
order.dest.depot = GetDepotByTile(tile)->index;
order.dest = GetDepotByTile(tile)->index;
return order;
}
}
@ -226,7 +226,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
if (GetRoadTileType(tile) == ROAD_TILE_DEPOT && v->type == VEH_Road && IsTileOwner(tile, _local_player)) {
order.type = OT_GOTO_DEPOT;
order.flags = OF_PART_OF_ORDERS;
order.dest.depot = GetDepotByTile(tile)->index;
order.dest = GetDepotByTile(tile)->index;
return order;
}
break;
@ -236,7 +236,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
if (IsHangar(tile) && IsTileOwner(tile, _local_player)) {
order.type = OT_GOTO_DEPOT;
order.flags = OF_PART_OF_ORDERS;
order.dest.station = GetStationIndex(tile);
order.dest = GetStationIndex(tile);
return order;
}
break;
@ -249,7 +249,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
order.type = OT_GOTO_DEPOT;
order.flags = OF_PART_OF_ORDERS;
order.dest.depot = GetDepotByTile(tile < tile2 ? tile : tile2)->index;
order.dest = GetDepotByTile(tile < tile2 ? tile : tile2)->index;
return order;
}
@ -265,7 +265,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
IsRailWaypoint(tile)) {
order.type = OT_GOTO_WAYPOINT;
order.flags = 0;
order.dest.waypoint = GetWaypointByTile(tile)->index;
order.dest = GetWaypointByTile(tile)->index;
return order;
}
@ -283,7 +283,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
if (st->facilities & facil) {
order.type = OT_GOTO_STATION;
order.flags = 0;
order.dest.station = st_index;
order.dest = st_index;
return order;
}
}
@ -292,7 +292,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
// not found
order.type = OT_NOTHING;
order.flags = 0;
order.dest.station = INVALID_STATION;
order.dest = INVALID_STATION;
return order;
}
@ -421,9 +421,9 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
TileIndex xy;
switch (ord->type) {
case OT_GOTO_STATION: xy = GetStation(ord->dest.station)->xy ; break;
case OT_GOTO_DEPOT: xy = GetDepot(ord->dest.depot)->xy; break;
case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->dest.waypoint)->xy; break;
case OT_GOTO_STATION: xy = GetStation(ord->dest)->xy ; break;
case OT_GOTO_DEPOT: xy = GetDepot(ord->dest)->xy; break;
case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->dest)->xy; break;
default: xy = 0; break;
}

View File

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

View File

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

View File

@ -125,7 +125,7 @@ static void CheckIfShipNeedsService(Vehicle *v)
v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP;
v->current_order.dest.depot = depot->index;
v->current_order.dest = depot->index;
v->dest_tile = depot->xy;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
}
@ -227,9 +227,9 @@ static void ProcessShipOrder(Vehicle *v)
return;
}
if (order->type == v->current_order.type &&
order->flags == v->current_order.flags &&
order->dest.station == v->current_order.dest.station)
if (order->type == v->current_order.type &&
order->flags == v->current_order.flags &&
order->dest == v->current_order.dest)
return;
v->current_order = *order;
@ -237,15 +237,15 @@ static void ProcessShipOrder(Vehicle *v)
if (order->type == OT_GOTO_STATION) {
const Station *st;
if (order->dest.station == v->last_station_visited)
if (order->dest == v->last_station_visited)
v->last_station_visited = INVALID_STATION;
st = GetStation(order->dest.station);
st = GetStation(order->dest);
if (st->dock_tile != 0) {
v->dest_tile = TILE_ADD(st->dock_tile, ToTileIndexDiff(GetDockOffset(st->dock_tile)));
}
} else if (order->type == OT_GOTO_DEPOT) {
v->dest_tile = GetDepot(order->dest.depot)->xy;
v->dest_tile = GetDepot(order->dest)->xy;
} else {
v->dest_tile = 0;
}
@ -722,10 +722,10 @@ static void ShipController(Vehicle *v)
} else if (v->current_order.type == OT_GOTO_STATION) {
Station *st;
v->last_station_visited = v->current_order.dest.station;
v->last_station_visited = v->current_order.dest;
/* Process station in the orderlist. */
st = GetStation(v->current_order.dest.station);
st = GetStation(v->current_order.dest);
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.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER;
@ -1055,7 +1055,7 @@ int32 CmdSendShipToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP;
if (!(p2 & DEPOT_SERVICE)) SETBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
v->current_order.dest.depot = dep->index;
v->current_order.dest = dep->index;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
}

View File

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

View File

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

View File

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

View File

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

View File

@ -1922,7 +1922,7 @@ uint GenerateVehicleSortList(const Vehicle** sort_list, byte type, PlayerID owne
const Order *order;
FOR_VEHICLE_ORDERS(v, order) {
if (order->type == OT_GOTO_STATION && order->dest.station == station) {
if (order->type == OT_GOTO_STATION && order->dest == station) {
sort_list[n++] = v;
break;
}
@ -2294,13 +2294,13 @@ const SaveLoad _common_veh_desc[] = {
/* This next line is for version 4 and prior compatibility.. it temporarily reads
type and flags (which were both 4 bits) into type. Later on this is
converted correctly */
SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, type), SLE_UINT8, 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, type), SLE_UINT8, 0, 4),
SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
/* 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, flags), SLE_UINT8, 5, SL_MAX_VERSION),
SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest.station), SLE_UINT16, 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, dest), SLE_UINT16, 5, SL_MAX_VERSION),
SLE_REF(Vehicle, orders, REF_ORDER),
@ -2465,8 +2465,8 @@ static const SaveLoad _disaster_desc[] = {
SLE_VAR(Vehicle, z_height, SLE_UINT8),
SLE_VAR(Vehicle, owner, SLE_UINT8),
SLE_VAR(Vehicle, vehstatus, SLE_UINT8),
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, dest.station), SLE_UINT16, 5, SL_MAX_VERSION),
SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest), SLE_UINT16, 5, SL_MAX_VERSION),
SLE_VAR(Vehicle, cur_image, SLE_UINT16),
SLE_CONDVAR(Vehicle, age, SLE_FILE_U16 | SLE_VAR_I32, 0, 30),

View File

@ -98,10 +98,7 @@ void UpdateAllWaypointSigns(void)
/* Internal handler to delete a waypoint */
void DestroyWaypoint(Waypoint *wp)
{
DestinationID dest;
dest.waypoint = wp->index;
RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, dest);
RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, wp->index);
if (wp->string != STR_NULL) DeleteName(wp->string);

View File

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