diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp --- 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(Network 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 --- 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 } /* 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 --- 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 V (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 --- 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 --- a/src/roadveh.h +++ b/src/roadveh.h @@ -132,6 +132,8 @@ struct RoadVehicle : public SpecializedV 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 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -82,6 +82,17 @@ static const Trackdir _roadveh_depot_exi 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(R 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(RoadV 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 --- 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 */ 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 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2699,7 +2699,7 @@ static VehicleEnterTileStatus VehicleEnt 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);