diff options
author | truelight <truelight@openttd.org> | 2006-08-26 16:34:03 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2006-08-26 16:34:03 +0000 |
commit | db8dfcd6e90f13ed0aafec06fc5975967afb1bb5 (patch) | |
tree | 7f558c2b1487df44a464aa980693e44cb438c592 | |
parent | f73a2829f364b07d6f944b8b49e156b9774db39b (diff) | |
download | openttd-db8dfcd6e90f13ed0aafec06fc5975967afb1bb5.tar.xz |
(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)
-rw-r--r-- | ai/default/default.c | 8 | ||||
-rw-r--r-- | ai/trolly/trolly.c | 8 | ||||
-rw-r--r-- | aircraft_cmd.c | 20 | ||||
-rw-r--r-- | aircraft_gui.c | 7 | ||||
-rw-r--r-- | depot.c | 2 | ||||
-rw-r--r-- | disaster_cmd.c | 60 | ||||
-rw-r--r-- | npf.c | 4 | ||||
-rw-r--r-- | openttd.h | 23 | ||||
-rw-r--r-- | order.h | 9 | ||||
-rw-r--r-- | order_cmd.c | 44 | ||||
-rw-r--r-- | order_gui.c | 30 | ||||
-rw-r--r-- | roadveh_cmd.c | 20 | ||||
-rw-r--r-- | roadveh_gui.c | 4 | ||||
-rw-r--r-- | ship_cmd.c | 16 | ||||
-rw-r--r-- | ship_gui.c | 8 | ||||
-rw-r--r-- | station_cmd.c | 8 | ||||
-rw-r--r-- | train_cmd.c | 30 | ||||
-rw-r--r-- | train_gui.c | 6 | ||||
-rw-r--r-- | vehicle.c | 8 | ||||
-rw-r--r-- | vehicle_gui.c | 2 | ||||
-rw-r--r-- | waypoint.c | 2 | ||||
-rw-r--r-- | waypoint.h | 6 | ||||
-rw-r--r-- | yapf/yapf_destrail.hpp | 4 |
23 files changed, 172 insertions, 157 deletions
diff --git a/ai/default/default.c b/ai/default/default.c index 08af2b119..623686fd7 100644 --- a/ai/default/default.c +++ b/ai/default/default.c @@ -2453,7 +2453,7 @@ handle_nocash: order.type = OT_GOTO_STATION; 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 (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.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 (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.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 (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->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 diff --git a/ai/trolly/trolly.c b/ai/trolly/trolly.c index 7d3398cec..e91c3a171 100644 --- a/ai/trolly/trolly.c +++ b/ai/trolly/trolly.c @@ -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->station) == st) { + if (order->type == OT_GOTO_STATION && GetStation(order->dest.station) == 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.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); } idx = 0; order.type = OT_GOTO_STATION; 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) 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.station = GetStationIndex(p->ainew.from_tile); + order.dest.station = 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); diff --git a/aircraft_cmd.c b/aircraft_cmd.c index 6dd814da0..ba4a64cea 100644 --- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -537,7 +537,7 @@ int32 CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uint32 p2 if (flags & DC_EXEC) { v->current_order.type = OT_GOTO_DEPOT; 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); 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 @@ -650,7 +650,7 @@ static void CheckIfAircraftNeedsService(Vehicle *v) 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) 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); @@ -1195,9 +1195,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->station == v->current_order.station) + if (order->type == v->current_order.type && + order->flags == v->current_order.flags && + order->dest.station == v->current_order.dest.station) return; v->current_order = *order; @@ -1205,7 +1205,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->station; + v->u.air.targetairport = order->dest.station; } InvalidateVehicleOrder(v); @@ -1347,7 +1347,7 @@ static void AircraftEntersTerminal(Vehicle *v) v->current_order.flags = 0; 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 = (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 || 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); 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; // 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: // 1. Find a free terminal, 2. Occupy it, 3. Set the vehicle's state to that terminal 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; break; 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; } else { v->u.air.state = (v->subtype != 0) ? TAKEOFF : HELITAKEOFF; diff --git a/aircraft_gui.c b/aircraft_gui.c index c562de46d..4c4425e34 100644 --- a/aircraft_gui.c +++ b/aircraft_gui.c @@ -548,13 +548,14 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e) } else { switch (v->current_order.type) { case OT_GOTO_STATION: { - SetDParam(0, v->current_order.station); + SetDParam(0, v->current_order.dest.station); SetDParam(1, v->cur_speed * 128 / 10); str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; } break; 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); str = STR_HEADING_FOR_HANGAR + _patches.vehicle_speed; } break; @@ -960,7 +961,7 @@ static void DrawSmallOrderList(const Vehicle *v, int x, int y) sel--; if (order->type == OT_GOTO_STATION) { - SetDParam(0, order->station); + SetDParam(0, order->dest.station); DrawString(x, y, STR_A036, 0); y += 6; @@ -83,7 +83,7 @@ void DestroyDepot(Depot *depot) DoClearSquare(depot->xy); /* Clear the depot from all order-lists */ - RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, depot->index); + RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, (DestinationID)depot->index); /* Delete the depot-window */ DeleteWindowById(WC_VEHICLE_DEPOT, depot->xy); diff --git a/disaster_cmd.c b/disaster_cmd.c index d44214e17..086f6cea1 100644 --- a/disaster_cmd.c +++ b/disaster_cmd.c @@ -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.station = 0; + v->current_order.dest.station = 0; DisasterVehicleUpdateImage(v); VehiclePositionChanged(v); @@ -165,7 +165,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v) ++v->tick_counter; - if (v->current_order.station < 2) { + if (v->current_order.dest.disaster < 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.station == 1) { + if (v->current_order.dest.disaster == 1) { if (++v->age == 38) { - v->current_order.station = 2; + v->current_order.dest.disaster = 2; v->age = 0; } if ((v->tick_counter&7)==0) { 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; /**/ if (IsValidTile(tile) && IsTileType(tile, MP_STATION) && IsAirport(tile) && IS_HUMAN_PLAYER(GetTileOwner(tile))) { - v->current_order.station = 1; + v->current_order.dest.disaster = 1; v->age = 0; SetDParam(0, GetStationIndex(tile)); @@ -204,7 +204,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v) return; } - if (v->current_order.station > 2) { + if (v->current_order.dest.disaster > 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.station = 3; + v->current_order.dest.disaster = 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.station == 0) { + if (v->current_order.dest.disaster == 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.station = 1; + v->current_order.dest.disaster = 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.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); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); @@ -370,7 +370,7 @@ static void DisasterTick_2(Vehicle *v) return; } - if (v->current_order.station == 2) { + if (v->current_order.dest.disaster == 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.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) { Industry *i; - v->current_order.station = 2; + v->current_order.dest.disaster = 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.station == 0) { + } else if (v->current_order.dest.disaster == 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.station = 1; + v->current_order.dest.disaster = 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.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); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); @@ -442,7 +442,7 @@ static void DisasterTick_3(Vehicle *v) return; } - if (v->current_order.station == 2) { + if (v->current_order.dest.disaster == 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.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) { Industry *i; - v->current_order.station = 2; + v->current_order.dest.disaster = 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.station == 0) { + } else if (v->current_order.dest.disaster == 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.station = 1; + v->current_order.dest.disaster = 1; v->age = 0; } } @@ -523,7 +523,7 @@ static void DisasterTick_4(Vehicle *v) 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 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.station = 2; + v->current_order.dest.disaster = 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.station < 1) { + } else if (v->current_order.dest.disaster < 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.station = 1; + v->current_order.dest.disaster = 1; tile_org = tile = RandomTile(); do { @@ -624,11 +624,11 @@ static void DisasterTick_4b(Vehicle *v) return; } - if (v->current_order.station == 0) { + if (v->current_order.dest.disaster == 0) { u = GetVehicle(v->u.disaster.unk2); if (abs(v->x_pos - u->x_pos) > TILE_SIZE) return; - v->current_order.station = 1; + v->current_order.dest.disaster = 1; CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE); SndPlayVehicleFx(SND_12_EXPLOSION, u); @@ -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.station; + fstd->station_index = v->current_order.dest.station; /* 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 { fstd->dest_coords = v->dest_tile; fstd->station_index = INVALID_STATION; @@ -40,18 +40,33 @@ typedef uint16 StationID; typedef uint16 TownID; typedef uint16 IndustryID; typedef uint16 DepotID; +typedef uint16 WaypointID; typedef byte PlayerID; typedef byte OrderID; typedef byte CargoID; typedef byte LandscapeID; typedef uint16 StringID; -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 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 CursorID; -typedef uint16 EngineID; ///< All enginenumbers should be of this type +typedef uint16 EngineID; typedef uint16 EngineRenewID; 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 byte WindowClass; @@ -70,7 +70,6 @@ enum { CO_UNSHARE = 2 }; - /* If you change this, keep in mind that it is saved on 3 places: * - Load_ORDR, all the global orders * - Vehicle -> current_order @@ -79,7 +78,7 @@ enum { typedef struct Order { OrderType type; uint8 flags; - StationID station; + DestinationID dest; ///< The destionation of the order. 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) { - 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) @@ -180,7 +179,7 @@ static inline Order UnpackOrder(uint32 packed) Order order; order.type = (OrderType)GB(packed, 0, 8); order.flags = GB(packed, 8, 8); - order.station = GB(packed, 16, 16); + order.dest.station = GB(packed, 16, 16); order.next = NULL; order.index = 0; // avoid compiler warning return order; @@ -189,7 +188,7 @@ static inline Order UnpackOrder(uint32 packed) /* Functions */ void BackupVehicleOrders(const Vehicle *v, 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); bool VehicleHasDepotOrders(const Vehicle *v); void CheckOrders(const Vehicle*); diff --git a/order_cmd.c b/order_cmd.c index f2b1924b9..e4d478caf 100644 --- a/order_cmd.c +++ b/order_cmd.c @@ -47,12 +47,12 @@ Order UnpackOldOrder(uint16 packed) Order order; order.type = GB(packed, 0, 4); order.flags = GB(packed, 4, 4); - order.station = GB(packed, 8, 8); + order.dest.station = 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.station != 0)) { + if (order.type == OT_NOTHING && (order.flags != 0 || order.dest.station != 0)) { order.type = OT_DUMMY; order.flags = 0; } @@ -70,7 +70,7 @@ static Order UnpackVersion4Order(uint16 packed) Order order; order.type = GB(packed, 0, 4); order.flags = GB(packed, 4, 4); - order.station = GB(packed, 8, 8); + order.dest.station = GB(packed, 8, 8); order.next = NULL; order.index = 0; // avoid compiler warning return order; @@ -144,7 +144,7 @@ void AssignOrder(Order *order, Order data) { order->type = data.type; 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: { const Station *st; - if (!IsValidStationID(new_order.station)) return CMD_ERROR; - st = GetStation(new_order.station); + if (!IsValidStationID(new_order.dest.station)) return CMD_ERROR; + st = GetStation(new_order.dest.station); 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.station)) return CMD_ERROR; - st = GetStation(new_order.station); + if (!IsValidStationID(new_order.dest.station)) return CMD_ERROR; + st = GetStation(new_order.dest.station); 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.station)) return CMD_ERROR; - dp = GetDepot(new_order.station); + if (!IsValidDepotID(new_order.dest.depot)) return CMD_ERROR; + dp = GetDepot(new_order.dest.depot); 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.station)) return CMD_ERROR; - wp = GetWaypoint(new_order.station); + if (!IsValidWaypointID(new_order.dest.waypoint)) return CMD_ERROR; + wp = GetWaypoint(new_order.dest.waypoint); 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)->station)->xy, - GetStation(new_order.station)->xy // XXX type != OT_GOTO_STATION? + GetStation(GetVehicleOrder(v, sel_ord - 1)->dest.station)->xy, + GetStation(new_order.dest.station)->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->station); + const Station *st = GetStation(order->dest.station); 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->station); + const Station* st = GetStation(order->dest.station); TileIndex required_tile = GetStationTileForVehicle(v, st); n_st++; @@ -933,7 +933,7 @@ void CheckOrders(const Vehicle* v) if (v->orders->type == last->type && v->orders->flags == last->flags && - v->orders->station == last->station) { + v->orders->dest.station == last->dest.station) { 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 destination The destination. Can be a StationID, DepotID or WaypointID. */ -void RemoveOrderFromAllVehicles(OrderType type, StationID destination) +void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination) { Vehicle *v; Order *order; @@ -973,11 +973,11 @@ void RemoveOrderFromAllVehicles(OrderType type, StationID destination) if (v->orders == NULL) continue; /* 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; /* 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 */ v->current_order.type = OT_DUMMY; v->current_order.flags = 0; @@ -987,7 +987,7 @@ void RemoveOrderFromAllVehicles(OrderType type, StationID destination) /* Clear the order from the order-list */ need_invalidate = false; 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 */ order->type = OT_DUMMY; order->flags = 0; @@ -1112,7 +1112,7 @@ void InitializeOrders(void) static const SaveLoad _order_desc[] = { SLE_VAR(Order, type, 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), // reserve extra space in savegame here. (currently 10 bytes) diff --git a/order_gui.c b/order_gui.c index 1cbdb56f9..10aba4f2b 100644 --- a/order_gui.c +++ b/order_gui.c @@ -134,7 +134,7 @@ static void DrawOrdersWindow(Window *w) switch (order->type) { case OT_GOTO_STATION: SetDParam(1, StationOrderStrings[order->flags]); - SetDParam(2, order->station); + SetDParam(2, order->dest.station); break; case OT_GOTO_DEPOT: { @@ -142,9 +142,9 @@ static void DrawOrdersWindow(Window *w) if (v->type == VEH_Aircraft) { s = STR_GO_TO_AIRPORT_HANGAR; - SetDParam(2, order->station); + SetDParam(2, order->dest.depot); } else { - SetDParam(2, GetDepot(order->station)->town_index); + SetDParam(2, GetDepot(order->dest.depot)->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; @@ -162,7 +162,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->station); + SetDParam(2, order->dest.waypoint); break; default: break; @@ -174,7 +174,7 @@ static void DrawOrdersWindow(Window *w) DrawString(2, y, str, color); } else { SetDParam(1, STR_INVALID_ORDER); - SetDParam(2, order->station); + SetDParam(2, order->dest.station); DrawString(2, y, str, color); } y += 10; @@ -205,7 +205,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) if (IsRailDepot(tile)) { order.type = OT_GOTO_DEPOT; order.flags = OF_PART_OF_ORDERS; - order.station = GetDepotByTile(tile)->index; + order.dest.depot = GetDepotByTile(tile)->index; 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)) { order.type = OT_GOTO_DEPOT; order.flags = OF_PART_OF_ORDERS; - order.station = GetDepotByTile(tile)->index; + order.dest.depot = GetDepotByTile(tile)->index; return order; } break; @@ -225,7 +225,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.station = GetStationIndex(tile); + order.dest.station = GetStationIndex(tile); return order; } break; @@ -238,7 +238,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) order.type = OT_GOTO_DEPOT; 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; } @@ -254,7 +254,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) IsRailWaypoint(tile)) { order.type = OT_GOTO_WAYPOINT; order.flags = 0; - order.station = GetWaypointByTile(tile)->index; + order.dest.waypoint = GetWaypointByTile(tile)->index; return order; } @@ -272,7 +272,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) if (st->facilities & facil) { order.type = OT_GOTO_STATION; order.flags = 0; - order.station = st_index; + order.dest.station = st_index; return order; } } @@ -281,7 +281,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) // not found order.type = OT_NOTHING; order.flags = 0; - order.station = INVALID_STATION; + order.dest.station = INVALID_STATION; return order; } @@ -410,9 +410,9 @@ static void OrdersWndProc(Window *w, WindowEvent *e) TileIndex xy; switch (ord->type) { - case OT_GOTO_STATION: xy = GetStation(ord->station)->xy ; break; - case OT_GOTO_DEPOT: xy = GetDepot(ord->station)->xy; break; - case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->station)->xy; break; + 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; default: xy = 0; break; } diff --git a/roadveh_cmd.c b/roadveh_cmd.c index 42562ee1f..406c55269 100644 --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -394,7 +394,7 @@ int32 CmdSendRoadVehToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) ClearSlot(v); v->current_order.type = OT_GOTO_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; InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); } @@ -649,7 +649,7 @@ static void ProcessRoadVehOrder(Vehicle *v) if (order->type == v->current_order.type && order->flags == v->current_order.flags && - order->station == v->current_order.station) { + order->dest.station == v->current_order.dest.station) { return; } @@ -659,12 +659,12 @@ static void ProcessRoadVehOrder(Vehicle *v) case OT_GOTO_STATION: { const RoadStop* rs; - if (order->station == v->last_station_visited) { + if (order->dest.station == v->last_station_visited) { v->last_station_visited = INVALID_STATION; } rs = GetPrimaryRoadStop( - GetStation(order->station), + GetStation(order->dest.station), v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK ); @@ -690,7 +690,7 @@ static void ProcessRoadVehOrder(Vehicle *v) } case OT_GOTO_DEPOT: - v->dest_tile = GetDepot(order->station)->xy; + v->dest_tile = GetDepot(order->dest.depot)->xy; break; default: @@ -1478,7 +1478,7 @@ again: v->current_order.flags = 0; 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 = (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) { DEBUG(ms, 0) ("Multistop: -- Current order type (%d) is not OT_GOTO_STATION.", v->current_order.type); } 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).", - st->index, v->current_order.station); + st->index, v->current_order.dest.station); } 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.flags = OF_NON_STOP; - v->current_order.station = depot->index; + v->current_order.dest.depot = depot->index; v->dest_tile = depot->xy; InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); } @@ -1665,7 +1665,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.station); + Station* st = GetStation(v->current_order.dest.station); RoadStop* rs = GetPrimaryRoadStop(st, v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK); RoadStop* best = NULL; diff --git a/roadveh_gui.c b/roadveh_gui.c index f47274091..6fe3c1333 100644 --- a/roadveh_gui.c +++ b/roadveh_gui.c @@ -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.station); + SetDParam(0, v->current_order.dest.station); 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.station); + Depot *depot = GetDepot(v->current_order.dest.depot); SetDParam(0, depot->town_index); SetDParam(1, v->cur_speed / 2); str = STR_HEADING_FOR_ROAD_DEPOT + _patches.vehicle_speed; diff --git a/ship_cmd.c b/ship_cmd.c index 367742802..4fceb3da3 100644 --- a/ship_cmd.c +++ b/ship_cmd.c @@ -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.station = depot->index; + v->current_order.dest.depot = depot->index; v->dest_tile = depot->xy; InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); } @@ -229,7 +229,7 @@ static void ProcessShipOrder(Vehicle *v) if (order->type == v->current_order.type && order->flags == v->current_order.flags && - order->station == v->current_order.station) + order->dest.station == v->current_order.dest.station) 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->station == v->last_station_visited) + if (order->dest.station == v->last_station_visited) v->last_station_visited = INVALID_STATION; - st = GetStation(order->station); + st = GetStation(order->dest.station); 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->station)->xy; + v->dest_tile = GetDepot(order->dest.depot)->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.station; + v->last_station_visited = v->current_order.dest.station; /* 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 */ v->current_order.type = OT_LOADING; 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->current_order.type = OT_GOTO_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); } diff --git a/ship_gui.c b/ship_gui.c index b10496446..faac96a0b 100644 --- a/ship_gui.c +++ b/ship_gui.c @@ -481,13 +481,13 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) } else { switch (v->current_order.type) { case OT_GOTO_STATION: { - SetDParam(0, v->current_order.station); + SetDParam(0, v->current_order.dest.station); 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.station); + Depot *depot = GetDepot(v->current_order.dest.depot); SetDParam(0, depot->town_index); SetDParam(1, v->cur_speed / 2); str = STR_HEADING_FOR_SHIP_DEPOT + _patches.vehicle_speed; @@ -906,8 +906,8 @@ static void DrawSmallOrderList(const Vehicle *v, int x, int y) sel--; if (order->type == OT_GOTO_STATION) { - if (!IsBuoy(GetStation(order->station))){ - SetDParam(0, order->station); + if (!IsBuoy(GetStation(order->dest.station))){ + SetDParam(0, order->dest.station); DrawString(x, y, STR_A036, 0); y += 6; diff --git a/station_cmd.c b/station_cmd.c index 49fd41017..6e7feda73 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -1863,7 +1863,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->station == st->index) { + if (order->type == OT_GOTO_STATION && order->dest.station == st->index) { return true; } } @@ -2333,7 +2333,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.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) && v->current_order.type != OT_LEAVESTATION && v->last_station_visited != station_id) { @@ -2412,7 +2412,7 @@ static void DeleteStation(Station *st) DeleteWindowById(WC_STATION_VIEW, index); /* 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 FOR_ALL_VEHICLES(v) { @@ -2420,7 +2420,7 @@ static void DeleteStation(Station *st) if (v->type == VEH_Aircraft) { Order *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->flags = 0; invalidate = true; diff --git a/train_cmd.c b/train_cmd.c index f5e539ce3..5fe309c98 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -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->station) { + if (_patches.new_nonstop && o->flags & OF_NON_STOP && sid == o->dest.station) { 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; } @@ -1960,7 +1960,7 @@ int32 CmdSendTrainToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) v->dest_tile = tfdd.tile; v->current_order.type = OT_GOTO_DEPOT; 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); /* If there is no depot in front, reverse automatically */ if (tfdd.reverse) @@ -2164,7 +2164,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.station; + fd->station_index = v->current_order.dest.station; } else { fd->station_index = INVALID_STATION; } @@ -2411,7 +2411,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.station == GetStationIndex(v->tile)) { + v->current_order.dest.station == GetStationIndex(v->tile)) { v->cur_order_index++; } @@ -2431,7 +2431,7 @@ 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->station == v->current_order.station) + order->dest.station == v->current_order.dest.station) return false; // Otherwise set it, and determine the destination tile. @@ -2443,17 +2443,17 @@ static bool ProcessTrainOrder(Vehicle *v) switch (order->type) { 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->dest_tile = GetStation(order->station)->xy; + v->dest_tile = GetStation(order->dest.station)->xy; break; case OT_GOTO_DEPOT: - v->dest_tile = GetDepot(order->station)->xy; + v->dest_tile = GetDepot(order->dest.depot)->xy; break; case OT_GOTO_WAYPOINT: - v->dest_tile = GetWaypoint(order->station)->xy; + v->dest_tile = GetWaypoint(order->dest.waypoint)->xy; break; default: @@ -2574,7 +2574,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.station == station) { + v->current_order.dest.station == station) { // Yeah, keep the load/unload flags // Non Stop now means if the order should be increased. 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.flags = 0; } - v->current_order.station = 0; + v->current_order.dest.station = 0; SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC); if (LoadUnloadVehicle(v) != 0) { @@ -3503,14 +3503,14 @@ static void CheckIfTrainNeedsService(Vehicle *v) depot = GetDepotByTile(tfdd.tile); if (v->current_order.type == OT_GOTO_DEPOT && - v->current_order.station != depot->index && + v->current_order.dest.depot != depot->index && !CHANCE16(3, 16)) { return; } v->current_order.type = OT_GOTO_DEPOT; 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; InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); } @@ -3555,7 +3555,7 @@ void OnNewDay_Train(Vehicle *v) /* update destination */ 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; } diff --git a/train_gui.c b/train_gui.c index 2070a7448..92e8cbba5 100644 --- a/train_gui.c +++ b/train_gui.c @@ -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.station); + SetDParam(0, v->current_order.dest.station); SetDParam(1, v->u.rail.last_speed); } break; case OT_GOTO_DEPOT: { - Depot *dep = GetDepot(v->current_order.station); + Depot *dep = GetDepot(v->current_order.dest.depot); SetDParam(0, dep->town_index); str = STR_HEADING_FOR_TRAIN_DEPOT + _patches.vehicle_speed; SetDParam(1, v->u.rail.last_speed); @@ -985,7 +985,7 @@ static void TrainViewWndProc(Window *w, WindowEvent *e) break; 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; SetDParam(1, v->u.rail.last_speed); break; @@ -2193,12 +2193,12 @@ const SaveLoad _common_veh_desc[] = { 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, 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 */ 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, 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), @@ -2363,8 +2363,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, 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_FILE_U8 | SLE_VAR_U16, 0, 4), + SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest.station), 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), diff --git a/vehicle_gui.c b/vehicle_gui.c index d5d60f780..3002df498 100644 --- a/vehicle_gui.c +++ b/vehicle_gui.c @@ -142,7 +142,7 @@ void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID sta const Order *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; break; } diff --git a/waypoint.c b/waypoint.c index d5cd4987d..aa29c7a84 100644 --- a/waypoint.c +++ b/waypoint.c @@ -249,7 +249,7 @@ static void DoDeleteWaypoint(Waypoint *wp) { wp->xy = 0; - RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, wp->index); + RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, (DestinationID)wp->index); if (wp->string != STR_NULL) DeleteName(wp->string); diff --git a/waypoint.h b/waypoint.h index 74ba5d8e4..9949ffaa4 100644 --- a/waypoint.h +++ b/waypoint.h @@ -8,7 +8,7 @@ struct Waypoint { TileIndex xy; ///< Tile of waypoint - StationID index; ///< Index of waypoint + WaypointID index; ///< Index of waypoint TownID town_index; ///< Town associated with the waypoint 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' */ -static inline Waypoint *GetWaypoint(uint index) +static inline Waypoint *GetWaypoint(WaypointID index) { return (Waypoint*)GetItemFromPool(&_waypoint_pool, index); } @@ -50,7 +50,7 @@ static inline bool IsValidWaypoint(const Waypoint *wp) return wp->xy != 0; } -static inline bool IsValidWaypointID(uint index) +static inline bool IsValidWaypointID(WaypointID index) { return index < GetWaypointPoolSize() && IsValidWaypoint(GetWaypoint(index)); } diff --git a/yapf/yapf_destrail.hpp b/yapf/yapf_destrail.hpp index 2720772f8..9d58d7013 100644 --- a/yapf/yapf_destrail.hpp +++ b/yapf/yapf_destrail.hpp @@ -85,8 +85,8 @@ public: void SetDestination(Vehicle* v) { if (v->current_order.type == OT_GOTO_STATION) { - m_destTile = CalcStationCenterTile(v->current_order.station); - m_dest_station_id = v->current_order.station; + m_destTile = CalcStationCenterTile(v->current_order.dest.station); + m_dest_station_id = v->current_order.dest.station; m_destTrackdirs = INVALID_TRACKDIR_BIT; } else { m_destTile = v->dest_tile; |