diff options
-rw-r--r-- | src/network/network_server.cpp | 4 | ||||
-rw-r--r-- | src/order_cmd.cpp | 3 | ||||
-rw-r--r-- | src/order_gui.cpp | 3 | ||||
-rw-r--r-- | src/pathfinder/yapf/yapf_road.cpp | 3 | ||||
-rw-r--r-- | src/roadveh.h | 2 | ||||
-rw-r--r-- | src/roadveh_cmd.cpp | 19 | ||||
-rw-r--r-- | src/station.cpp | 3 | ||||
-rw-r--r-- | src/station_cmd.cpp | 2 |
8 files changed, 25 insertions, 14 deletions
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 641de9109..82e8de6a4 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -28,7 +28,7 @@ #include "../company_func.h" #include "../company_gui.h" #include "../window_func.h" -#include "../cargotype.h" +#include "../roadveh.h" #include "table/strings.h" @@ -1368,7 +1368,7 @@ void NetworkPopulateCompanyStats(NetworkCompanyStats *stats) byte type = 0; switch (v->type) { case VEH_TRAIN: type = 0; break; - case VEH_ROAD: type = IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? 2 : 1; break; + case VEH_ROAD: type = RoadVehicle::From(v)->IsBus() ? 2 : 1; break; case VEH_AIRCRAFT: type = 3; break; case VEH_SHIP: type = 4; break; default: continue; diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 0573ea655..a912b328f 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -15,7 +15,6 @@ #include "company_func.h" #include "news_func.h" #include "vehicle_gui.h" -#include "cargotype.h" #include "strings_func.h" #include "functions.h" #include "window_func.h" @@ -1140,7 +1139,7 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 } /* Trucks can't share orders with busses (and visa versa) */ - if (src->type == VEH_ROAD && IsCargoInClass(src->cargo_type, CC_PASSENGERS) != IsCargoInClass(dst->cargo_type, CC_PASSENGERS)) { + if (src->type == VEH_ROAD && RoadVehicle::From(src)->IsBus() != RoadVehicle::From(dst)->IsBus()) { return CMD_ERROR; } diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 328cb18b6..608ac3d62 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -17,6 +17,7 @@ #include "depot_base.h" #include "vehicle_base.h" #include "vehicle_gui.h" +#include "roadveh.h" #include "timetable.h" #include "cargotype.h" #include "strings_func.h" @@ -379,7 +380,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) (facil = FACIL_DOCK, v->type == VEH_SHIP) || (facil = FACIL_TRAIN, v->type == VEH_TRAIN) || (facil = FACIL_AIRPORT, v->type == VEH_AIRCRAFT) || - (facil = FACIL_BUS_STOP, v->type == VEH_ROAD && IsCargoInClass(v->cargo_type, CC_PASSENGERS)) || + (facil = FACIL_BUS_STOP, v->type == VEH_ROAD && RoadVehicle::From(v)->IsBus()) || (facil = FACIL_TRUCK_STOP, 1); if (st->facilities & facil) { order.MakeGoToStation(st_index); diff --git a/src/pathfinder/yapf/yapf_road.cpp b/src/pathfinder/yapf/yapf_road.cpp index 21a125f8b..af4413111 100644 --- a/src/pathfinder/yapf/yapf_road.cpp +++ b/src/pathfinder/yapf/yapf_road.cpp @@ -11,7 +11,6 @@ #include "../../stdafx.h" #include "../../roadstop_base.h" -#include "../../cargotype.h" #include "yapf.hpp" #include "yapf_node_road.hpp" @@ -209,7 +208,7 @@ public: { m_dest_station = sid; m_destTile = destTile; - m_bus = IsCargoInClass(v->cargo_type, CC_PASSENGERS); + m_bus = v->IsBus(); m_non_artic = !v->HasArticulatedPart(); } diff --git a/src/roadveh.h b/src/roadveh.h index 7ac87fca3..e1c8ef123 100644 --- a/src/roadveh.h +++ b/src/roadveh.h @@ -132,6 +132,8 @@ struct RoadVehicle : public SpecializedVehicle<RoadVehicle, VEH_ROAD> { bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse); void FindRoadStopSlot(); + bool IsBus() const; + /** * Check if vehicle is a front engine * @return Returns true if vehicle is a front engine diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 346c561bc..5ccb779e8 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -82,6 +82,17 @@ static const Trackdir _roadveh_depot_exit_trackdir[DIAGDIR_END] = { TRACKDIR_X_NE, TRACKDIR_Y_SE, TRACKDIR_X_SW, TRACKDIR_Y_NW }; + +/** + * Check whether a roadvehicle is a bus + * @return true if bus + */ +bool RoadVehicle::IsBus() const +{ + assert(this->IsRoadVehFront()); + return IsCargoInClass(this->cargo_type, CC_PASSENGERS); +} + /** * Get the width of a road vehicle image in the GUI. * @param offset Additional offset for positioning the sprite; set to NULL if not needed @@ -729,7 +740,7 @@ static RoadVehicle *RoadVehFindCloseTo(RoadVehicle *v, int x, int y, Direction d static void RoadVehArrivesAt(const RoadVehicle *v, Station *st) { - if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) { + if (v->IsBus()) { /* Check if station was ever visited before */ if (!(st->had_vehicle_of_type & HVOT_BUS)) { st->had_vehicle_of_type |= HVOT_BUS; @@ -960,7 +971,7 @@ static Trackdir RoadFindPathToDest(RoadVehicle *v, TileIndex tile, DiagDirection trackdirs = TRACKDIR_BIT_NONE; } else { /* Our station */ - RoadStopType rstype = IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK; + RoadStopType rstype = v->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK; if (GetRoadStopType(tile) != rstype) { /* Wrong station type */ @@ -1489,7 +1500,7 @@ again: (IsInsideMM(v->state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) && v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile)) && v->owner == GetTileOwner(v->tile) && - GetRoadStopType(v->tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK) && + GetRoadStopType(v->tile) == (v->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK) && v->frame == RVC_DRIVE_THROUGH_STOP_FRAME))) { RoadStop *rs = RoadStop::GetByTile(v->tile, GetRoadStopType(v->tile)); @@ -1503,7 +1514,7 @@ again: if (IsDriveThroughStopTile(v->tile)) { TileIndex next_tile = TILE_ADD(v->tile, TileOffsByDir(v->direction)); - RoadStopType type = IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK; + RoadStopType type = v->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK; /* Check if next inline bay is free */ if (IsDriveThroughStopTile(next_tile) && (GetRoadStopType(next_tile) == type) && GetStationIndex(v->tile) == GetStationIndex(next_tile)) { diff --git a/src/station.cpp b/src/station.cpp index 09204ec0a..a3c58052a 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -11,7 +11,6 @@ #include "stdafx.h" #include "company_func.h" -#include "cargotype.h" #include "roadveh.h" #include "functions.h" #include "window_func.h" @@ -119,7 +118,7 @@ void BaseStation::PostDestructor(size_t index) */ RoadStop *Station::GetPrimaryRoadStop(const RoadVehicle *v) const { - RoadStop *rs = this->GetPrimaryRoadStop(IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK); + RoadStop *rs = this->GetPrimaryRoadStop(v->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK); for (; rs != NULL; rs = rs->next) { /* The vehicle cannot go to this roadstop (different roadtype) */ diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 8346a61ba..2fd46ca82 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2699,7 +2699,7 @@ static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, i if (!rs->IsFreeBay(side)) return VETSB_CANNOT_ENTER; /* Check if the vehicle is stopping at this road stop */ - if (GetRoadStopType(tile) == (IsCargoInClass(rv->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK) && + if (GetRoadStopType(tile) == (rv->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK) && rv->current_order.GetDestination() == GetStationIndex(tile)) { SetBit(rv->state, RVS_IS_STOPPING); rs->AllocateDriveThroughBay(side); |