diff options
author | rubidium <rubidium@openttd.org> | 2008-04-06 07:48:51 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-04-06 07:48:51 +0000 |
commit | 935b5620744b96c6b44e20e0ea89dc7bdca127c3 (patch) | |
tree | bf63686bb4da660cbcdc1074a869b5b86df60166 | |
parent | a3224512ccbc50a2bfaf6b3375db78dc5a807dca (diff) | |
download | openttd-935b5620744b96c6b44e20e0ea89dc7bdca127c3.tar.xz |
(svn r12588) -Codechange: do not access the destination of an order directly.
-rw-r--r-- | src/ai/default/default.cpp | 6 | ||||
-rw-r--r-- | src/ai/trolly/trolly.cpp | 2 | ||||
-rw-r--r-- | src/aircraft_cmd.cpp | 10 | ||||
-rw-r--r-- | src/disaster_cmd.cpp | 58 | ||||
-rw-r--r-- | src/industry_cmd.cpp | 2 | ||||
-rw-r--r-- | src/npf.cpp | 4 | ||||
-rw-r--r-- | src/openttd.cpp | 2 | ||||
-rw-r--r-- | src/order_base.h | 16 | ||||
-rw-r--r-- | src/order_cmd.cpp | 48 | ||||
-rw-r--r-- | src/order_gui.cpp | 19 | ||||
-rw-r--r-- | src/roadveh_cmd.cpp | 8 | ||||
-rw-r--r-- | src/ship_cmd.cpp | 4 | ||||
-rw-r--r-- | src/station_cmd.cpp | 4 | ||||
-rw-r--r-- | src/timetable_gui.cpp | 8 | ||||
-rw-r--r-- | src/train_cmd.cpp | 7 | ||||
-rw-r--r-- | src/vehicle.cpp | 6 | ||||
-rw-r--r-- | src/vehicle_gui.cpp | 12 | ||||
-rw-r--r-- | src/yapf/yapf_destrail.hpp | 8 |
18 files changed, 116 insertions, 108 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp index 9436fd6ae..2408674af 100644 --- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -263,8 +263,8 @@ static EngineID AiChooseAircraftToReplaceWith(const Player* p, const Vehicle* v) FOR_VEHICLE_ORDERS(v, o) { if (!o->IsValid()) continue; - if (!IsValidStationID(o->dest)) continue; - const Station *st = GetStation(o->dest); + if (!IsValidStationID(o->GetDestination())) continue; + const Station *st = GetStation(o->GetDestination()); if (!(st->facilities & FACIL_AIRPORT)) continue; AirportFTAClass::Flags flags = st->Airport()->flags; @@ -3662,7 +3662,7 @@ static void AiStateRemoveStation(Player *p) byte *in_use = MallocT<byte>(GetMaxStationIndex() + 1); memset(in_use, 0, GetMaxStationIndex() + 1); FOR_ALL_ORDERS(ord) { - if (ord->IsType(OT_GOTO_STATION)) in_use[ord->dest] = 1; + if (ord->IsType(OT_GOTO_STATION)) in_use[ord->GetDestination()] = 1; } // Go through all stations and delete those that aren't in use diff --git a/src/ai/trolly/trolly.cpp b/src/ai/trolly/trolly.cpp index 2876d240e..46aa0f10d 100644 --- a/src/ai/trolly/trolly.cpp +++ b/src/ai/trolly/trolly.cpp @@ -553,7 +553,7 @@ static bool AiNew_CheckVehicleStation(Player *p, Station *st) const Order *order; FOR_VEHICLE_ORDERS(v, order) { - if (order->IsType(OT_GOTO_STATION) && GetStation(order->dest) == st) { + if (order->IsType(OT_GOTO_STATION) && GetStation(order->GetDestination()) == st) { // This vehicle has this city in its list count++; } diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index d21382763..ed5106c1f 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -705,7 +705,7 @@ static void CheckIfAircraftNeedsService(Vehicle *v) return; } - const Station *st = GetStation(v->current_order.dest); + const Station *st = GetStation(v->current_order.GetDestination()); /* only goto depot if the target airport has terminals (eg. it is airport) */ if (st->IsValid() && st->airport_tile != 0 && st->Airport()->terminals != NULL) { // printf("targetairport = %d, st->index = %d\n", v->u.air.targetairport, st->index); @@ -1054,7 +1054,7 @@ static bool AircraftController(Vehicle *v) /* Jump into our "holding pattern" state machine if possible */ if (v->u.air.pos >= afc->nofelements) { v->u.air.pos = v->u.air.previous_pos = AircraftGetEntryPoint(v, afc); - } else if (v->u.air.targetairport != v->current_order.dest) { + } else if (v->u.air.targetairport != v->current_order.GetDestination()) { /* If not possible, just get out of here fast */ v->u.air.state = FLYING; UpdateAircraftCache(v); @@ -1501,7 +1501,7 @@ static void AircraftNextAirportPos_and_Order(Vehicle *v) { if (v->current_order.IsType(OT_GOTO_STATION) || v->current_order.IsType(OT_GOTO_DEPOT)) - v->u.air.targetairport = v->current_order.dest; + v->u.air.targetairport = v->current_order.GetDestination(); const AirportFTAClass *apc = GetStation(v->u.air.targetairport)->Airport(); v->u.air.pos = v->u.air.previous_pos = AircraftGetEntryPoint(v, apc); @@ -1610,7 +1610,7 @@ static void AircraftEventHandler_InHangar(Vehicle *v, const AirportFTAClass *apc if (AirportHasBlock(v, &apc->layout[v->u.air.pos], apc)) return; /* We are already at the target airport, we need to find a terminal */ - if (v->current_order.dest == v->u.air.targetairport) { + if (v->current_order.GetDestination() == v->u.air.targetairport) { /* FindFreeTerminal: * 1. Find a free terminal, 2. Occupy it, 3. Set the vehicle's state to that terminal */ if (v->subtype == AIR_HELICOPTER) { @@ -1660,7 +1660,7 @@ static void AircraftEventHandler_AtTerminal(Vehicle *v, const AirportFTAClass *a v->u.air.state = (v->subtype == AIR_HELICOPTER) ? HELITAKEOFF : TAKEOFF; break; case OT_GOTO_DEPOT: // visit hangar for serivicing, sale, etc. - if (v->current_order.dest == v->u.air.targetairport) { + if (v->current_order.GetDestination() == v->u.air.targetairport) { v->u.air.state = HANGAR; } else { v->u.air.state = (v->subtype == AIR_HELICOPTER) ? HELITAKEOFF : TAKEOFF; diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp index 097aaf567..efffb1494 100644 --- a/src/disaster_cmd.cpp +++ b/src/disaster_cmd.cpp @@ -206,29 +206,29 @@ static void DisasterTick_Zeppeliner(Vehicle *v) v->tick_counter++; - if (v->current_order.dest < 2) { + if (v->current_order.GetDestination() < 2) { if (HasBit(v->tick_counter, 0)) return; GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); - if (v->current_order.dest == 1) { + if (v->current_order.GetDestination() == 1) { if (++v->age == 38) { - v->current_order.dest = 2; + v->current_order.SetDestination(2); v->age = 0; } if (GB(v->tick_counter, 0, 3) == 0) CreateEffectVehicleRel(v, 0, -17, 2, EV_SMOKE); - } else if (v->current_order.dest == 0) { + } else if (v->current_order.GetDestination() == 0) { tile = v->tile; if (IsValidTile(tile) && IsTileType(tile, MP_STATION) && IsAirport(tile) && IsHumanPlayer(GetTileOwner(tile))) { - v->current_order.dest = 1; + v->current_order.SetDestination(1); v->age = 0; SetDParam(0, GetStationIndex(tile)); @@ -243,7 +243,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v) return; } - if (v->current_order.dest > 2) { + if (v->current_order.GetDestination() > 2) { if (++v->age <= 13320) return; tile = v->tile; @@ -284,7 +284,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v) EV_EXPLOSION_SMALL); } } else if (v->age == 350) { - v->current_order.dest = 3; + v->current_order.SetDestination(3); v->age = 0; } @@ -312,7 +312,7 @@ static void DisasterTick_Ufo(Vehicle *v) v->u.disaster.image_override = (HasBit(++v->tick_counter, 3)) ? SPR_UFO_SMALL_SCOUT_DARKER : SPR_UFO_SMALL_SCOUT; - if (v->current_order.dest == 0) { + if (v->current_order.GetDestination() == 0) { /* Fly around randomly */ int x = TileX(v->dest_tile) * TILE_SIZE; int y = TileY(v->dest_tile) * TILE_SIZE; @@ -326,7 +326,7 @@ static void DisasterTick_Ufo(Vehicle *v) v->dest_tile = RandomTile(); return; } - v->current_order.dest = 1; + v->current_order.SetDestination(1); FOR_ALL_VEHICLES(u) { if (u->type == VEH_ROAD && IsHumanPlayer(u->owner)) { @@ -405,7 +405,7 @@ static void DisasterTick_Airplane(Vehicle *v) { v->tick_counter++; v->u.disaster.image_override = - (v->current_order.dest == 1 && HasBit(v->tick_counter, 2)) ? SPR_F_15_FIRING : 0; + (v->current_order.GetDestination() == 1 && HasBit(v->tick_counter, 2)) ? SPR_F_15_FIRING : 0; GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); @@ -415,7 +415,7 @@ static void DisasterTick_Airplane(Vehicle *v) return; } - if (v->current_order.dest == 2) { + if (v->current_order.GetDestination() == 2) { if (GB(v->tick_counter, 0, 2) == 0) { Industry *i = GetIndustry(v->dest_tile); int x = TileX(i->xy) * TILE_SIZE; @@ -428,13 +428,13 @@ static void DisasterTick_Airplane(Vehicle *v) GB(r, 12, 4), EV_EXPLOSION_SMALL); - if (++v->age >= 55) v->current_order.dest = 3; + if (++v->age >= 55) v->current_order.SetDestination(3); } - } else if (v->current_order.dest == 1) { + } else if (v->current_order.GetDestination() == 1) { if (++v->age == 112) { Industry *i; - v->current_order.dest = 2; + v->current_order.SetDestination(2); v->age = 0; i = GetIndustry(v->dest_tile); @@ -444,7 +444,7 @@ static void DisasterTick_Airplane(Vehicle *v) AddNewsItem(STR_B002_OIL_REFINERY_EXPLOSION, NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, DNC_NONE, i->xy, 0); SndPlayTileFx(SND_12_EXPLOSION, i->xy); } - } else if (v->current_order.dest == 0) { + } else if (v->current_order.GetDestination() == 0) { int x, y; TileIndex tile; uint ind; @@ -461,7 +461,7 @@ static void DisasterTick_Airplane(Vehicle *v) v->dest_tile = ind; if (GetIndustrySpec(GetIndustry(ind)->type)->behaviour & INDUSTRYBEH_AIRPLANE_ATTACKS) { - v->current_order.dest = 1; + v->current_order.SetDestination(1); v->age = 0; } } @@ -478,7 +478,7 @@ static void DisasterTick_Helicopter(Vehicle *v) { v->tick_counter++; v->u.disaster.image_override = - (v->current_order.dest == 1 && HasBit(v->tick_counter, 2)) ? SPR_AH_64A_FIRING : 0; + (v->current_order.GetDestination() == 1 && HasBit(v->tick_counter, 2)) ? SPR_AH_64A_FIRING : 0; GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); @@ -488,7 +488,7 @@ static void DisasterTick_Helicopter(Vehicle *v) return; } - if (v->current_order.dest == 2) { + if (v->current_order.GetDestination() == 2) { if (GB(v->tick_counter, 0, 2) == 0) { Industry *i = GetIndustry(v->dest_tile); int x = TileX(i->xy) * TILE_SIZE; @@ -501,13 +501,13 @@ static void DisasterTick_Helicopter(Vehicle *v) GB(r, 12, 4), EV_EXPLOSION_SMALL); - if (++v->age >= 55) v->current_order.dest = 3; + if (++v->age >= 55) v->current_order.SetDestination(3); } - } else if (v->current_order.dest == 1) { + } else if (v->current_order.GetDestination() == 1) { if (++v->age == 112) { Industry *i; - v->current_order.dest = 2; + v->current_order.SetDestination(2); v->age = 0; i = GetIndustry(v->dest_tile); @@ -517,7 +517,7 @@ static void DisasterTick_Helicopter(Vehicle *v) AddNewsItem(STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS, NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, DNC_NONE, i->xy, 0); SndPlayTileFx(SND_12_EXPLOSION, i->xy); } - } else if (v->current_order.dest == 0) { + } else if (v->current_order.GetDestination() == 0) { int x, y; TileIndex tile; uint ind; @@ -534,7 +534,7 @@ static void DisasterTick_Helicopter(Vehicle *v) v->dest_tile = ind; if (GetIndustrySpec(GetIndustry(ind)->type)->behaviour & INDUSTRYBEH_CHOPPER_ATTACKS) { - v->current_order.dest = 1; + v->current_order.SetDestination(1); v->age = 0; } } @@ -568,7 +568,7 @@ static void DisasterTick_Big_Ufo(Vehicle *v) v->tick_counter++; - if (v->current_order.dest == 1) { + if (v->current_order.GetDestination() == 1) { int x = TileX(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2; int y = TileY(v->dest_tile) * TILE_SIZE + TILE_SIZE / 2; if (Delta(v->x_pos, x) + Delta(v->y_pos, y) >= 8) { @@ -585,7 +585,7 @@ static void DisasterTick_Big_Ufo(Vehicle *v) return; } - v->current_order.dest = 2; + v->current_order.SetDestination(2); FOR_ALL_VEHICLES(u) { if (u->type == VEH_TRAIN || u->type == VEH_ROAD) { @@ -618,7 +618,7 @@ static void DisasterTick_Big_Ufo(Vehicle *v) u->SetNext(w); InitializeDisasterVehicle(w, -6 * TILE_SIZE, v->y_pos, 0, DIR_SW, ST_Big_Ufo_Destroyer_Shadow); w->vehstatus |= VS_SHADOW; - } else if (v->current_order.dest == 0) { + } else if (v->current_order.GetDestination() == 0) { int x = TileX(v->dest_tile) * TILE_SIZE; int y = TileY(v->dest_tile) * TILE_SIZE; if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= TILE_SIZE) { @@ -632,7 +632,7 @@ static void DisasterTick_Big_Ufo(Vehicle *v) v->dest_tile = RandomTile(); return; } - v->current_order.dest = 1; + v->current_order.SetDestination(1); tile_org = tile = RandomTile(); do { @@ -669,10 +669,10 @@ static void DisasterTick_Big_Ufo_Destroyer(Vehicle *v) return; } - if (v->current_order.dest == 0) { + if (v->current_order.GetDestination() == 0) { u = GetVehicle(v->u.disaster.big_ufo_destroyer_target); if (Delta(v->x_pos, u->x_pos) > TILE_SIZE) return; - v->current_order.dest = 1; + v->current_order.SetDestination(1); CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE); SndPlayVehicleFx(SND_12_EXPLOSION, u); diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 65ca9cf28..abba55152 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -1969,7 +1969,7 @@ int WhoCanServiceIndustry(Industry* ind) FOR_VEHICLE_ORDERS(v, o) { if (o->IsType(OT_GOTO_STATION) && !HasBit(o->flags, OF_TRANSFER)) { /* Vehicle visits a station to load or unload */ - Station *st = GetStation(o->dest); + Station *st = GetStation(o->GetDestination()); if (!st->IsValid()) continue; /* Same cargo produced by industry is dropped here => not serviced by vehicle v */ diff --git a/src/npf.cpp b/src/npf.cpp index 2bb1a5ba9..2b5050307 100644 --- a/src/npf.cpp +++ b/src/npf.cpp @@ -981,9 +981,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.IsType(OT_GOTO_STATION) && v->type == VEH_TRAIN) { - fstd->station_index = v->current_order.dest; + fstd->station_index = v->current_order.GetDestination(); /* Let's take the closest tile of the station as our target for trains */ - fstd->dest_coords = CalcClosestStationTile(v->current_order.dest, v->tile); + fstd->dest_coords = CalcClosestStationTile(fstd->station_index, v->tile); } else { fstd->dest_coords = v->dest_tile; fstd->station_index = INVALID_STATION; diff --git a/src/openttd.cpp b/src/openttd.cpp index bbe017a35..923a67af5 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -2305,7 +2305,7 @@ bool AfterLoadGame() /* Update go to buoy orders because they are just waypoints */ Order *order; FOR_ALL_ORDERS(order) { - if (order->IsType(OT_GOTO_STATION) && GetStation(order->dest)->IsBuoy()) { + if (order->IsType(OT_GOTO_STATION) && GetStation(order->GetDestination())->IsBuoy()) { order->flags = 0; } } diff --git a/src/order_base.h b/src/order_base.h index 9fc7514ac..a7301687b 100644 --- a/src/order_base.h +++ b/src/order_base.h @@ -28,6 +28,7 @@ private: friend const struct SaveLoad *GetOrderDescription(); ///< Saving and loading of orders. OrderTypeByte type; ///< The type of order + DestinationID dest; ///< The destination of the order. CargoID refit_cargo; ///< Refit CargoID byte refit_subtype; ///< Refit subtype @@ -36,7 +37,6 @@ public: Order *next; ///< Pointer to next order. If NULL, end of list uint8 flags; - DestinationID dest; ///< The destionation of the order. uint16 wait_time; ///< How long in ticks to wait at the destination. uint16 travel_time; ///< How long in ticks the journey to this destination should take. @@ -118,6 +118,20 @@ public: void FreeChain(); /** + * Gets the destination of this order. + * @pre IsType(OT_GOTO_WAYPOINT) || IsType(OT_GOTO_DEPOT) || IsType(OT_GOTO_STATION). + * @return the destination of the order. + */ + inline DestinationID GetDestination() const { return this->dest; } + + /** + * Sets the destination of this order. + * @param destination the new destination of the order. + * @pre IsType(OT_GOTO_WAYPOINT) || IsType(OT_GOTO_DEPOT) || IsType(OT_GOTO_STATION). + */ + inline void SetDestination(DestinationID destination) { this->dest = destination; } + + /** * Is this order a refit order. * @pre IsType(OT_GOTO_DEPOT) * @return true if a refit should happen. diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 3dc27670a..38a56a2ab 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -160,7 +160,7 @@ Order UnpackOldOrder(uint16 packed) * Sanity check * TTD stores invalid orders as OT_NOTHING with non-zero flags/station */ - if (!order.IsValid() && (order.flags != 0 || order.dest != 0)) { + if (!order.IsValid() && (order.flags != 0 || order.GetDestination() != 0)) { order.MakeDummy(); } @@ -234,8 +234,8 @@ static TileIndex GetOrderLocation(const Order& o) { switch (o.GetType()) { default: NOT_REACHED(); - case OT_GOTO_STATION: return GetStation(o.dest)->xy; - case OT_GOTO_DEPOT: return GetDepot(o.dest)->xy; + case OT_GOTO_STATION: return GetStation(o.GetDestination())->xy; + case OT_GOTO_DEPOT: return GetDepot(o.GetDestination())->xy; } } @@ -267,10 +267,9 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) * and has the correct flags if any */ switch (new_order.GetType()) { case OT_GOTO_STATION: { - const Station *st; + if (!IsValidStationID(new_order.GetDestination())) return CMD_ERROR; - if (!IsValidStationID(new_order.dest)) return CMD_ERROR; - st = GetStation(new_order.dest); + const Station *st = GetStation(new_order.GetDestination()); if (st->owner != OWNER_NONE && !CheckOwnership(st->owner)) { return CMD_ERROR; @@ -330,10 +329,9 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) case OT_GOTO_DEPOT: { if (v->type == VEH_AIRCRAFT) { - const Station* st; + if (!IsValidStationID(new_order.GetDestination())) return CMD_ERROR; - if (!IsValidStationID(new_order.dest)) return CMD_ERROR; - st = GetStation(new_order.dest); + const Station *st = GetStation(new_order.GetDestination()); if (!CheckOwnership(st->owner) || !(st->facilities & FACIL_AIRPORT) || @@ -342,10 +340,9 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) return CMD_ERROR; } } else { - const Depot* dp; + if (!IsValidDepotID(new_order.GetDestination())) return CMD_ERROR; - if (!IsValidDepotID(new_order.dest)) return CMD_ERROR; - dp = GetDepot(new_order.dest); + const Depot *dp = GetDepot(new_order.GetDestination()); if (!CheckOwnership(GetTileOwner(dp->xy))) return CMD_ERROR; @@ -385,12 +382,11 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) } case OT_GOTO_WAYPOINT: { - const Waypoint* wp; if (v->type != VEH_TRAIN) return CMD_ERROR; - if (!IsValidWaypointID(new_order.dest)) return CMD_ERROR; - wp = GetWaypoint(new_order.dest); + if (!IsValidWaypointID(new_order.GetDestination())) return CMD_ERROR; + const Waypoint *wp = GetWaypoint(new_order.GetDestination()); if (!CheckOwnership(GetTileOwner(wp->xy))) return CMD_ERROR; @@ -769,7 +765,7 @@ CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (sel_ord >= v->num_orders) return CMD_ERROR; order = GetVehicleOrder(v, sel_ord); - if ((!order->IsType(OT_GOTO_STATION) || GetStation(order->dest)->IsBuoy()) && + if ((!order->IsType(OT_GOTO_STATION) || GetStation(order->GetDestination())->IsBuoy()) && (!order->IsType(OT_GOTO_DEPOT) || p2 == OF_UNLOAD) && (!order->IsType(OT_GOTO_WAYPOINT) || p2 != OF_NON_STOP)) { return CMD_ERROR; @@ -909,7 +905,7 @@ CommandCost CmdCloneOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) FOR_VEHICLE_ORDERS(src, order) { if (order->IsType(OT_GOTO_STATION)) { - const Station *st = GetStation(order->dest); + const Station *st = GetStation(order->GetDestination()); if (IsCargoInClass(dst->cargo_type, CC_PASSENGERS)) { if (st->bus_stops != NULL) required_dst = st->bus_stops->xy; } else { @@ -1190,7 +1186,7 @@ void CheckOrders(const Vehicle* v) } /* Does station have a load-bay for this vehicle? */ if (order->IsType(OT_GOTO_STATION)) { - const Station* st = GetStation(order->dest); + const Station* st = GetStation(order->GetDestination()); TileIndex required_tile = GetStationTileForVehicle(v, st); n_st++; @@ -1251,7 +1247,7 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination) order = &v->current_order; if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) ? OT_GOTO_STATION : order->GetType()) == type && - v->current_order.dest == destination) { + v->current_order.GetDestination() == destination) { order->MakeDummy(); InvalidateWindow(WC_VEHICLE_VIEW, v->index); } @@ -1260,7 +1256,7 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination) invalidate = false; FOR_VEHICLE_ORDERS(v, order) { if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) ? OT_GOTO_STATION : order->GetType()) == type && - order->dest == destination) { + order->GetDestination() == destination) { order->MakeDummy(); invalidate = true; } @@ -1414,8 +1410,8 @@ bool ProcessOrders(Vehicle *v) if (_patches.new_nonstop && v->current_order.flags & OFB_NON_STOP && IsTileType(v->tile, MP_STATION) && - v->current_order.dest == GetStationIndex(v->tile)) { - v->last_station_visited = v->current_order.dest; + v->current_order.GetDestination() == GetStationIndex(v->tile)) { + v->last_station_visited = v->current_order.GetDestination(); UpdateVehicleTimetable(v, true); v->cur_order_index++; } @@ -1442,7 +1438,7 @@ bool ProcessOrders(Vehicle *v) /* If it is unchanged, keep it. */ if (order->Equals(v->current_order) && - (v->type != VEH_SHIP || !order->IsType(OT_GOTO_STATION) || GetStation(order->dest)->dock_tile != 0)) { + (v->type != VEH_SHIP || !order->IsType(OT_GOTO_STATION) || GetStation(order->GetDestination())->dock_tile != 0)) { return false; } @@ -1466,15 +1462,15 @@ bool ProcessOrders(Vehicle *v) switch (order->GetType()) { case OT_GOTO_STATION: - v->dest_tile = v->GetOrderStationLocation(order->dest); + v->dest_tile = v->GetOrderStationLocation(order->GetDestination()); break; case OT_GOTO_DEPOT: - if (v->type != VEH_AIRCRAFT) v->dest_tile = GetDepot(order->dest)->xy; + if (v->type != VEH_AIRCRAFT) v->dest_tile = GetDepot(order->GetDestination())->xy; break; case OT_GOTO_WAYPOINT: - v->dest_tile = GetWaypoint(order->dest)->xy; + v->dest_tile = GetWaypoint(order->GetDestination())->xy; break; default: diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 1fe9149a1..ffc18a602 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -155,7 +155,7 @@ static void DrawOrdersWindow(Window *w) if (order != NULL) { switch (order->GetType()) { case OT_GOTO_STATION: - if (!GetStation(order->dest)->IsBuoy()) break; + if (!GetStation(order->GetDestination())->IsBuoy()) break; /* Fall-through */ case OT_GOTO_WAYPOINT: @@ -197,12 +197,12 @@ static void DrawOrdersWindow(Window *w) switch (order->GetType()) { case OT_DUMMY: SetDParam(1, STR_INVALID_ORDER); - SetDParam(2, order->dest); + SetDParam(2, order->GetDestination()); break; case OT_GOTO_STATION: SetDParam(1, StationOrderStrings[order->flags]); - SetDParam(2, order->dest); + SetDParam(2, order->GetDestination()); break; case OT_GOTO_DEPOT: { @@ -210,9 +210,9 @@ static void DrawOrdersWindow(Window *w) if (v->type == VEH_AIRCRAFT) { s = STR_GO_TO_AIRPORT_HANGAR; - SetDParam(2, order->dest); + SetDParam(2, order->GetDestination()); } else { - SetDParam(2, GetDepot(order->dest)->town_index); + SetDParam(2, GetDepot(order->GetDestination())->town_index); switch (v->type) { case VEH_TRAIN: s = (order->flags & OFB_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break; @@ -236,7 +236,7 @@ static void DrawOrdersWindow(Window *w) case OT_GOTO_WAYPOINT: SetDParam(1, (order->flags & OFB_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT); - SetDParam(2, order->dest); + SetDParam(2, order->GetDestination()); break; default: break; @@ -335,7 +335,6 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) // not found order.Free(); - order.dest = INVALID_STATION; return order; } @@ -563,9 +562,9 @@ static void OrdersWndProc(Window *w, WindowEvent *e) TileIndex xy; switch (ord->GetType()) { - case OT_GOTO_STATION: xy = GetStation(ord->dest)->xy ; break; - case OT_GOTO_DEPOT: xy = (v->type == VEH_AIRCRAFT) ? GetStation(ord->dest)->xy : GetDepot(ord->dest)->xy; break; - case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->dest)->xy; break; + case OT_GOTO_STATION: xy = GetStation(ord->GetDestination())->xy ; break; + case OT_GOTO_DEPOT: xy = (v->type == VEH_AIRCRAFT) ? GetStation(ord->GetDestination())->xy : GetDepot(ord->GetDestination())->xy; break; + case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->GetDestination())->xy; break; default: xy = 0; break; } diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index a53ed5270..b5a751e93 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -1743,7 +1743,7 @@ again: if (IsRoadVehFront(v) && ((IsInsideMM(v->u.road.state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END) && _road_veh_data_1[v->u.road.state - RVSB_IN_ROAD_STOP + (_opt.road_side << RVS_DRIVE_SIDE)] == v->u.road.frame) || (IsInsideMM(v->u.road.state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) && - v->current_order.dest == GetStationIndex(v->tile) && + v->current_order.GetDestination() == GetStationIndex(v->tile) && GetRoadStopType(v->tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK) && v->u.road.frame == RVC_DRIVE_THROUGH_STOP_FRAME))) { @@ -1820,9 +1820,9 @@ again: if (!v->current_order.IsType(OT_GOTO_STATION)) { DEBUG(ms, 2, " current order type (%d) is not OT_GOTO_STATION", v->current_order.GetType()); } else { - if (v->current_order.dest != st->index) + if (v->current_order.GetDestination() != st->index) DEBUG(ms, 2, " current station %d is not target station in current_order.station (%d)", - st->index, v->current_order.dest); + st->index, v->current_order.GetDestination()); } DEBUG(ms, 2, " force a slot clearing"); @@ -1963,7 +1963,7 @@ void RoadVehicle::OnNewDay() /* update destination */ if (!(this->vehstatus & VS_STOPPED) && this->current_order.IsType(OT_GOTO_STATION) && this->u.road.slot == NULL && !(this->vehstatus & VS_CRASHED)) { - Station *st = GetStation(this->current_order.dest); + Station *st = GetStation(this->current_order.GetDestination()); RoadStop *rs = st->GetPrimaryRoadStop(this); RoadStop *best = NULL; diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index ffcd723b5..0f29dd81e 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -645,10 +645,10 @@ static void ShipController(Vehicle *v) return; } } else if (v->current_order.IsType(OT_GOTO_STATION)) { - v->last_station_visited = v->current_order.dest; + v->last_station_visited = v->current_order.GetDestination(); /* Process station in the orderlist. */ - Station *st = GetStation(v->current_order.dest); + Station *st = GetStation(v->current_order.GetDestination()); if (st->facilities & FACIL_DOCK) { // ugly, ugly workaround for problem with ships able to drop off cargo at wrong stations ShipArrivesAt(v, st); v->BeginLoading(); diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index b8490960f..fad63166c 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -1898,7 +1898,7 @@ bool HasStationInUse(StationID station, PlayerID player) if (player == INVALID_PLAYER || v->owner == player) { const Order *order; FOR_VEHICLE_ORDERS(v, order) { - if (order->IsType(OT_GOTO_STATION) && order->dest == station) { + if (order->IsType(OT_GOTO_STATION) && order->GetDestination() == station) { return true; } } @@ -2437,7 +2437,7 @@ static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, i /* Check if the vehicle is stopping at this road stop */ if (GetRoadStopType(tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK) && - v->current_order.dest == GetStationIndex(tile)) { + v->current_order.GetDestination() == GetStationIndex(tile)) { SetBit(v->u.road.state, RVS_IS_STOPPING); rs->AllocateDriveThroughBay(side); } diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 192031b52..dae9648da 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -120,7 +120,7 @@ static void DrawTimetableWindow(Window *w) case OT_GOTO_STATION: SetDParam(0, (order->flags & OFB_NON_STOP) ? STR_880A_GO_NON_STOP_TO : STR_8806_GO_TO); - SetDParam(1, order->dest); + SetDParam(1, order->GetDestination()); if (order->wait_time > 0) { SetDParam(2, STR_TIMETABLE_STAY_FOR); @@ -134,9 +134,9 @@ static void DrawTimetableWindow(Window *w) if (v->type == VEH_AIRCRAFT) { string = STR_GO_TO_AIRPORT_HANGAR; - SetDParam(1, order->dest); + SetDParam(1, order->GetDestination()); } else { - SetDParam(1, GetDepot(order->dest)->town_index); + SetDParam(1, GetDepot(order->GetDestination())->town_index); switch (v->type) { case VEH_TRAIN: string = (order->flags & OFB_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break; @@ -153,7 +153,7 @@ static void DrawTimetableWindow(Window *w) case OT_GOTO_WAYPOINT: SetDParam(0, (order->flags & OFB_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT); - SetDParam(1, order->dest); + SetDParam(1, order->GetDestination()); break; default: break; diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index a13d88d1a..84d128e77 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2342,7 +2342,7 @@ static bool NtpCallbFindStation(TileIndex tile, TrainTrackFollowerData *ttfd, Tr static void FillWithStationData(TrainTrackFollowerData* fd, const Vehicle* v) { fd->dest_coords = v->dest_tile; - fd->station_index = v->current_order.IsType(OT_GOTO_STATION) ? v->current_order.dest : INVALID_STATION; + fd->station_index = v->current_order.IsType(OT_GOTO_STATION) ? v->current_order.GetDestination() : INVALID_STATION; } static const byte _initial_tile_subcoord[6][4][3] = { @@ -2658,7 +2658,6 @@ static void TrainEnterStation(Vehicle *v, StationID station) } v->BeginLoading(); - v->current_order.dest = 0; } static byte AfterSetTrainPos(Vehicle *v, bool new_tile) @@ -3559,7 +3558,7 @@ static void CheckIfTrainNeedsService(Vehicle *v) const Depot* depot = GetDepotByTile(tfdd.tile); if (v->current_order.IsType(OT_GOTO_DEPOT) && - v->current_order.dest != depot->index && + v->current_order.GetDestination() != depot->index && !Chance16(3, 16)) { return; } @@ -3583,7 +3582,7 @@ void Train::OnNewDay() /* update destination */ if (this->current_order.IsType(OT_GOTO_STATION)) { - TileIndex tile = GetStation(this->current_order.dest)->train_tile; + TileIndex tile = GetStation(this->current_order.GetDestination())->train_tile; if (tile != 0) this->dest_tile = tile; } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index bf3618517..8325897a2 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2033,7 +2033,7 @@ uint GenerateVehicleSortList(const Vehicle ***sort_list, uint16 *length_of_array const Order *order; FOR_VEHICLE_ORDERS(v, order) { - if (order->IsType(OT_GOTO_STATION) && order->dest == index) { + if (order->IsType(OT_GOTO_STATION) && order->GetDestination() == index) { if (n == *length_of_array) ExtendVehicleListSize(sort_list, length_of_array, 50); (*sort_list)[n++] = v; break; @@ -2077,7 +2077,7 @@ uint GenerateVehicleSortList(const Vehicle ***sort_list, uint16 *length_of_array const Order *order; FOR_VEHICLE_ORDERS(v, order) { - if (order->IsType(OT_GOTO_DEPOT) && order->dest == index) { + if (order->IsType(OT_GOTO_DEPOT) && order->GetDestination() == index) { if (n == *length_of_array) ExtendVehicleListSize(sort_list, length_of_array, 25); (*sort_list)[n++] = v; break; @@ -3131,7 +3131,7 @@ void Vehicle::BeginLoading() assert(IsTileType(tile, MP_STATION) || type == VEH_SHIP); if (this->current_order.IsType(OT_GOTO_STATION) && - this->current_order.dest == this->last_station_visited) { + this->current_order.GetDestination() == this->last_station_visited) { /* Arriving at the ordered station. * Keep the load/unload flags, as we (obviously) still need them. */ this->current_order.flags &= OFB_FULL_LOAD | OFB_UNLOAD | OFB_TRANSFER; diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 8732673fa..9ef5a71ce 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -918,9 +918,9 @@ void DrawSmallOrderList(const Vehicle *v, int x, int y) sel--; if (order->IsType(OT_GOTO_STATION)) { - if (v->type == VEH_SHIP && GetStation(order->dest)->IsBuoy()) continue; + if (v->type == VEH_SHIP && GetStation(order->GetDestination())->IsBuoy()) continue; - SetDParam(0, order->dest); + SetDParam(0, order->GetDestination()); DrawString(x, y, STR_A036, TC_FROMSTRING); y += 6; @@ -1954,7 +1954,7 @@ static void DrawVehicleViewWindow(Window *w) } else { // vehicle is in a "normal" state, show current order switch (v->current_order.GetType()) { case OT_GOTO_STATION: { - SetDParam(0, v->current_order.dest); + SetDParam(0, v->current_order.GetDestination()); SetDParam(1, v->GetDisplaySpeed()); str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; } break; @@ -1962,10 +1962,10 @@ static void DrawVehicleViewWindow(Window *w) case OT_GOTO_DEPOT: { if (v->type == VEH_AIRCRAFT) { /* Aircrafts always go to a station, even if you say depot */ - SetDParam(0, v->current_order.dest); + SetDParam(0, v->current_order.GetDestination()); SetDParam(1, v->GetDisplaySpeed()); } else { - Depot *depot = GetDepot(v->current_order.dest); + Depot *depot = GetDepot(v->current_order.GetDestination()); SetDParam(0, depot->town_index); SetDParam(1, v->GetDisplaySpeed()); } @@ -1982,7 +1982,7 @@ static void DrawVehicleViewWindow(Window *w) case OT_GOTO_WAYPOINT: { assert(v->type == VEH_TRAIN); - SetDParam(0, v->current_order.dest); + SetDParam(0, v->current_order.GetDestination()); str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed; SetDParam(1, v->GetDisplaySpeed()); break; diff --git a/src/yapf/yapf_destrail.hpp b/src/yapf/yapf_destrail.hpp index 16a0ea38a..1de192334 100644 --- a/src/yapf/yapf_destrail.hpp +++ b/src/yapf/yapf_destrail.hpp @@ -88,16 +88,16 @@ public: { switch (v->current_order.GetType()) { case OT_GOTO_STATION: - m_destTile = CalcStationCenterTile(v->current_order.dest); - m_dest_station_id = v->current_order.dest; + m_destTile = CalcStationCenterTile(v->current_order.GetDestination()); + m_dest_station_id = v->current_order.GetDestination(); m_destTrackdirs = INVALID_TRACKDIR_BIT; break; case OT_GOTO_WAYPOINT: { - Waypoint *wp = GetWaypoint(v->current_order.dest); + Waypoint *wp = GetWaypoint(v->current_order.GetDestination()); if (wp == NULL) { /* Invalid waypoint in orders! */ - DEBUG(yapf, 0, "Invalid waypoint in orders == 0x%04X (train %d, player %d)", v->current_order.dest, v->unitnumber, (PlayerID)v->owner); + DEBUG(yapf, 0, "Invalid waypoint in orders == 0x%04X (train %d, player %d)", v->current_order.GetDestination(), v->unitnumber, (PlayerID)v->owner); break; } m_destTile = wp->xy; |