mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
Codechange: Make RoadStopType an enum class. (#13340)
This commit is contained in:
parent
65665ccb78
commit
5f0e4cd646
@ -523,11 +523,11 @@ bool GetIfStopIsForType(const RoadStopSpec *roadstopspec, RoadStopType rs, RoadT
|
|||||||
if (roadstopspec->stop_type == ROADSTOPTYPE_ALL) return true;
|
if (roadstopspec->stop_type == ROADSTOPTYPE_ALL) return true;
|
||||||
|
|
||||||
switch (rs) {
|
switch (rs) {
|
||||||
case ROADSTOP_BUS:
|
case RoadStopType::Bus:
|
||||||
if (roadstopspec->stop_type == ROADSTOPTYPE_PASSENGER) return true;
|
if (roadstopspec->stop_type == ROADSTOPTYPE_PASSENGER) return true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ROADSTOP_TRUCK:
|
case RoadStopType::Truck:
|
||||||
if (roadstopspec->stop_type == ROADSTOPTYPE_FREIGHT) return true;
|
if (roadstopspec->stop_type == ROADSTOPTYPE_FREIGHT) return true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -549,14 +549,14 @@ struct BuildRoadToolbarWindow : Window {
|
|||||||
|
|
||||||
case WID_ROT_BUS_STATION:
|
case WID_ROT_BUS_STATION:
|
||||||
if (HandlePlacePushButton(this, WID_ROT_BUS_STATION, SPR_CURSOR_BUS_STATION, HT_RECT)) {
|
if (HandlePlacePushButton(this, WID_ROT_BUS_STATION, SPR_CURSOR_BUS_STATION, HT_RECT)) {
|
||||||
ShowRVStationPicker(this, ROADSTOP_BUS);
|
ShowRVStationPicker(this, RoadStopType::Bus);
|
||||||
this->last_started_action = widget;
|
this->last_started_action = widget;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_ROT_TRUCK_STATION:
|
case WID_ROT_TRUCK_STATION:
|
||||||
if (HandlePlacePushButton(this, WID_ROT_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, HT_RECT)) {
|
if (HandlePlacePushButton(this, WID_ROT_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, HT_RECT)) {
|
||||||
ShowRVStationPicker(this, ROADSTOP_TRUCK);
|
ShowRVStationPicker(this, RoadStopType::Truck);
|
||||||
this->last_started_action = widget;
|
this->last_started_action = widget;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -779,24 +779,28 @@ struct BuildRoadToolbarWindow : Window {
|
|||||||
|
|
||||||
case DDSP_BUILD_BUSSTOP:
|
case DDSP_BUILD_BUSSTOP:
|
||||||
case DDSP_REMOVE_BUSSTOP:
|
case DDSP_REMOVE_BUSSTOP:
|
||||||
if (this->IsWidgetLowered(WID_ROT_BUS_STATION) && GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui.sel_class), ROADSTOP_BUS, _cur_roadtype)) {
|
if (this->IsWidgetLowered(WID_ROT_BUS_STATION) && GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui.sel_class), RoadStopType::Bus, _cur_roadtype)) {
|
||||||
if (_remove_button_clicked) {
|
if (_remove_button_clicked) {
|
||||||
TileArea ta(start_tile, end_tile);
|
TileArea ta(start_tile, end_tile);
|
||||||
Command<CMD_REMOVE_ROAD_STOP>::Post(GetRoadTypeInfo(this->roadtype)->strings.err_remove_station[ROADSTOP_BUS], CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, ROADSTOP_BUS, _ctrl_pressed);
|
StringID str = GetRoadTypeInfo(this->roadtype)->strings.err_remove_station[to_underlying(RoadStopType::Bus)];
|
||||||
|
Command<CMD_REMOVE_ROAD_STOP>::Post(str, CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, RoadStopType::Bus, _ctrl_pressed);
|
||||||
} else {
|
} else {
|
||||||
PlaceRoadStop(start_tile, end_tile, ROADSTOP_BUS, _ctrl_pressed, _cur_roadtype, GetRoadTypeInfo(this->roadtype)->strings.err_build_station[ROADSTOP_BUS]);
|
StringID str = GetRoadTypeInfo(this->roadtype)->strings.err_build_station[to_underlying(RoadStopType::Bus)];
|
||||||
|
PlaceRoadStop(start_tile, end_tile, RoadStopType::Bus, _ctrl_pressed, _cur_roadtype, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DDSP_BUILD_TRUCKSTOP:
|
case DDSP_BUILD_TRUCKSTOP:
|
||||||
case DDSP_REMOVE_TRUCKSTOP:
|
case DDSP_REMOVE_TRUCKSTOP:
|
||||||
if (this->IsWidgetLowered(WID_ROT_TRUCK_STATION) && GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui.sel_class), ROADSTOP_TRUCK, _cur_roadtype)) {
|
if (this->IsWidgetLowered(WID_ROT_TRUCK_STATION) && GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui.sel_class), RoadStopType::Truck, _cur_roadtype)) {
|
||||||
if (_remove_button_clicked) {
|
if (_remove_button_clicked) {
|
||||||
TileArea ta(start_tile, end_tile);
|
TileArea ta(start_tile, end_tile);
|
||||||
Command<CMD_REMOVE_ROAD_STOP>::Post(GetRoadTypeInfo(this->roadtype)->strings.err_remove_station[ROADSTOP_TRUCK], CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, ROADSTOP_TRUCK, _ctrl_pressed);
|
StringID str = GetRoadTypeInfo(this->roadtype)->strings.err_remove_station[to_underlying(RoadStopType::Truck)];
|
||||||
|
Command<CMD_REMOVE_ROAD_STOP>::Post(str, CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, RoadStopType::Truck, _ctrl_pressed);
|
||||||
} else {
|
} else {
|
||||||
PlaceRoadStop(start_tile, end_tile, ROADSTOP_TRUCK, _ctrl_pressed, _cur_roadtype, GetRoadTypeInfo(this->roadtype)->strings.err_build_station[ROADSTOP_TRUCK]);
|
StringID str = GetRoadTypeInfo(this->roadtype)->strings.err_build_station[to_underlying(RoadStopType::Truck)];
|
||||||
|
PlaceRoadStop(start_tile, end_tile, RoadStopType::Truck, _ctrl_pressed, _cur_roadtype, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1189,8 +1193,8 @@ public:
|
|||||||
if (IsWaypointClass(cls)) continue;
|
if (IsWaypointClass(cls)) continue;
|
||||||
for (const auto *spec : cls.Specs()) {
|
for (const auto *spec : cls.Specs()) {
|
||||||
if (spec == nullptr) continue;
|
if (spec == nullptr) continue;
|
||||||
if (roadstoptype == ROADSTOP_TRUCK && spec->stop_type != ROADSTOPTYPE_FREIGHT && spec->stop_type != ROADSTOPTYPE_ALL) continue;
|
if (roadstoptype == RoadStopType::Truck && spec->stop_type != ROADSTOPTYPE_FREIGHT && spec->stop_type != ROADSTOPTYPE_ALL) continue;
|
||||||
if (roadstoptype == ROADSTOP_BUS && spec->stop_type != ROADSTOPTYPE_PASSENGER && spec->stop_type != ROADSTOPTYPE_ALL) continue;
|
if (roadstoptype == RoadStopType::Bus && spec->stop_type != ROADSTOPTYPE_PASSENGER && spec->stop_type != ROADSTOPTYPE_ALL) continue;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1223,25 +1227,25 @@ public:
|
|||||||
StringID GetTypeName(int cls_id, int id) const override
|
StringID GetTypeName(int cls_id, int id) const override
|
||||||
{
|
{
|
||||||
const auto *spec = this->GetSpec(cls_id, id);
|
const auto *spec = this->GetSpec(cls_id, id);
|
||||||
if (!IsRoadStopEverAvailable(spec, roadstoptype == ROADSTOP_BUS ? StationType::Bus : StationType::Truck)) return INVALID_STRING_ID;
|
if (!IsRoadStopEverAvailable(spec, roadstoptype == RoadStopType::Bus ? StationType::Bus : StationType::Truck)) return INVALID_STRING_ID;
|
||||||
return (spec == nullptr) ? STR_STATION_CLASS_DFLT_ROADSTOP : spec->name;
|
return (spec == nullptr) ? STR_STATION_CLASS_DFLT_ROADSTOP : spec->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsTypeAvailable(int cls_id, int id) const override
|
bool IsTypeAvailable(int cls_id, int id) const override
|
||||||
{
|
{
|
||||||
const auto *spec = this->GetSpec(cls_id, id);
|
const auto *spec = this->GetSpec(cls_id, id);
|
||||||
return IsRoadStopAvailable(spec, roadstoptype == ROADSTOP_BUS ? StationType::Bus : StationType::Truck);
|
return IsRoadStopAvailable(spec, roadstoptype == RoadStopType::Bus ? StationType::Bus : StationType::Truck);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawType(int x, int y, int cls_id, int id) const override
|
void DrawType(int x, int y, int cls_id, int id) const override
|
||||||
{
|
{
|
||||||
const auto *spec = this->GetSpec(cls_id, id);
|
const auto *spec = this->GetSpec(cls_id, id);
|
||||||
if (spec == nullptr) {
|
if (spec == nullptr) {
|
||||||
StationPickerDrawSprite(x, y, roadstoptype == ROADSTOP_BUS ? StationType::Bus : StationType::Truck, INVALID_RAILTYPE, _cur_roadtype, _roadstop_gui.orientation);
|
StationPickerDrawSprite(x, y, roadstoptype == RoadStopType::Bus ? StationType::Bus : StationType::Truck, INVALID_RAILTYPE, _cur_roadtype, _roadstop_gui.orientation);
|
||||||
} else {
|
} else {
|
||||||
DiagDirection orientation = _roadstop_gui.orientation;
|
DiagDirection orientation = _roadstop_gui.orientation;
|
||||||
if (orientation < DIAGDIR_END && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) orientation = DIAGDIR_END;
|
if (orientation < DIAGDIR_END && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) orientation = DIAGDIR_END;
|
||||||
DrawRoadStopTile(x, y, _cur_roadtype, spec, roadstoptype == ROADSTOP_BUS ? StationType::Bus : StationType::Truck, (uint8_t)orientation);
|
DrawRoadStopTile(x, y, _cur_roadtype, spec, roadstoptype == RoadStopType::Bus ? StationType::Bus : StationType::Truck, (uint8_t)orientation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1249,31 +1253,31 @@ public:
|
|||||||
{
|
{
|
||||||
for (const Station *st : Station::Iterate()) {
|
for (const Station *st : Station::Iterate()) {
|
||||||
if (st->owner != _local_company) continue;
|
if (st->owner != _local_company) continue;
|
||||||
if (roadstoptype == ROADSTOP_TRUCK && !(st->facilities & FACIL_TRUCK_STOP)) continue;
|
if (roadstoptype == RoadStopType::Truck && !(st->facilities & FACIL_TRUCK_STOP)) continue;
|
||||||
if (roadstoptype == ROADSTOP_BUS && !(st->facilities & FACIL_BUS_STOP)) continue;
|
if (roadstoptype == RoadStopType::Bus && !(st->facilities & FACIL_BUS_STOP)) continue;
|
||||||
items.insert({0, 0, ROADSTOP_CLASS_DFLT, 0}); // We would need to scan the map to find out if default is used.
|
items.insert({0, 0, ROADSTOP_CLASS_DFLT, 0}); // We would need to scan the map to find out if default is used.
|
||||||
for (const auto &sm : st->roadstop_speclist) {
|
for (const auto &sm : st->roadstop_speclist) {
|
||||||
if (sm.spec == nullptr) continue;
|
if (sm.spec == nullptr) continue;
|
||||||
if (roadstoptype == ROADSTOP_TRUCK && sm.spec->stop_type != ROADSTOPTYPE_FREIGHT && sm.spec->stop_type != ROADSTOPTYPE_ALL) continue;
|
if (roadstoptype == RoadStopType::Truck && sm.spec->stop_type != ROADSTOPTYPE_FREIGHT && sm.spec->stop_type != ROADSTOPTYPE_ALL) continue;
|
||||||
if (roadstoptype == ROADSTOP_BUS && sm.spec->stop_type != ROADSTOPTYPE_PASSENGER && sm.spec->stop_type != ROADSTOPTYPE_ALL) continue;
|
if (roadstoptype == RoadStopType::Bus && sm.spec->stop_type != ROADSTOPTYPE_PASSENGER && sm.spec->stop_type != ROADSTOPTYPE_ALL) continue;
|
||||||
items.insert({sm.grfid, sm.localidx, sm.spec->class_index, sm.spec->index});
|
items.insert({sm.grfid, sm.localidx, sm.spec->class_index, sm.spec->index});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <> StringID RoadStopPickerCallbacks<ROADSTOP_BUS>::GetClassTooltip() const { return STR_PICKER_ROADSTOP_BUS_CLASS_TOOLTIP; }
|
template <> StringID RoadStopPickerCallbacks<RoadStopType::Bus>::GetClassTooltip() const { return STR_PICKER_ROADSTOP_BUS_CLASS_TOOLTIP; }
|
||||||
template <> StringID RoadStopPickerCallbacks<ROADSTOP_BUS>::GetTypeTooltip() const { return STR_PICKER_ROADSTOP_BUS_TYPE_TOOLTIP; }
|
template <> StringID RoadStopPickerCallbacks<RoadStopType::Bus>::GetTypeTooltip() const { return STR_PICKER_ROADSTOP_BUS_TYPE_TOOLTIP; }
|
||||||
|
|
||||||
template <> StringID RoadStopPickerCallbacks<ROADSTOP_TRUCK>::GetClassTooltip() const { return STR_PICKER_ROADSTOP_TRUCK_CLASS_TOOLTIP; }
|
template <> StringID RoadStopPickerCallbacks<RoadStopType::Truck>::GetClassTooltip() const { return STR_PICKER_ROADSTOP_TRUCK_CLASS_TOOLTIP; }
|
||||||
template <> StringID RoadStopPickerCallbacks<ROADSTOP_TRUCK>::GetTypeTooltip() const { return STR_PICKER_ROADSTOP_TRUCK_TYPE_TOOLTIP; }
|
template <> StringID RoadStopPickerCallbacks<RoadStopType::Truck>::GetTypeTooltip() const { return STR_PICKER_ROADSTOP_TRUCK_TYPE_TOOLTIP; }
|
||||||
|
|
||||||
static RoadStopPickerCallbacks<ROADSTOP_BUS> _bus_callback_instance("fav_passenger_roadstops");
|
static RoadStopPickerCallbacks<RoadStopType::Bus> _bus_callback_instance("fav_passenger_roadstops");
|
||||||
static RoadStopPickerCallbacks<ROADSTOP_TRUCK> _truck_callback_instance("fav_freight_roadstops");
|
static RoadStopPickerCallbacks<RoadStopType::Truck> _truck_callback_instance("fav_freight_roadstops");
|
||||||
|
|
||||||
static PickerCallbacks &GetRoadStopPickerCallbacks(RoadStopType rs)
|
static PickerCallbacks &GetRoadStopPickerCallbacks(RoadStopType rs)
|
||||||
{
|
{
|
||||||
return rs == ROADSTOP_BUS ? static_cast<PickerCallbacks &>(_bus_callback_instance) : static_cast<PickerCallbacks &>(_truck_callback_instance);
|
return rs == RoadStopType::Bus ? static_cast<PickerCallbacks &>(_bus_callback_instance) : static_cast<PickerCallbacks &>(_truck_callback_instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BuildRoadStationWindow : public PickerWindow {
|
struct BuildRoadStationWindow : public PickerWindow {
|
||||||
@ -1314,16 +1318,16 @@ public:
|
|||||||
this->ConstructWindow();
|
this->ConstructWindow();
|
||||||
|
|
||||||
const RoadTypeInfo *rti = GetRoadTypeInfo(_cur_roadtype);
|
const RoadTypeInfo *rti = GetRoadTypeInfo(_cur_roadtype);
|
||||||
this->GetWidget<NWidgetCore>(WID_BROS_CAPTION)->SetString(rti->strings.picker_title[rs]);
|
this->GetWidget<NWidgetCore>(WID_BROS_CAPTION)->SetString(rti->strings.picker_title[to_underlying(rs)]);
|
||||||
|
|
||||||
for (WidgetID i = RoadTypeIsTram(_cur_roadtype) ? WID_BROS_STATION_X : WID_BROS_STATION_NE; i < WID_BROS_LT_OFF; i++) {
|
for (WidgetID i = RoadTypeIsTram(_cur_roadtype) ? WID_BROS_STATION_X : WID_BROS_STATION_NE; i < WID_BROS_LT_OFF; i++) {
|
||||||
this->GetWidget<NWidgetCore>(i)->SetToolTip(rti->strings.picker_tooltip[rs]);
|
this->GetWidget<NWidgetCore>(i)->SetToolTip(rti->strings.picker_tooltip[to_underlying(rs)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
|
this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
|
||||||
this->LowerWidget(WID_BROS_LT_OFF + _settings_client.gui.station_show_coverage);
|
this->LowerWidget(WID_BROS_LT_OFF + _settings_client.gui.station_show_coverage);
|
||||||
|
|
||||||
this->window_class = (rs == ROADSTOP_BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
|
this->window_class = (rs == RoadStopType::Bus) ? WC_BUS_STATION : WC_TRUCK_STATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Close([[maybe_unused]] int data = 0) override
|
void Close([[maybe_unused]] int data = 0) override
|
||||||
|
@ -902,7 +902,7 @@ static Trackdir RoadFindPathToDest(RoadVehicle *v, TileIndex tile, DiagDirection
|
|||||||
trackdirs = TRACKDIR_BIT_NONE;
|
trackdirs = TRACKDIR_BIT_NONE;
|
||||||
} else {
|
} else {
|
||||||
/* Our station */
|
/* Our station */
|
||||||
RoadStopType rstype = v->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK;
|
RoadStopType rstype = v->IsBus() ? RoadStopType::Bus : RoadStopType::Truck;
|
||||||
|
|
||||||
if (GetRoadStopType(tile) != rstype) {
|
if (GetRoadStopType(tile) != rstype) {
|
||||||
/* Wrong station type */
|
/* Wrong station type */
|
||||||
@ -1451,7 +1451,7 @@ again:
|
|||||||
if (v->cur_speed == 0 && IsInsideMM(v->state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) &&
|
if (v->cur_speed == 0 && IsInsideMM(v->state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) &&
|
||||||
v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile)) &&
|
v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile)) &&
|
||||||
v->owner == GetTileOwner(v->tile) && !v->current_order.IsType(OT_LEAVESTATION) &&
|
v->owner == GetTileOwner(v->tile) && !v->current_order.IsType(OT_LEAVESTATION) &&
|
||||||
GetRoadStopType(v->tile) == (v->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK)) {
|
GetRoadStopType(v->tile) == (v->IsBus() ? RoadStopType::Bus : RoadStopType::Truck)) {
|
||||||
Station *st = Station::GetByTile(v->tile);
|
Station *st = Station::GetByTile(v->tile);
|
||||||
v->last_station_visited = st->index;
|
v->last_station_visited = st->index;
|
||||||
RoadVehArrivesAt(v, st);
|
RoadVehArrivesAt(v, st);
|
||||||
@ -1484,7 +1484,7 @@ again:
|
|||||||
(IsInsideMM(v->state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) &&
|
(IsInsideMM(v->state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) &&
|
||||||
v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile)) &&
|
v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile)) &&
|
||||||
v->owner == GetTileOwner(v->tile) &&
|
v->owner == GetTileOwner(v->tile) &&
|
||||||
GetRoadStopType(v->tile) == (v->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK) &&
|
GetRoadStopType(v->tile) == (v->IsBus() ? RoadStopType::Bus : RoadStopType::Truck) &&
|
||||||
v->frame == RVC_DRIVE_THROUGH_STOP_FRAME))) {
|
v->frame == RVC_DRIVE_THROUGH_STOP_FRAME))) {
|
||||||
|
|
||||||
RoadStop *rs = RoadStop::GetByTile(v->tile, GetRoadStopType(v->tile));
|
RoadStop *rs = RoadStop::GetByTile(v->tile, GetRoadStopType(v->tile));
|
||||||
|
@ -578,7 +578,7 @@ static bool NeighbourHasReachableRoad(::RoadType rt, TileIndex start_tile, DiagD
|
|||||||
EnforcePrecondition(false, IsRoadTypeAvailable(GetCurrentRoadType()));
|
EnforcePrecondition(false, IsRoadTypeAvailable(GetCurrentRoadType()));
|
||||||
|
|
||||||
DiagDirection entrance_dir = DiagdirBetweenTiles(tile, front);
|
DiagDirection entrance_dir = DiagdirBetweenTiles(tile, front);
|
||||||
RoadStopType stop_type = road_veh_type == ROADVEHTYPE_TRUCK ? ROADSTOP_TRUCK : ROADSTOP_BUS;
|
RoadStopType stop_type = road_veh_type == ROADVEHTYPE_TRUCK ? RoadStopType::Truck : RoadStopType::Bus;
|
||||||
StationID to_join = ScriptStation::IsValidStation(station_id) ? station_id : INVALID_STATION;
|
StationID to_join = ScriptStation::IsValidStation(station_id) ? station_id : INVALID_STATION;
|
||||||
return ScriptObject::Command<CMD_BUILD_ROAD_STOP>::Do(tile, 1, 1, stop_type, drive_through, entrance_dir, ScriptObject::GetRoadType(), ROADSTOP_CLASS_DFLT, 0, to_join, station_id != ScriptStation::STATION_JOIN_ADJACENT);
|
return ScriptObject::Command<CMD_BUILD_ROAD_STOP>::Do(tile, 1, 1, stop_type, drive_through, entrance_dir, ScriptObject::GetRoadType(), ROADSTOP_CLASS_DFLT, 0, to_join, station_id != ScriptStation::STATION_JOIN_ADJACENT);
|
||||||
}
|
}
|
||||||
|
@ -217,10 +217,10 @@ template <bool Tfrom, bool Tvia>
|
|||||||
if (!IsValidStation(station_id)) return false;
|
if (!IsValidStation(station_id)) return false;
|
||||||
if (!ScriptRoad::IsRoadTypeAvailable(road_type)) return false;
|
if (!ScriptRoad::IsRoadTypeAvailable(road_type)) return false;
|
||||||
|
|
||||||
for (const RoadStop *rs = ::Station::Get(station_id)->GetPrimaryRoadStop(ROADSTOP_BUS); rs != nullptr; rs = rs->next) {
|
for (const RoadStop *rs = ::Station::Get(station_id)->GetPrimaryRoadStop(RoadStopType::Bus); rs != nullptr; rs = rs->next) {
|
||||||
if (HasBit(::GetPresentRoadTypes(rs->xy), (::RoadType)road_type)) return true;
|
if (HasBit(::GetPresentRoadTypes(rs->xy), (::RoadType)road_type)) return true;
|
||||||
}
|
}
|
||||||
for (const RoadStop *rs = ::Station::Get(station_id)->GetPrimaryRoadStop(ROADSTOP_TRUCK); rs != nullptr; rs = rs->next) {
|
for (const RoadStop *rs = ::Station::Get(station_id)->GetPrimaryRoadStop(RoadStopType::Truck); rs != nullptr; rs = rs->next) {
|
||||||
if (HasBit(::GetPresentRoadTypes(rs->xy), (::RoadType)road_type)) return true;
|
if (HasBit(::GetPresentRoadTypes(rs->xy), (::RoadType)road_type)) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ void BaseStation::RemoveRoadStopTileData(TileIndex tile)
|
|||||||
*/
|
*/
|
||||||
RoadStop *Station::GetPrimaryRoadStop(const RoadVehicle *v) const
|
RoadStop *Station::GetPrimaryRoadStop(const RoadVehicle *v) const
|
||||||
{
|
{
|
||||||
RoadStop *rs = this->GetPrimaryRoadStop(v->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK);
|
RoadStop *rs = this->GetPrimaryRoadStop(v->IsBus() ? RoadStopType::Bus : RoadStopType::Truck);
|
||||||
|
|
||||||
for (; rs != nullptr; rs = rs->next) {
|
for (; rs != nullptr; rs = rs->next) {
|
||||||
/* The vehicle cannot go to this roadstop (different roadtype) */
|
/* The vehicle cannot go to this roadstop (different roadtype) */
|
||||||
|
@ -497,7 +497,7 @@ struct Station final : SpecializedStation<Station, false> {
|
|||||||
public:
|
public:
|
||||||
RoadStop *GetPrimaryRoadStop(RoadStopType type) const
|
RoadStop *GetPrimaryRoadStop(RoadStopType type) const
|
||||||
{
|
{
|
||||||
return type == ROADSTOP_BUS ? bus_stops : truck_stops;
|
return type == RoadStopType::Bus ? bus_stops : truck_stops;
|
||||||
}
|
}
|
||||||
|
|
||||||
RoadStop *GetPrimaryRoadStop(const struct RoadVehicle *v) const;
|
RoadStop *GetPrimaryRoadStop(const struct RoadVehicle *v) const;
|
||||||
|
@ -1867,7 +1867,7 @@ static CommandCost RemoveRailWaypoint(TileIndex tile, DoCommandFlag flags)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param truck_station Determines whether a stop is #ROADSTOP_BUS or #ROADSTOP_TRUCK
|
* @param truck_station Determines whether a stop is #RoadStopType::Bus or #RoadStopType::Truck
|
||||||
* @param st The Station to do the whole procedure for
|
* @param st The Station to do the whole procedure for
|
||||||
* @return a pointer to where to link a new RoadStop*
|
* @return a pointer to where to link a new RoadStop*
|
||||||
*/
|
*/
|
||||||
@ -1964,7 +1964,7 @@ CommandCost CalculateRoadStopCost(TileArea tile_area, DoCommandFlag flags, bool
|
|||||||
CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t length, RoadStopType stop_type, bool is_drive_through,
|
CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t length, RoadStopType stop_type, bool is_drive_through,
|
||||||
DiagDirection ddir, RoadType rt, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
|
DiagDirection ddir, RoadType rt, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
|
||||||
{
|
{
|
||||||
if (!ValParamRoadType(rt) || !IsValidDiagDirection(ddir) || stop_type >= ROADSTOP_END) return CMD_ERROR;
|
if (!ValParamRoadType(rt) || !IsValidDiagDirection(ddir) || stop_type >= RoadStopType::End) return CMD_ERROR;
|
||||||
bool reuse = (station_to_join != NEW_STATION);
|
bool reuse = (station_to_join != NEW_STATION);
|
||||||
if (!reuse) station_to_join = INVALID_STATION;
|
if (!reuse) station_to_join = INVALID_STATION;
|
||||||
bool distant_join = (station_to_join != INVALID_STATION);
|
bool distant_join = (station_to_join != INVALID_STATION);
|
||||||
@ -1977,8 +1977,8 @@ CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width,
|
|||||||
|
|
||||||
const RoadStopSpec *roadstopspec = cls->GetSpec(spec_index);
|
const RoadStopSpec *roadstopspec = cls->GetSpec(spec_index);
|
||||||
if (roadstopspec != nullptr) {
|
if (roadstopspec != nullptr) {
|
||||||
if (stop_type == ROADSTOP_TRUCK && roadstopspec->stop_type != ROADSTOPTYPE_FREIGHT && roadstopspec->stop_type != ROADSTOPTYPE_ALL) return CMD_ERROR;
|
if (stop_type == RoadStopType::Truck && roadstopspec->stop_type != ROADSTOPTYPE_FREIGHT && roadstopspec->stop_type != ROADSTOPTYPE_ALL) return CMD_ERROR;
|
||||||
if (stop_type == ROADSTOP_BUS && roadstopspec->stop_type != ROADSTOPTYPE_PASSENGER && roadstopspec->stop_type != ROADSTOPTYPE_ALL) return CMD_ERROR;
|
if (stop_type == RoadStopType::Bus && roadstopspec->stop_type != ROADSTOPTYPE_PASSENGER && roadstopspec->stop_type != ROADSTOPTYPE_ALL) return CMD_ERROR;
|
||||||
if (!is_drive_through && HasBit(roadstopspec->flags, RSF_DRIVE_THROUGH_ONLY)) return CMD_ERROR;
|
if (!is_drive_through && HasBit(roadstopspec->flags, RSF_DRIVE_THROUGH_ONLY)) return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2001,7 +2001,7 @@ CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width,
|
|||||||
CommandCost ret = CheckIfAuthorityAllowsNewStation(tile, flags);
|
CommandCost ret = CheckIfAuthorityAllowsNewStation(tile, flags);
|
||||||
if (ret.Failed()) return ret;
|
if (ret.Failed()) return ret;
|
||||||
|
|
||||||
bool is_truck_stop = stop_type != ROADSTOP_BUS;
|
bool is_truck_stop = stop_type != RoadStopType::Bus;
|
||||||
|
|
||||||
/* Total road stop cost. */
|
/* Total road stop cost. */
|
||||||
Money unit_cost;
|
Money unit_cost;
|
||||||
@ -2073,7 +2073,7 @@ CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width,
|
|||||||
|
|
||||||
st->rect.BeforeAddTile(cur_tile, StationRect::ADD_TRY);
|
st->rect.BeforeAddTile(cur_tile, StationRect::ADD_TRY);
|
||||||
|
|
||||||
RoadStopType rs_type = is_truck_stop ? ROADSTOP_TRUCK : ROADSTOP_BUS;
|
RoadStopType rs_type = is_truck_stop ? RoadStopType::Truck : RoadStopType::Bus;
|
||||||
if (is_drive_through) {
|
if (is_drive_through) {
|
||||||
/* Update company infrastructure counts. If the current tile is a normal road tile, remove the old
|
/* Update company infrastructure counts. If the current tile is a normal road tile, remove the old
|
||||||
* bits first. */
|
* bits first. */
|
||||||
@ -2085,7 +2085,7 @@ CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width,
|
|||||||
if (road_rt == INVALID_ROADTYPE && RoadTypeIsRoad(rt)) road_rt = rt;
|
if (road_rt == INVALID_ROADTYPE && RoadTypeIsRoad(rt)) road_rt = rt;
|
||||||
if (tram_rt == INVALID_ROADTYPE && RoadTypeIsTram(rt)) tram_rt = rt;
|
if (tram_rt == INVALID_ROADTYPE && RoadTypeIsTram(rt)) tram_rt = rt;
|
||||||
|
|
||||||
MakeDriveThroughRoadStop(cur_tile, st->owner, road_owner, tram_owner, st->index, (rs_type == ROADSTOP_BUS ? StationType::Bus : StationType::Truck), road_rt, tram_rt, axis);
|
MakeDriveThroughRoadStop(cur_tile, st->owner, road_owner, tram_owner, st->index, (rs_type == RoadStopType::Bus ? StationType::Bus : StationType::Truck), road_rt, tram_rt, axis);
|
||||||
road_stop->MakeDriveThrough();
|
road_stop->MakeDriveThrough();
|
||||||
} else {
|
} else {
|
||||||
if (road_rt == INVALID_ROADTYPE && RoadTypeIsRoad(rt)) road_rt = rt;
|
if (road_rt == INVALID_ROADTYPE && RoadTypeIsRoad(rt)) road_rt = rt;
|
||||||
@ -2152,10 +2152,10 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags, int repla
|
|||||||
RoadStop *cur_stop;
|
RoadStop *cur_stop;
|
||||||
if (is_truck) { // truck stop
|
if (is_truck) { // truck stop
|
||||||
primary_stop = &st->truck_stops;
|
primary_stop = &st->truck_stops;
|
||||||
cur_stop = RoadStop::GetByTile(tile, ROADSTOP_TRUCK);
|
cur_stop = RoadStop::GetByTile(tile, RoadStopType::Truck);
|
||||||
} else {
|
} else {
|
||||||
primary_stop = &st->bus_stops;
|
primary_stop = &st->bus_stops;
|
||||||
cur_stop = RoadStop::GetByTile(tile, ROADSTOP_BUS);
|
cur_stop = RoadStop::GetByTile(tile, RoadStopType::Bus);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(cur_stop != nullptr);
|
assert(cur_stop != nullptr);
|
||||||
@ -2380,7 +2380,7 @@ static CommandCost RemoveGenericRoadStop(DoCommandFlag flags, const TileArea &ro
|
|||||||
*/
|
*/
|
||||||
CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t height, RoadStopType stop_type, bool remove_road)
|
CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t height, RoadStopType stop_type, bool remove_road)
|
||||||
{
|
{
|
||||||
if (stop_type >= ROADSTOP_END) return CMD_ERROR;
|
if (stop_type >= RoadStopType::End) return CMD_ERROR;
|
||||||
/* Check for incorrect width / height. */
|
/* Check for incorrect width / height. */
|
||||||
if (width == 0 || height == 0) return CMD_ERROR;
|
if (width == 0 || height == 0) return CMD_ERROR;
|
||||||
/* Check if the first tile and the last tile are valid */
|
/* Check if the first tile and the last tile are valid */
|
||||||
@ -2390,7 +2390,7 @@ CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width
|
|||||||
|
|
||||||
TileArea roadstop_area(tile, width, height);
|
TileArea roadstop_area(tile, width, height);
|
||||||
|
|
||||||
return RemoveGenericRoadStop(flags, roadstop_area, stop_type == ROADSTOP_BUS ? StationType::Bus : StationType::Truck, remove_road);
|
return RemoveGenericRoadStop(flags, roadstop_area, stop_type == RoadStopType::Bus ? StationType::Bus : StationType::Truck, remove_road);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -4637,7 +4637,7 @@ static void ChangeTileOwner_Station(TileIndex tile, Owner old_owner, Owner new_o
|
|||||||
if (IsRoadWaypoint(tile)) {
|
if (IsRoadWaypoint(tile)) {
|
||||||
Command<CMD_REMOVE_FROM_ROAD_WAYPOINT>::Do(DC_EXEC | DC_BANKRUPT, tile, tile);
|
Command<CMD_REMOVE_FROM_ROAD_WAYPOINT>::Do(DC_EXEC | DC_BANKRUPT, tile, tile);
|
||||||
} else {
|
} else {
|
||||||
Command<CMD_REMOVE_ROAD_STOP>::Do(DC_EXEC | DC_BANKRUPT, tile, 1, 1, (GetStationType(tile) == StationType::Truck) ? ROADSTOP_TRUCK : ROADSTOP_BUS, false);
|
Command<CMD_REMOVE_ROAD_STOP>::Do(DC_EXEC | DC_BANKRUPT, tile, 1, 1, (GetStationType(tile) == StationType::Truck) ? RoadStopType::Truck : RoadStopType::Bus, false);
|
||||||
}
|
}
|
||||||
assert(IsTileType(tile, MP_ROAD));
|
assert(IsTileType(tile, MP_ROAD));
|
||||||
/* Change owner of tile and all roadtypes */
|
/* Change owner of tile and all roadtypes */
|
||||||
|
@ -56,7 +56,7 @@ inline StationType GetStationType(Tile t)
|
|||||||
inline RoadStopType GetRoadStopType(Tile t)
|
inline RoadStopType GetRoadStopType(Tile t)
|
||||||
{
|
{
|
||||||
assert(GetStationType(t) == StationType::Truck || GetStationType(t) == StationType::Bus);
|
assert(GetStationType(t) == StationType::Truck || GetStationType(t) == StationType::Bus);
|
||||||
return GetStationType(t) == StationType::Truck ? ROADSTOP_TRUCK : ROADSTOP_BUS;
|
return GetStationType(t) == StationType::Truck ? RoadStopType::Truck : RoadStopType::Bus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -774,7 +774,7 @@ inline void MakeRailWaypoint(Tile t, Owner o, StationID sid, Axis a, uint8_t sec
|
|||||||
*/
|
*/
|
||||||
inline void MakeRoadStop(Tile t, Owner o, StationID sid, RoadStopType rst, RoadType road_rt, RoadType tram_rt, DiagDirection d)
|
inline void MakeRoadStop(Tile t, Owner o, StationID sid, RoadStopType rst, RoadType road_rt, RoadType tram_rt, DiagDirection d)
|
||||||
{
|
{
|
||||||
MakeStation(t, o, sid, (rst == ROADSTOP_BUS ? StationType::Bus : StationType::Truck), d);
|
MakeStation(t, o, sid, (rst == RoadStopType::Bus ? StationType::Bus : StationType::Truck), d);
|
||||||
SetRoadTypes(t, road_rt, tram_rt);
|
SetRoadTypes(t, road_rt, tram_rt);
|
||||||
SetRoadOwner(t, RTT_ROAD, o);
|
SetRoadOwner(t, RTT_ROAD, o);
|
||||||
SetRoadOwner(t, RTT_TRAM, o);
|
SetRoadOwner(t, RTT_TRAM, o);
|
||||||
|
@ -42,10 +42,10 @@ enum class StationType : uint8_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Types of RoadStops */
|
/** Types of RoadStops */
|
||||||
enum RoadStopType : uint8_t {
|
enum class RoadStopType : uint8_t {
|
||||||
ROADSTOP_BUS, ///< A standard stop for buses
|
Bus, ///< A standard stop for buses
|
||||||
ROADSTOP_TRUCK, ///< A standard stop for trucks
|
Truck, ///< A standard stop for trucks
|
||||||
ROADSTOP_END, ///< End of valid types
|
End, ///< End of valid types
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The facilities a station might be having */
|
/** The facilities a station might be having */
|
||||||
|
@ -3109,7 +3109,7 @@ StringID GetVehicleCannotUseStationReason(const Vehicle *v, const Station *st)
|
|||||||
|
|
||||||
case VEH_ROAD: {
|
case VEH_ROAD: {
|
||||||
const RoadVehicle *rv = RoadVehicle::From(v);
|
const RoadVehicle *rv = RoadVehicle::From(v);
|
||||||
RoadStop *rs = st->GetPrimaryRoadStop(rv->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK);
|
RoadStop *rs = st->GetPrimaryRoadStop(rv->IsBus() ? RoadStopType::Bus : RoadStopType::Truck);
|
||||||
|
|
||||||
StringID err = rv->IsBus() ? STR_ERROR_NO_BUS_STATION : STR_ERROR_NO_TRUCK_STATION;
|
StringID err = rv->IsBus() ? STR_ERROR_NO_BUS_STATION : STR_ERROR_NO_TRUCK_STATION;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user