mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-21 19:32:54 +01:00
Codechange: Use EnumBitSet for RoadStopSpecFlags.
This commit is contained in:
committed by
Peter Nelson
parent
1a6e7f2162
commit
17f6da413d
@@ -83,8 +83,8 @@ static bool IsRoadStopEverAvailable(const RoadStopSpec *spec, StationType type)
|
||||
{
|
||||
if (spec == nullptr) return true;
|
||||
|
||||
if (HasBit(spec->flags, RSF_BUILD_MENU_ROAD_ONLY) && !RoadTypeIsRoad(_cur_roadtype)) return false;
|
||||
if (HasBit(spec->flags, RSF_BUILD_MENU_TRAM_ONLY) && !RoadTypeIsTram(_cur_roadtype)) return false;
|
||||
if (spec->flags.Test(RoadStopSpecFlag::RoadOnly) && !RoadTypeIsRoad(_cur_roadtype)) return false;
|
||||
if (spec->flags.Test(RoadStopSpecFlag::TramOnly) && !RoadTypeIsTram(_cur_roadtype)) return false;
|
||||
|
||||
switch (spec->stop_type) {
|
||||
case ROADSTOPTYPE_ALL: return true;
|
||||
@@ -202,7 +202,7 @@ void CcRoadStop(Commands, const CommandCost &result, TileIndex tile, uint8_t wid
|
||||
bool connect_to_road = true;
|
||||
if ((uint)spec_class < RoadStopClass::GetClassCount() && spec_index < RoadStopClass::Get(spec_class)->GetSpecCount()) {
|
||||
const RoadStopSpec *roadstopspec = RoadStopClass::Get(spec_class)->GetSpec(spec_index);
|
||||
if (roadstopspec != nullptr && HasBit(roadstopspec->flags, RSF_NO_AUTO_ROAD_CONNECTION)) connect_to_road = false;
|
||||
if (roadstopspec != nullptr && roadstopspec->flags.Test(RoadStopSpecFlag::NoAutoRoadConnection)) connect_to_road = false;
|
||||
}
|
||||
|
||||
if (connect_to_road) {
|
||||
@@ -1244,7 +1244,7 @@ public:
|
||||
StationPickerDrawSprite(x, y, roadstoptype == RoadStopType::Bus ? StationType::Bus : StationType::Truck, INVALID_RAILTYPE, _cur_roadtype, _roadstop_gui.orientation);
|
||||
} else {
|
||||
DiagDirection orientation = _roadstop_gui.orientation;
|
||||
if (orientation < DIAGDIR_END && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) orientation = DIAGDIR_END;
|
||||
if (orientation < DIAGDIR_END && spec->flags.Test(RoadStopSpecFlag::DriveThroughOnly)) orientation = DIAGDIR_END;
|
||||
DrawRoadStopTile(x, y, _cur_roadtype, spec, roadstoptype == RoadStopType::Bus ? StationType::Bus : StationType::Truck, (uint8_t)orientation);
|
||||
}
|
||||
}
|
||||
@@ -1291,13 +1291,13 @@ private:
|
||||
/* Raise and lower to ensure the correct widget is lowered after changing displayed orientation plane. */
|
||||
if (RoadTypeIsRoad(_cur_roadtype)) {
|
||||
this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
|
||||
this->GetWidget<NWidgetStacked>(WID_BROS_AVAILABLE_ORIENTATIONS)->SetDisplayedPlane((spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) ? 1 : 0);
|
||||
this->GetWidget<NWidgetStacked>(WID_BROS_AVAILABLE_ORIENTATIONS)->SetDisplayedPlane((spec != nullptr && spec->flags.Test(RoadStopSpecFlag::DriveThroughOnly)) ? 1 : 0);
|
||||
this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
|
||||
}
|
||||
|
||||
if (_roadstop_gui.orientation >= DIAGDIR_END) return;
|
||||
|
||||
if (spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) {
|
||||
if (spec != nullptr && spec->flags.Test(RoadStopSpecFlag::DriveThroughOnly)) {
|
||||
this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
|
||||
_roadstop_gui.orientation = DIAGDIR_END;
|
||||
this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
|
||||
@@ -1452,7 +1452,7 @@ public:
|
||||
case WID_BROS_STATION_Y:
|
||||
if (widget < WID_BROS_STATION_X) {
|
||||
const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui.sel_class)->GetSpec(_roadstop_gui.sel_type);
|
||||
if (spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) return;
|
||||
if (spec != nullptr && spec->flags.Test(RoadStopSpecFlag::DriveThroughOnly)) return;
|
||||
}
|
||||
this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
|
||||
_roadstop_gui.orientation = (DiagDirection)(widget - WID_BROS_STATION_NE);
|
||||
|
||||
Reference in New Issue
Block a user