From 7016d2bee3a742924ec72e728a0a29d0e9a6c4d2 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sat, 11 Apr 2026 10:26:33 +0200 Subject: [PATCH] Codechange: make ChangeInfoResult a scoped enum --- src/newgrf/newgrf_act0.cpp | 28 ++++++++++---------- src/newgrf/newgrf_act0_aircraft.cpp | 6 ++--- src/newgrf/newgrf_act0_airports.cpp | 20 +++++++------- src/newgrf/newgrf_act0_badges.cpp | 10 +++---- src/newgrf/newgrf_act0_bridges.cpp | 8 +++--- src/newgrf/newgrf_act0_canals.cpp | 8 +++--- src/newgrf/newgrf_act0_cargo.cpp | 8 +++--- src/newgrf/newgrf_act0_globalvar.cpp | 16 +++++------ src/newgrf/newgrf_act0_houses.cpp | 14 +++++----- src/newgrf/newgrf_act0_industries.cpp | 38 +++++++++++++-------------- src/newgrf/newgrf_act0_objects.cpp | 12 ++++----- src/newgrf/newgrf_act0_railtypes.cpp | 14 +++++----- src/newgrf/newgrf_act0_roadstops.cpp | 12 ++++----- src/newgrf/newgrf_act0_roadtypes.cpp | 16 +++++------ src/newgrf/newgrf_act0_roadvehs.cpp | 6 ++--- src/newgrf/newgrf_act0_ships.cpp | 6 ++--- src/newgrf/newgrf_act0_sounds.cpp | 10 +++---- src/newgrf/newgrf_act0_stations.cpp | 16 +++++------ src/newgrf/newgrf_act0_trains.cpp | 6 ++--- src/newgrf/newgrf_act3.cpp | 2 +- src/newgrf/newgrf_internal.h | 12 ++++----- 21 files changed, 134 insertions(+), 134 deletions(-) diff --git a/src/newgrf/newgrf_act0.cpp b/src/newgrf/newgrf_act0.cpp index f922698dbe..ea4b81dd1c 100644 --- a/src/newgrf/newgrf_act0.cpp +++ b/src/newgrf/newgrf_act0.cpp @@ -59,10 +59,10 @@ ChangeInfoResult CommonVehicleChangeInfo(EngineInfo *ei, int prop, ByteReader &b break; default: - return CIR_UNKNOWN; + return ChangeInfoResult::Unknown; } - return CIR_SUCCESS; + return ChangeInfoResult::Success; } /** @@ -114,25 +114,25 @@ bool HandleChangeInfoResult(std::string_view caller, ChangeInfoResult cir, GrfSp switch (cir) { default: NOT_REACHED(); - case CIR_DISABLED: + case ChangeInfoResult::Disabled: /* Error has already been printed; just stop parsing */ return true; - case CIR_SUCCESS: + case ChangeInfoResult::Success: return false; - case CIR_UNHANDLED: + case ChangeInfoResult::Unhandled: GrfMsg(1, "{}: Ignoring property 0x{:02X} of feature 0x{:02X} (not implemented)", caller, property, feature); return false; - case CIR_UNKNOWN: + case ChangeInfoResult::Unknown: GrfMsg(0, "{}: Unknown property 0x{:02X} of feature 0x{:02X}, disabling", caller, property, feature); [[fallthrough]]; - case CIR_INVALID_ID: { + case ChangeInfoResult::InvalidId: { /* No debug message for an invalid ID, as it has already been output */ - GRFError *error = DisableGrf(cir == CIR_INVALID_ID ? STR_NEWGRF_ERROR_INVALID_ID : STR_NEWGRF_ERROR_UNKNOWN_PROPERTY); - if (cir != CIR_INVALID_ID) error->param_value[1] = property; + GRFError *error = DisableGrf(cir == ChangeInfoResult::InvalidId ? STR_NEWGRF_ERROR_INVALID_ID : STR_NEWGRF_ERROR_UNKNOWN_PROPERTY); + if (cir != ChangeInfoResult::InvalidId) error->param_value[1] = property; return true; } } @@ -163,7 +163,7 @@ struct InvokeGrfChangeInfoHandler { static ChangeInfoResult Invoke(GrfSpecFeature feature, uint first, uint last, int prop, ByteReader &buf, GrfLoadingStage stage) { Invoker func = feature < std::size(funcs) ? funcs[feature] : nullptr; - if (func == nullptr) return CIR_UNKNOWN; + if (func == nullptr) return ChangeInfoResult::Unknown; return func(first, last, prop, buf, stage); } }; @@ -197,8 +197,8 @@ static void FeatureChangeInfo(ByteReader &buf) /* Test if feature handles change. */ ChangeInfoResult cir_test = InvokeGrfChangeInfoHandler::Invoke(feature, 0, 0, 0, buf, GrfLoadingStage::Activation); - if (cir_test == CIR_UNHANDLED) return; - if (cir_test == CIR_UNKNOWN) { + if (cir_test == ChangeInfoResult::Unhandled) return; + if (cir_test == ChangeInfoResult::Unknown) { GrfMsg(1, "FeatureChangeInfo: Unsupported feature 0x{:02X}, skipping", feature); return; } @@ -255,8 +255,8 @@ static void ReserveChangeInfo(ByteReader &buf) /* Test if feature handles reservation. */ ChangeInfoResult cir_test = InvokeGrfChangeInfoHandler::Invoke(feature, 0, 0, 0, buf, GrfLoadingStage::Reserve); - if (cir_test == CIR_UNHANDLED) return; - if (cir_test == CIR_UNKNOWN) { + if (cir_test == ChangeInfoResult::Unhandled) return; + if (cir_test == ChangeInfoResult::Unknown) { GrfMsg(1, "ReserveChangeInfo: Unsupported feature 0x{:02X}, skipping", feature); return; } diff --git a/src/newgrf/newgrf_act0_aircraft.cpp b/src/newgrf/newgrf_act0_aircraft.cpp index 521692e1f8..6b1f50f24a 100644 --- a/src/newgrf/newgrf_act0_aircraft.cpp +++ b/src/newgrf/newgrf_act0_aircraft.cpp @@ -28,11 +28,11 @@ */ static ChangeInfoResult AircraftVehicleChangeInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; for (uint id = first; id < last; ++id) { Engine *e = GetNewEngine(_cur_gps.grffile, VEH_AIRCRAFT, id); - if (e == nullptr) return CIR_INVALID_ID; // No engine could be allocated, so neither can any next vehicles + if (e == nullptr) return ChangeInfoResult::InvalidId; // No engine could be allocated, so neither can any next vehicles EngineInfo *ei = &e->info; AircraftVehicleInfo *avi = &e->VehInfo(); @@ -197,5 +197,5 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint first, uint last, int pro return ret; } -template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return CIR_UNHANDLED; } +template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return ChangeInfoResult::Unhandled; } template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint first, uint last, int prop, ByteReader &buf) { return AircraftVehicleChangeInfo(first, last, prop, buf); } diff --git a/src/newgrf/newgrf_act0_airports.cpp b/src/newgrf/newgrf_act0_airports.cpp index 9e16e7730d..ce774fa739 100644 --- a/src/newgrf/newgrf_act0_airports.cpp +++ b/src/newgrf/newgrf_act0_airports.cpp @@ -27,11 +27,11 @@ */ static ChangeInfoResult AirportChangeInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; if (last > NUM_AIRPORTS_PER_GRF) { GrfMsg(1, "AirportChangeInfo: Too many airports, trying id ({}), max ({}). Ignoring.", last, NUM_AIRPORTS_PER_GRF); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } /* Allocate industry specs if they haven't been allocated already. */ @@ -42,7 +42,7 @@ static ChangeInfoResult AirportChangeInfo(uint first, uint last, int prop, ByteR if (as == nullptr && prop != 0x08 && prop != 0x09) { GrfMsg(2, "AirportChangeInfo: Attempt to modify undefined airport {}, ignoring", id); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } switch (prop) { @@ -165,7 +165,7 @@ static ChangeInfoResult AirportChangeInfo(uint first, uint last, int prop, ByteR break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } @@ -175,11 +175,11 @@ static ChangeInfoResult AirportChangeInfo(uint first, uint last, int prop, ByteR static ChangeInfoResult AirportTilesChangeInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; if (last > NUM_AIRPORTTILES_PER_GRF) { GrfMsg(1, "AirportTileChangeInfo: Too many airport tiles loaded ({}), max ({}). Ignoring.", last, NUM_AIRPORTTILES_PER_GRF); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } /* Allocate airport tile specs if they haven't been allocated already. */ @@ -190,7 +190,7 @@ static ChangeInfoResult AirportTilesChangeInfo(uint first, uint last, int prop, if (prop != 0x08 && tsp == nullptr) { GrfMsg(2, "AirportTileChangeInfo: Attempt to modify undefined airport tile {}. Ignoring.", id); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } switch (prop) { @@ -253,7 +253,7 @@ static ChangeInfoResult AirportTilesChangeInfo(uint first, uint last, int prop, break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } @@ -261,8 +261,8 @@ static ChangeInfoResult AirportTilesChangeInfo(uint first, uint last, int prop, return ret; } -template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return CIR_UNHANDLED; } +template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return ChangeInfoResult::Unhandled; } template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint first, uint last, int prop, ByteReader &buf) { return AirportChangeInfo(first, last, prop, buf); } -template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return CIR_UNHANDLED; } +template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return ChangeInfoResult::Unhandled; } template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint first, uint last, int prop, ByteReader &buf) { return AirportTilesChangeInfo(first, last, prop, buf); } diff --git a/src/newgrf/newgrf_act0_badges.cpp b/src/newgrf/newgrf_act0_badges.cpp index 4322a34e3a..e25eaf8079 100644 --- a/src/newgrf/newgrf_act0_badges.cpp +++ b/src/newgrf/newgrf_act0_badges.cpp @@ -18,18 +18,18 @@ static ChangeInfoResult BadgeChangeInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; if (last >= UINT16_MAX) { GrfMsg(1, "BadgeChangeInfo: Tag {} is invalid, max {}, ignoring", last, UINT16_MAX - 1); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } for (uint id = first; id < last; ++id) { auto it = _cur_gps.grffile->badge_map.find(id); if (prop != 0x08 && it == std::end(_cur_gps.grffile->badge_map)) { GrfMsg(1, "BadgeChangeInfo: Attempt to modify undefined tag {}, ignoring", id); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } Badge *badge = nullptr; @@ -47,7 +47,7 @@ static ChangeInfoResult BadgeChangeInfo(uint first, uint last, int prop, ByteRea break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } @@ -55,5 +55,5 @@ static ChangeInfoResult BadgeChangeInfo(uint first, uint last, int prop, ByteRea return ret; } -template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return CIR_UNHANDLED; } +template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return ChangeInfoResult::Unhandled; } template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint first, uint last, int prop, ByteReader &buf) { return BadgeChangeInfo(first, last, prop, buf); } diff --git a/src/newgrf/newgrf_act0_bridges.cpp b/src/newgrf/newgrf_act0_bridges.cpp index e21ab2c6a7..60d1b174d3 100644 --- a/src/newgrf/newgrf_act0_bridges.cpp +++ b/src/newgrf/newgrf_act0_bridges.cpp @@ -26,11 +26,11 @@ */ static ChangeInfoResult BridgeChangeInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; if (last > MAX_BRIDGES) { GrfMsg(1, "BridgeChangeInfo: Bridge {} is invalid, max {}, ignoring", last, MAX_BRIDGES); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } for (uint id = first; id < last; ++id) { @@ -137,7 +137,7 @@ static ChangeInfoResult BridgeChangeInfo(uint first, uint last, int prop, ByteRe } default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } @@ -145,5 +145,5 @@ static ChangeInfoResult BridgeChangeInfo(uint first, uint last, int prop, ByteRe return ret; } -template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return CIR_UNHANDLED; } +template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return ChangeInfoResult::Unhandled; } template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint first, uint last, int prop, ByteReader &buf) { return BridgeChangeInfo(first, last, prop, buf); } diff --git a/src/newgrf/newgrf_act0_canals.cpp b/src/newgrf/newgrf_act0_canals.cpp index a83e8fbf05..ed3058452d 100644 --- a/src/newgrf/newgrf_act0_canals.cpp +++ b/src/newgrf/newgrf_act0_canals.cpp @@ -24,11 +24,11 @@ */ static ChangeInfoResult CanalChangeInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; if (last > CF_END) { GrfMsg(1, "CanalChangeInfo: Canal feature 0x{:02X} is invalid, max {}, ignoring", last, CF_END); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } for (uint id = first; id < last; ++id) { @@ -44,7 +44,7 @@ static ChangeInfoResult CanalChangeInfo(uint first, uint last, int prop, ByteRea break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } @@ -52,5 +52,5 @@ static ChangeInfoResult CanalChangeInfo(uint first, uint last, int prop, ByteRea return ret; } -template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return CIR_UNHANDLED; } +template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return ChangeInfoResult::Unhandled; } template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint first, uint last, int prop, ByteReader &buf) { return CanalChangeInfo(first, last, prop, buf); } diff --git a/src/newgrf/newgrf_act0_cargo.cpp b/src/newgrf/newgrf_act0_cargo.cpp index 00d07efb35..eea0da6662 100644 --- a/src/newgrf/newgrf_act0_cargo.cpp +++ b/src/newgrf/newgrf_act0_cargo.cpp @@ -49,11 +49,11 @@ static void MaybeInstallFallbackCargoLabel(uint id, uint last, CargoLabel label) */ static ChangeInfoResult CargoReserveInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; if (last > NUM_CARGO) { GrfMsg(2, "CargoChangeInfo: Cargo type {} out of range (max {})", last, NUM_CARGO - 1); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } for (uint id = first; id < last; ++id) { @@ -189,7 +189,7 @@ static ChangeInfoResult CargoReserveInfo(uint first, uint last, int prop, ByteRe break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } @@ -198,4 +198,4 @@ static ChangeInfoResult CargoReserveInfo(uint first, uint last, int prop, ByteRe } template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint first, uint last, int prop, ByteReader &buf) { return CargoReserveInfo(first, last, prop, buf); } -template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint, uint, int, ByteReader &) { return CIR_UNHANDLED; } +template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint, uint, int, ByteReader &) { return ChangeInfoResult::Unhandled; } diff --git a/src/newgrf/newgrf_act0_globalvar.cpp b/src/newgrf/newgrf_act0_globalvar.cpp index 2d80f27b18..11f10487fc 100644 --- a/src/newgrf/newgrf_act0_globalvar.cpp +++ b/src/newgrf/newgrf_act0_globalvar.cpp @@ -46,7 +46,7 @@ static ChangeInfoResult LoadTranslationTable(uint first, uint last, ByteReader & { if (first != 0) { GrfMsg(1, "LoadTranslationTable: {} translation table must start at zero", name); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } std::vector &translation_table = gettable(*_cur_gps.grffile); @@ -64,14 +64,14 @@ static ChangeInfoResult LoadTranslationTable(uint first, uint last, ByteReader & override_table = translation_table; } - return CIR_SUCCESS; + return ChangeInfoResult::Success; } static ChangeInfoResult LoadBadgeTranslationTable(uint first, uint last, ByteReader &buf, std::vector &translation_table, std::string_view name) { if (first != 0 && first != std::size(translation_table)) { GrfMsg(1, "LoadBadgeTranslationTable: {} translation table must start at zero or {}", name, std::size(translation_table)); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } if (first == 0) translation_table.clear(); @@ -81,7 +81,7 @@ static ChangeInfoResult LoadBadgeTranslationTable(uint first, uint last, ByteRea translation_table.push_back(GetOrCreateBadge(label).index); } - return CIR_SUCCESS; + return ChangeInfoResult::Success; } /** @@ -131,7 +131,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint first, uint last, int prop, Byt } /* Properties which are handled per item */ - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; for (uint id = first; id < last; ++id) { switch (prop) { case 0x08: { // Cost base factor @@ -325,7 +325,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint first, uint last, int prop, Byt } default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } @@ -359,7 +359,7 @@ static ChangeInfoResult GlobalVarReserveInfo(uint first, uint last, int prop, By } /* Properties which are handled per item */ - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; for (uint id = first; id < last; ++id) { switch (prop) { @@ -399,7 +399,7 @@ static ChangeInfoResult GlobalVarReserveInfo(uint first, uint last, int prop, By break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } diff --git a/src/newgrf/newgrf_act0_houses.cpp b/src/newgrf/newgrf_act0_houses.cpp index 7e7bb145d8..9e6058a0a8 100644 --- a/src/newgrf/newgrf_act0_houses.cpp +++ b/src/newgrf/newgrf_act0_houses.cpp @@ -28,7 +28,7 @@ */ static ChangeInfoResult IgnoreTownHouseProperty(int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; switch (prop) { case 0x09: @@ -79,7 +79,7 @@ static ChangeInfoResult IgnoreTownHouseProperty(int prop, ByteReader &buf) break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } return ret; @@ -95,11 +95,11 @@ static ChangeInfoResult IgnoreTownHouseProperty(int prop, ByteReader &buf) */ static ChangeInfoResult TownHouseChangeInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; if (last > NUM_HOUSES_PER_GRF) { GrfMsg(1, "TownHouseChangeInfo: Too many houses loaded ({}), max ({}). Ignoring.", last, NUM_HOUSES_PER_GRF); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } /* Allocate house specs if they haven't been allocated already. */ @@ -324,7 +324,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint first, uint last, int prop, Byt if (count > lengthof(housespec->accepts_cargo)) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG); error->param_value[1] = prop; - return CIR_DISABLED; + return ChangeInfoResult::Disabled; } /* Always write the full accepts_cargo array, and check each index for being inside the * provided data. This ensures all values are properly initialized, and also avoids @@ -347,7 +347,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint first, uint last, int prop, Byt break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } @@ -355,5 +355,5 @@ static ChangeInfoResult TownHouseChangeInfo(uint first, uint last, int prop, Byt return ret; } -template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return CIR_UNHANDLED; } +template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return ChangeInfoResult::Unhandled; } template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint first, uint last, int prop, ByteReader &buf) { return TownHouseChangeInfo(first, last, prop, buf); } diff --git a/src/newgrf/newgrf_act0_industries.cpp b/src/newgrf/newgrf_act0_industries.cpp index 2f9a6e9b81..4ee8e8c3ef 100644 --- a/src/newgrf/newgrf_act0_industries.cpp +++ b/src/newgrf/newgrf_act0_industries.cpp @@ -33,7 +33,7 @@ extern const IndustrySpec _origin_industry_specs[NEW_INDUSTRYOFFSET]; */ static ChangeInfoResult IgnoreIndustryTileProperty(int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; switch (prop) { case 0x09: @@ -57,7 +57,7 @@ static ChangeInfoResult IgnoreIndustryTileProperty(int prop, ByteReader &buf) break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } return ret; @@ -73,11 +73,11 @@ static ChangeInfoResult IgnoreIndustryTileProperty(int prop, ByteReader &buf) */ static ChangeInfoResult IndustrytilesChangeInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; if (last > NUM_INDUSTRYTILES_PER_GRF) { GrfMsg(1, "IndustryTilesChangeInfo: Too many industry tiles loaded ({}), max ({}). Ignoring.", last, NUM_INDUSTRYTILES_PER_GRF); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } /* Allocate industry tile specs if they haven't been allocated already. */ @@ -174,7 +174,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint first, uint last, int prop, if (num_cargoes > std::size(tsp->acceptance)) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG); error->param_value[1] = prop; - return CIR_DISABLED; + return ChangeInfoResult::Disabled; } for (uint i = 0; i < std::size(tsp->acceptance); i++) { if (i < num_cargoes) { @@ -195,7 +195,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint first, uint last, int prop, break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } @@ -211,7 +211,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint first, uint last, int prop, */ static ChangeInfoResult IgnoreIndustryProperty(int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; switch (prop) { case 0x09: @@ -292,7 +292,7 @@ static ChangeInfoResult IgnoreIndustryProperty(int prop, ByteReader &buf) break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } return ret; @@ -338,11 +338,11 @@ static bool ValidateIndustryLayout(const IndustryTileLayout &layout) */ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; if (last > NUM_INDUSTRYTYPES_PER_GRF) { GrfMsg(1, "IndustriesChangeInfo: Too many industries loaded ({}), max ({}). Ignoring.", last, NUM_INDUSTRYTYPES_PER_GRF); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } /* Allocate industry specs if they haven't been allocated already. */ @@ -432,12 +432,12 @@ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, By if (type >= lengthof(_origin_industry_specs)) { GrfMsg(1, "IndustriesChangeInfo: Invalid original industry number for layout import, industry {}", id); DisableGrf(STR_NEWGRF_ERROR_INVALID_ID); - return CIR_DISABLED; + return ChangeInfoResult::Disabled; } if (laynbr >= _origin_industry_specs[type].layouts.size()) { GrfMsg(1, "IndustriesChangeInfo: Invalid original industry layout index for layout import, industry {}", id); DisableGrf(STR_NEWGRF_ERROR_INVALID_ID); - return CIR_DISABLED; + return ChangeInfoResult::Disabled; } layout = _origin_industry_specs[type].layouts[laynbr]; break; @@ -622,7 +622,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, By if (num_cargoes > std::size(indsp->produced_cargo)) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG); error->param_value[1] = prop; - return CIR_DISABLED; + return ChangeInfoResult::Disabled; } for (size_t i = 0; i < std::size(indsp->produced_cargo); i++) { if (i < num_cargoes) { @@ -641,7 +641,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, By if (num_cargoes > std::size(indsp->accepts_cargo)) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG); error->param_value[1] = prop; - return CIR_DISABLED; + return ChangeInfoResult::Disabled; } for (size_t i = 0; i < std::size(indsp->accepts_cargo); i++) { if (i < num_cargoes) { @@ -660,7 +660,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, By if (num_cargoes > lengthof(indsp->production_rate)) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG); error->param_value[1] = prop; - return CIR_DISABLED; + return ChangeInfoResult::Disabled; } for (uint i = 0; i < lengthof(indsp->production_rate); i++) { if (i < num_cargoes) { @@ -678,7 +678,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, By if (num_inputs > std::size(indsp->accepts_cargo) || num_outputs > std::size(indsp->produced_cargo)) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LIST_PROPERTY_TOO_LONG); error->param_value[1] = prop; - return CIR_DISABLED; + return ChangeInfoResult::Disabled; } for (size_t i = 0; i < std::size(indsp->accepts_cargo); i++) { for (size_t j = 0; j < std::size(indsp->produced_cargo); j++) { @@ -695,7 +695,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, By break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } @@ -703,8 +703,8 @@ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, By return ret; } -template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return CIR_UNHANDLED; } +template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return ChangeInfoResult::Unhandled; } template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint first, uint last, int prop, ByteReader &buf) { return IndustrytilesChangeInfo(first, last, prop, buf); } -template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return CIR_UNHANDLED; } +template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return ChangeInfoResult::Unhandled; } template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint first, uint last, int prop, ByteReader &buf) { return IndustriesChangeInfo(first, last, prop, buf); } diff --git a/src/newgrf/newgrf_act0_objects.cpp b/src/newgrf/newgrf_act0_objects.cpp index 1ec6fa5eeb..2a542e28bf 100644 --- a/src/newgrf/newgrf_act0_objects.cpp +++ b/src/newgrf/newgrf_act0_objects.cpp @@ -24,7 +24,7 @@ */ static ChangeInfoResult IgnoreObjectProperty(uint prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; switch (prop) { case 0x0B: @@ -58,7 +58,7 @@ static ChangeInfoResult IgnoreObjectProperty(uint prop, ByteReader &buf) break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } @@ -75,11 +75,11 @@ static ChangeInfoResult IgnoreObjectProperty(uint prop, ByteReader &buf) */ static ChangeInfoResult ObjectChangeInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; if (last > NUM_OBJECTS_PER_GRF) { GrfMsg(1, "ObjectChangeInfo: Too many objects loaded ({}), max ({}). Ignoring.", last, NUM_OBJECTS_PER_GRF); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } /* Allocate object specs if they haven't been allocated already. */ @@ -191,7 +191,7 @@ static ChangeInfoResult ObjectChangeInfo(uint first, uint last, int prop, ByteRe break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } @@ -199,5 +199,5 @@ static ChangeInfoResult ObjectChangeInfo(uint first, uint last, int prop, ByteRe return ret; } -template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return CIR_UNHANDLED; } +template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return ChangeInfoResult::Unhandled; } template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint first, uint last, int prop, ByteReader &buf) { return ObjectChangeInfo(first, last, prop, buf); } diff --git a/src/newgrf/newgrf_act0_railtypes.cpp b/src/newgrf/newgrf_act0_railtypes.cpp index 1b3b75e739..35d912fa1d 100644 --- a/src/newgrf/newgrf_act0_railtypes.cpp +++ b/src/newgrf/newgrf_act0_railtypes.cpp @@ -26,19 +26,19 @@ */ static ChangeInfoResult RailTypeChangeInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; extern RailTypeInfo _railtypes[RAILTYPE_END]; const auto &type_map = _cur_gps.grffile->railtype_map; if (last > std::size(type_map)) { GrfMsg(1, "RailTypeChangeInfo: Rail type {} is invalid, max {}, ignoring", last, std::size(type_map)); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } for (uint id = first; id < last; ++id) { RailType rt = type_map[id]; - if (rt == INVALID_RAILTYPE) return CIR_INVALID_ID; + if (rt == INVALID_RAILTYPE) return ChangeInfoResult::InvalidId; RailTypeInfo *rti = &_railtypes[rt]; @@ -151,7 +151,7 @@ static ChangeInfoResult RailTypeChangeInfo(uint first, uint last, int prop, Byte break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } @@ -161,14 +161,14 @@ static ChangeInfoResult RailTypeChangeInfo(uint first, uint last, int prop, Byte static ChangeInfoResult RailTypeReserveInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; extern RailTypeInfo _railtypes[RAILTYPE_END]; auto &type_map = _cur_gps.grffile->railtype_map; if (last > std::size(type_map)) { GrfMsg(1, "RailTypeReserveInfo: Rail type {} is invalid, max {}, ignoring", last, std::size(type_map)); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } for (uint id = first; id < last; ++id) { @@ -236,7 +236,7 @@ static ChangeInfoResult RailTypeReserveInfo(uint first, uint last, int prop, Byt break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } diff --git a/src/newgrf/newgrf_act0_roadstops.cpp b/src/newgrf/newgrf_act0_roadstops.cpp index fe407af08f..c23f46f3ef 100644 --- a/src/newgrf/newgrf_act0_roadstops.cpp +++ b/src/newgrf/newgrf_act0_roadstops.cpp @@ -25,7 +25,7 @@ */ static ChangeInfoResult IgnoreRoadStopProperty(uint prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; switch (prop) { case 0x09: @@ -59,7 +59,7 @@ static ChangeInfoResult IgnoreRoadStopProperty(uint prop, ByteReader &buf) break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } @@ -68,11 +68,11 @@ static ChangeInfoResult IgnoreRoadStopProperty(uint prop, ByteReader &buf) static ChangeInfoResult RoadStopChangeInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; if (last > NUM_ROADSTOPS_PER_GRF) { GrfMsg(1, "RoadStopChangeInfo: RoadStop {} is invalid, max {}, ignoring", last, NUM_ROADSTOPS_PER_GRF); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } if (_cur_gps.grffile->roadstops.size() < last) _cur_gps.grffile->roadstops.resize(last); @@ -173,7 +173,7 @@ static ChangeInfoResult RoadStopChangeInfo(uint first, uint last, int prop, Byte break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } @@ -181,5 +181,5 @@ static ChangeInfoResult RoadStopChangeInfo(uint first, uint last, int prop, Byte return ret; } -template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return CIR_UNHANDLED; } +template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return ChangeInfoResult::Unhandled; } template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint first, uint last, int prop, ByteReader &buf) { return RoadStopChangeInfo(first, last, prop, buf); } diff --git a/src/newgrf/newgrf_act0_roadtypes.cpp b/src/newgrf/newgrf_act0_roadtypes.cpp index 72f58e2e6e..3a8e695bb0 100644 --- a/src/newgrf/newgrf_act0_roadtypes.cpp +++ b/src/newgrf/newgrf_act0_roadtypes.cpp @@ -27,19 +27,19 @@ */ static ChangeInfoResult RoadTypeChangeInfo(uint first, uint last, int prop, ByteReader &buf, RoadTramType rtt) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; extern RoadTypeInfo _roadtypes[ROADTYPE_END]; const auto &type_map = (rtt == RTT_TRAM) ? _cur_gps.grffile->tramtype_map : _cur_gps.grffile->roadtype_map; if (last > std::size(type_map)) { GrfMsg(1, "RoadTypeChangeInfo: Road type {} is invalid, max {}, ignoring", last, std::size(type_map)); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } for (uint id = first; id < last; ++id) { RoadType rt = type_map[id]; - if (rt == INVALID_ROADTYPE) return CIR_INVALID_ID; + if (rt == INVALID_ROADTYPE) return ChangeInfoResult::InvalidId; RoadTypeInfo *rti = &_roadtypes[rt]; @@ -138,7 +138,7 @@ static ChangeInfoResult RoadTypeChangeInfo(uint first, uint last, int prop, Byte break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } @@ -148,14 +148,14 @@ static ChangeInfoResult RoadTypeChangeInfo(uint first, uint last, int prop, Byte static ChangeInfoResult RoadTypeReserveInfo(uint first, uint last, int prop, ByteReader &buf, RoadTramType rtt) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; extern RoadTypeInfo _roadtypes[ROADTYPE_END]; auto &type_map = (rtt == RTT_TRAM) ? _cur_gps.grffile->tramtype_map : _cur_gps.grffile->roadtype_map; if (last > std::size(type_map)) { GrfMsg(1, "RoadTypeReserveInfo: Road type {} is invalid, max {}, ignoring", last, std::size(type_map)); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } for (uint id = first; id < last; ++id) { @@ -170,7 +170,7 @@ static ChangeInfoResult RoadTypeReserveInfo(uint first, uint last, int prop, Byt rt = AllocateRoadType(rtl, rtt); } else if (GetRoadTramType(rt) != rtt) { GrfMsg(1, "RoadTypeReserveInfo: Road type {} is invalid type (road/tram), ignoring", id); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } type_map[id] = rt; @@ -220,7 +220,7 @@ static ChangeInfoResult RoadTypeReserveInfo(uint first, uint last, int prop, Byt break; default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } diff --git a/src/newgrf/newgrf_act0_roadvehs.cpp b/src/newgrf/newgrf_act0_roadvehs.cpp index 17e8b7a23a..0217e06f28 100644 --- a/src/newgrf/newgrf_act0_roadvehs.cpp +++ b/src/newgrf/newgrf_act0_roadvehs.cpp @@ -29,11 +29,11 @@ */ static ChangeInfoResult RoadVehicleChangeInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; for (uint id = first; id < last; ++id) { Engine *e = GetNewEngine(_cur_gps.grffile, VEH_ROAD, id); - if (e == nullptr) return CIR_INVALID_ID; // No engine could be allocated, so neither can any next vehicles + if (e == nullptr) return ChangeInfoResult::InvalidId; // No engine could be allocated, so neither can any next vehicles EngineInfo *ei = &e->info; RoadVehicleInfo *rvi = &e->VehInfo(); @@ -234,5 +234,5 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint first, uint last, int prop, B return ret; } -template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return CIR_UNHANDLED; } +template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return ChangeInfoResult::Unhandled; } template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint first, uint last, int prop, ByteReader &buf) { return RoadVehicleChangeInfo(first, last, prop, buf); } diff --git a/src/newgrf/newgrf_act0_ships.cpp b/src/newgrf/newgrf_act0_ships.cpp index f5f2c902b8..0c72c840e7 100644 --- a/src/newgrf/newgrf_act0_ships.cpp +++ b/src/newgrf/newgrf_act0_ships.cpp @@ -30,11 +30,11 @@ */ static ChangeInfoResult ShipVehicleChangeInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; for (uint id = first; id < last; ++id) { Engine *e = GetNewEngine(_cur_gps.grffile, VEH_SHIP, id); - if (e == nullptr) return CIR_INVALID_ID; // No engine could be allocated, so neither can any next vehicles + if (e == nullptr) return ChangeInfoResult::InvalidId; // No engine could be allocated, so neither can any next vehicles EngineInfo *ei = &e->info; ShipVehicleInfo *svi = &e->VehInfo(); @@ -221,5 +221,5 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint first, uint last, int prop, B return ret; } -template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return CIR_UNHANDLED; } +template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return ChangeInfoResult::Unhandled; } template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint first, uint last, int prop, ByteReader &buf) { return ShipVehicleChangeInfo(first, last, prop, buf); } diff --git a/src/newgrf/newgrf_act0_sounds.cpp b/src/newgrf/newgrf_act0_sounds.cpp index 5318e9be82..4f1ad730c4 100644 --- a/src/newgrf/newgrf_act0_sounds.cpp +++ b/src/newgrf/newgrf_act0_sounds.cpp @@ -25,17 +25,17 @@ */ static ChangeInfoResult SoundEffectChangeInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; if (first == last) return ret; if (_cur_gps.grffile->sound_offset == 0) { GrfMsg(1, "SoundEffectChangeInfo: No effects defined, skipping"); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } if (last - ORIGINAL_SAMPLE_COUNT > _cur_gps.grffile->num_sounds) { GrfMsg(1, "SoundEffectChangeInfo: Attempting to change undefined sound effect ({}), max ({}). Ignoring.", last, ORIGINAL_SAMPLE_COUNT + _cur_gps.grffile->num_sounds); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } for (uint id = first; id < last; ++id) { @@ -65,7 +65,7 @@ static ChangeInfoResult SoundEffectChangeInfo(uint first, uint last, int prop, B } default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } @@ -73,5 +73,5 @@ static ChangeInfoResult SoundEffectChangeInfo(uint first, uint last, int prop, B return ret; } -template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return CIR_UNHANDLED; } +template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return ChangeInfoResult::Unhandled; } template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint first, uint last, int prop, ByteReader &buf) { return SoundEffectChangeInfo(first, last, prop, buf); } diff --git a/src/newgrf/newgrf_act0_stations.cpp b/src/newgrf/newgrf_act0_stations.cpp index 5e129d27ea..10873495fa 100644 --- a/src/newgrf/newgrf_act0_stations.cpp +++ b/src/newgrf/newgrf_act0_stations.cpp @@ -29,11 +29,11 @@ static const uint NUM_STATIONS_PER_GRF = UINT16_MAX - 1; */ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; if (last > NUM_STATIONS_PER_GRF) { GrfMsg(1, "StationChangeInfo: Station {} is invalid, max {}, ignoring", last, NUM_STATIONS_PER_GRF); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } /* Allocate station specs if necessary */ @@ -45,7 +45,7 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR /* Check that the station we are modifying is defined. */ if (statspec == nullptr && prop != 0x08) { GrfMsg(2, "StationChangeInfo: Attempt to modify undefined station {}, ignoring", id); - return CIR_INVALID_ID; + return ChangeInfoResult::InvalidId; } switch (prop) { @@ -81,7 +81,7 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR ReadSpriteLayoutSprite(buf, false, false, false, GSF_STATIONS, &dts->ground); /* On error, bail out immediately. Temporary GRF data was already freed */ - if (_cur_gps.skip_sprites < 0) return CIR_DISABLED; + if (_cur_gps.skip_sprites < 0) return ChangeInfoResult::Disabled; std::vector tmp_layout; for (;;) { @@ -99,7 +99,7 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR ReadSpriteLayoutSprite(buf, false, true, false, GSF_STATIONS, &dtss.image); /* On error, bail out immediately. Temporary GRF data was already freed */ - if (_cur_gps.skip_sprites < 0) return CIR_DISABLED; + if (_cur_gps.skip_sprites < 0) return ChangeInfoResult::Disabled; } dts->seq = std::move(tmp_layout); } @@ -257,7 +257,7 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR NewGRFSpriteLayout *dts = &statspec->renderdata.emplace_back(); uint num_building_sprites = buf.ReadByte(); /* On error, bail out immediately. Temporary GRF data was already freed */ - if (ReadSpriteLayout(buf, num_building_sprites, false, GSF_STATIONS, true, false, dts)) return CIR_DISABLED; + if (ReadSpriteLayout(buf, num_building_sprites, false, GSF_STATIONS, true, false, dts)) return ChangeInfoResult::Disabled; } /* Number of layouts must be even, alternating X and Y */ @@ -313,7 +313,7 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR } default: - ret = CIR_UNKNOWN; + ret = ChangeInfoResult::Unknown; break; } } @@ -321,5 +321,5 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR return ret; } -template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return CIR_UNHANDLED; } +template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return ChangeInfoResult::Unhandled; } template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint first, uint last, int prop, ByteReader &buf) { return StationChangeInfo(first, last, prop, buf); } diff --git a/src/newgrf/newgrf_act0_trains.cpp b/src/newgrf/newgrf_act0_trains.cpp index fe33efa9e3..e8dbfad7c7 100644 --- a/src/newgrf/newgrf_act0_trains.cpp +++ b/src/newgrf/newgrf_act0_trains.cpp @@ -28,11 +28,11 @@ */ ChangeInfoResult RailVehicleChangeInfo(uint first, uint last, int prop, ByteReader &buf) { - ChangeInfoResult ret = CIR_SUCCESS; + ChangeInfoResult ret = ChangeInfoResult::Success; for (uint id = first; id < last; ++id) { Engine *e = GetNewEngine(_cur_gps.grffile, VEH_TRAIN, id); - if (e == nullptr) return CIR_INVALID_ID; // No engine could be allocated, so neither can any next vehicles + if (e == nullptr) return ChangeInfoResult::InvalidId; // No engine could be allocated, so neither can any next vehicles EngineInfo *ei = &e->info; RailVehicleInfo *rvi = &e->VehInfo(); @@ -353,5 +353,5 @@ ChangeInfoResult RailVehicleChangeInfo(uint first, uint last, int prop, ByteRead return ret; } -template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return CIR_UNHANDLED; } +template <> ChangeInfoResult GrfChangeInfoHandler::Reserve(uint, uint, int, ByteReader &) { return ChangeInfoResult::Unhandled; } template <> ChangeInfoResult GrfChangeInfoHandler::Activation(uint first, uint last, int prop, ByteReader &buf) { return RailVehicleChangeInfo(first, last, prop, buf); } diff --git a/src/newgrf/newgrf_act3.cpp b/src/newgrf/newgrf_act3.cpp index c29100a6de..83720c59b4 100644 --- a/src/newgrf/newgrf_act3.cpp +++ b/src/newgrf/newgrf_act3.cpp @@ -104,7 +104,7 @@ static void VehicleMapSpriteGroup(ByteReader &buf, GrfSpecFeature feature, uint8 /* No engine could be allocated?!? Deal with it. Okay, * this might look bad. Also make sure this NewGRF * gets disabled, as a half loaded one is bad. */ - HandleChangeInfoResult("VehicleMapSpriteGroup", CIR_INVALID_ID, feature, 0); + HandleChangeInfoResult("VehicleMapSpriteGroup", ChangeInfoResult::InvalidId, feature, 0); return; } diff --git a/src/newgrf/newgrf_internal.h b/src/newgrf/newgrf_internal.h index 5aec0441b3..4db87c5d38 100644 --- a/src/newgrf/newgrf_internal.h +++ b/src/newgrf/newgrf_internal.h @@ -17,12 +17,12 @@ #include "newgrf_bytereader.h" /** Possible return values for the GrfChangeInfoHandler functions */ -enum ChangeInfoResult : uint8_t { - CIR_SUCCESS, ///< Variable was parsed and read - CIR_DISABLED, ///< GRF was disabled due to error - CIR_UNHANDLED, ///< Variable was parsed but unread - CIR_UNKNOWN, ///< Variable is unknown - CIR_INVALID_ID, ///< Attempt to modify an invalid ID +enum class ChangeInfoResult : uint8_t { + Success, ///< Variable was parsed and read + Disabled, ///< GRF was disabled due to error + Unhandled, ///< Variable was parsed but unread + Unknown, ///< Variable is unknown + InvalidId, ///< Attempt to modify an invalid ID }; /** GRF feature handler */