diff --git a/src/fios.h b/src/fios.h index 8a2fc84c8d..d80910c374 100644 --- a/src/fios.h +++ b/src/fios.h @@ -45,7 +45,7 @@ struct LoadCheckData { CompanyPropertiesMap companies{}; ///< Company information. GRFConfigList grfconfig{}; ///< NewGrf configuration from save. - GRFListCompatibility grf_compatibility = GLC_NOT_FOUND; ///< Summary state of NewGrfs, whether missing files or only compatible found. + GRFListCompatibility grf_compatibility = GRFListCompatibility::NotFound; ///< Summary state of NewGrfs, whether missing files or only compatible found. Gamelog gamelog{}; ///< Gamelog actions diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index 7ede8083e8..50f47fab69 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -626,7 +626,7 @@ public: if (tr.top > tr.bottom) return; /* NewGrf compatibility */ - DrawString(tr, GetString(STR_SAVELOAD_DETAIL_GRFSTATUS, _load_check_data.grfconfig.empty() ? STR_NEWGRF_LIST_NONE : STR_NEWGRF_LIST_ALL_FOUND + _load_check_data.grf_compatibility)); + DrawString(tr, GetString(STR_SAVELOAD_DETAIL_GRFSTATUS, _load_check_data.grfconfig.empty() ? STR_NEWGRF_LIST_NONE : STR_NEWGRF_LIST_ALL_FOUND + to_underlying(_load_check_data.grf_compatibility))); tr.top += GetCharacterHeight(FS_NORMAL); } if (tr.top > tr.bottom) return; @@ -719,7 +719,7 @@ public: } else if (this->abstract_filetype == FT_TOWN_DATA) { this->Close(); LoadTownData(); - } else if (!_load_check_data.HasNewGrfs() || _load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs()) { + } else if (!_load_check_data.HasNewGrfs() || _load_check_data.grf_compatibility != GRFListCompatibility::NotFound || _settings_client.gui.UserIsAllowedToChangeNewGRFs()) { _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD_GAME; ClearErrorMessages(); this->Close(); @@ -948,12 +948,12 @@ public: case FT_SCENARIO: { bool disabled = this->selected == nullptr || _load_check_data.HasErrors(); if (!_settings_client.gui.UserIsAllowedToChangeNewGRFs()) { - disabled |= _load_check_data.HasNewGrfs() && _load_check_data.grf_compatibility == GLC_NOT_FOUND; + disabled |= _load_check_data.HasNewGrfs() && _load_check_data.grf_compatibility == GRFListCompatibility::NotFound; } this->SetWidgetDisabledState(WID_SL_LOAD_BUTTON, disabled); this->SetWidgetDisabledState(WID_SL_NEWGRF_INFO, !_load_check_data.HasNewGrfs()); this->SetWidgetDisabledState(WID_SL_MISSING_NEWGRFS, - !_load_check_data.HasNewGrfs() || _load_check_data.grf_compatibility == GLC_ALL_GOOD); + !_load_check_data.HasNewGrfs() || _load_check_data.grf_compatibility == GRFListCompatibility::AllGood); break; } diff --git a/src/gamelog.cpp b/src/gamelog.cpp index 413e239de2..a06160b734 100644 --- a/src/gamelog.cpp +++ b/src/gamelog.cpp @@ -509,7 +509,7 @@ bool Gamelog::GRFBugReverse(uint32_t grfid, uint16_t internal_id) */ static inline bool IsLoggableGrfConfig(const GRFConfig &g) { - return !g.flags.Test(GRFConfigFlag::Static) && g.status != GCS_NOT_FOUND; + return !g.flags.Test(GRFConfigFlag::Static) && g.status != GRFStatus::NotFound; } /** diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp index a3a5b91a6e..0772e8cdec 100644 --- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -270,7 +270,7 @@ static bool SwitchNewGRFBlitter() uint depth_wanted_by_base = BaseGraphics::GetUsedSet()->blitter == BLT_32BPP ? 32 : 8; uint depth_wanted_by_grf = _support8bpp != S8BPP_NONE ? 8 : 32; for (const auto &c : _grfconfig) { - if (c->status == GCS_DISABLED || c->status == GCS_NOT_FOUND || c->flags.Test(GRFConfigFlag::InitOnly)) continue; + if (c->status == GRFStatus::Disabled || c->status == GRFStatus::NotFound || c->flags.Test(GRFConfigFlag::InitOnly)) continue; if (c->palette & GRFP_BLT_32BPP) depth_wanted_by_grf = 32; } /* We need a 32bpp blitter for font anti-alias. */ diff --git a/src/network/core/network_game_info.cpp b/src/network/core/network_game_info.cpp index 1449436541..d12a3ca818 100644 --- a/src/network/core/network_game_info.cpp +++ b/src/network/core/network_game_info.cpp @@ -132,7 +132,7 @@ void CheckGameCompatibility(NetworkGameInfo &ngi) /* Check if we have all the GRFs on the client-system too. */ for (const auto &c : ngi.grfconfig) { - if (c->status == GCS_NOT_FOUND) ngi.compatible = false; + if (c->status == GRFStatus::NotFound) ngi.compatible = false; } } @@ -188,7 +188,7 @@ static void HandleIncomingNetworkGameInfoGRFConfig(GRFConfig &config, std::strin const GRFConfig *f = FindGRFConfig(config.ident.grfid, FGCM_EXACT, &config.ident.md5sum); if (f == nullptr) { AddGRFTextToList(config.name, name.empty() ? GetString(STR_CONFIG_ERROR_INVALID_GRF_UNKNOWN) : name); - config.status = GCS_NOT_FOUND; + config.status = GRFStatus::NotFound; } else { config.filename = f->filename; config.name = f->name; diff --git a/src/network/network_gamelist.cpp b/src/network/network_gamelist.cpp index 8912abbdae..f72674e909 100644 --- a/src/network/network_gamelist.cpp +++ b/src/network/network_gamelist.cpp @@ -86,7 +86,7 @@ void NetworkAfterNewGRFScan() const GRFConfig *f = FindGRFConfig(c->ident.grfid, FGCM_EXACT, &c->ident.md5sum); if (f == nullptr) { /* Don't know the GRF (anymore), so mark game incompatible. */ - c->status = GCS_NOT_FOUND; + c->status = GRFStatus::NotFound; /* If we miss a file, we're obviously incompatible. */ item->info.compatible = false; @@ -94,7 +94,7 @@ void NetworkAfterNewGRFScan() c->filename = f->filename; c->name = f->name; c->info = f->info; - c->status = GCS_UNKNOWN; + c->status = GRFStatus::Unknown; } } } diff --git a/src/newgrf.cpp b/src/newgrf.cpp index b3a401549b..1edcdc2172 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -146,7 +146,7 @@ GRFError *DisableGrf(StringID message, GRFConfig *config) file = _cur_gps.grffile; } - config->status = GCS_DISABLED; + config->status = GRFStatus::Disabled; if (file != nullptr) ClearTemporaryNewGRFData(file); if (config == _cur_gps.grfconfig) _cur_gps.skip_sprites = -1; @@ -1410,7 +1410,7 @@ void LoadNewGRFFile(GRFConfig &config, GrfLoadingStage stage, Subdirectory subdi if (stage != GrfLoadingStage::FileScan && stage != GrfLoadingStage::SafetyScan && stage != GrfLoadingStage::LabelScan) { _cur_gps.grffile = GetFileByFilename(filename); if (_cur_gps.grffile == nullptr) UserError("File '{}' lost in cache.\n", filename); - if (stage == GrfLoadingStage::Reserve && config.status != GCS_INITIALISED) return; + if (stage == GrfLoadingStage::Reserve && config.status != GRFStatus::Initialised) return; if (stage == GrfLoadingStage::Activation && !config.flags.Test(GRFConfigFlag::Reserved)) return; } @@ -1802,7 +1802,7 @@ void LoadNewGRF(SpriteID load_index, uint num_baseset) * have been enabled. */ for (const auto &c : _grfconfig) { - if (c->status != GCS_NOT_FOUND) c->status = GCS_UNKNOWN; + if (c->status != GRFStatus::NotFound) c->status = GRFStatus::Unknown; } _cur_gps.spriteid = load_index; @@ -1814,7 +1814,7 @@ void LoadNewGRF(SpriteID load_index, uint num_baseset) /* Set activated grfs back to will-be-activated between reservation- and activation-stage. * This ensures that action7/9 conditions 0x06 - 0x0A work correctly. */ for (const auto &c : _grfconfig) { - if (c->status == GCS_ACTIVATED) c->status = GCS_INITIALISED; + if (c->status == GRFStatus::Activated) c->status = GRFStatus::Initialised; } if (stage == GrfLoadingStage::Reserve) { @@ -1833,13 +1833,13 @@ void LoadNewGRF(SpriteID load_index, uint num_baseset) _cur_gps.stage = stage; for (const auto &c : _grfconfig) { - if (c->status == GCS_DISABLED || c->status == GCS_NOT_FOUND) continue; + if (c->status == GRFStatus::Disabled || c->status == GRFStatus::NotFound) continue; if (stage > GrfLoadingStage::Init && c->flags.Test(GRFConfigFlag::InitOnly)) continue; Subdirectory subdir = num_grfs < num_baseset ? BASESET_DIR : NEWGRF_DIR; if (!FioCheckFileExists(c->filename, subdir)) { Debug(grf, 0, "NewGRF file is missing '{}'; disabling", c->filename); - c->status = GCS_NOT_FOUND; + c->status = GRFStatus::NotFound; continue; } @@ -1848,7 +1848,7 @@ void LoadNewGRF(SpriteID load_index, uint num_baseset) if (!c->flags.Test(GRFConfigFlag::Static) && !c->flags.Test(GRFConfigFlag::System)) { if (num_non_static == NETWORK_MAX_GRF_COUNT) { Debug(grf, 0, "'{}' is not loaded as the maximum number of non-static GRFs has been reached", c->filename); - c->status = GCS_DISABLED; + c->status = GRFStatus::Disabled; c->errors.emplace_back(STR_NEWGRF_ERROR_MSG_FATAL, 0, STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED); continue; } diff --git a/src/newgrf/newgrf_act13.cpp b/src/newgrf/newgrf_act13.cpp index 3091e697bc..c717275773 100644 --- a/src/newgrf/newgrf_act13.cpp +++ b/src/newgrf/newgrf_act13.cpp @@ -33,12 +33,12 @@ static void TranslateGRFStrings(ByteReader &buf) uint32_t grfid = buf.ReadDWord(); const GRFConfig *c = GetGRFConfig(grfid); - if (c == nullptr || (c->status != GCS_INITIALISED && c->status != GCS_ACTIVATED)) { + if (c == nullptr || (c->status != GRFStatus::Initialised && c->status != GRFStatus::Activated)) { GrfMsg(7, "TranslateGRFStrings: GRFID 0x{:08X} unknown, skipping action 13", std::byteswap(grfid)); return; } - if (c->status == GCS_INITIALISED) { + if (c->status == GRFStatus::Initialised) { /* If the file is not active but will be activated later, give an error * and disable this file. */ GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LOAD_AFTER); diff --git a/src/newgrf/newgrf_act14.cpp b/src/newgrf/newgrf_act14.cpp index d85441915b..924a5518af 100644 --- a/src/newgrf/newgrf_act14.cpp +++ b/src/newgrf/newgrf_act14.cpp @@ -152,11 +152,16 @@ static bool ChangeGRFParamType(size_t len, ByteReader &buf) GrfMsg(2, "StaticGRFInfo: expected 1 byte for 'INFO'->'PARA'->'TYPE' but got {}, ignoring this field", len); buf.Skip(len); } else { - GRFParameterType type = (GRFParameterType)buf.ReadByte(); - if (type < PTYPE_END) { - _cur_parameter->type = type; - } else { - GrfMsg(3, "StaticGRFInfo: unknown parameter type {}, ignoring this field", type); + GRFParameterType type = static_cast(buf.ReadByte()); + switch (type) { + case GRFParameterType::UintEnum: + case GRFParameterType::Bool: + _cur_parameter->type = type; + break; + + default: + GrfMsg(3, "StaticGRFInfo: unknown parameter type {}, ignoring this field", type); + break; } } return true; @@ -165,7 +170,7 @@ static bool ChangeGRFParamType(size_t len, ByteReader &buf) /** Callback function for 'INFO'->'PARAM'->param_num->'LIMI' to set the min/max value of a parameter. @copydoc DataHandler */ static bool ChangeGRFParamLimits(size_t len, ByteReader &buf) { - if (_cur_parameter->type != PTYPE_UINT_ENUM) { + if (_cur_parameter->type != GRFParameterType::UintEnum) { GrfMsg(2, "StaticGRFInfo: 'INFO'->'PARA'->'LIMI' is only valid for parameters with type uint/enum, ignoring this field"); buf.Skip(len); } else if (len != 8) { diff --git a/src/newgrf/newgrf_act7_9.cpp b/src/newgrf/newgrf_act7_9.cpp index 464c2eb05f..80c813a987 100644 --- a/src/newgrf/newgrf_act7_9.cpp +++ b/src/newgrf/newgrf_act7_9.cpp @@ -250,24 +250,24 @@ static void SkipIf(ByteReader &buf) switch (condtype) { /* Tests 0x06 to 0x0A are only for param 0x88, GRFID checks */ case 0x06: // Is GRFID active? - result = c->status == GCS_ACTIVATED; + result = c->status == GRFStatus::Activated; break; case 0x07: // Is GRFID non-active? - result = c->status != GCS_ACTIVATED; + result = c->status != GRFStatus::Activated; break; case 0x08: // GRFID is not but will be active? - result = c->status == GCS_INITIALISED; + result = c->status == GRFStatus::Initialised; break; case 0x09: // GRFID is or will be active? - result = c->status == GCS_ACTIVATED || c->status == GCS_INITIALISED; + result = c->status == GRFStatus::Activated || c->status == GRFStatus::Initialised; break; case 0x0A: // GRFID is not nor will be active /* This is the only condtype that doesn't get ignored if the GRFID is not found */ - result = c == nullptr || c->status == GCS_DISABLED || c->status == GCS_NOT_FOUND; + result = c == nullptr || c->status == GRFStatus::Disabled || c->status == GRFStatus::NotFound; break; default: GrfMsg(1, "SkipIf: Unsupported GRF condition type {:02X}. Ignoring", condtype); return; @@ -332,7 +332,7 @@ static void SkipIf(ByteReader &buf) _cur_gps.skip_sprites = -1; /* If an action 8 hasn't been encountered yet, disable the grf. */ - if (_cur_gps.grfconfig->status != (_cur_gps.stage < GrfLoadingStage::Reserve ? GCS_INITIALISED : GCS_ACTIVATED)) { + if (_cur_gps.grfconfig->status != (_cur_gps.stage < GrfLoadingStage::Reserve ? GRFStatus::Initialised : GRFStatus::Activated)) { DisableGrf(); } } diff --git a/src/newgrf/newgrf_act8.cpp b/src/newgrf/newgrf_act8.cpp index 6284871eb4..6e1e259803 100644 --- a/src/newgrf/newgrf_act8.cpp +++ b/src/newgrf/newgrf_act8.cpp @@ -59,7 +59,7 @@ static void GRFInfo(ByteReader &buf) uint32_t grfid = buf.ReadDWord(); std::string_view name = buf.ReadString(); - if (_cur_gps.stage < GrfLoadingStage::Reserve && _cur_gps.grfconfig->status != GCS_UNKNOWN) { + if (_cur_gps.stage < GrfLoadingStage::Reserve && _cur_gps.grfconfig->status != GRFStatus::Unknown) { DisableGrf(STR_NEWGRF_ERROR_MULTIPLE_ACTION_8); return; } @@ -70,7 +70,7 @@ static void GRFInfo(ByteReader &buf) } _cur_gps.grffile->grf_version = version; - _cur_gps.grfconfig->status = _cur_gps.stage < GrfLoadingStage::Reserve ? GCS_INITIALISED : GCS_ACTIVATED; + _cur_gps.grfconfig->status = _cur_gps.stage < GrfLoadingStage::Reserve ? GRFStatus::Initialised : GRFStatus::Activated; /* Do swap the GRFID for displaying purposes since people expect that */ Debug(grf, 1, "GRFInfo: Loaded GRFv{} set {:08X} - {} (palette: {}, version: {})", version, std::byteswap(grfid), StrMakeValid(name), (_cur_gps.grfconfig->palette & GRFP_USE_MASK) ? "Windows" : "DOS", _cur_gps.grfconfig->version); diff --git a/src/newgrf/newgrf_actd.cpp b/src/newgrf/newgrf_actd.cpp index e552fbfd5c..b7a2f00627 100644 --- a/src/newgrf/newgrf_actd.cpp +++ b/src/newgrf/newgrf_actd.cpp @@ -322,7 +322,7 @@ static void ParamSet(ByteReader &buf) /* Disable the read GRF if it is a static NewGRF. */ DisableStaticNewGRFInfluencingNonStaticNewGRFs(*c); src1 = 0; - } else if (file == nullptr || c == nullptr || c->status == GCS_DISABLED) { + } else if (file == nullptr || c == nullptr || c->status == GRFStatus::Disabled) { src1 = 0; } else if (src1 == 0xFE) { src1 = c->version; diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index 85660b07f4..982bc0b696 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -294,7 +294,7 @@ static bool CalcGRFMD5Sum(GRFConfig &config, Subdirectory subdir) bool FillGRFDetails(GRFConfig &config, bool is_static, Subdirectory subdir) { if (!FioCheckFileExists(config.filename, subdir)) { - config.status = GCS_NOT_FOUND; + config.status = GRFStatus::NotFound; return false; } @@ -421,15 +421,15 @@ void ResetGRFConfig(bool defaults) * @param grfconfig GrfConfig to check * @return will return any of the following 3 values:
* */ GRFListCompatibility IsGoodGRFConfigList(GRFConfigList &grfconfig) { - GRFListCompatibility res = GLC_ALL_GOOD; + GRFListCompatibility res = GRFListCompatibility::AllGood; for (auto &c : grfconfig) { const GRFConfig *f = FindGRFConfig(c->ident.grfid, FGCM_EXACT, &c->ident.md5sum); @@ -446,15 +446,15 @@ GRFListCompatibility IsGoodGRFConfigList(GRFConfigList &grfconfig) } /* Non-found has precedence over compatibility load */ - if (res != GLC_NOT_FOUND) res = GLC_COMPATIBLE; + if (res != GRFListCompatibility::NotFound) res = GRFListCompatibility::Compatible; goto compatible_grf; } /* No compatible grf was found, mark it as disabled */ Debug(grf, 0, "NewGRF {:08X} ({}) not found; checksum {}", std::byteswap(c->ident.grfid), c->filename, FormatArrayAsHex(c->ident.md5sum)); - c->status = GCS_NOT_FOUND; - res = GLC_NOT_FOUND; + c->status = GRFStatus::NotFound; + res = GRFListCompatibility::NotFound; } else { compatible_grf: Debug(grf, 1, "Loading GRF {:08X} from {}", std::byteswap(f->ident.grfid), f->filename); diff --git a/src/newgrf_config.h b/src/newgrf_config.h index 0dab5f68d7..0bb5f27c9b 100644 --- a/src/newgrf_config.h +++ b/src/newgrf_config.h @@ -30,12 +30,12 @@ enum class GRFConfigFlag : uint8_t { using GRFConfigFlags = EnumBitSet; /** Status of GRF */ -enum GRFStatus : uint8_t { - GCS_UNKNOWN, ///< The status of this grf file is unknown - GCS_DISABLED, ///< GRF file is disabled - GCS_NOT_FOUND, ///< GRF file was not found in the local cache - GCS_INITIALISED, ///< GRF file has been initialised - GCS_ACTIVATED, ///< GRF file has been activated +enum class GRFStatus : uint8_t { + Unknown, ///< The status of this grf file is unknown + Disabled, ///< GRF file is disabled + NotFound, ///< GRF file was not found in the local cache + Initialised, ///< GRF file has been initialised + Activated, ///< GRF file has been activated }; /** Encountered GRF bugs */ @@ -49,10 +49,10 @@ enum class GRFBug : uint8_t { using GRFBugs = EnumBitSet; /** Status of post-gameload GRF compatibility check */ -enum GRFListCompatibility : uint8_t { - GLC_ALL_GOOD, ///< All GRF needed by game are present - GLC_COMPATIBLE, ///< Compatible (eg. the same ID, but different checksum) GRF found in at least one case - GLC_NOT_FOUND, ///< At least one GRF couldn't be found (higher priority than GLC_COMPATIBLE) +enum class GRFListCompatibility : uint8_t { + AllGood, ///< All GRF needed by game are present + Compatible, ///< Compatible (eg. the same ID, but different checksum) GRF found in at least one case + NotFound, ///< At least one GRF couldn't be found (higher priority than GRFListCompatibility::Compatible) }; /** Information that can/has to be stored about a GRF's palette. */ @@ -119,10 +119,9 @@ struct GRFError { }; /** The possible types of a newgrf parameter. */ -enum GRFParameterType : uint8_t { - PTYPE_UINT_ENUM, ///< The parameter allows a range of numbers, each of which can have a special name - PTYPE_BOOL, ///< The parameter is either 0 or 1 - PTYPE_END, ///< Invalid parameter type +enum class GRFParameterType : uint8_t { + UintEnum, ///< The parameter allows a range of numbers, each of which can have a special name + Bool, ///< The parameter is either 0 or 1 }; /** Information about one grf parameter. */ @@ -140,7 +139,7 @@ struct GRFParameterInfo { uint32_t max_value = UINT32_MAX; ///< The maximal value of this parameter uint32_t def_value = 0; ///< Default value of this parameter - GRFParameterType type = PTYPE_UINT_ENUM; ///< The type of this parameter + GRFParameterType type = GRFParameterType::UintEnum; ///< The type of this parameter uint8_t param_nr; ///< GRF parameter to store content in uint8_t first_bit = 0; ///< First bit to use in the GRF parameter @@ -176,7 +175,7 @@ struct GRFConfig { uint32_t version = 0; ///< NOSAVE: Version a NewGRF can set so only the newest NewGRF is shown uint32_t min_loadable_version = 0; ///< NOSAVE: Minimum compatible version a NewGRF can define GRFConfigFlags flags = {}; ///< NOSAVE: GCF_Flags, bitset - GRFStatus status = GCS_UNKNOWN; ///< NOSAVE: GRFStatus, enum + GRFStatus status = GRFStatus::Unknown; ///< NOSAVE: GRFStatus, enum GRFBugs grf_bugs = {}; ///< NOSAVE: bugs in this GRF in this run, @see enum GRFBugs uint8_t num_valid_params = MAX_NUM_PARAMS; ///< NOSAVE: Number of valid parameters (action 0x14) uint8_t palette = 0; ///< GRFPalette, bitset diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index cbe6727a6c..a299288fe5 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -126,8 +126,8 @@ static void ShowNewGRFInfo(const GRFConfig &c, const Rect &r, bool show_params) } /* Show flags */ - if (c.status == GCS_NOT_FOUND) tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_NOT_FOUND); - if (c.status == GCS_DISABLED) tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_DISABLED); + if (c.status == GRFStatus::NotFound) tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_NOT_FOUND); + if (c.status == GRFStatus::Disabled) tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_DISABLED); if (c.flags.Test(GRFConfigFlag::Invalid)) tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_INCOMPATIBLE); if (c.flags.Test(GRFConfigFlag::Compatible)) tr.top = DrawStringMultiLine(tr, STR_NEWGRF_COMPATIBLE_LOADED); @@ -260,7 +260,7 @@ struct NewGRFParametersWindow : public Window { std::pair GetValueParams(const GRFParameterInfo &par_info, uint32_t value) const { - if (par_info.type == PTYPE_BOOL) return {value != 0 ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF, {}}; + if (par_info.type == GRFParameterType::Bool) return {value != 0 ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF, {}}; auto it = std::ranges::lower_bound(par_info.value_names, value, std::less{}, &GRFParameterInfo::ValueName::first); if (it != std::end(par_info.value_names) && it->first == value) { @@ -304,9 +304,9 @@ struct NewGRFParametersWindow : public Window { uint32_t current_value = this->grf_config.GetValue(par_info); bool selected = (i == this->clicked_row); - if (par_info.type == PTYPE_BOOL) { + if (par_info.type == GRFParameterType::Bool) { DrawBoolButton(buttons_left, ir.top + button_y_offset, COLOUR_YELLOW, COLOUR_MAUVE, current_value != 0, this->editable); - } else if (par_info.type == PTYPE_UINT_ENUM) { + } else if (par_info.type == GRFParameterType::UintEnum) { if (par_info.complete_labels) { DrawDropDownButton(buttons_left, ir.top + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && this->clicked_dropdown, this->editable); } else { @@ -367,7 +367,7 @@ struct NewGRFParametersWindow : public Window { /* One of the arrows is clicked */ uint32_t old_val = this->grf_config.GetValue(par_info); - if (par_info.type != PTYPE_BOOL && IsInsideMM(x, 0, SETTING_BUTTON_WIDTH) && par_info.complete_labels) { + if (par_info.type != GRFParameterType::Bool && IsInsideMM(x, 0, SETTING_BUTTON_WIDTH) && par_info.complete_labels) { if (this->clicked_dropdown) { /* unclick the dropdown */ this->CloseChildWindows(WC_DROPDOWN_MENU); @@ -399,7 +399,7 @@ struct NewGRFParametersWindow : public Window { } } else if (IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) { uint32_t val = old_val; - if (par_info.type == PTYPE_BOOL) { + if (par_info.type == GRFParameterType::Bool) { val = !val; } else { if (x >= SETTING_BUTTON_WIDTH / 2) { @@ -418,7 +418,7 @@ struct NewGRFParametersWindow : public Window { this->clicked_button = num; this->unclick_timeout.Reset(); } - } else if (par_info.type == PTYPE_UINT_ENUM && !par_info.complete_labels && click_count >= 2) { + } else if (par_info.type == GRFParameterType::UintEnum && !par_info.complete_labels && click_count >= 2) { /* Display a query box so users can enter a custom value. */ ShowQueryString(GetString(STR_JUST_INT, old_val), STR_CONFIG_SETTING_QUERY_CAPTION, 10, this, CS_NUMERAL, {}); } @@ -808,11 +808,11 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { /* Pick a colour */ switch (c.status) { - case GCS_NOT_FOUND: - case GCS_DISABLED: + case GRFStatus::NotFound: + case GRFStatus::Disabled: pal = PALETTE_TO_RED; break; - case GCS_ACTIVATED: + case GRFStatus::Activated: pal = PALETTE_TO_GREEN; break; default: @@ -1205,7 +1205,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { /* Search the list for items that are now found and mark them as such. */ for (auto &c : this->actives) { bool compatible = c->flags.Test(GRFConfigFlag::Compatible); - if (c->status != GCS_NOT_FOUND && !compatible) continue; + if (c->status != GRFStatus::NotFound && !compatible) continue; const GRFConfig *f = FindGRFConfig(c->ident.grfid, FGCM_EXACT, compatible ? &c->original_md5sum : &c->ident.md5sum); if (f == nullptr || f->flags.Test(GRFConfigFlag::Invalid)) continue; @@ -1273,7 +1273,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { bool has_missing = false; bool has_compatible = false; for (const auto &c : this->actives) { - has_missing |= c->status == GCS_NOT_FOUND; + has_missing |= c->status == GRFStatus::NotFound; has_compatible |= c->flags.Test(GRFConfigFlag::Compatible); } StringID text; @@ -1507,7 +1507,7 @@ void ShowMissingContentWindow(const GRFConfigList &list) /* Only show the things in the current list, or everything when nothing's selected */ ContentVector cv; for (const auto &c : list) { - if (c->status != GCS_NOT_FOUND && !c->flags.Test(GRFConfigFlag::Compatible)) continue; + if (c->status != GRFStatus::NotFound && !c->flags.Test(GRFConfigFlag::Compatible)) continue; auto ci = std::make_unique(); ci->type = CONTENT_TYPE_NEWGRF; diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index f08eb42bf4..67392006dc 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -366,7 +366,7 @@ static void CDECL HandleSavegameLoadCrash(int signum) message.reserve(1024); message += "Loading your savegame caused OpenTTD to crash.\n"; - _saveload_crash_with_missing_newgrfs = std::ranges::any_of(_grfconfig, [](const auto &c) { return c->flags.Test(GRFConfigFlag::Compatible) || c->status == GCS_NOT_FOUND; }); + _saveload_crash_with_missing_newgrfs = std::ranges::any_of(_grfconfig, [](const auto &c) { return c->flags.Test(GRFConfigFlag::Compatible) || c->status == GRFStatus::NotFound; }); if (_saveload_crash_with_missing_newgrfs) { message += @@ -388,7 +388,7 @@ static void CDECL HandleSavegameLoadCrash(int signum) format_append(message, "NewGRF {:08X} (checksum {}) not found.\n Loaded NewGRF \"{}\" (checksum {}) with same GRF ID instead.\n", std::byteswap(c->ident.grfid), FormatArrayAsHex(c->original_md5sum), c->filename, FormatArrayAsHex(replaced.md5sum)); } - if (c->status == GCS_NOT_FOUND) { + if (c->status == GRFStatus::NotFound) { format_append(message, "NewGRF {:08X} ({}) not found; checksum {}.\n", std::byteswap(c->ident.grfid), c->filename, FormatArrayAsHex(c->ident.md5sum)); } @@ -706,14 +706,14 @@ bool AfterLoadGame() /* Check if all NewGRFs are present, we are very strict in MP mode */ GRFListCompatibility gcf_res = IsGoodGRFConfigList(_grfconfig); for (const auto &c : _grfconfig) { - if (c->status == GCS_NOT_FOUND) { + if (c->status == GRFStatus::NotFound) { _gamelog.GRFRemove(c->ident.grfid); } else if (c->flags.Test(GRFConfigFlag::Compatible)) { _gamelog.GRFCompatible(c->ident); } } - if (_networking && gcf_res != GLC_ALL_GOOD) { + if (_networking && gcf_res != GRFListCompatibility::AllGood) { SetSaveLoadError(STR_NETWORK_ERROR_CLIENT_NEWGRF_MISMATCH); /* Restore the signals */ ResetSignalHandlers(); @@ -721,8 +721,8 @@ bool AfterLoadGame() } switch (gcf_res) { - case GLC_COMPATIBLE: ShowErrorMessage(GetEncodedString(STR_NEWGRF_COMPATIBLE_LOAD_WARNING), {}, WL_CRITICAL); break; - case GLC_NOT_FOUND: ShowErrorMessage(GetEncodedString(STR_NEWGRF_DISABLED_WARNING), {}, WL_CRITICAL); _pause_mode = PauseMode::Error; break; + case GRFListCompatibility::Compatible: ShowErrorMessage(GetEncodedString(STR_NEWGRF_COMPATIBLE_LOAD_WARNING), {}, WL_CRITICAL); break; + case GRFListCompatibility::NotFound: ShowErrorMessage(GetEncodedString(STR_NEWGRF_DISABLED_WARNING), {}, WL_CRITICAL); _pause_mode = PauseMode::Error; break; default: break; } @@ -2957,7 +2957,7 @@ bool AfterLoadGame() /* When any NewGRF has been changed the availability of some vehicles might * have been changed too. e->company_avail must be set to 0 in that case * which is done by StartupEngines(). */ - if (gcf_res != GLC_ALL_GOOD) StartupEngines(); + if (gcf_res != GRFListCompatibility::AllGood) StartupEngines(); /* The road owner of standard road stops was not properly accounted for. */ if (IsSavegameVersionBefore(SLV_172)) { diff --git a/src/settings.cpp b/src/settings.cpp index 769f6528a5..2ee51b6309 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1121,7 +1121,7 @@ static GRFConfigList GRFLoadConfig(const IniFile &ini, std::string_view grpname, /* Check if item is valid */ if (!FillGRFDetails(*c, is_static) || c->flags.Test(GRFConfigFlag::Invalid)) { StringID reason; - if (c->status == GCS_NOT_FOUND) { + if (c->status == GRFStatus::NotFound) { reason = STR_CONFIG_ERROR_INVALID_GRF_NOT_FOUND; } else if (c->flags.Test(GRFConfigFlag::Unsafe)) { reason = STR_CONFIG_ERROR_INVALID_GRF_UNSAFE; diff --git a/src/survey.cpp b/src/survey.cpp index 15ac6c1384..607b59c741 100644 --- a/src/survey.cpp +++ b/src/survey.cpp @@ -82,11 +82,11 @@ #ifndef DOXYGEN_API NLOHMANN_JSON_SERIALIZE_ENUM(GRFStatus, { - {GRFStatus::GCS_UNKNOWN, "unknown"}, - {GRFStatus::GCS_DISABLED, "disabled"}, - {GRFStatus::GCS_NOT_FOUND, "not found"}, - {GRFStatus::GCS_INITIALISED, "initialised"}, - {GRFStatus::GCS_ACTIVATED, "activated"}, + {GRFStatus::Unknown, "unknown"}, + {GRFStatus::Disabled, "disabled"}, + {GRFStatus::NotFound, "not found"}, + {GRFStatus::Initialised, "initialised"}, + {GRFStatus::Activated, "activated"}, }) NLOHMANN_JSON_SERIALIZE_ENUM(SocialIntegrationPlugin::State, {