1
0
Fork 0

Codechange: Make StationType an enum class. (#13339)

pull/13340/head
Peter Nelson 2025-01-19 20:53:08 +00:00 committed by GitHub
parent b0ec3d6959
commit 4397aa3909
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 196 additions and 196 deletions

View File

@ -772,10 +772,10 @@ GrfSpecFeature GetGrfSpecFeature(TileIndex tile)
case MP_STATION:
switch (GetStationType(tile)) {
case STATION_RAIL: return GSF_STATIONS;
case STATION_AIRPORT: return GSF_AIRPORTTILES;
case STATION_BUS: return GSF_ROADSTOPS;
case STATION_TRUCK: return GSF_ROADSTOPS;
case StationType::Rail: return GSF_STATIONS;
case StationType::Airport: return GSF_AIRPORTTILES;
case StationType::Bus: return GSF_ROADSTOPS;
case StationType::Truck: return GSF_ROADSTOPS;
default: return GSF_INVALID;
}
}

View File

@ -86,8 +86,8 @@ uint32_t RoadStopScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] u
/* Stop type: 0: bus, 1: truck, 2: waypoint */
case 0x41:
if (this->type == STATION_BUS) return 0;
if (this->type == STATION_TRUCK) return 1;
if (this->type == StationType::Bus) return 0;
if (this->type == StationType::Truck) return 1;
return 2;
/* Terrain type */
@ -159,8 +159,8 @@ uint32_t RoadStopScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] u
bool same_station = GetStationIndex(nearby_tile) == this->st->index;
uint32_t res = GetStationGfx(nearby_tile) << 12 | !same_orientation << 11 | !!same_station << 10;
StationType type = GetStationType(nearby_tile);
if (type == STATION_TRUCK) res |= (1 << 16);
if (type == STATION_ROADWAYPOINT) res |= (2 << 16);
if (type == StationType::Truck) res |= (1 << 16);
if (type == StationType::RoadWaypoint) res |= (2 << 16);
if (type == this->type) SetBit(res, 20);
if (IsCustomRoadStopSpecIndex(nearby_tile)) {
@ -301,7 +301,7 @@ void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec,
draw_mode = spec->draw_mode;
}
if (type == STATION_ROADWAYPOINT) {
if (type == StationType::RoadWaypoint) {
DrawSprite(SPR_ROAD_PAVED_STRAIGHT_X, PAL_NONE, x, y);
if ((draw_mode & ROADSTOP_DRAW_MODE_WAYP_GROUND) && GB(image, 0, SPRITE_WIDTH) != 0) {
DrawSprite(image, GroundSpritePaletteTransform(image, pal, palette), x, y);
@ -315,7 +315,7 @@ void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec,
uint sprite_offset = 5 - view;
/* Road underlay takes precedence over tram */
if (type == STATION_ROADWAYPOINT || draw_mode & ROADSTOP_DRAW_MODE_OVERLAY) {
if (type == StationType::RoadWaypoint || draw_mode & ROADSTOP_DRAW_MODE_OVERLAY) {
if (rti->UsesOverlay()) {
SpriteID ground = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_GROUND);
DrawSprite(ground + sprite_offset, PAL_NONE, x, y);

View File

@ -82,7 +82,7 @@ struct ETileArea : TileArea {
}
case TA_WHOLE:
st->GetTileArea(this, Station::IsExpected(st) ? STATION_RAIL : STATION_WAYPOINT);
st->GetTileArea(this, Station::IsExpected(st) ? StationType::Rail : StationType::RailWaypoint);
break;
}
}
@ -797,7 +797,7 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID
DrawTileSprites tmp_rail_layout;
if (statspec->renderdata.empty()) {
sprites = GetStationTileLayout(STATION_RAIL, tile + axis);
sprites = GetStationTileLayout(StationType::Rail, tile + axis);
} else {
layout = &statspec->renderdata[(tile < statspec->renderdata.size()) ? tile + axis : (uint)axis];
if (!layout->NeedsPreprocessing()) {

View File

@ -146,7 +146,7 @@ public:
[[fallthrough]];
case OT_GOTO_STATION:
this->dest_tile = CalcClosestStationTile(v->current_order.GetDestination(), v->tile, v->current_order.IsType(OT_GOTO_STATION) ? STATION_RAIL : STATION_WAYPOINT);
this->dest_tile = CalcClosestStationTile(v->current_order.GetDestination(), v->tile, v->current_order.IsType(OT_GOTO_STATION) ? StationType::Rail : StationType::RailWaypoint);
this->dest_station_id = v->current_order.GetDestination();
this->dest_trackdirs = INVALID_TRACKDIR_BIT;
break;

View File

@ -242,13 +242,13 @@ public:
{
if (v->current_order.IsType(OT_GOTO_STATION)) {
this->dest_station = v->current_order.GetDestination();
this->station_type = v->IsBus() ? STATION_BUS : STATION_TRUCK;
this->station_type = v->IsBus() ? StationType::Bus : StationType::Truck;
this->dest_tile = CalcClosestStationTile(this->dest_station, v->tile, this->station_type);
this->non_artic = !v->HasArticulatedPart();
this->dest_trackdirs = INVALID_TRACKDIR_BIT;
} else if (v->current_order.IsType(OT_GOTO_WAYPOINT)) {
this->dest_station = v->current_order.GetDestination();
this->station_type = STATION_ROADWAYPOINT;
this->station_type = StationType::RoadWaypoint;
this->dest_tile = CalcClosestStationTile(this->dest_station, v->tile, this->station_type);
this->non_artic = !v->HasArticulatedPart();
this->dest_trackdirs = INVALID_TRACKDIR_BIT;

View File

@ -46,7 +46,7 @@ public:
{
if (v->current_order.IsType(OT_GOTO_STATION)) {
this->dest_station = v->current_order.GetDestination();
this->dest_tile = CalcClosestStationTile(this->dest_station, v->tile, STATION_DOCK);
this->dest_tile = CalcClosestStationTile(this->dest_station, v->tile, StationType::Dock);
this->dest_trackdirs = INVALID_TRACKDIR_BIT;
} else {
this->dest_station = INVALID_STATION;

View File

@ -188,7 +188,7 @@ public:
DestinationID station_id = v->current_order.GetDestination();
const BaseStation *station = BaseStation::Get(station_id);
TileArea tile_area;
station->GetTileArea(&tile_area, STATION_DOCK);
station->GetTileArea(&tile_area, StationType::Dock);
for (const auto &tile : tile_area) {
if (IsDockingTile(tile) && IsShipDestinationTile(tile, station_id)) {
pf.AddOrigin(GetWaterRegionPatchInfo(tile));

View File

@ -1015,7 +1015,7 @@ public:
void DrawType(int x, int y, int cls_id, int id) const override
{
if (!DrawStationTile(x, y, _cur_railtype, _station_gui.axis, this->GetClassIndex(cls_id), id)) {
StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2 + _station_gui.axis);
StationPickerDrawSprite(x, y, StationType::Rail, _cur_railtype, INVALID_ROADTYPE, 2 + _station_gui.axis);
}
}
@ -1194,7 +1194,7 @@ public:
int x = (ir.Width() - ScaleSpriteTrad(PREVIEW_WIDTH)) / 2 + ScaleSpriteTrad(PREVIEW_LEFT);
int y = (ir.Height() + ScaleSpriteTrad(PREVIEW_HEIGHT)) / 2 - ScaleSpriteTrad(PREVIEW_BOTTOM);
if (!DrawStationTile(x, y, _cur_railtype, AXIS_X, _station_gui.sel_class, _station_gui.sel_type)) {
StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2);
StationPickerDrawSprite(x, y, StationType::Rail, _cur_railtype, INVALID_ROADTYPE, 2);
}
}
break;
@ -1208,7 +1208,7 @@ public:
int x = (ir.Width() - ScaleSpriteTrad(PREVIEW_WIDTH)) / 2 + ScaleSpriteTrad(PREVIEW_LEFT);
int y = (ir.Height() + ScaleSpriteTrad(PREVIEW_HEIGHT)) / 2 - ScaleSpriteTrad(PREVIEW_BOTTOM);
if (!DrawStationTile(x, y, _cur_railtype, AXIS_Y, _station_gui.sel_class, _station_gui.sel_type)) {
StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 3);
StationPickerDrawSprite(x, y, StationType::Rail, _cur_railtype, INVALID_ROADTYPE, 3);
}
}
break;

View File

@ -88,8 +88,8 @@ static bool IsRoadStopEverAvailable(const RoadStopSpec *spec, StationType type)
switch (spec->stop_type) {
case ROADSTOPTYPE_ALL: return true;
case ROADSTOPTYPE_PASSENGER: return type == STATION_BUS;
case ROADSTOPTYPE_FREIGHT: return type == STATION_TRUCK;
case ROADSTOPTYPE_PASSENGER: return type == StationType::Bus;
case ROADSTOPTYPE_FREIGHT: return type == StationType::Truck;
default: NOT_REACHED();
}
}
@ -1223,25 +1223,25 @@ public:
StringID GetTypeName(int cls_id, int id) const override
{
const auto *spec = this->GetSpec(cls_id, id);
if (!IsRoadStopEverAvailable(spec, roadstoptype == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK)) return INVALID_STRING_ID;
if (!IsRoadStopEverAvailable(spec, roadstoptype == ROADSTOP_BUS ? StationType::Bus : StationType::Truck)) return INVALID_STRING_ID;
return (spec == nullptr) ? STR_STATION_CLASS_DFLT_ROADSTOP : spec->name;
}
bool IsTypeAvailable(int cls_id, int id) const override
{
const auto *spec = this->GetSpec(cls_id, id);
return IsRoadStopAvailable(spec, roadstoptype == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK);
return IsRoadStopAvailable(spec, roadstoptype == ROADSTOP_BUS ? StationType::Bus : StationType::Truck);
}
void DrawType(int x, int y, int cls_id, int id) const override
{
const auto *spec = this->GetSpec(cls_id, id);
if (spec == nullptr) {
StationPickerDrawSprite(x, y, roadstoptype == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK, INVALID_RAILTYPE, _cur_roadtype, _roadstop_gui.orientation);
StationPickerDrawSprite(x, y, roadstoptype == ROADSTOP_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;
DrawRoadStopTile(x, y, _cur_roadtype, spec, roadstoptype == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK, (uint8_t)orientation);
DrawRoadStopTile(x, y, _cur_roadtype, spec, roadstoptype == ROADSTOP_BUS ? StationType::Bus : StationType::Truck, (uint8_t)orientation);
}
}
@ -1398,8 +1398,8 @@ public:
StationType GetRoadStationTypeByWindowClass(WindowClass window_class) const
{
switch (window_class) {
case WC_BUS_STATION: return STATION_BUS;
case WC_TRUCK_STATION: return STATION_TRUCK;
case WC_BUS_STATION: return StationType::Bus;
case WC_TRUCK_STATION: return StationType::Truck;
default: NOT_REACHED();
}
}
@ -1639,16 +1639,16 @@ public:
bool IsTypeAvailable(int cls_id, int id) const override
{
return IsRoadStopAvailable(this->GetSpec(cls_id, id), STATION_ROADWAYPOINT);
return IsRoadStopAvailable(this->GetSpec(cls_id, id), StationType::RoadWaypoint);
}
void DrawType(int x, int y, int cls_id, int id) const override
{
const auto *spec = this->GetSpec(cls_id, id);
if (spec == nullptr) {
StationPickerDrawSprite(x, y, STATION_ROADWAYPOINT, INVALID_RAILTYPE, _cur_roadtype, RSV_DRIVE_THROUGH_X);
StationPickerDrawSprite(x, y, StationType::RoadWaypoint, INVALID_RAILTYPE, _cur_roadtype, RSV_DRIVE_THROUGH_X);
} else {
DrawRoadStopTile(x, y, _cur_roadtype, spec, STATION_ROADWAYPOINT, RSV_DRIVE_THROUGH_X);
DrawRoadStopTile(x, y, _cur_roadtype, spec, StationType::RoadWaypoint, RSV_DRIVE_THROUGH_X);
}
}

View File

@ -878,41 +878,41 @@ bool AfterLoadGame()
StationGfx gfx = GetStationGfx(t);
StationType st;
if ( IsInsideMM(gfx, 0, 8)) { // Rail station
st = STATION_RAIL;
st = StationType::Rail;
SetStationGfx(t, gfx - 0);
} else if (IsInsideMM(gfx, 8, 67)) { // Airport
st = STATION_AIRPORT;
st = StationType::Airport;
SetStationGfx(t, gfx - 8);
} else if (IsInsideMM(gfx, 67, 71)) { // Truck
st = STATION_TRUCK;
st = StationType::Truck;
SetStationGfx(t, gfx - 67);
} else if (IsInsideMM(gfx, 71, 75)) { // Bus
st = STATION_BUS;
st = StationType::Bus;
SetStationGfx(t, gfx - 71);
} else if (gfx == 75) { // Oil rig
st = STATION_OILRIG;
st = StationType::Oilrig;
SetStationGfx(t, gfx - 75);
} else if (IsInsideMM(gfx, 76, 82)) { // Dock
st = STATION_DOCK;
st = StationType::Dock;
SetStationGfx(t, gfx - 76);
} else if (gfx == 82) { // Buoy
st = STATION_BUOY;
st = StationType::Buoy;
SetStationGfx(t, gfx - 82);
} else if (IsInsideMM(gfx, 83, 168)) { // Extended airport
st = STATION_AIRPORT;
st = StationType::Airport;
SetStationGfx(t, gfx - 83 + 67 - 8);
} else if (IsInsideMM(gfx, 168, 170)) { // Drive through truck
st = STATION_TRUCK;
st = StationType::Truck;
SetStationGfx(t, gfx - 168 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
} else if (IsInsideMM(gfx, 170, 172)) { // Drive through bus
st = STATION_BUS;
st = StationType::Bus;
SetStationGfx(t, gfx - 170 + GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
} else {
/* Restore the signals */
ResetSignalHandlers();
return false;
}
SB(t.m6(), 3, 3, st);
SB(t.m6(), 3, 3, to_underlying(st));
break;
}
}
@ -944,8 +944,8 @@ bool AfterLoadGame()
Station *st = Station::From(bst);
switch (GetStationType(t)) {
case STATION_TRUCK:
case STATION_BUS:
case StationType::Truck:
case StationType::Bus:
if (IsSavegameVersionBefore(SLV_6)) {
/* Before version 5 you could not have more than 250 stations.
* Version 6 adds large maps, so you could only place 253*253
@ -966,7 +966,7 @@ bool AfterLoadGame()
}
break;
case STATION_OILRIG: {
case StationType::Oilrig: {
/* The internal encoding of oil rigs was changed twice.
* It was 3 (till 2.2) and later 5 (till 5.1).
* DeleteOilRig asserts on the correct type, and
@ -1820,9 +1820,9 @@ bool AfterLoadGame()
switch (GetTileType(t)) {
case MP_STATION:
switch (GetStationType(t)) {
case STATION_OILRIG:
case STATION_DOCK:
case STATION_BUOY:
case StationType::Oilrig:
case StationType::Dock:
case StationType::Buoy:
SetWaterClass(t, (WaterClass)GB(t.m3(), 0, 2));
SB(t.m3(), 0, 2, 0);
break;

View File

@ -142,17 +142,17 @@ void AfterLoadCompanyStats()
case MP_STATION:
c = Company::GetIfValid(GetTileOwner(tile));
if (c != nullptr && GetStationType(tile) != STATION_AIRPORT && !IsBuoy(tile)) c->infrastructure.station++;
if (c != nullptr && GetStationType(tile) != StationType::Airport && !IsBuoy(tile)) c->infrastructure.station++;
switch (GetStationType(tile)) {
case STATION_RAIL:
case STATION_WAYPOINT:
case StationType::Rail:
case StationType::RailWaypoint:
if (c != nullptr && !IsStationTileBlocked(tile)) c->infrastructure.rail[GetRailType(tile)]++;
break;
case STATION_BUS:
case STATION_TRUCK:
case STATION_ROADWAYPOINT: {
case StationType::Bus:
case StationType::Truck:
case StationType::RoadWaypoint: {
/* Iterate all present road types as each can have a different owner. */
for (RoadTramType rtt : _roadtramtypes) {
RoadType rt = GetRoadType(tile, rtt);
@ -163,8 +163,8 @@ void AfterLoadCompanyStats()
break;
}
case STATION_DOCK:
case STATION_BUOY:
case StationType::Dock:
case StationType::Buoy:
if (GetWaterClass(tile) == WATER_CLASS_CANAL) {
if (c != nullptr) c->infrastructure.water++;
}

View File

@ -95,7 +95,7 @@ void MoveBuoysToWaypoints()
Tile tile(t);
if (!IsTileType(tile, MP_STATION) || GetStationIndex(tile) != index) continue;
SB(tile.m6(), 3, 3, STATION_WAYPOINT);
SB(tile.m6(), 3, 3, to_underlying(StationType::RailWaypoint));
wp->rect.BeforeAddTile(t, StationRect::ADD_FORCE);
}

View File

@ -133,17 +133,17 @@ ScriptTileList_StationType::ScriptTileList_StationType(StationID station_id, Scr
uint station_type_value = 0;
/* Convert ScriptStation::StationType to ::StationType, but do it in a
* bitmask, so we can scan for multiple entries at the same time. */
if ((station_type & ScriptStation::STATION_TRAIN) != 0) station_type_value |= (1 << ::STATION_RAIL);
if ((station_type & ScriptStation::STATION_TRUCK_STOP) != 0) station_type_value |= (1 << ::STATION_TRUCK);
if ((station_type & ScriptStation::STATION_BUS_STOP) != 0) station_type_value |= (1 << ::STATION_BUS);
if ((station_type & ScriptStation::STATION_AIRPORT) != 0) station_type_value |= (1 << ::STATION_AIRPORT) | (1 << ::STATION_OILRIG);
if ((station_type & ScriptStation::STATION_DOCK) != 0) station_type_value |= (1 << ::STATION_DOCK) | (1 << ::STATION_OILRIG);
if ((station_type & ScriptStation::STATION_TRAIN) != 0) station_type_value |= (1 << to_underlying(::StationType::Rail));
if ((station_type & ScriptStation::STATION_TRUCK_STOP) != 0) station_type_value |= (1 << to_underlying(::StationType::Truck));
if ((station_type & ScriptStation::STATION_BUS_STOP) != 0) station_type_value |= (1 << to_underlying(::StationType::Bus));
if ((station_type & ScriptStation::STATION_AIRPORT) != 0) station_type_value |= (1 << to_underlying(::StationType::Airport)) | (1 << to_underlying(::StationType::Oilrig));
if ((station_type & ScriptStation::STATION_DOCK) != 0) station_type_value |= (1 << to_underlying(::StationType::Dock)) | (1 << to_underlying(::StationType::Oilrig));
TileArea ta(::TileXY(rect->left, rect->top), rect->Width(), rect->Height());
for (TileIndex cur_tile : ta) {
if (!::IsTileType(cur_tile, MP_STATION)) continue;
if (::GetStationIndex(cur_tile) != station_id) continue;
if (!HasBit(station_type_value, ::GetStationType(cur_tile))) continue;
if (!HasBit(station_type_value, to_underlying(::GetStationType(cur_tile)))) continue;
this->AddTile(cur_tile);
}
}

View File

@ -470,11 +470,11 @@ static inline uint32_t GetSmallMapRoutesPixels(TileIndex tile, TileType t)
switch (t) {
case MP_STATION:
switch (GetStationType(tile)) {
case STATION_RAIL: return MKCOLOUR_XXXX(PC_VERY_DARK_BROWN);
case STATION_AIRPORT: return MKCOLOUR_XXXX(PC_RED);
case STATION_TRUCK: return MKCOLOUR_XXXX(PC_ORANGE);
case STATION_BUS: return MKCOLOUR_XXXX(PC_YELLOW);
case STATION_DOCK: return MKCOLOUR_XXXX(PC_LIGHT_BLUE);
case StationType::Rail: return MKCOLOUR_XXXX(PC_VERY_DARK_BROWN);
case StationType::Airport: return MKCOLOUR_XXXX(PC_RED);
case StationType::Truck: return MKCOLOUR_XXXX(PC_ORANGE);
case StationType::Bus: return MKCOLOUR_XXXX(PC_YELLOW);
case StationType::Dock: return MKCOLOUR_XXXX(PC_LIGHT_BLUE);
default: return MKCOLOUR_FFFF;
}

View File

@ -313,24 +313,24 @@ static uint GetTileCatchmentRadius(TileIndex tile, const Station *st)
if (_settings_game.station.modified_catchment) {
switch (GetStationType(tile)) {
case STATION_RAIL: return CA_TRAIN;
case STATION_OILRIG: return CA_UNMODIFIED;
case STATION_AIRPORT: return st->airport.GetSpec()->catchment;
case STATION_TRUCK: return CA_TRUCK;
case STATION_BUS: return CA_BUS;
case STATION_DOCK: return CA_DOCK;
case StationType::Rail: return CA_TRAIN;
case StationType::Oilrig: return CA_UNMODIFIED;
case StationType::Airport: return st->airport.GetSpec()->catchment;
case StationType::Truck: return CA_TRUCK;
case StationType::Bus: return CA_BUS;
case StationType::Dock: return CA_DOCK;
default: NOT_REACHED();
case STATION_BUOY:
case STATION_WAYPOINT:
case STATION_ROADWAYPOINT: return CA_NONE;
case StationType::Buoy:
case StationType::RailWaypoint:
case StationType::RoadWaypoint: return CA_NONE;
}
} else {
switch (GetStationType(tile)) {
default: return CA_UNMODIFIED;
case STATION_BUOY:
case STATION_WAYPOINT:
case STATION_ROADWAYPOINT: return CA_NONE;
case StationType::Buoy:
case StationType::RailWaypoint:
case StationType::RoadWaypoint: return CA_NONE;
}
}
}

View File

@ -411,24 +411,24 @@ static Station *GetClosestDeletedStation(TileIndex tile)
void Station::GetTileArea(TileArea *ta, StationType type) const
{
switch (type) {
case STATION_RAIL:
case StationType::Rail:
*ta = this->train_station;
return;
case STATION_AIRPORT:
case StationType::Airport:
*ta = this->airport;
return;
case STATION_TRUCK:
case StationType::Truck:
*ta = this->truck_station;
return;
case STATION_BUS:
case StationType::Bus:
*ta = this->bus_station;
return;
case STATION_DOCK:
case STATION_OILRIG:
case StationType::Dock:
case StationType::Oilrig:
*ta = this->docking_station;
return;
@ -764,16 +764,16 @@ void Station::AfterStationTileSetChange(bool adding, StationType type)
}
switch (type) {
case STATION_RAIL:
case StationType::Rail:
SetWindowWidgetDirty(WC_STATION_VIEW, this->index, WID_SV_TRAINS);
break;
case STATION_AIRPORT:
case StationType::Airport:
break;
case STATION_TRUCK:
case STATION_BUS:
case StationType::Truck:
case StationType::Bus:
SetWindowWidgetDirty(WC_STATION_VIEW, this->index, WID_SV_ROADVEHS);
break;
case STATION_DOCK:
case StationType::Dock:
SetWindowWidgetDirty(WC_STATION_VIEW, this->index, WID_SV_SHIPS);
break;
default: NOT_REACHED();
@ -1541,7 +1541,7 @@ CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailTyp
}
st->MarkTilesDirty(false);
st->AfterStationTileSetChange(true, STATION_RAIL);
st->AfterStationTileSetChange(true, StationType::Rail);
}
return cost;
@ -2011,7 +2011,7 @@ CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width,
unit_cost = _price[is_truck_stop ? PR_BUILD_STATION_TRUCK : PR_BUILD_STATION_BUS];
}
StationID est = INVALID_STATION;
CommandCost cost = CalculateRoadStopCost(roadstop_area, flags, is_drive_through, is_truck_stop ? STATION_TRUCK : STATION_BUS, axis, ddir, &est, rt, unit_cost);
CommandCost cost = CalculateRoadStopCost(roadstop_area, flags, is_drive_through, is_truck_stop ? StationType::Truck : StationType::Bus, axis, ddir, &est, rt, unit_cost);
if (cost.Failed()) return cost;
Station *st = nullptr;
@ -2033,7 +2033,7 @@ CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width,
/* Check if the road stop is buildable */
if (HasBit(roadstopspec->callback_mask, CBM_ROAD_STOP_AVAIL)) {
uint16_t cb_res = GetRoadStopCallback(CBID_STATION_AVAILABILITY, 0, 0, roadstopspec, nullptr, INVALID_TILE, rt, is_truck_stop ? STATION_TRUCK : STATION_BUS, 0);
uint16_t cb_res = GetRoadStopCallback(CBID_STATION_AVAILABILITY, 0, 0, roadstopspec, nullptr, INVALID_TILE, rt, is_truck_stop ? StationType::Truck : StationType::Bus, 0);
if (cb_res != CALLBACK_FAILED && !Convert8bitBooleanCallback(roadstopspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res)) return CMD_ERROR;
}
}
@ -2085,7 +2085,7 @@ CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width,
if (road_rt == INVALID_ROADTYPE && RoadTypeIsRoad(rt)) road_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 ? STATION_BUS : STATION_TRUCK), road_rt, tram_rt, axis);
MakeDriveThroughRoadStop(cur_tile, st->owner, road_owner, tram_owner, st->index, (rs_type == ROADSTOP_BUS ? StationType::Bus : StationType::Truck), road_rt, tram_rt, axis);
road_stop->MakeDriveThrough();
} else {
if (road_rt == INVALID_ROADTYPE && RoadTypeIsRoad(rt)) road_rt = rt;
@ -2106,7 +2106,7 @@ CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width,
}
if (st != nullptr) {
st->AfterStationTileSetChange(true, is_truck_stop ? STATION_TRUCK: STATION_BUS);
st->AfterStationTileSetChange(true, is_truck_stop ? StationType::Truck: StationType::Bus);
}
}
return cost;
@ -2225,7 +2225,7 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags, int repla
st->rect.AfterRemoveTile(st, tile);
if (replacement_spec_index < 0) st->AfterStationTileSetChange(false, is_truck ? STATION_TRUCK: STATION_BUS);
if (replacement_spec_index < 0) st->AfterStationTileSetChange(false, is_truck ? StationType::Truck: StationType::Bus);
st->RemoveRoadStopTileData(tile);
if ((int)specindex != replacement_spec_index) DeallocateSpecFromRoadStop(st, specindex);
@ -2341,7 +2341,7 @@ static CommandCost RemoveGenericRoadStop(DoCommandFlag flags, const TileArea &ro
}
CommandCost ret;
if (station_type == STATION_ROADWAYPOINT) {
if (station_type == StationType::RoadWaypoint) {
ret = RemoveRoadWaypointStop(cur_tile, flags);
} else {
ret = RemoveRoadStop(cur_tile, flags);
@ -2390,7 +2390,7 @@ CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width
TileArea roadstop_area(tile, width, height);
return RemoveGenericRoadStop(flags, roadstop_area, stop_type == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK, remove_road);
return RemoveGenericRoadStop(flags, roadstop_area, stop_type == ROADSTOP_BUS ? StationType::Bus : StationType::Truck, remove_road);
}
/**
@ -2407,7 +2407,7 @@ CommandCost CmdRemoveFromRoadWaypoint(DoCommandFlag flags, TileIndex start, Tile
TileArea roadstop_area(start, end);
return RemoveGenericRoadStop(flags, roadstop_area, STATION_ROADWAYPOINT, false);
return RemoveGenericRoadStop(flags, roadstop_area, StationType::RoadWaypoint, false);
}
/**
@ -2634,7 +2634,7 @@ CommandCost CmdBuildAirport(DoCommandFlag flags, TileIndex tile, uint8_t airport
Company::Get(st->owner)->infrastructure.airport++;
st->AfterStationTileSetChange(true, STATION_AIRPORT);
st->AfterStationTileSetChange(true, StationType::Airport);
InvalidateWindowData(WC_STATION_VIEW, st->index, -1);
if (_settings_game.economy.station_noise_level) {
@ -2718,7 +2718,7 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
Company::Get(st->owner)->infrastructure.airport--;
st->AfterStationTileSetChange(false, STATION_AIRPORT);
st->AfterStationTileSetChange(false, StationType::Airport);
DeleteNewGRFInspectWindow(GSF_AIRPORTS, st->index);
}
@ -2868,7 +2868,7 @@ CommandCost CmdBuildDock(DoCommandFlag flags, TileIndex tile, StationID station_
MakeDock(tile, st->owner, st->index, direction, wc);
UpdateStationDockingTiles(st);
st->AfterStationTileSetChange(true, STATION_DOCK);
st->AfterStationTileSetChange(true, StationType::Dock);
}
return cost;
@ -2973,7 +2973,7 @@ static CommandCost RemoveDock(TileIndex tile, DoCommandFlag flags)
Company::Get(st->owner)->infrastructure.station -= 2;
st->AfterStationTileSetChange(false, STATION_DOCK);
st->AfterStationTileSetChange(false, StationType::Dock);
ClearDockingTilesCheckingNeighbours(tile1);
ClearDockingTilesCheckingNeighbours(tile2);
@ -3013,7 +3013,7 @@ static CommandCost RemoveDock(TileIndex tile, DoCommandFlag flags)
*/
const DrawTileSprites *GetStationTileLayout(StationType st, uint8_t gfx)
{
const auto &layouts = _station_display_datas[st];
const auto &layouts = _station_display_datas[to_underlying(st)];
if (gfx >= layouts.size()) gfx &= 1;
return layouts.data() + gfx;
}
@ -3345,7 +3345,7 @@ draw_default_foundation:
if (HasBit(stopspec->flags, RSF_DRAW_MODE_REGISTER)) {
stop_draw_mode = static_cast<RoadStopDrawMode>(GetRegister(0x100));
}
if (type == STATION_ROADWAYPOINT && (stop_draw_mode & ROADSTOP_DRAW_MODE_WAYP_GROUND)) {
if (type == StationType::RoadWaypoint && (stop_draw_mode & ROADSTOP_DRAW_MODE_WAYP_GROUND)) {
draw_ground = true;
}
t = ((const TileLayoutSpriteGroup *)group)->ProcessRegisters(nullptr);
@ -3364,7 +3364,7 @@ draw_default_foundation:
}
if (IsDriveThroughStopTile(ti->tile)) {
if (type != STATION_ROADWAYPOINT && (stopspec == nullptr || (stop_draw_mode & ROADSTOP_DRAW_MODE_OVERLAY) != 0)) {
if (type != StationType::RoadWaypoint && (stopspec == nullptr || (stop_draw_mode & ROADSTOP_DRAW_MODE_OVERLAY) != 0)) {
uint sprite_offset = GetDriveThroughStopAxis(ti->tile) == AXIS_X ? 1 : 0;
DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset);
}
@ -3440,7 +3440,7 @@ void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, Ro
}
/* Default waypoint has no railtype specific sprites */
DrawRailTileSeqInGUI(x, y, t, (st == STATION_WAYPOINT || st == STATION_ROADWAYPOINT) ? 0 : total_offset, 0, pal);
DrawRailTileSeqInGUI(x, y, t, (st == StationType::RailWaypoint || st == StationType::RoadWaypoint) ? 0 : total_offset, 0, pal);
}
static int GetSlopePixelZ_Station(TileIndex tile, uint, uint, bool)
@ -3540,13 +3540,13 @@ static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
StringID str;
switch (GetStationType(tile)) {
default: NOT_REACHED();
case STATION_RAIL: str = STR_LAI_STATION_DESCRIPTION_RAILROAD_STATION; break;
case STATION_AIRPORT:
case StationType::Rail: str = STR_LAI_STATION_DESCRIPTION_RAILROAD_STATION; break;
case StationType::Airport:
str = (IsHangar(tile) ? STR_LAI_STATION_DESCRIPTION_AIRCRAFT_HANGAR : STR_LAI_STATION_DESCRIPTION_AIRPORT);
break;
case STATION_TRUCK: str = STR_LAI_STATION_DESCRIPTION_TRUCK_LOADING_AREA; break;
case STATION_BUS: str = STR_LAI_STATION_DESCRIPTION_BUS_STATION; break;
case STATION_OILRIG: {
case StationType::Truck: str = STR_LAI_STATION_DESCRIPTION_TRUCK_LOADING_AREA; break;
case StationType::Bus: str = STR_LAI_STATION_DESCRIPTION_BUS_STATION; break;
case StationType::Oilrig: {
const Industry *i = Station::GetByTile(tile)->industry;
const IndustrySpec *is = GetIndustrySpec(i->type);
td->owner[0] = i->owner;
@ -3554,10 +3554,10 @@ static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
if (is->grf_prop.HasGrfFile()) td->grf = GetGRFConfig(is->grf_prop.grfid)->GetName();
break;
}
case STATION_DOCK: str = STR_LAI_STATION_DESCRIPTION_SHIP_DOCK; break;
case STATION_BUOY: str = STR_LAI_STATION_DESCRIPTION_BUOY; break;
case STATION_WAYPOINT: str = STR_LAI_STATION_DESCRIPTION_WAYPOINT; break;
case STATION_ROADWAYPOINT: str = STR_LAI_STATION_DESCRIPTION_WAYPOINT; break;
case StationType::Dock: str = STR_LAI_STATION_DESCRIPTION_SHIP_DOCK; break;
case StationType::Buoy: str = STR_LAI_STATION_DESCRIPTION_BUOY; break;
case StationType::RailWaypoint: str = STR_LAI_STATION_DESCRIPTION_WAYPOINT; break;
case StationType::RoadWaypoint: str = STR_LAI_STATION_DESCRIPTION_WAYPOINT; break;
}
td->str = str;
}
@ -3615,20 +3615,20 @@ static void TileLoop_Station(TileIndex tile)
/* FIXME -- GetTileTrackStatus_Station -> animated stationtiles
* hardcoded.....not good */
switch (GetStationType(tile)) {
case STATION_AIRPORT:
case StationType::Airport:
AirportTileAnimationTrigger(Station::GetByTile(tile), tile, AAT_TILELOOP);
break;
case STATION_DOCK:
case StationType::Dock:
if (!IsTileFlat(tile)) break; // only handle water part
[[fallthrough]];
case STATION_OILRIG: //(station part)
case STATION_BUOY:
case StationType::Oilrig: //(station part)
case StationType::Buoy:
TileLoop_Water(tile);
break;
case STATION_ROADWAYPOINT: {
case StationType::RoadWaypoint: {
switch (_settings_game.game_creation.landscape) {
case LT_ARCTIC:
if (IsRoadWaypointOnSnowOrDesert(tile) != (GetTileZ(tile) > GetSnowLine())) {
@ -4596,22 +4596,22 @@ static void ChangeTileOwner_Station(TileIndex tile, Owner old_owner, Owner new_o
/* Update counts for underlying infrastructure. */
switch (GetStationType(tile)) {
case STATION_RAIL:
case STATION_WAYPOINT:
case StationType::Rail:
case StationType::RailWaypoint:
if (!IsStationTileBlocked(tile)) {
old_company->infrastructure.rail[GetRailType(tile)]--;
new_company->infrastructure.rail[GetRailType(tile)]++;
}
break;
case STATION_BUS:
case STATION_TRUCK:
case STATION_ROADWAYPOINT:
case StationType::Bus:
case StationType::Truck:
case StationType::RoadWaypoint:
/* Road stops were already handled above. */
break;
case STATION_BUOY:
case STATION_DOCK:
case StationType::Buoy:
case StationType::Dock:
if (GetWaterClass(tile) == WATER_CLASS_CANAL) {
old_company->infrastructure.water--;
new_company->infrastructure.water++;
@ -4637,7 +4637,7 @@ static void ChangeTileOwner_Station(TileIndex tile, Owner old_owner, Owner new_o
if (IsRoadWaypoint(tile)) {
Command<CMD_REMOVE_FROM_ROAD_WAYPOINT>::Do(DC_EXEC | DC_BANKRUPT, tile, tile);
} else {
Command<CMD_REMOVE_ROAD_STOP>::Do(DC_EXEC | DC_BANKRUPT, tile, 1, 1, (GetStationType(tile) == STATION_TRUCK) ? ROADSTOP_TRUCK : ROADSTOP_BUS, false);
Command<CMD_REMOVE_ROAD_STOP>::Do(DC_EXEC | DC_BANKRUPT, tile, 1, 1, (GetStationType(tile) == StationType::Truck) ? ROADSTOP_TRUCK : ROADSTOP_BUS, false);
}
assert(IsTileType(tile, MP_ROAD));
/* Change owner of tile and all roadtypes */
@ -4700,38 +4700,38 @@ CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags)
if (flags & DC_AUTO) {
switch (GetStationType(tile)) {
default: break;
case STATION_RAIL: return CommandCost(STR_ERROR_MUST_DEMOLISH_RAILROAD);
case STATION_WAYPOINT: return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
case STATION_AIRPORT: return CommandCost(STR_ERROR_MUST_DEMOLISH_AIRPORT_FIRST);
case STATION_TRUCK: return CommandCost(HasTileRoadType(tile, RTT_TRAM) ? STR_ERROR_MUST_DEMOLISH_CARGO_TRAM_STATION_FIRST : STR_ERROR_MUST_DEMOLISH_TRUCK_STATION_FIRST);
case STATION_BUS: return CommandCost(HasTileRoadType(tile, RTT_TRAM) ? STR_ERROR_MUST_DEMOLISH_PASSENGER_TRAM_STATION_FIRST : STR_ERROR_MUST_DEMOLISH_BUS_STATION_FIRST);
case STATION_ROADWAYPOINT: return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
case STATION_BUOY: return CommandCost(STR_ERROR_BUOY_IN_THE_WAY);
case STATION_DOCK: return CommandCost(STR_ERROR_MUST_DEMOLISH_DOCK_FIRST);
case STATION_OILRIG:
case StationType::Rail: return CommandCost(STR_ERROR_MUST_DEMOLISH_RAILROAD);
case StationType::RailWaypoint: return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
case StationType::Airport: return CommandCost(STR_ERROR_MUST_DEMOLISH_AIRPORT_FIRST);
case StationType::Truck: return CommandCost(HasTileRoadType(tile, RTT_TRAM) ? STR_ERROR_MUST_DEMOLISH_CARGO_TRAM_STATION_FIRST : STR_ERROR_MUST_DEMOLISH_TRUCK_STATION_FIRST);
case StationType::Bus: return CommandCost(HasTileRoadType(tile, RTT_TRAM) ? STR_ERROR_MUST_DEMOLISH_PASSENGER_TRAM_STATION_FIRST : STR_ERROR_MUST_DEMOLISH_BUS_STATION_FIRST);
case StationType::RoadWaypoint: return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
case StationType::Buoy: return CommandCost(STR_ERROR_BUOY_IN_THE_WAY);
case StationType::Dock: return CommandCost(STR_ERROR_MUST_DEMOLISH_DOCK_FIRST);
case StationType::Oilrig:
SetDParam(1, STR_INDUSTRY_NAME_OIL_RIG);
return CommandCost(STR_ERROR_GENERIC_OBJECT_IN_THE_WAY);
}
}
switch (GetStationType(tile)) {
case STATION_RAIL: return RemoveRailStation(tile, flags);
case STATION_WAYPOINT: return RemoveRailWaypoint(tile, flags);
case STATION_AIRPORT: return RemoveAirport(tile, flags);
case STATION_TRUCK: [[fallthrough]];
case STATION_BUS:
case StationType::Rail: return RemoveRailStation(tile, flags);
case StationType::RailWaypoint: return RemoveRailWaypoint(tile, flags);
case StationType::Airport: return RemoveAirport(tile, flags);
case StationType::Truck: [[fallthrough]];
case StationType::Bus:
if (IsDriveThroughStopTile(tile)) {
CommandCost remove_road = CanRemoveRoadWithStop(tile, flags);
if (remove_road.Failed()) return remove_road;
}
return RemoveRoadStop(tile, flags);
case STATION_ROADWAYPOINT: {
case StationType::RoadWaypoint: {
CommandCost remove_road = CanRemoveRoadWithStop(tile, flags);
if (remove_road.Failed()) return remove_road;
return RemoveRoadWaypointStop(tile, flags);
}
case STATION_BUOY: return RemoveBuoy(tile, flags);
case STATION_DOCK: return RemoveDock(tile, flags);
case StationType::Buoy: return RemoveBuoy(tile, flags);
case StationType::Dock: return RemoveDock(tile, flags);
default: break;
}
@ -4746,18 +4746,18 @@ static CommandCost TerraformTile_Station(TileIndex tile, DoCommandFlag flags, in
*/
if (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new)) {
switch (GetStationType(tile)) {
case STATION_WAYPOINT:
case STATION_RAIL: {
case StationType::RailWaypoint:
case StationType::Rail: {
if (!AutoslopeCheckForAxis(tile, z_new, tileh_new, GetRailStationAxis(tile))) break;
return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
}
case STATION_AIRPORT:
case StationType::Airport:
return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
case STATION_TRUCK:
case STATION_BUS:
case STATION_ROADWAYPOINT: {
case StationType::Truck:
case StationType::Bus:
case StationType::RoadWaypoint: {
if (IsDriveThroughStopTile(tile)) {
if (!AutoslopeCheckForAxis(tile, z_new, tileh_new, GetDriveThroughStopAxis(tile))) break;
} else {

View File

@ -50,13 +50,13 @@ inline StationType GetStationType(Tile t)
/**
* Get the road stop type of this tile
* @param t the tile to query
* @pre GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS
* @pre GetStationType(t) == StationType::Truck || GetStationType(t) == StationType::Bus
* @return the road stop type
*/
inline RoadStopType GetRoadStopType(Tile t)
{
assert(GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS);
return GetStationType(t) == STATION_TRUCK ? ROADSTOP_TRUCK : ROADSTOP_BUS;
assert(GetStationType(t) == StationType::Truck || GetStationType(t) == StationType::Bus);
return GetStationType(t) == StationType::Truck ? ROADSTOP_TRUCK : ROADSTOP_BUS;
}
/**
@ -91,7 +91,7 @@ inline void SetStationGfx(Tile t, StationGfx gfx)
*/
inline bool IsRailStation(Tile t)
{
return GetStationType(t) == STATION_RAIL;
return GetStationType(t) == StationType::Rail;
}
/**
@ -112,7 +112,7 @@ inline bool IsRailStationTile(Tile t)
*/
inline bool IsRailWaypoint(Tile t)
{
return GetStationType(t) == STATION_WAYPOINT;
return GetStationType(t) == StationType::RailWaypoint;
}
/**
@ -156,7 +156,7 @@ inline bool HasStationTileRail(Tile t)
*/
inline bool IsAirport(Tile t)
{
return GetStationType(t) == STATION_AIRPORT;
return GetStationType(t) == StationType::Airport;
}
/**
@ -179,7 +179,7 @@ bool IsHangar(Tile t);
*/
inline bool IsTruckStop(Tile t)
{
return GetStationType(t) == STATION_TRUCK;
return GetStationType(t) == StationType::Truck;
}
/**
@ -190,7 +190,7 @@ inline bool IsTruckStop(Tile t)
*/
inline bool IsBusStop(Tile t)
{
return GetStationType(t) == STATION_BUS;
return GetStationType(t) == StationType::Bus;
}
/**
@ -201,7 +201,7 @@ inline bool IsBusStop(Tile t)
*/
inline bool IsRoadWaypoint(Tile t)
{
return GetStationType(t) == STATION_ROADWAYPOINT;
return GetStationType(t) == StationType::RoadWaypoint;
}
/**
@ -367,7 +367,7 @@ inline Axis GetDriveThroughStopAxis(Tile t)
*/
inline bool IsOilRig(Tile t)
{
return GetStationType(t) == STATION_OILRIG;
return GetStationType(t) == StationType::Oilrig;
}
/**
@ -378,7 +378,7 @@ inline bool IsOilRig(Tile t)
*/
inline bool IsDock(Tile t)
{
return GetStationType(t) == STATION_DOCK;
return GetStationType(t) == StationType::Dock;
}
/**
@ -388,7 +388,7 @@ inline bool IsDock(Tile t)
*/
inline bool IsDockTile(Tile t)
{
return IsTileType(t, MP_STATION) && GetStationType(t) == STATION_DOCK;
return IsTileType(t, MP_STATION) && GetStationType(t) == StationType::Dock;
}
/**
@ -399,7 +399,7 @@ inline bool IsDockTile(Tile t)
*/
inline bool IsBuoy(Tile t)
{
return GetStationType(t) == STATION_BUOY;
return GetStationType(t) == StationType::Buoy;
}
/**
@ -725,7 +725,7 @@ inline void MakeStation(Tile t, Owner o, StationID sid, StationType st, uint8_t
t.m4() = 0;
t.m5() = section;
SB(t.m6(), 2, 1, 0);
SB(t.m6(), 3, 4, st);
SB(t.m6(), 3, 4, to_underlying(st));
t.m7() = 0;
t.m8() = 0;
}
@ -741,7 +741,7 @@ inline void MakeStation(Tile t, Owner o, StationID sid, StationType st, uint8_t
*/
inline void MakeRailStation(Tile t, Owner o, StationID sid, Axis a, uint8_t section, RailType rt)
{
MakeStation(t, o, sid, STATION_RAIL, section + a);
MakeStation(t, o, sid, StationType::Rail, section + a);
SetRailType(t, rt);
SetRailStationReservation(t, false);
}
@ -757,7 +757,7 @@ inline void MakeRailStation(Tile t, Owner o, StationID sid, Axis a, uint8_t sect
*/
inline void MakeRailWaypoint(Tile t, Owner o, StationID sid, Axis a, uint8_t section, RailType rt)
{
MakeStation(t, o, sid, STATION_WAYPOINT, section + a);
MakeStation(t, o, sid, StationType::RailWaypoint, section + a);
SetRailType(t, rt);
SetRailStationReservation(t, false);
}
@ -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)
{
MakeStation(t, o, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), d);
MakeStation(t, o, sid, (rst == ROADSTOP_BUS ? StationType::Bus : StationType::Truck), d);
SetRoadTypes(t, road_rt, tram_rt);
SetRoadOwner(t, RTT_ROAD, o);
SetRoadOwner(t, RTT_TRAM, o);
@ -810,7 +810,7 @@ inline void MakeDriveThroughRoadStop(Tile t, Owner station, Owner road, Owner tr
*/
inline void MakeAirport(Tile t, Owner o, StationID sid, uint8_t section, WaterClass wc)
{
MakeStation(t, o, sid, STATION_AIRPORT, section, wc);
MakeStation(t, o, sid, StationType::Airport, section, wc);
}
/**
@ -824,7 +824,7 @@ inline void MakeBuoy(Tile t, StationID sid, WaterClass wc)
/* Make the owner of the buoy tile the same as the current owner of the
* water tile. In this way, we can reset the owner of the water to its
* original state when the buoy gets removed. */
MakeStation(t, GetTileOwner(t), sid, STATION_BUOY, 0, wc);
MakeStation(t, GetTileOwner(t), sid, StationType::Buoy, 0, wc);
}
/**
@ -837,8 +837,8 @@ inline void MakeBuoy(Tile t, StationID sid, WaterClass wc)
*/
inline void MakeDock(Tile t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
{
MakeStation(t, o, sid, STATION_DOCK, d);
MakeStation(TileIndex(t) + TileOffsByDiagDir(d), o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d), wc);
MakeStation(t, o, sid, StationType::Dock, d);
MakeStation(TileIndex(t) + TileOffsByDiagDir(d), o, sid, StationType::Dock, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d), wc);
}
/**
@ -849,7 +849,7 @@ inline void MakeDock(Tile t, Owner o, StationID sid, DiagDirection d, WaterClass
*/
inline void MakeOilrig(Tile t, StationID sid, WaterClass wc)
{
MakeStation(t, OWNER_NONE, sid, STATION_OILRIG, 0, wc);
MakeStation(t, OWNER_NONE, sid, StationType::Oilrig, 0, wc);
}
#endif /* STATION_MAP_H */

View File

@ -28,17 +28,17 @@ static const StationID INVALID_STATION = 0xFFFF;
typedef SmallStack<StationID, StationID, INVALID_STATION, 8, 0xFFFD> StationIDStack;
/** Station types */
enum StationType : uint8_t {
STATION_RAIL,
STATION_AIRPORT,
STATION_TRUCK,
STATION_BUS,
STATION_OILRIG,
STATION_DOCK,
STATION_BUOY,
STATION_WAYPOINT,
STATION_ROADWAYPOINT,
STATION_END,
enum class StationType : uint8_t {
Rail,
Airport,
Truck,
Bus,
Oilrig,
Dock,
Buoy,
RailWaypoint,
RoadWaypoint,
End,
};
/** Types of RoadStops */

View File

@ -1013,7 +1013,7 @@ static const DrawTileSprites _station_display_datas_waypoint[] = {
* As these are drawn/build like stations, they may use the same number of layouts. */
static_assert(lengthof(_station_display_datas_rail) == lengthof(_station_display_datas_waypoint));
static const std::array<std::span<const DrawTileSprites>, STATION_END> _station_display_datas = {{
static const std::array<std::span<const DrawTileSprites>, to_underlying(StationType::End)> _station_display_datas = {{
_station_display_datas_rail,
_station_display_datas_airport,
_station_display_datas_truck,

View File

@ -28,22 +28,22 @@
void DrawWaypointSprite(int x, int y, StationClassID station_class, uint16_t station_type, RailType railtype)
{
if (!DrawStationTile(x, y, railtype, AXIS_X, station_class, station_type)) {
StationPickerDrawSprite(x, y, STATION_WAYPOINT, railtype, INVALID_ROADTYPE, AXIS_X);
StationPickerDrawSprite(x, y, StationType::RailWaypoint, railtype, INVALID_ROADTYPE, AXIS_X);
}
}
void Waypoint::GetTileArea(TileArea *ta, StationType type) const
{
switch (type) {
case STATION_WAYPOINT:
case StationType::RailWaypoint:
*ta = this->train_station;
return;
case STATION_ROADWAYPOINT:
case StationType::RoadWaypoint:
*ta = this->road_waypoint_area;
return;
case STATION_BUOY:
case StationType::Buoy:
ta->tile = this->xy;
ta->w = 1;
ta->h = 1;

View File

@ -365,7 +365,7 @@ CommandCost CmdBuildRoadWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis
unit_cost = _price[PR_BUILD_STATION_TRUCK];
}
StationID est = INVALID_STATION;
CommandCost cost = CalculateRoadStopCost(roadstop_area, flags, true, STATION_ROADWAYPOINT, axis, AxisToDiagDir(axis), &est, INVALID_ROADTYPE, unit_cost);
CommandCost cost = CalculateRoadStopCost(roadstop_area, flags, true, StationType::RoadWaypoint, axis, AxisToDiagDir(axis), &est, INVALID_ROADTYPE, unit_cost);
if (cost.Failed()) return cost;
Waypoint *wp = nullptr;
@ -446,7 +446,7 @@ CommandCost CmdBuildRoadWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis
UpdateCompanyRoadInfrastructure(road_rt, road_owner, ROAD_STOP_TRACKBIT_FACTOR);
UpdateCompanyRoadInfrastructure(tram_rt, tram_owner, ROAD_STOP_TRACKBIT_FACTOR);
MakeDriveThroughRoadStop(cur_tile, wp->owner, road_owner, tram_owner, wp->index, STATION_ROADWAYPOINT, road_rt, tram_rt, axis);
MakeDriveThroughRoadStop(cur_tile, wp->owner, road_owner, tram_owner, wp->index, StationType::RoadWaypoint, road_rt, tram_rt, axis);
SetCustomRoadStopSpecIndex(cur_tile, map_spec_index);
if (roadstopspec != nullptr) wp->SetRoadStopRandomBits(cur_tile, 0);

View File

@ -46,15 +46,15 @@ private:
StationType type;
switch (this->vt) {
case VEH_TRAIN:
type = STATION_WAYPOINT;
type = StationType::RailWaypoint;
break;
case VEH_ROAD:
type = STATION_ROADWAYPOINT;
type = StationType::RoadWaypoint;
break;
case VEH_SHIP:
type = STATION_BUOY;
type = StationType::Buoy;
break;
default: