From 1cfad1474a8deec5d48c6d1f91bff543b5c1dc29 Mon Sep 17 00:00:00 2001 From: frosch Date: Wed, 9 Apr 2025 20:13:28 +0200 Subject: [PATCH] Codechange: Rename _cur to _cur_gps. --- src/newgrf.cpp | 74 +++++++-------- src/newgrf/newgrf_act0.cpp | 8 +- src/newgrf/newgrf_act0_aircraft.cpp | 12 +-- src/newgrf/newgrf_act0_airports.cpp | 20 ++--- src/newgrf/newgrf_act0_badges.cpp | 6 +- src/newgrf/newgrf_act0_canals.cpp | 2 +- src/newgrf/newgrf_act0_cargo.cpp | 2 +- src/newgrf/newgrf_act0_globalvar.cpp | 16 ++-- src/newgrf/newgrf_act0_houses.cpp | 16 ++-- src/newgrf/newgrf_act0_industries.cpp | 34 +++---- src/newgrf/newgrf_act0_objects.cpp | 4 +- src/newgrf/newgrf_act0_railtypes.cpp | 10 +-- src/newgrf/newgrf_act0_roadstops.cpp | 4 +- src/newgrf/newgrf_act0_roadtypes.cpp | 4 +- src/newgrf/newgrf_act0_roadvehs.cpp | 16 ++-- src/newgrf/newgrf_act0_ships.cpp | 16 ++-- src/newgrf/newgrf_act0_sounds.cpp | 8 +- src/newgrf/newgrf_act0_stations.cpp | 14 +-- src/newgrf/newgrf_act0_trains.cpp | 20 ++--- src/newgrf/newgrf_act1.cpp | 16 ++-- src/newgrf/newgrf_act10.cpp | 2 +- src/newgrf/newgrf_act11.cpp | 34 +++---- src/newgrf/newgrf_act12.cpp | 10 +-- src/newgrf/newgrf_act13.cpp | 2 +- src/newgrf/newgrf_act14.cpp | 50 +++++------ src/newgrf/newgrf_act2.cpp | 52 +++++------ src/newgrf/newgrf_act3.cpp | 124 +++++++++++++------------- src/newgrf/newgrf_act4.cpp | 36 ++++---- src/newgrf/newgrf_act5.cpp | 38 ++++---- src/newgrf/newgrf_act6.cpp | 6 +- src/newgrf/newgrf_act7_9.cpp | 30 +++---- src/newgrf/newgrf_act8.cpp | 28 +++--- src/newgrf/newgrf_acta.cpp | 14 +-- src/newgrf/newgrf_actb.cpp | 20 ++--- src/newgrf/newgrf_actd.cpp | 42 ++++----- src/newgrf/newgrf_acte.cpp | 6 +- src/newgrf/newgrf_actf.cpp | 4 +- src/newgrf/newgrf_internal.h | 2 +- src/newgrf/newgrf_stringmapping.cpp | 2 +- 39 files changed, 402 insertions(+), 402 deletions(-) diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 46c95a643d..55182b8b5a 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -71,7 +71,7 @@ GrfMiscBits _misc_grf_features{}; /** Indicates which are the newgrf features currently loaded ingame */ GRFLoadedFeatures _loaded_newgrf_features; -GrfProcessingState _cur; +GrfProcessingState _cur_gps; ReferenceThroughBaseContainer> _gted; ///< Temporary engine data used during NewGRF loading @@ -87,7 +87,7 @@ ReferenceThroughBaseContainer> _gted; ///< Tempo */ void GrfMsgI(int severity, const std::string &msg) { - Debug(grf, severity, "[{}:{}] {}", _cur.grfconfig->filename, _cur.nfo_line, msg); + Debug(grf, severity, "[{}:{}] {}", _cur_gps.grfconfig->filename, _cur_gps.nfo_line, msg); } /** @@ -132,18 +132,18 @@ GRFError *DisableGrf(StringID message, GRFConfig *config) if (config != nullptr) { file = GetFileByGRFID(config->ident.grfid); } else { - config = _cur.grfconfig; - file = _cur.grffile; + config = _cur_gps.grfconfig; + file = _cur_gps.grffile; } config->status = GCS_DISABLED; if (file != nullptr) ClearTemporaryNewGRFData(file); - if (config == _cur.grfconfig) _cur.skip_sprites = -1; + if (config == _cur_gps.grfconfig) _cur_gps.skip_sprites = -1; if (message == STR_NULL) return nullptr; config->error = {STR_NEWGRF_ERROR_MSG_FATAL, message}; - if (config == _cur.grfconfig) config->error->param_value[0] = _cur.nfo_line; + if (config == _cur_gps.grfconfig) config->error->param_value[0] = _cur_gps.nfo_line; return &config->error.value(); } @@ -159,7 +159,7 @@ GRFError *DisableGrf(StringID message, GRFConfig *config) void DisableStaticNewGRFInfluencingNonStaticNewGRFs(GRFConfig &c) { GRFError *error = DisableGrf(STR_NEWGRF_ERROR_STATIC_GRF_CAUSES_DESYNC, &c); - error->data = _cur.grfconfig->GetName(); + error->data = _cur_gps.grfconfig->GetName(); } static std::map _grf_id_overrides; @@ -186,7 +186,7 @@ void SetNewGRFOverride(uint32_t source_grfid, uint32_t target_grfid) */ GRFFile *GetCurrentGRFOverride() { - auto found = _grf_id_overrides.find(_cur.grffile->grfid); + auto found = _grf_id_overrides.find(_cur_gps.grffile->grfid); if (found != std::end(_grf_id_overrides)) { GRFFile *grffile = GetFileByGRFID(found->second); if (grffile != nullptr) return grffile; @@ -306,7 +306,7 @@ CargoTypes TranslateRefitMask(uint32_t refit_mask) { CargoTypes result = 0; for (uint8_t bit : SetBitIterator(refit_mask)) { - CargoType cargo = GetCargoTranslation(bit, _cur.grffile, true); + CargoType cargo = GetCargoTranslation(bit, _cur_gps.grffile, true); if (IsValidCargoType(cargo)) SetBit(result, cargo); } return result; @@ -362,16 +362,16 @@ void ConvertTTDBasePrice(uint32_t base_pointer, const char *error_location, Pric */ void GRFUnsafe(ByteReader &) { - _cur.grfconfig->flags.Set(GRFConfigFlag::Unsafe); + _cur_gps.grfconfig->flags.Set(GRFConfigFlag::Unsafe); /* Skip remainder of GRF */ - _cur.skip_sprites = -1; + _cur_gps.skip_sprites = -1; } /** Reset and clear all NewGRFs */ static void ResetNewGRF() { - _cur.grffile = nullptr; + _cur_gps.grffile = nullptr; _grf_files.clear(); /* We store pointers to GRFFiles in many places, so need to ensure that the pointers do not become invalid @@ -522,14 +522,14 @@ void ResetPersistentNewGRFData() */ static void BuildCargoTranslationMap() { - _cur.grffile->cargo_map.fill(UINT8_MAX); + _cur_gps.grffile->cargo_map.fill(UINT8_MAX); - auto cargo_list = GetCargoTranslationTable(*_cur.grffile); + auto cargo_list = GetCargoTranslationTable(*_cur_gps.grffile); for (const CargoSpec *cs : CargoSpec::Iterate()) { /* Check the translation table for this cargo's label */ int idx = find_index(cargo_list, cs->label); - if (idx >= 0) _cur.grffile->cargo_map[cs->Index()] = idx; + if (idx >= 0) _cur_gps.grffile->cargo_map[cs->Index()] = idx; } } @@ -542,12 +542,12 @@ static void InitNewGRFFile(const GRFConfig &config) GRFFile *newfile = GetFileByFilename(config.filename); if (newfile != nullptr) { /* We already loaded it once. */ - _cur.grffile = newfile; + _cur_gps.grffile = newfile; return; } assert(_grf_files.size() < _grf_files.capacity()); // We must not invalidate pointers. - _cur.grffile = &_grf_files.emplace_back(config); + _cur_gps.grffile = &_grf_files.emplace_back(config); } /** @@ -1215,18 +1215,18 @@ struct InvokeGrfActionHandler { * better make this more robust in the future. */ static void DecodeSpecialSprite(uint8_t *buf, uint num, GrfLoadingStage stage) { - auto it = _grf_line_to_action6_sprite_override.find({_cur.grfconfig->ident.grfid, _cur.nfo_line}); + auto it = _grf_line_to_action6_sprite_override.find({_cur_gps.grfconfig->ident.grfid, _cur_gps.nfo_line}); if (it == _grf_line_to_action6_sprite_override.end()) { /* No preloaded sprite to work with; read the * pseudo sprite content. */ - _cur.file->ReadBlock(buf, num); + _cur_gps.file->ReadBlock(buf, num); } else { /* Use the preloaded sprite data. */ buf = it->second.data(); GrfMsg(7, "DecodeSpecialSprite: Using preloaded pseudo sprite data"); /* Skip the real (original) content of this action. */ - _cur.file->SeekTo(num, SEEK_CUR); + _cur_gps.file->SeekTo(num, SEEK_CUR); } ByteReader br(buf, buf + num); @@ -1255,8 +1255,8 @@ static void DecodeSpecialSprite(uint8_t *buf, uint num, GrfLoadingStage stage) */ static void LoadNewGRFFileFromFile(GRFConfig &config, GrfLoadingStage stage, SpriteFile &file) { - AutoRestoreBackup cur_file(_cur.file, &file); - AutoRestoreBackup cur_config(_cur.grfconfig, &config); + AutoRestoreBackup cur_file(_cur_gps.file, &file); + AutoRestoreBackup cur_config(_cur_gps.grfconfig, &config); Debug(grf, 2, "LoadNewGRFFile: Reading NewGRF-file '{}'", config.filename); @@ -1295,16 +1295,16 @@ static void LoadNewGRFFileFromFile(GRFConfig &config, GrfLoadingStage stage, Spr return; } - _cur.ClearDataForNextFile(); + _cur_gps.ClearDataForNextFile(); ReusableBuffer buf; while ((num = (grf_container_version >= 2 ? file.ReadDword() : file.ReadWord())) != 0) { uint8_t type = file.ReadByte(); - _cur.nfo_line++; + _cur_gps.nfo_line++; if (type == 0xFF) { - if (_cur.skip_sprites == 0) { + if (_cur_gps.skip_sprites == 0) { /* Limit the special sprites to 1 MiB. */ if (num > 1024 * 1024) { GrfMsg(0, "LoadNewGRFFile: Unexpectedly large sprite, disabling"); @@ -1315,14 +1315,14 @@ static void LoadNewGRFFileFromFile(GRFConfig &config, GrfLoadingStage stage, Spr DecodeSpecialSprite(buf.Allocate(num), num, stage); /* Stop all processing if we are to skip the remaining sprites */ - if (_cur.skip_sprites == -1) break; + if (_cur_gps.skip_sprites == -1) break; continue; } else { file.SkipBytes(num); } } else { - if (_cur.skip_sprites == 0) { + if (_cur_gps.skip_sprites == 0) { GrfMsg(0, "LoadNewGRFFile: Unexpected sprite, disabling"); DisableGrf(STR_NEWGRF_ERROR_UNEXPECTED_SPRITE); break; @@ -1337,7 +1337,7 @@ static void LoadNewGRFFileFromFile(GRFConfig &config, GrfLoadingStage stage, Spr } } - if (_cur.skip_sprites > 0) _cur.skip_sprites--; + if (_cur_gps.skip_sprites > 0) _cur_gps.skip_sprites--; } } @@ -1363,8 +1363,8 @@ void LoadNewGRFFile(GRFConfig &config, GrfLoadingStage stage, Subdirectory subdi * carried out. All others are ignored, because they only need to be * processed once at initialization. */ if (stage != GLS_FILESCAN && stage != GLS_SAFETYSCAN && stage != GLS_LABELSCAN) { - _cur.grffile = GetFileByFilename(filename); - if (_cur.grffile == nullptr) UserError("File '{}' lost in cache.\n", filename); + _cur_gps.grffile = GetFileByFilename(filename); + if (_cur_gps.grffile == nullptr) UserError("File '{}' lost in cache.\n", filename); if (stage == GLS_RESERVE && config.status != GCS_INITIALISED) return; if (stage == GLS_ACTIVATION && !config.flags.Test(GRFConfigFlag::Reserved)) return; } @@ -1755,7 +1755,7 @@ void LoadNewGRF(SpriteID load_index, uint num_baseset) if (c->status != GCS_NOT_FOUND) c->status = GCS_UNKNOWN; } - _cur.spriteid = load_index; + _cur_gps.spriteid = load_index; /* Load newgrf sprites * in each loading stage, (try to) open each file specified in the config @@ -1781,7 +1781,7 @@ void LoadNewGRF(SpriteID load_index, uint num_baseset) uint num_grfs = 0; uint num_non_static = 0; - _cur.stage = stage; + _cur_gps.stage = stage; for (const auto &c : _grfconfig) { if (c->status == GCS_DISABLED || c->status == GCS_NOT_FOUND) continue; if (stage > GLS_INIT && c->flags.Test(GRFConfigFlag::InitOnly)) continue; @@ -1812,19 +1812,19 @@ void LoadNewGRF(SpriteID load_index, uint num_baseset) c->flags.Set(GRFConfigFlag::Reserved); } else if (stage == GLS_ACTIVATION) { c->flags.Reset(GRFConfigFlag::Reserved); - assert(GetFileByGRFID(c->ident.grfid) == _cur.grffile); - ClearTemporaryNewGRFData(_cur.grffile); + assert(GetFileByGRFID(c->ident.grfid) == _cur_gps.grffile); + ClearTemporaryNewGRFData(_cur_gps.grffile); BuildCargoTranslationMap(); - Debug(sprite, 2, "LoadNewGRF: Currently {} sprites are loaded", _cur.spriteid); + Debug(sprite, 2, "LoadNewGRF: Currently {} sprites are loaded", _cur_gps.spriteid); } else if (stage == GLS_INIT && c->flags.Test(GRFConfigFlag::InitOnly)) { /* We're not going to activate this, so free whatever data we allocated */ - ClearTemporaryNewGRFData(_cur.grffile); + ClearTemporaryNewGRFData(_cur_gps.grffile); } } } /* Pseudo sprite processing is finished; free temporary stuff */ - _cur.ClearDataForNextFile(); + _cur_gps.ClearDataForNextFile(); /* Call any functions that should be run after GRFs have been loaded. */ AfterLoadGRFs(); diff --git a/src/newgrf/newgrf_act0.cpp b/src/newgrf/newgrf_act0.cpp index 9f13c1e478..6562ff8f8e 100644 --- a/src/newgrf/newgrf_act0.cpp +++ b/src/newgrf/newgrf_act0.cpp @@ -92,12 +92,12 @@ std::vector ReadBadgeList(ByteReader &buf, GrfSpecFeature feature) while (count-- > 0) { uint16_t local_index = buf.ReadWord(); - if (local_index >= std::size(_cur.grffile->badge_list)) { - GrfMsg(1, "ReadBadgeList: Badge label {} out of range (max {}), skipping.", local_index, std::size(_cur.grffile->badge_list) - 1); + if (local_index >= std::size(_cur_gps.grffile->badge_list)) { + GrfMsg(1, "ReadBadgeList: Badge label {} out of range (max {}), skipping.", local_index, std::size(_cur_gps.grffile->badge_list) - 1); continue; } - BadgeID index = _cur.grffile->badge_list[local_index]; + BadgeID index = _cur_gps.grffile->badge_list[local_index]; /* Is badge already present? */ if (std::ranges::find(badges, index) != std::end(badges)) continue; @@ -204,7 +204,7 @@ static void FeatureChangeInfo(ByteReader &buf) } /* Mark the feature as used by the grf */ - SetBit(_cur.grffile->grf_features, feature); + SetBit(_cur_gps.grffile->grf_features, feature); while (numprops-- && buf.HasData()) { uint8_t prop = buf.ReadByte(); diff --git a/src/newgrf/newgrf_act0_aircraft.cpp b/src/newgrf/newgrf_act0_aircraft.cpp index 922d0b6e07..1c614d0d32 100644 --- a/src/newgrf/newgrf_act0_aircraft.cpp +++ b/src/newgrf/newgrf_act0_aircraft.cpp @@ -31,7 +31,7 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint first, uint last, int pro ChangeInfoResult ret = CIR_SUCCESS; for (uint id = first; id < last; ++id) { - Engine *e = GetNewEngine(_cur.grffile, VEH_AIRCRAFT, 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 EngineInfo *ei = &e->info; @@ -93,14 +93,14 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint first, uint last, int pro break; case 0x12: // SFX - avi->sfx = GetNewGRFSoundID(_cur.grffile, buf.ReadByte()); + avi->sfx = GetNewGRFSoundID(_cur_gps.grffile, buf.ReadByte()); break; case 0x13: { // Cargoes available for refitting uint32_t mask = buf.ReadDWord(); _gted[e->index].UpdateRefittability(mask != 0); ei->refit_mask = TranslateRefitMask(mask); - _gted[e->index].defaultcargo_grf = _cur.grffile; + _gted[e->index].defaultcargo_grf = _cur_gps.grffile; break; } @@ -127,7 +127,7 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint first, uint last, int pro case 0x18: // Cargo classes allowed _gted[e->index].cargo_allowed = CargoClasses{buf.ReadWord()}; _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed.Any()); - _gted[e->index].defaultcargo_grf = _cur.grffile; + _gted[e->index].defaultcargo_grf = _cur_gps.grffile; break; case 0x19: // Cargo classes disallowed @@ -151,11 +151,11 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint first, uint last, int pro case 0x1E: { // CTT refit exclude list uint8_t count = buf.ReadByte(); _gted[e->index].UpdateRefittability(prop == 0x1D && count != 0); - if (prop == 0x1D) _gted[e->index].defaultcargo_grf = _cur.grffile; + if (prop == 0x1D) _gted[e->index].defaultcargo_grf = _cur_gps.grffile; CargoTypes &ctt = prop == 0x1D ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; ctt = 0; while (count--) { - CargoType ctype = GetCargoTranslation(buf.ReadByte(), _cur.grffile); + CargoType ctype = GetCargoTranslation(buf.ReadByte(), _cur_gps.grffile); if (IsValidCargoType(ctype)) SetBit(ctt, ctype); } break; diff --git a/src/newgrf/newgrf_act0_airports.cpp b/src/newgrf/newgrf_act0_airports.cpp index e70a165f15..0063a78361 100644 --- a/src/newgrf/newgrf_act0_airports.cpp +++ b/src/newgrf/newgrf_act0_airports.cpp @@ -35,10 +35,10 @@ static ChangeInfoResult AirportChangeInfo(uint first, uint last, int prop, ByteR } /* Allocate industry specs if they haven't been allocated already. */ - if (_cur.grffile->airportspec.size() < last) _cur.grffile->airportspec.resize(last); + if (_cur_gps.grffile->airportspec.size() < last) _cur_gps.grffile->airportspec.resize(last); for (uint id = first; id < last; ++id) { - auto &as = _cur.grffile->airportspec[id]; + auto &as = _cur_gps.grffile->airportspec[id]; if (as == nullptr && prop != 0x08 && prop != 0x09) { GrfMsg(2, "AirportChangeInfo: Attempt to modify undefined airport {}, ignoring", id); @@ -68,9 +68,9 @@ static ChangeInfoResult AirportChangeInfo(uint first, uint last, int prop, ByteR as->enabled = true; as->grf_prop.local_id = id; as->grf_prop.subst_id = subs_id; - as->grf_prop.SetGRFFile(_cur.grffile); + as->grf_prop.SetGRFFile(_cur_gps.grffile); /* override the default airport */ - _airport_mngr.Add(id, _cur.grffile->grfid, subs_id); + _airport_mngr.Add(id, _cur_gps.grffile->grfid, subs_id); } break; } @@ -107,7 +107,7 @@ static ChangeInfoResult AirportChangeInfo(uint first, uint last, int prop, ByteR int local_tile_id = buf.ReadWord(); /* Read the ID from the _airporttile_mngr. */ - uint16_t tempid = _airporttile_mngr.GetID(local_tile_id, _cur.grffile->grfid); + uint16_t tempid = _airporttile_mngr.GetID(local_tile_id, _cur_gps.grffile->grfid); if (tempid == INVALID_AIRPORTTILE) { GrfMsg(2, "AirportChangeInfo: Attempt to use airport tile {} with airport id {}, not yet defined. Ignoring.", local_tile_id, id); @@ -185,10 +185,10 @@ static ChangeInfoResult AirportTilesChangeInfo(uint first, uint last, int prop, } /* Allocate airport tile specs if they haven't been allocated already. */ - if (_cur.grffile->airtspec.size() < last) _cur.grffile->airtspec.resize(last); + if (_cur_gps.grffile->airtspec.size() < last) _cur_gps.grffile->airtspec.resize(last); for (uint id = first; id < last; ++id) { - auto &tsp = _cur.grffile->airtspec[id]; + auto &tsp = _cur_gps.grffile->airtspec[id]; if (prop != 0x08 && tsp == nullptr) { GrfMsg(2, "AirportTileChangeInfo: Attempt to modify undefined airport tile {}. Ignoring.", id); @@ -214,8 +214,8 @@ static ChangeInfoResult AirportTilesChangeInfo(uint first, uint last, int prop, tsp->grf_prop.local_id = id; tsp->grf_prop.subst_id = subs_id; - tsp->grf_prop.SetGRFFile(_cur.grffile); - _airporttile_mngr.AddEntityID(id, _cur.grffile->grfid, subs_id); // pre-reserve the tile slot + tsp->grf_prop.SetGRFFile(_cur_gps.grffile); + _airporttile_mngr.AddEntityID(id, _cur_gps.grffile->grfid, subs_id); // pre-reserve the tile slot } break; } @@ -229,7 +229,7 @@ static ChangeInfoResult AirportTilesChangeInfo(uint first, uint last, int prop, continue; } - _airporttile_mngr.Add(id, _cur.grffile->grfid, override_id); + _airporttile_mngr.Add(id, _cur_gps.grffile->grfid, override_id); break; } diff --git a/src/newgrf/newgrf_act0_badges.cpp b/src/newgrf/newgrf_act0_badges.cpp index 3945e802e2..823cf0e0d5 100644 --- a/src/newgrf/newgrf_act0_badges.cpp +++ b/src/newgrf/newgrf_act0_badges.cpp @@ -26,8 +26,8 @@ static ChangeInfoResult BadgeChangeInfo(uint first, uint last, int prop, ByteRea } for (uint id = first; id < last; ++id) { - auto it = _cur.grffile->badge_map.find(id); - if (prop != 0x08 && it == std::end(_cur.grffile->badge_map)) { + 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; } @@ -38,7 +38,7 @@ static ChangeInfoResult BadgeChangeInfo(uint first, uint last, int prop, ByteRea switch (prop) { case 0x08: { // Label std::string_view label = buf.ReadString(); - _cur.grffile->badge_map[id] = GetOrCreateBadge(label).index; + _cur_gps.grffile->badge_map[id] = GetOrCreateBadge(label).index; break; } diff --git a/src/newgrf/newgrf_act0_canals.cpp b/src/newgrf/newgrf_act0_canals.cpp index 38d32cdc02..b48c8af3f7 100644 --- a/src/newgrf/newgrf_act0_canals.cpp +++ b/src/newgrf/newgrf_act0_canals.cpp @@ -32,7 +32,7 @@ static ChangeInfoResult CanalChangeInfo(uint first, uint last, int prop, ByteRea } for (uint id = first; id < last; ++id) { - CanalProperties *cp = &_cur.grffile->canal_local_properties[id]; + CanalProperties *cp = &_cur_gps.grffile->canal_local_properties[id]; switch (prop) { case 0x08: diff --git a/src/newgrf/newgrf_act0_cargo.cpp b/src/newgrf/newgrf_act0_cargo.cpp index db111dda06..c5794a2874 100644 --- a/src/newgrf/newgrf_act0_cargo.cpp +++ b/src/newgrf/newgrf_act0_cargo.cpp @@ -40,7 +40,7 @@ static ChangeInfoResult CargoReserveInfo(uint first, uint last, int prop, ByteRe case 0x08: // Bit number of cargo cs->bitnum = buf.ReadByte(); if (cs->IsValid()) { - cs->grffile = _cur.grffile; + cs->grffile = _cur_gps.grffile; SetBit(_cargo_mask, id); } else { ClrBit(_cargo_mask, id); diff --git a/src/newgrf/newgrf_act0_globalvar.cpp b/src/newgrf/newgrf_act0_globalvar.cpp index eb004161cb..837f68da3d 100644 --- a/src/newgrf/newgrf_act0_globalvar.cpp +++ b/src/newgrf/newgrf_act0_globalvar.cpp @@ -49,7 +49,7 @@ static ChangeInfoResult LoadTranslationTable(uint first, uint last, ByteReader & return CIR_INVALID_ID; } - std::vector &translation_table = gettable(*_cur.grffile); + std::vector &translation_table = gettable(*_cur_gps.grffile); translation_table.clear(); translation_table.reserve(last); for (uint id = first; id < last; ++id) { @@ -122,7 +122,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint first, uint last, int prop, Byt return LoadTranslationTable(first, last, buf, [](GRFFile &grf) -> std::vector & { return grf.tramtype_list; }, "Tram type"); case 0x18: // Badge translation table - return LoadBadgeTranslationTable(first, last, buf, _cur.grffile->badge_list, "Badge"); + return LoadBadgeTranslationTable(first, last, buf, _cur_gps.grffile->badge_list, "Badge"); default: break; @@ -136,7 +136,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint first, uint last, int prop, Byt int factor = buf.ReadByte(); if (id < PR_END) { - _cur.grffile->price_base_multipliers[id] = std::min(factor - 8, MAX_PRICE_MODIFIER); + _cur_gps.grffile->price_base_multipliers[id] = std::min(factor - 8, MAX_PRICE_MODIFIER); } else { GrfMsg(1, "GlobalVarChangeInfo: Price {} out of range, ignoring", id); } @@ -235,7 +235,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint first, uint last, int prop, Byt for (uint j = 0; j < SNOW_LINE_DAYS; j++) { uint8_t &level = snow_line->table[i][j]; level = buf.ReadByte(); - if (_cur.grffile->grf_version >= 8) { + if (_cur_gps.grffile->grf_version >= 8) { if (level != 0xFF) level = level * (1 + _settings_game.construction.map_height_limit) / 256; } else { if (level >= 128) { @@ -283,7 +283,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint first, uint last, int prop, Byt if (plural_form >= LANGUAGE_MAX_PLURAL) { GrfMsg(1, "GlobalVarChanceInfo: Plural form {} is out of range, ignoring", plural_form); } else { - _cur.grffile->language_map[curidx].plural_form = plural_form; + _cur_gps.grffile->language_map[curidx].plural_form = plural_form; } break; } @@ -306,14 +306,14 @@ static ChangeInfoResult GlobalVarChangeInfo(uint first, uint last, int prop, Byt if (map.openttd_id >= MAX_NUM_GENDERS) { GrfMsg(1, "GlobalVarChangeInfo: Gender name {} is not known, ignoring", StrMakeValid(name)); } else { - _cur.grffile->language_map[curidx].gender_map.push_back(map); + _cur_gps.grffile->language_map[curidx].gender_map.push_back(map); } } else { map.openttd_id = lang->GetCaseIndex(name); if (map.openttd_id >= MAX_NUM_CASES) { GrfMsg(1, "GlobalVarChangeInfo: Case name {} is not known, ignoring", StrMakeValid(name)); } else { - _cur.grffile->language_map[curidx].case_map.push_back(map); + _cur_gps.grffile->language_map[curidx].case_map.push_back(map); } } newgrf_id = buf.ReadByte(); @@ -347,7 +347,7 @@ static ChangeInfoResult GlobalVarReserveInfo(uint first, uint last, int prop, By return LoadTranslationTable(first, last, buf, [](GRFFile &grf) -> std::vector & { return grf.tramtype_list; }, "Tram type"); case 0x18: // Badge translation table - return LoadBadgeTranslationTable(first, last, buf, _cur.grffile->badge_list, "Badge"); + return LoadBadgeTranslationTable(first, last, buf, _cur_gps.grffile->badge_list, "Badge"); default: break; diff --git a/src/newgrf/newgrf_act0_houses.cpp b/src/newgrf/newgrf_act0_houses.cpp index 51996ac3bc..86b5c83910 100644 --- a/src/newgrf/newgrf_act0_houses.cpp +++ b/src/newgrf/newgrf_act0_houses.cpp @@ -103,10 +103,10 @@ static ChangeInfoResult TownHouseChangeInfo(uint first, uint last, int prop, Byt } /* Allocate house specs if they haven't been allocated already. */ - if (_cur.grffile->housespec.size() < last) _cur.grffile->housespec.resize(last); + if (_cur_gps.grffile->housespec.size() < last) _cur_gps.grffile->housespec.resize(last); for (uint id = first; id < last; ++id) { - auto &housespec = _cur.grffile->housespec[id]; + auto &housespec = _cur_gps.grffile->housespec[id]; if (prop != 0x08 && housespec == nullptr) { /* If the house property 08 is not yet set, ignore this property */ @@ -137,7 +137,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint first, uint last, int prop, Byt housespec->enabled = true; housespec->grf_prop.local_id = id; housespec->grf_prop.subst_id = subs_id; - housespec->grf_prop.SetGRFFile(_cur.grffile); + housespec->grf_prop.SetGRFFile(_cur_gps.grffile); /* Set default colours for randomization, used if not overridden. */ housespec->random_colour[0] = COLOUR_RED; housespec->random_colour[1] = COLOUR_BLUE; @@ -233,7 +233,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint first, uint last, int prop, Byt continue; } - _house_mngr.Add(id, _cur.grffile->grfid, override_id); + _house_mngr.Add(id, _cur_gps.grffile->grfid, override_id); break; } @@ -264,7 +264,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint first, uint last, int prop, Byt break; case 0x1C: // Class of the building type - housespec->class_id = AllocateHouseClassID(buf.ReadByte(), _cur.grffile->grfid); + housespec->class_id = AllocateHouseClassID(buf.ReadByte(), _cur_gps.grffile->grfid); break; case 0x1D: { // Callback mask part 2 @@ -283,7 +283,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint first, uint last, int prop, Byt for (uint j = 0; j < HOUSE_ORIGINAL_NUM_ACCEPTS; j++) { /* Get the cargo number from the 'list' */ uint8_t cargo_part = GB(cargotypes, 8 * j, 8); - CargoType cargo = GetCargoTranslation(cargo_part, _cur.grffile); + CargoType cargo = GetCargoTranslation(cargo_part, _cur_gps.grffile); if (!IsValidCargoType(cargo)) { /* Disable acceptance of invalid cargo type */ @@ -303,7 +303,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint first, uint last, int prop, Byt case 0x20: { // Cargo acceptance watch list uint8_t count = buf.ReadByte(); for (uint8_t j = 0; j < count; j++) { - CargoType cargo = GetCargoTranslation(buf.ReadByte(), _cur.grffile); + CargoType cargo = GetCargoTranslation(buf.ReadByte(), _cur_gps.grffile); if (IsValidCargoType(cargo)) SetBit(housespec->watched_cargoes, cargo); } break; @@ -330,7 +330,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint first, uint last, int prop, Byt * any risks of array overrun. */ for (uint i = 0; i < lengthof(housespec->accepts_cargo); i++) { if (i < count) { - housespec->accepts_cargo[i] = GetCargoTranslation(buf.ReadByte(), _cur.grffile); + housespec->accepts_cargo[i] = GetCargoTranslation(buf.ReadByte(), _cur_gps.grffile); housespec->cargo_acceptance[i] = buf.ReadByte(); } else { housespec->accepts_cargo[i] = INVALID_CARGO; diff --git a/src/newgrf/newgrf_act0_industries.cpp b/src/newgrf/newgrf_act0_industries.cpp index 03f4d79ea3..5f46bc3d2f 100644 --- a/src/newgrf/newgrf_act0_industries.cpp +++ b/src/newgrf/newgrf_act0_industries.cpp @@ -79,10 +79,10 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint first, uint last, int prop, } /* Allocate industry tile specs if they haven't been allocated already. */ - if (_cur.grffile->indtspec.size() < last) _cur.grffile->indtspec.resize(last); + if (_cur_gps.grffile->indtspec.size() < last) _cur_gps.grffile->indtspec.resize(last); for (uint id = first; id < last; ++id) { - auto &tsp = _cur.grffile->indtspec[id]; + auto &tsp = _cur_gps.grffile->indtspec[id]; if (prop != 0x08 && tsp == nullptr) { ChangeInfoResult cir = IgnoreIndustryTileProperty(prop, buf); @@ -113,8 +113,8 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint first, uint last, int prop, tsp->grf_prop.local_id = id; tsp->grf_prop.subst_id = subs_id; - tsp->grf_prop.SetGRFFile(_cur.grffile); - _industile_mngr.AddEntityID(id, _cur.grffile->grfid, subs_id); // pre-reserve the tile slot + tsp->grf_prop.SetGRFFile(_cur_gps.grffile); + _industile_mngr.AddEntityID(id, _cur_gps.grffile->grfid, subs_id); // pre-reserve the tile slot } break; } @@ -128,7 +128,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint first, uint last, int prop, continue; } - _industile_mngr.Add(id, _cur.grffile->grfid, ovrid); + _industile_mngr.Add(id, _cur_gps.grffile->grfid, ovrid); break; } @@ -136,7 +136,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint first, uint last, int prop, case 0x0B: case 0x0C: { uint16_t acctp = buf.ReadWord(); - tsp->accepts_cargo[prop - 0x0A] = GetCargoTranslation(GB(acctp, 0, 8), _cur.grffile); + tsp->accepts_cargo[prop - 0x0A] = GetCargoTranslation(GB(acctp, 0, 8), _cur_gps.grffile); tsp->acceptance[prop - 0x0A] = Clamp(GB(acctp, 8, 8), 0, 16); tsp->accepts_cargo_label[prop - 0x0A] = CT_INVALID; break; @@ -176,7 +176,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint first, uint last, int prop, } for (uint i = 0; i < std::size(tsp->acceptance); i++) { if (i < num_cargoes) { - tsp->accepts_cargo[i] = GetCargoTranslation(buf.ReadByte(), _cur.grffile); + tsp->accepts_cargo[i] = GetCargoTranslation(buf.ReadByte(), _cur_gps.grffile); /* Tile acceptance can be negative to counteract the IndustryTileSpecialFlag::AcceptsAllCargo flag */ tsp->acceptance[i] = (int8_t)buf.ReadByte(); } else { @@ -344,10 +344,10 @@ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, By } /* Allocate industry specs if they haven't been allocated already. */ - if (_cur.grffile->industryspec.size() < last) _cur.grffile->industryspec.resize(last); + if (_cur_gps.grffile->industryspec.size() < last) _cur_gps.grffile->industryspec.resize(last); for (uint id = first; id < last; ++id) { - auto &indsp = _cur.grffile->industryspec[id]; + auto &indsp = _cur_gps.grffile->industryspec[id]; if (prop != 0x08 && indsp == nullptr) { ChangeInfoResult cir = IgnoreIndustryProperty(prop, buf); @@ -378,7 +378,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, By indsp->enabled = true; indsp->grf_prop.local_id = id; indsp->grf_prop.subst_id = subs_id; - indsp->grf_prop.SetGRFFile(_cur.grffile); + indsp->grf_prop.SetGRFFile(_cur_gps.grffile); /* If the grf industry needs to check its surrounding upon creation, it should * rely on callbacks, not on the original placement functions */ indsp->check_proc = CHECK_NOTHING; @@ -395,7 +395,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, By continue; } indsp->grf_prop.override_id = ovrid; - _industry_mngr.Add(id, _cur.grffile->grfid, ovrid); + _industry_mngr.Add(id, _cur_gps.grffile->grfid, ovrid); break; } @@ -459,7 +459,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, By bytes_read += 2; /* Read the ID from the _industile_mngr. */ - int tempid = _industile_mngr.GetID(local_tile_id, _cur.grffile->grfid); + int tempid = _industile_mngr.GetID(local_tile_id, _cur_gps.grffile->grfid); if (tempid == INVALID_INDUSTRYTILE) { GrfMsg(2, "IndustriesChangeInfo: Attempt to use industry tile {} with industry id {}, not yet defined. Ignoring.", local_tile_id, id); @@ -478,7 +478,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, By * Since GRF version 8 the position is interpreted as pair of independent int8. * For GRF version < 8 we need to emulate the old shifting behaviour. */ - if (_cur.grffile->grf_version < 8 && it.ti.x < 0) it.ti.y += 1; + if (_cur_gps.grffile->grf_version < 8 && it.ti.x < 0) it.ti.y += 1; } } @@ -517,14 +517,14 @@ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, By case 0x10: // Production cargo types for (uint8_t j = 0; j < INDUSTRY_ORIGINAL_NUM_OUTPUTS; j++) { - indsp->produced_cargo[j] = GetCargoTranslation(buf.ReadByte(), _cur.grffile); + indsp->produced_cargo[j] = GetCargoTranslation(buf.ReadByte(), _cur_gps.grffile); indsp->produced_cargo_label[j] = CT_INVALID; } break; case 0x11: // Acceptance cargo types for (uint8_t j = 0; j < INDUSTRY_ORIGINAL_NUM_INPUTS; j++) { - indsp->accepts_cargo[j] = GetCargoTranslation(buf.ReadByte(), _cur.grffile); + indsp->accepts_cargo[j] = GetCargoTranslation(buf.ReadByte(), _cur_gps.grffile); indsp->accepts_cargo_label[j] = CT_INVALID; } buf.ReadByte(); // Unnused, eat it up @@ -624,7 +624,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, By } for (size_t i = 0; i < std::size(indsp->produced_cargo); i++) { if (i < num_cargoes) { - CargoType cargo = GetCargoTranslation(buf.ReadByte(), _cur.grffile); + CargoType cargo = GetCargoTranslation(buf.ReadByte(), _cur_gps.grffile); indsp->produced_cargo[i] = cargo; } else { indsp->produced_cargo[i] = INVALID_CARGO; @@ -643,7 +643,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint first, uint last, int prop, By } for (size_t i = 0; i < std::size(indsp->accepts_cargo); i++) { if (i < num_cargoes) { - CargoType cargo = GetCargoTranslation(buf.ReadByte(), _cur.grffile); + CargoType cargo = GetCargoTranslation(buf.ReadByte(), _cur_gps.grffile); indsp->accepts_cargo[i] = cargo; } else { indsp->accepts_cargo[i] = INVALID_CARGO; diff --git a/src/newgrf/newgrf_act0_objects.cpp b/src/newgrf/newgrf_act0_objects.cpp index b83f2fd0bc..fad95d7911 100644 --- a/src/newgrf/newgrf_act0_objects.cpp +++ b/src/newgrf/newgrf_act0_objects.cpp @@ -83,10 +83,10 @@ static ChangeInfoResult ObjectChangeInfo(uint first, uint last, int prop, ByteRe } /* Allocate object specs if they haven't been allocated already. */ - if (_cur.grffile->objectspec.size() < last) _cur.grffile->objectspec.resize(last); + if (_cur_gps.grffile->objectspec.size() < last) _cur_gps.grffile->objectspec.resize(last); for (uint id = first; id < last; ++id) { - auto &spec = _cur.grffile->objectspec[id]; + auto &spec = _cur_gps.grffile->objectspec[id]; if (prop != 0x08 && spec == nullptr) { /* If the object property 08 is not yet set, ignore this property */ diff --git a/src/newgrf/newgrf_act0_railtypes.cpp b/src/newgrf/newgrf_act0_railtypes.cpp index 18ed679f8f..fe9e52132d 100644 --- a/src/newgrf/newgrf_act0_railtypes.cpp +++ b/src/newgrf/newgrf_act0_railtypes.cpp @@ -36,7 +36,7 @@ static ChangeInfoResult RailTypeChangeInfo(uint first, uint last, int prop, Byte } for (uint id = first; id < last; ++id) { - RailType rt = _cur.grffile->railtype_map[id]; + RailType rt = _cur_gps.grffile->railtype_map[id]; if (rt == INVALID_RAILTYPE) return CIR_INVALID_ID; RailTypeInfo *rti = &_railtypes[rt]; @@ -50,7 +50,7 @@ static ChangeInfoResult RailTypeChangeInfo(uint first, uint last, int prop, Byte case 0x09: { // Toolbar caption of railtype (sets name as well for backwards compatibility for grf ver < 8) GRFStringID str{buf.ReadWord()}; AddStringForMapping(str, &rti->strings.toolbar_caption); - if (_cur.grffile->grf_version < 8) { + if (_cur_gps.grffile->grf_version < 8) { AddStringForMapping(str, &rti->strings.name); } break; @@ -182,7 +182,7 @@ static ChangeInfoResult RailTypeReserveInfo(uint first, uint last, int prop, Byt rt = AllocateRailType(rtl); } - _cur.grffile->railtype_map[id] = rt; + _cur_gps.grffile->railtype_map[id] = rt; break; } @@ -199,10 +199,10 @@ static ChangeInfoResult RailTypeReserveInfo(uint first, uint last, int prop, Byt break; case 0x1D: // Alternate rail type label list - if (_cur.grffile->railtype_map[id] != INVALID_RAILTYPE) { + if (_cur_gps.grffile->railtype_map[id] != INVALID_RAILTYPE) { int n = buf.ReadByte(); for (int j = 0; j != n; j++) { - _railtypes[_cur.grffile->railtype_map[id]].alternate_labels.push_back(std::byteswap(buf.ReadDWord())); + _railtypes[_cur_gps.grffile->railtype_map[id]].alternate_labels.push_back(std::byteswap(buf.ReadDWord())); } break; } diff --git a/src/newgrf/newgrf_act0_roadstops.cpp b/src/newgrf/newgrf_act0_roadstops.cpp index 4ff60db79a..3da28acf04 100644 --- a/src/newgrf/newgrf_act0_roadstops.cpp +++ b/src/newgrf/newgrf_act0_roadstops.cpp @@ -70,10 +70,10 @@ static ChangeInfoResult RoadStopChangeInfo(uint first, uint last, int prop, Byte return CIR_INVALID_ID; } - if (_cur.grffile->roadstops.size() < last) _cur.grffile->roadstops.resize(last); + if (_cur_gps.grffile->roadstops.size() < last) _cur_gps.grffile->roadstops.resize(last); for (uint id = first; id < last; ++id) { - auto &rs = _cur.grffile->roadstops[id]; + auto &rs = _cur_gps.grffile->roadstops[id]; if (rs == nullptr && prop != 0x08) { GrfMsg(1, "RoadStopChangeInfo: Attempt to modify undefined road stop {}, ignoring", id); diff --git a/src/newgrf/newgrf_act0_roadtypes.cpp b/src/newgrf/newgrf_act0_roadtypes.cpp index 795762f1a6..f6b6f48926 100644 --- a/src/newgrf/newgrf_act0_roadtypes.cpp +++ b/src/newgrf/newgrf_act0_roadtypes.cpp @@ -30,7 +30,7 @@ static ChangeInfoResult RoadTypeChangeInfo(uint first, uint last, int prop, Byte ChangeInfoResult ret = CIR_SUCCESS; extern RoadTypeInfo _roadtypes[ROADTYPE_END]; - std::array &type_map = (rtt == RTT_TRAM) ? _cur.grffile->tramtype_map : _cur.grffile->roadtype_map; + std::array &type_map = (rtt == RTT_TRAM) ? _cur_gps.grffile->tramtype_map : _cur_gps.grffile->roadtype_map; if (last > ROADTYPE_END) { GrfMsg(1, "RoadTypeChangeInfo: Road type {} is invalid, max {}, ignoring", last, ROADTYPE_END); @@ -151,7 +151,7 @@ static ChangeInfoResult RoadTypeReserveInfo(uint first, uint last, int prop, Byt ChangeInfoResult ret = CIR_SUCCESS; extern RoadTypeInfo _roadtypes[ROADTYPE_END]; - std::array &type_map = (rtt == RTT_TRAM) ? _cur.grffile->tramtype_map : _cur.grffile->roadtype_map; + std::array &type_map = (rtt == RTT_TRAM) ? _cur_gps.grffile->tramtype_map : _cur_gps.grffile->roadtype_map; if (last > ROADTYPE_END) { GrfMsg(1, "RoadTypeReserveInfo: Road type {} is invalid, max {}, ignoring", last, ROADTYPE_END); diff --git a/src/newgrf/newgrf_act0_roadvehs.cpp b/src/newgrf/newgrf_act0_roadvehs.cpp index c34fd3a96f..aba759f8f7 100644 --- a/src/newgrf/newgrf_act0_roadvehs.cpp +++ b/src/newgrf/newgrf_act0_roadvehs.cpp @@ -32,7 +32,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint first, uint last, int prop, B ChangeInfoResult ret = CIR_SUCCESS; for (uint id = first; id < last; ++id) { - Engine *e = GetNewEngine(_cur.grffile, VEH_ROAD, 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 EngineInfo *ei = &e->info; @@ -80,7 +80,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint first, uint last, int prop, B break; case 0x10: { // Cargo type - _gted[e->index].defaultcargo_grf = _cur.grffile; + _gted[e->index].defaultcargo_grf = _cur_gps.grffile; uint8_t ctype = buf.ReadByte(); if (ctype == 0xFF) { @@ -88,7 +88,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint first, uint last, int prop, B ei->cargo_type = INVALID_CARGO; } else { /* Use translated cargo. Might result in INVALID_CARGO (first refittable), if cargo is not defined. */ - ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile); + ei->cargo_type = GetCargoTranslation(ctype, _cur_gps.grffile); if (ei->cargo_type == INVALID_CARGO) GrfMsg(2, "RoadVehicleChangeInfo: Invalid cargo type {}, using first refittable", ctype); } ei->cargo_label = CT_INVALID; @@ -100,7 +100,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint first, uint last, int prop, B break; case 0x12: // SFX - rvi->sfx = GetNewGRFSoundID(_cur.grffile, buf.ReadByte()); + rvi->sfx = GetNewGRFSoundID(_cur_gps.grffile, buf.ReadByte()); break; case PROP_ROADVEH_POWER: // Power in units of 10 HP. @@ -119,7 +119,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint first, uint last, int prop, B uint32_t mask = buf.ReadDWord(); _gted[e->index].UpdateRefittability(mask != 0); ei->refit_mask = TranslateRefitMask(mask); - _gted[e->index].defaultcargo_grf = _cur.grffile; + _gted[e->index].defaultcargo_grf = _cur_gps.grffile; break; } @@ -154,7 +154,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint first, uint last, int prop, B case 0x1D: // Cargo classes allowed _gted[e->index].cargo_allowed = CargoClasses{buf.ReadWord()}; _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed.Any()); - _gted[e->index].defaultcargo_grf = _cur.grffile; + _gted[e->index].defaultcargo_grf = _cur_gps.grffile; break; case 0x1E: // Cargo classes disallowed @@ -192,11 +192,11 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint first, uint last, int prop, B case 0x25: { // CTT refit exclude list uint8_t count = buf.ReadByte(); _gted[e->index].UpdateRefittability(prop == 0x24 && count != 0); - if (prop == 0x24) _gted[e->index].defaultcargo_grf = _cur.grffile; + if (prop == 0x24) _gted[e->index].defaultcargo_grf = _cur_gps.grffile; CargoTypes &ctt = prop == 0x24 ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; ctt = 0; while (count--) { - CargoType ctype = GetCargoTranslation(buf.ReadByte(), _cur.grffile); + CargoType ctype = GetCargoTranslation(buf.ReadByte(), _cur_gps.grffile); if (IsValidCargoType(ctype)) SetBit(ctt, ctype); } break; diff --git a/src/newgrf/newgrf_act0_ships.cpp b/src/newgrf/newgrf_act0_ships.cpp index 9641212b45..f24be94bda 100644 --- a/src/newgrf/newgrf_act0_ships.cpp +++ b/src/newgrf/newgrf_act0_ships.cpp @@ -33,7 +33,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint first, uint last, int prop, B ChangeInfoResult ret = CIR_SUCCESS; for (uint id = first; id < last; ++id) { - Engine *e = GetNewEngine(_cur.grffile, VEH_SHIP, 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 EngineInfo *ei = &e->info; @@ -71,7 +71,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint first, uint last, int prop, B break; case 0x0C: { // Cargo type - _gted[e->index].defaultcargo_grf = _cur.grffile; + _gted[e->index].defaultcargo_grf = _cur_gps.grffile; uint8_t ctype = buf.ReadByte(); if (ctype == 0xFF) { @@ -79,7 +79,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint first, uint last, int prop, B ei->cargo_type = INVALID_CARGO; } else { /* Use translated cargo. Might result in INVALID_CARGO (first refittable), if cargo is not defined. */ - ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile); + ei->cargo_type = GetCargoTranslation(ctype, _cur_gps.grffile); if (ei->cargo_type == INVALID_CARGO) GrfMsg(2, "ShipVehicleChangeInfo: Invalid cargo type {}, using first refittable", ctype); } ei->cargo_label = CT_INVALID; @@ -95,14 +95,14 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint first, uint last, int prop, B break; case 0x10: // SFX - svi->sfx = GetNewGRFSoundID(_cur.grffile, buf.ReadByte()); + svi->sfx = GetNewGRFSoundID(_cur_gps.grffile, buf.ReadByte()); break; case 0x11: { // Cargoes available for refitting uint32_t mask = buf.ReadDWord(); _gted[e->index].UpdateRefittability(mask != 0); ei->refit_mask = TranslateRefitMask(mask); - _gted[e->index].defaultcargo_grf = _cur.grffile; + _gted[e->index].defaultcargo_grf = _cur_gps.grffile; break; } @@ -137,7 +137,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint first, uint last, int prop, B case 0x18: // Cargo classes allowed _gted[e->index].cargo_allowed = CargoClasses{buf.ReadWord()}; _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed.Any()); - _gted[e->index].defaultcargo_grf = _cur.grffile; + _gted[e->index].defaultcargo_grf = _cur_gps.grffile; break; case 0x19: // Cargo classes disallowed @@ -171,11 +171,11 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint first, uint last, int prop, B case 0x1F: { // CTT refit exclude list uint8_t count = buf.ReadByte(); _gted[e->index].UpdateRefittability(prop == 0x1E && count != 0); - if (prop == 0x1E) _gted[e->index].defaultcargo_grf = _cur.grffile; + if (prop == 0x1E) _gted[e->index].defaultcargo_grf = _cur_gps.grffile; CargoTypes &ctt = prop == 0x1E ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; ctt = 0; while (count--) { - CargoType ctype = GetCargoTranslation(buf.ReadByte(), _cur.grffile); + CargoType ctype = GetCargoTranslation(buf.ReadByte(), _cur_gps.grffile); if (IsValidCargoType(ctype)) SetBit(ctt, ctype); } break; diff --git a/src/newgrf/newgrf_act0_sounds.cpp b/src/newgrf/newgrf_act0_sounds.cpp index d74bb4b45b..7f5c5300e6 100644 --- a/src/newgrf/newgrf_act0_sounds.cpp +++ b/src/newgrf/newgrf_act0_sounds.cpp @@ -27,18 +27,18 @@ static ChangeInfoResult SoundEffectChangeInfo(uint first, uint last, int prop, B { ChangeInfoResult ret = CIR_SUCCESS; - if (_cur.grffile->sound_offset == 0) { + if (_cur_gps.grffile->sound_offset == 0) { GrfMsg(1, "SoundEffectChangeInfo: No effects defined, skipping"); return CIR_INVALID_ID; } - if (last - ORIGINAL_SAMPLE_COUNT > _cur.grffile->num_sounds) { - GrfMsg(1, "SoundEffectChangeInfo: Attempting to change undefined sound effect ({}), max ({}). Ignoring.", last, ORIGINAL_SAMPLE_COUNT + _cur.grffile->num_sounds); + 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; } for (uint id = first; id < last; ++id) { - SoundEntry *sound = GetSound(first + _cur.grffile->sound_offset - ORIGINAL_SAMPLE_COUNT); + SoundEntry *sound = GetSound(first + _cur_gps.grffile->sound_offset - ORIGINAL_SAMPLE_COUNT); switch (prop) { case 0x08: // Relative volume diff --git a/src/newgrf/newgrf_act0_stations.cpp b/src/newgrf/newgrf_act0_stations.cpp index 97bbcbef2b..3041060040 100644 --- a/src/newgrf/newgrf_act0_stations.cpp +++ b/src/newgrf/newgrf_act0_stations.cpp @@ -37,10 +37,10 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR } /* Allocate station specs if necessary */ - if (_cur.grffile->stations.size() < last) _cur.grffile->stations.resize(last); + if (_cur_gps.grffile->stations.size() < last) _cur_gps.grffile->stations.resize(last); for (uint id = first; id < last; ++id) { - auto &statspec = _cur.grffile->stations[id]; + auto &statspec = _cur_gps.grffile->stations[id]; /* Check that the station we are modifying is defined. */ if (statspec == nullptr && prop != 0x08) { @@ -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.skip_sprites < 0) return CIR_DISABLED; + if (_cur_gps.skip_sprites < 0) return CIR_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.skip_sprites < 0) return CIR_DISABLED; + if (_cur_gps.skip_sprites < 0) return CIR_DISABLED; } dts->seq = std::move(tmp_layout); } @@ -114,7 +114,7 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR case 0x0A: { // Copy sprite layout uint16_t srcid = buf.ReadExtendedByte(); - const StationSpec *srcstatspec = srcid >= _cur.grffile->stations.size() ? nullptr : _cur.grffile->stations[srcid].get(); + const StationSpec *srcstatspec = srcid >= _cur_gps.grffile->stations.size() ? nullptr : _cur_gps.grffile->stations[srcid].get(); if (srcstatspec == nullptr) { GrfMsg(1, "StationChangeInfo: Station {} is not defined, cannot copy sprite layout to {}.", srcid, id); @@ -167,7 +167,7 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR case 0x0F: { // Copy custom layout uint16_t srcid = buf.ReadExtendedByte(); - const StationSpec *srcstatspec = srcid >= _cur.grffile->stations.size() ? nullptr : _cur.grffile->stations[srcid].get(); + const StationSpec *srcstatspec = srcid >= _cur_gps.grffile->stations.size() ? nullptr : _cur_gps.grffile->stations[srcid].get(); if (srcstatspec == nullptr) { GrfMsg(1, "StationChangeInfo: Station {} is not defined, cannot copy tile layout to {}.", srcid, id); @@ -196,7 +196,7 @@ static ChangeInfoResult StationChangeInfo(uint first, uint last, int prop, ByteR } case 0x12: // Cargo types for random triggers - if (_cur.grffile->grf_version >= 7) { + if (_cur_gps.grffile->grf_version >= 7) { statspec->cargo_triggers = TranslateRefitMask(buf.ReadDWord()); } else { statspec->cargo_triggers = (CargoTypes)buf.ReadDWord(); diff --git a/src/newgrf/newgrf_act0_trains.cpp b/src/newgrf/newgrf_act0_trains.cpp index 7840f63e6e..29fa3e473a 100644 --- a/src/newgrf/newgrf_act0_trains.cpp +++ b/src/newgrf/newgrf_act0_trains.cpp @@ -31,7 +31,7 @@ ChangeInfoResult RailVehicleChangeInfo(uint first, uint last, int prop, ByteRead ChangeInfoResult ret = CIR_SUCCESS; for (uint id = first; id < last; ++id) { - Engine *e = GetNewEngine(_cur.grffile, VEH_TRAIN, 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 EngineInfo *ei = &e->info; @@ -41,8 +41,8 @@ ChangeInfoResult RailVehicleChangeInfo(uint first, uint last, int prop, ByteRead case 0x05: { // Track type uint8_t tracktype = buf.ReadByte(); - if (tracktype < _cur.grffile->railtype_list.size()) { - _gted[e->index].railtypelabel = _cur.grffile->railtype_list[tracktype]; + if (tracktype < _cur_gps.grffile->railtype_list.size()) { + _gted[e->index].railtypelabel = _cur_gps.grffile->railtype_list[tracktype]; break; } @@ -126,7 +126,7 @@ ChangeInfoResult RailVehicleChangeInfo(uint first, uint last, int prop, ByteRead break; case 0x15: { // Cargo type - _gted[e->index].defaultcargo_grf = _cur.grffile; + _gted[e->index].defaultcargo_grf = _cur_gps.grffile; uint8_t ctype = buf.ReadByte(); if (ctype == 0xFF) { @@ -134,7 +134,7 @@ ChangeInfoResult RailVehicleChangeInfo(uint first, uint last, int prop, ByteRead ei->cargo_type = INVALID_CARGO; } else { /* Use translated cargo. Might result in INVALID_CARGO (first refittable), if cargo is not defined. */ - ei->cargo_type = GetCargoTranslation(ctype, _cur.grffile); + ei->cargo_type = GetCargoTranslation(ctype, _cur_gps.grffile); if (ei->cargo_type == INVALID_CARGO) GrfMsg(2, "RailVehicleChangeInfo: Invalid cargo type {}, using first refittable", ctype); } ei->cargo_label = CT_INVALID; @@ -179,7 +179,7 @@ ChangeInfoResult RailVehicleChangeInfo(uint first, uint last, int prop, ByteRead break; } - if (_cur.grffile->railtype_list.empty()) { + if (_cur_gps.grffile->railtype_list.empty()) { /* Use traction type to select between normal and electrified * rail only when no translation list is in place. */ if (_gted[e->index].railtypelabel == RAILTYPE_LABEL_RAIL && engclass >= EC_ELECTRIC) _gted[e->index].railtypelabel = RAILTYPE_LABEL_ELECTRIC; @@ -206,7 +206,7 @@ ChangeInfoResult RailVehicleChangeInfo(uint first, uint last, int prop, ByteRead uint32_t mask = buf.ReadDWord(); _gted[e->index].UpdateRefittability(mask != 0); ei->refit_mask = TranslateRefitMask(mask); - _gted[e->index].defaultcargo_grf = _cur.grffile; + _gted[e->index].defaultcargo_grf = _cur_gps.grffile; break; } @@ -270,7 +270,7 @@ ChangeInfoResult RailVehicleChangeInfo(uint first, uint last, int prop, ByteRead case 0x28: // Cargo classes allowed _gted[e->index].cargo_allowed = CargoClasses{buf.ReadWord()}; _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed.Any()); - _gted[e->index].defaultcargo_grf = _cur.grffile; + _gted[e->index].defaultcargo_grf = _cur_gps.grffile; break; case 0x29: // Cargo classes disallowed @@ -290,11 +290,11 @@ ChangeInfoResult RailVehicleChangeInfo(uint first, uint last, int prop, ByteRead case 0x2D: { // CTT refit exclude list uint8_t count = buf.ReadByte(); _gted[e->index].UpdateRefittability(prop == 0x2C && count != 0); - if (prop == 0x2C) _gted[e->index].defaultcargo_grf = _cur.grffile; + if (prop == 0x2C) _gted[e->index].defaultcargo_grf = _cur_gps.grffile; CargoTypes &ctt = prop == 0x2C ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; ctt = 0; while (count--) { - CargoType ctype = GetCargoTranslation(buf.ReadByte(), _cur.grffile); + CargoType ctype = GetCargoTranslation(buf.ReadByte(), _cur_gps.grffile); if (IsValidCargoType(ctype)) SetBit(ctt, ctype); } break; diff --git a/src/newgrf/newgrf_act1.cpp b/src/newgrf/newgrf_act1.cpp index 21ff5c658f..2336dcc57d 100644 --- a/src/newgrf/newgrf_act1.cpp +++ b/src/newgrf/newgrf_act1.cpp @@ -45,20 +45,20 @@ static void NewSpriteSet(ByteReader &buf) uint16_t num_ents = buf.ReadExtendedByte(); if (feature >= GSF_END) { - _cur.skip_sprites = num_sets * num_ents; - GrfMsg(1, "NewSpriteSet: Unsupported feature 0x{:02X}, skipping {} sprites", feature, _cur.skip_sprites); + _cur_gps.skip_sprites = num_sets * num_ents; + GrfMsg(1, "NewSpriteSet: Unsupported feature 0x{:02X}, skipping {} sprites", feature, _cur_gps.skip_sprites); return; } - _cur.AddSpriteSets(feature, _cur.spriteid, first_set, num_sets, num_ents); + _cur_gps.AddSpriteSets(feature, _cur_gps.spriteid, first_set, num_sets, num_ents); GrfMsg(7, "New sprite set at {} of feature 0x{:02X}, consisting of {} sets with {} views each (total {})", - _cur.spriteid, feature, num_sets, num_ents, num_sets * num_ents + _cur_gps.spriteid, feature, num_sets, num_ents, num_sets * num_ents ); for (int i = 0; i < num_sets * num_ents; i++) { - _cur.nfo_line++; - LoadNextSprite(_cur.spriteid++, *_cur.file, _cur.nfo_line); + _cur_gps.nfo_line++; + LoadNextSprite(_cur_gps.spriteid++, *_cur_gps.file, _cur_gps.nfo_line); } } @@ -76,9 +76,9 @@ static void SkipAct1(ByteReader &buf) } uint16_t num_ents = buf.ReadExtendedByte(); - _cur.skip_sprites = num_sets * num_ents; + _cur_gps.skip_sprites = num_sets * num_ents; - GrfMsg(3, "SkipAct1: Skipping {} sprites", _cur.skip_sprites); + GrfMsg(3, "SkipAct1: Skipping {} sprites", _cur_gps.skip_sprites); } template <> void GrfActionHandler<0x01>::FileScan(ByteReader &buf) { SkipAct1(buf); } diff --git a/src/newgrf/newgrf_act10.cpp b/src/newgrf/newgrf_act10.cpp index bb9cbb5cb3..7c41d7cb0c 100644 --- a/src/newgrf/newgrf_act10.cpp +++ b/src/newgrf/newgrf_act10.cpp @@ -24,7 +24,7 @@ static void DefineGotoLabel(ByteReader &buf) uint8_t nfo_label = buf.ReadByte(); - _cur.grffile->labels.emplace_back(nfo_label, _cur.nfo_line, _cur.file->GetPos()); + _cur_gps.grffile->labels.emplace_back(nfo_label, _cur_gps.nfo_line, _cur_gps.file->GetPos()); GrfMsg(2, "DefineGotoLabel: GOTO target with label 0x{:02X}", nfo_label); } diff --git a/src/newgrf/newgrf_act11.cpp b/src/newgrf/newgrf_act11.cpp index 9d1fc766f2..fd1dc38029 100644 --- a/src/newgrf/newgrf_act11.cpp +++ b/src/newgrf/newgrf_act11.cpp @@ -24,8 +24,8 @@ static void ImportGRFSound(SoundEntry *sound) { const GRFFile *file; - uint32_t grfid = _cur.file->ReadDword(); - SoundID sound_id = _cur.file->ReadWord(); + uint32_t grfid = _cur_gps.file->ReadDword(); + SoundID sound_id = _cur_gps.file->ReadWord(); file = GetFileByGRFID(grfid); if (file == nullptr || file->sound_offset == 0) { @@ -60,10 +60,10 @@ static void LoadGRFSound(size_t offs, SoundEntry *sound) if (offs != SIZE_MAX) { /* Sound is present in the NewGRF. */ - sound->file = _cur.file; + sound->file = _cur_gps.file; sound->file_offset = offs; sound->source = SoundSource::NewGRF; - sound->grf_container_ver = _cur.file->GetContainerVersion(); + sound->grf_container_ver = _cur_gps.file->GetContainerVersion(); } } @@ -78,22 +78,22 @@ static void GRFSound(ByteReader &buf) if (num == 0) return; SoundEntry *sound; - if (_cur.grffile->sound_offset == 0) { - _cur.grffile->sound_offset = GetNumSounds(); - _cur.grffile->num_sounds = num; + if (_cur_gps.grffile->sound_offset == 0) { + _cur_gps.grffile->sound_offset = GetNumSounds(); + _cur_gps.grffile->num_sounds = num; sound = AllocateSound(num); } else { - sound = GetSound(_cur.grffile->sound_offset); + sound = GetSound(_cur_gps.grffile->sound_offset); } - SpriteFile &file = *_cur.file; + SpriteFile &file = *_cur_gps.file; uint8_t grf_container_version = file.GetContainerVersion(); for (int i = 0; i < num; i++) { - _cur.nfo_line++; + _cur_gps.nfo_line++; /* Check whether the index is in range. This might happen if multiple action 11 are present. * While this is invalid, we do not check for this. But we should prevent it from causing bigger trouble */ - bool invalid = i >= _cur.grffile->num_sounds; + bool invalid = i >= _cur_gps.grffile->num_sounds; size_t offs = file.GetPos(); @@ -110,7 +110,7 @@ static void GRFSound(ByteReader &buf) file.SkipBytes(len); } else { uint32_t id = file.ReadDword(); - if (_cur.stage == GLS_INIT) LoadGRFSound(GetGRFSpriteOffset(id), sound + i); + if (_cur_gps.stage == GLS_INIT) LoadGRFSound(GetGRFSpriteOffset(id), sound + i); } continue; } @@ -118,7 +118,7 @@ static void GRFSound(ByteReader &buf) if (type != 0xFF) { GrfMsg(1, "GRFSound: Unexpected RealSprite found, skipping"); file.SkipBytes(7); - SkipSpriteData(*_cur.file, type, len - 8); + SkipSpriteData(*_cur_gps.file, type, len - 8); continue; } @@ -131,7 +131,7 @@ static void GRFSound(ByteReader &buf) switch (action) { case 0xFF: /* Allocate sound only in init stage. */ - if (_cur.stage == GLS_INIT) { + if (_cur_gps.stage == GLS_INIT) { if (grf_container_version >= 2) { GrfMsg(1, "GRFSound: Inline sounds are not supported for container version >= 2"); } else { @@ -142,7 +142,7 @@ static void GRFSound(ByteReader &buf) break; case 0xFE: - if (_cur.stage == GLS_ACTIVATION) { + if (_cur_gps.stage == GLS_ACTIVATION) { /* XXX 'Action 0xFE' isn't really specified. It is only mentioned for * importing sounds, so this is probably all wrong... */ if (file.ReadByte() != 0) GrfMsg(1, "GRFSound: Import type mismatch"); @@ -167,9 +167,9 @@ static void SkipAct11(ByteReader &buf) * * W num Number of sound files that follow */ - _cur.skip_sprites = buf.ReadWord(); + _cur_gps.skip_sprites = buf.ReadWord(); - GrfMsg(3, "SkipAct11: Skipping {} sprites", _cur.skip_sprites); + GrfMsg(3, "SkipAct11: Skipping {} sprites", _cur_gps.skip_sprites); } template <> void GrfActionHandler<0x11>::FileScan(ByteReader &buf) { SkipAct11(buf); } diff --git a/src/newgrf/newgrf_act12.cpp b/src/newgrf/newgrf_act12.cpp index 65d2b2825f..2e0250775b 100644 --- a/src/newgrf/newgrf_act12.cpp +++ b/src/newgrf/newgrf_act12.cpp @@ -39,9 +39,9 @@ static void LoadFontGlyph(ByteReader &buf) GrfMsg(7, "LoadFontGlyph: Loading {} glyph(s) at 0x{:04X} for size {}", num_char, base_char, size); for (uint c = 0; c < num_char; c++) { - if (size < FS_END) SetUnicodeGlyph(size, base_char + c, _cur.spriteid); - _cur.nfo_line++; - LoadNextSprite(_cur.spriteid++, *_cur.file, _cur.nfo_line); + if (size < FS_END) SetUnicodeGlyph(size, base_char + c, _cur_gps.spriteid); + _cur_gps.nfo_line++; + LoadNextSprite(_cur_gps.spriteid++, *_cur_gps.file, _cur_gps.nfo_line); } } } @@ -63,13 +63,13 @@ static void SkipAct12(ByteReader &buf) buf.ReadByte(); /* Sum up number of characters */ - _cur.skip_sprites += buf.ReadByte(); + _cur_gps.skip_sprites += buf.ReadByte(); /* Ignore 'base_char' word */ buf.ReadWord(); } - GrfMsg(3, "SkipAct12: Skipping {} sprites", _cur.skip_sprites); + GrfMsg(3, "SkipAct12: Skipping {} sprites", _cur_gps.skip_sprites); } template <> void GrfActionHandler<0x12>::FileScan(ByteReader &buf) { SkipAct12(buf); } diff --git a/src/newgrf/newgrf_act13.cpp b/src/newgrf/newgrf_act13.cpp index 9f8f08beb0..d9bcab51e7 100644 --- a/src/newgrf/newgrf_act13.cpp +++ b/src/newgrf/newgrf_act13.cpp @@ -50,7 +50,7 @@ static void TranslateGRFStrings(ByteReader &buf) * new_scheme has to be true as well, which will also be implicitly the case for version 8 * and higher. A language id of 0x7F will be overridden by a non-generic id, so this will * not change anything if a string has been provided specifically for this language. */ - uint8_t language = _cur.grffile->grf_version >= 8 ? buf.ReadByte() : 0x7F; + uint8_t language = _cur_gps.grffile->grf_version >= 8 ? buf.ReadByte() : 0x7F; uint8_t num_strings = buf.ReadByte(); uint16_t first_id = buf.ReadWord(); diff --git a/src/newgrf/newgrf_act14.cpp b/src/newgrf/newgrf_act14.cpp index 3d7ae47570..824cb58905 100644 --- a/src/newgrf/newgrf_act14.cpp +++ b/src/newgrf/newgrf_act14.cpp @@ -18,21 +18,21 @@ /** Callback function for 'INFO'->'NAME' to add a translation to the newgrf name. */ static bool ChangeGRFName(uint8_t langid, std::string_view str) { - AddGRFTextToList(_cur.grfconfig->name, langid, _cur.grfconfig->ident.grfid, false, str); + AddGRFTextToList(_cur_gps.grfconfig->name, langid, _cur_gps.grfconfig->ident.grfid, false, str); return true; } /** Callback function for 'INFO'->'DESC' to add a translation to the newgrf description. */ static bool ChangeGRFDescription(uint8_t langid, std::string_view str) { - AddGRFTextToList(_cur.grfconfig->info, langid, _cur.grfconfig->ident.grfid, true, str); + AddGRFTextToList(_cur_gps.grfconfig->info, langid, _cur_gps.grfconfig->ident.grfid, true, str); return true; } /** Callback function for 'INFO'->'URL_' to set the newgrf url. */ static bool ChangeGRFURL(uint8_t langid, std::string_view str) { - AddGRFTextToList(_cur.grfconfig->url, langid, _cur.grfconfig->ident.grfid, false, str); + AddGRFTextToList(_cur_gps.grfconfig->url, langid, _cur_gps.grfconfig->ident.grfid, false, str); return true; } @@ -43,7 +43,7 @@ static bool ChangeGRFNumUsedParams(size_t len, ByteReader &buf) GrfMsg(2, "StaticGRFInfo: expected only 1 byte for 'INFO'->'NPAR' but got {}, ignoring this field", len); buf.Skip(len); } else { - _cur.grfconfig->num_valid_params = std::min(buf.ReadByte(), GRFConfig::MAX_NUM_PARAMS); + _cur_gps.grfconfig->num_valid_params = std::min(buf.ReadByte(), GRFConfig::MAX_NUM_PARAMS); } return true; } @@ -67,8 +67,8 @@ static bool ChangeGRFPalette(size_t len, ByteReader &buf) break; } if (pal != GRFP_GRF_UNSET) { - _cur.grfconfig->palette &= ~GRFP_GRF_MASK; - _cur.grfconfig->palette |= pal; + _cur_gps.grfconfig->palette &= ~GRFP_GRF_MASK; + _cur_gps.grfconfig->palette |= pal; } } return true; @@ -90,8 +90,8 @@ static bool ChangeGRFBlitter(size_t len, ByteReader &buf) GrfMsg(2, "StaticGRFInfo: unexpected value '{:02X}' for 'INFO'->'BLTR', ignoring this field", data); return true; } - _cur.grfconfig->palette &= ~GRFP_BLT_MASK; - _cur.grfconfig->palette |= pal; + _cur_gps.grfconfig->palette &= ~GRFP_BLT_MASK; + _cur_gps.grfconfig->palette |= pal; } return true; } @@ -104,7 +104,7 @@ static bool ChangeGRFVersion(size_t len, ByteReader &buf) buf.Skip(len); } else { /* Set min_loadable_version as well (default to minimal compatibility) */ - _cur.grfconfig->version = _cur.grfconfig->min_loadable_version = buf.ReadDWord(); + _cur_gps.grfconfig->version = _cur_gps.grfconfig->min_loadable_version = buf.ReadDWord(); } return true; } @@ -116,14 +116,14 @@ static bool ChangeGRFMinVersion(size_t len, ByteReader &buf) GrfMsg(2, "StaticGRFInfo: expected 4 bytes for 'INFO'->'MINV' but got {}, ignoring this field", len); buf.Skip(len); } else { - _cur.grfconfig->min_loadable_version = buf.ReadDWord(); - if (_cur.grfconfig->version == 0) { + _cur_gps.grfconfig->min_loadable_version = buf.ReadDWord(); + if (_cur_gps.grfconfig->version == 0) { GrfMsg(2, "StaticGRFInfo: 'MINV' defined before 'VRSN' or 'VRSN' set to 0, ignoring this field"); - _cur.grfconfig->min_loadable_version = 0; + _cur_gps.grfconfig->min_loadable_version = 0; } - if (_cur.grfconfig->version < _cur.grfconfig->min_loadable_version) { - GrfMsg(2, "StaticGRFInfo: 'MINV' defined as {}, limiting it to 'VRSN'", _cur.grfconfig->min_loadable_version); - _cur.grfconfig->min_loadable_version = _cur.grfconfig->version; + if (_cur_gps.grfconfig->version < _cur_gps.grfconfig->min_loadable_version) { + GrfMsg(2, "StaticGRFInfo: 'MINV' defined as {}, limiting it to 'VRSN'", _cur_gps.grfconfig->min_loadable_version); + _cur_gps.grfconfig->min_loadable_version = _cur_gps.grfconfig->version; } } return true; @@ -134,14 +134,14 @@ static GRFParameterInfo *_cur_parameter; ///< The parameter which info is curren /** Callback function for 'INFO'->'PARAM'->param_num->'NAME' to set the name of a parameter. */ static bool ChangeGRFParamName(uint8_t langid, std::string_view str) { - AddGRFTextToList(_cur_parameter->name, langid, _cur.grfconfig->ident.grfid, false, str); + AddGRFTextToList(_cur_parameter->name, langid, _cur_gps.grfconfig->ident.grfid, false, str); return true; } /** Callback function for 'INFO'->'PARAM'->param_num->'DESC' to set the description of a parameter. */ static bool ChangeGRFParamDescription(uint8_t langid, std::string_view str) { - AddGRFTextToList(_cur_parameter->desc, langid, _cur.grfconfig->ident.grfid, true, str); + AddGRFTextToList(_cur_parameter->desc, langid, _cur_gps.grfconfig->ident.grfid, true, str); return true; } @@ -214,7 +214,7 @@ static bool ChangeGRFParamDefault(size_t len, ByteReader &buf) } else { _cur_parameter->def_value = buf.ReadDWord(); } - _cur.grfconfig->has_param_defaults = true; + _cur_gps.grfconfig->has_param_defaults = true; return true; } @@ -265,7 +265,7 @@ static bool ChangeGRFParamValueNames(ByteReader &buf) if (it == std::end(_cur_parameter->value_names) || it->first != id) { it = _cur_parameter->value_names.emplace(it, id, GRFTextList{}); } - AddGRFTextToList(it->second, langid, _cur.grfconfig->ident.grfid, false, name_string); + AddGRFTextToList(it->second, langid, _cur_gps.grfconfig->ident.grfid, false, name_string); type = buf.ReadByte(); } @@ -294,20 +294,20 @@ static bool HandleParameterInfo(ByteReader &buf) uint8_t type = buf.ReadByte(); while (type != 0) { uint32_t id = buf.ReadDWord(); - if (type != 'C' || id >= _cur.grfconfig->num_valid_params) { + if (type != 'C' || id >= _cur_gps.grfconfig->num_valid_params) { GrfMsg(2, "StaticGRFInfo: all child nodes of 'INFO'->'PARA' should have type 'C' and their parameter number as id"); if (!SkipUnknownInfo(buf, type)) return false; type = buf.ReadByte(); continue; } - if (id >= _cur.grfconfig->param_info.size()) { - _cur.grfconfig->param_info.resize(id + 1); + if (id >= _cur_gps.grfconfig->param_info.size()) { + _cur_gps.grfconfig->param_info.resize(id + 1); } - if (!_cur.grfconfig->param_info[id].has_value()) { - _cur.grfconfig->param_info[id] = GRFParameterInfo(id); + if (!_cur_gps.grfconfig->param_info[id].has_value()) { + _cur_gps.grfconfig->param_info[id] = GRFParameterInfo(id); } - _cur_parameter = &_cur.grfconfig->param_info[id].value(); + _cur_parameter = &_cur_gps.grfconfig->param_info[id].value(); /* Read all parameter-data and process each node. */ if (!HandleNodes(buf, _tags_parameters)) return false; type = buf.ReadByte(); diff --git a/src/newgrf/newgrf_act2.cpp b/src/newgrf/newgrf_act2.cpp index acbafcc94e..8c9642b649 100644 --- a/src/newgrf/newgrf_act2.cpp +++ b/src/newgrf/newgrf_act2.cpp @@ -70,13 +70,13 @@ TileLayoutFlags ReadSpriteLayoutSprite(ByteReader &buf, bool read_flags, bool in if (custom_sprite) { /* Use sprite from Action 1 */ uint index = GB(grf_sprite->sprite, 0, 14); - if (use_cur_spritesets && (!_cur.IsValidSpriteSet(feature, index) || _cur.GetNumEnts(feature, index) == 0)) { + if (use_cur_spritesets && (!_cur_gps.IsValidSpriteSet(feature, index) || _cur_gps.GetNumEnts(feature, index) == 0)) { GrfMsg(1, "ReadSpriteLayoutSprite: Spritelayout uses undefined custom spriteset {}", index); grf_sprite->sprite = SPR_IMG_QUERY; grf_sprite->pal = PAL_NONE; } else { - SpriteID sprite = use_cur_spritesets ? _cur.GetSprite(feature, index) : index; - if (max_sprite_offset != nullptr) *max_sprite_offset = use_cur_spritesets ? _cur.GetNumEnts(feature, index) : UINT16_MAX; + SpriteID sprite = use_cur_spritesets ? _cur_gps.GetSprite(feature, index) : index; + if (max_sprite_offset != nullptr) *max_sprite_offset = use_cur_spritesets ? _cur_gps.GetNumEnts(feature, index) : UINT16_MAX; SB(grf_sprite->sprite, 0, SPRITE_WIDTH, sprite); SetBit(grf_sprite->sprite, SPRITE_MODIFIER_CUSTOM_SPRITE); } @@ -89,12 +89,12 @@ TileLayoutFlags ReadSpriteLayoutSprite(ByteReader &buf, bool read_flags, bool in if (flags & TLF_CUSTOM_PALETTE) { /* Use palette from Action 1 */ uint index = GB(grf_sprite->pal, 0, 14); - if (use_cur_spritesets && (!_cur.IsValidSpriteSet(feature, index) || _cur.GetNumEnts(feature, index) == 0)) { + if (use_cur_spritesets && (!_cur_gps.IsValidSpriteSet(feature, index) || _cur_gps.GetNumEnts(feature, index) == 0)) { GrfMsg(1, "ReadSpriteLayoutSprite: Spritelayout uses undefined custom spriteset {} for 'palette'", index); grf_sprite->pal = PAL_NONE; } else { - SpriteID sprite = use_cur_spritesets ? _cur.GetSprite(feature, index) : index; - if (max_palette_offset != nullptr) *max_palette_offset = use_cur_spritesets ? _cur.GetNumEnts(feature, index) : UINT16_MAX; + SpriteID sprite = use_cur_spritesets ? _cur_gps.GetSprite(feature, index) : index; + if (max_palette_offset != nullptr) *max_palette_offset = use_cur_spritesets ? _cur_gps.GetNumEnts(feature, index) : UINT16_MAX; SB(grf_sprite->pal, 0, SPRITE_WIDTH, sprite); SetBit(grf_sprite->pal, SPRITE_MODIFIER_CUSTOM_SPRITE); } @@ -181,7 +181,7 @@ bool ReadSpriteLayout(ByteReader &buf, uint num_building_sprites, bool use_cur_s /* Groundsprite */ TileLayoutFlags flags = ReadSpriteLayoutSprite(buf, has_flags, false, use_cur_spritesets, feature, &dts->ground, max_sprite_offset.data(), max_palette_offset.data()); - if (_cur.skip_sprites < 0) return true; + if (_cur_gps.skip_sprites < 0) return true; if (flags & ~(valid_flags & ~TLF_NON_GROUND_FLAGS)) { GrfMsg(1, "ReadSpriteLayout: Spritelayout uses invalid flag 0x{:X} for ground sprite", flags & ~(valid_flags & ~TLF_NON_GROUND_FLAGS)); @@ -190,13 +190,13 @@ bool ReadSpriteLayout(ByteReader &buf, uint num_building_sprites, bool use_cur_s } ReadSpriteLayoutRegisters(buf, flags, false, dts, 0); - if (_cur.skip_sprites < 0) return true; + if (_cur_gps.skip_sprites < 0) return true; for (uint i = 0; i < num_building_sprites; i++) { DrawTileSeqStruct *seq = const_cast(&dts->seq[i]); flags = ReadSpriteLayoutSprite(buf, has_flags, false, use_cur_spritesets, feature, &seq->image, max_sprite_offset.data() + i + 1, max_palette_offset.data() + i + 1); - if (_cur.skip_sprites < 0) return true; + if (_cur_gps.skip_sprites < 0) return true; if (flags & ~valid_flags) { GrfMsg(1, "ReadSpriteLayout: Spritelayout uses unknown flag 0x{:X}", flags & ~valid_flags); @@ -216,7 +216,7 @@ bool ReadSpriteLayout(ByteReader &buf, uint num_building_sprites, bool use_cur_s } ReadSpriteLayoutRegisters(buf, flags, seq->IsParentSprite(), dts, i + 1); - if (_cur.skip_sprites < 0) return true; + if (_cur_gps.skip_sprites < 0) return true; } /* Check if the number of sprites per spriteset is consistent */ @@ -271,7 +271,7 @@ static const SpriteGroup *GetCallbackResultGroup(uint16_t value) { /* Old style callback results (only valid for version < 8) have the highest byte 0xFF to signify it is a callback result. * New style ones only have the highest bit set (allows 15-bit results, instead of just 8) */ - if (_cur.grffile->grf_version < 8 && GB(value, 8, 8) == 0xFF) { + if (_cur_gps.grffile->grf_version < 8 && GB(value, 8, 8) == 0xFF) { value &= ~0xFF00; } else { value &= ~0x8000; @@ -294,12 +294,12 @@ static const SpriteGroup *GetGroupFromGroupID(uint8_t setid, uint8_t type, uint1 { if (HasBit(groupid, 15)) return GetCallbackResultGroup(groupid); - if (groupid > MAX_SPRITEGROUP || _cur.spritegroups[groupid] == nullptr) { + if (groupid > MAX_SPRITEGROUP || _cur_gps.spritegroups[groupid] == nullptr) { GrfMsg(1, "GetGroupFromGroupID(0x{:02X}:0x{:02X}): Groupid 0x{:04X} does not exist, leaving empty", setid, type, groupid); return nullptr; } - return _cur.spritegroups[groupid]; + return _cur_gps.spritegroups[groupid]; } /** @@ -314,16 +314,16 @@ static const SpriteGroup *CreateGroupFromGroupID(uint8_t feature, uint8_t setid, { if (HasBit(spriteid, 15)) return GetCallbackResultGroup(spriteid); - if (!_cur.IsValidSpriteSet(feature, spriteid)) { + if (!_cur_gps.IsValidSpriteSet(feature, spriteid)) { GrfMsg(1, "CreateGroupFromGroupID(0x{:02X}:0x{:02X}): Sprite set {} invalid", setid, type, spriteid); return nullptr; } - SpriteID spriteset_start = _cur.GetSprite(feature, spriteid); - uint num_sprites = _cur.GetNumEnts(feature, spriteid); + SpriteID spriteset_start = _cur_gps.GetSprite(feature, spriteid); + uint num_sprites = _cur_gps.GetNumEnts(feature, spriteid); /* Ensure that the sprites are loeded */ - assert(spriteset_start + num_sprites <= _cur.spriteid); + assert(spriteset_start + num_sprites <= _cur_gps.spriteid); assert(ResultSpriteGroup::CanAllocateItem()); return new ResultSpriteGroup(spriteset_start, num_sprites); @@ -371,7 +371,7 @@ static void NewSpriteGroup(ByteReader &buf) assert(DeterministicSpriteGroup::CanAllocateItem()); DeterministicSpriteGroup *group = new DeterministicSpriteGroup(); - group->nfo_line = _cur.nfo_line; + group->nfo_line = _cur_gps.nfo_line; act_group = group; group->var_scope = HasBit(type, 1) ? VSG_SCOPE_PARENT : VSG_SCOPE_SELF; @@ -475,7 +475,7 @@ static void NewSpriteGroup(ByteReader &buf) { assert(RandomizedSpriteGroup::CanAllocateItem()); RandomizedSpriteGroup *group = new RandomizedSpriteGroup(); - group->nfo_line = _cur.nfo_line; + group->nfo_line = _cur_gps.nfo_line; act_group = group; group->var_scope = HasBit(type, 1) ? VSG_SCOPE_PARENT : VSG_SCOPE_SELF; @@ -522,7 +522,7 @@ static void NewSpriteGroup(ByteReader &buf) uint8_t num_loaded = type; uint8_t num_loading = buf.ReadByte(); - if (!_cur.HasValidSpriteSets(feature)) { + if (!_cur_gps.HasValidSpriteSets(feature)) { GrfMsg(0, "NewSpriteGroup: No sprite set to work on! Skipping"); return; } @@ -569,7 +569,7 @@ static void NewSpriteGroup(ByteReader &buf) assert(RealSpriteGroup::CanAllocateItem()); RealSpriteGroup *group = new RealSpriteGroup(); - group->nfo_line = _cur.nfo_line; + group->nfo_line = _cur_gps.nfo_line; act_group = group; if (loaded_same && loaded.size() > 1) loaded.resize(1); @@ -598,7 +598,7 @@ static void NewSpriteGroup(ByteReader &buf) assert(TileLayoutSpriteGroup::CanAllocateItem()); TileLayoutSpriteGroup *group = new TileLayoutSpriteGroup(); - group->nfo_line = _cur.nfo_line; + group->nfo_line = _cur_gps.nfo_line; act_group = group; /* On error, bail out immediately. Temporary GRF data was already freed */ @@ -614,7 +614,7 @@ static void NewSpriteGroup(ByteReader &buf) assert(IndustryProductionSpriteGroup::CanAllocateItem()); IndustryProductionSpriteGroup *group = new IndustryProductionSpriteGroup(); - group->nfo_line = _cur.nfo_line; + group->nfo_line = _cur_gps.nfo_line; act_group = group; group->version = type; if (type == 0) { @@ -646,7 +646,7 @@ static void NewSpriteGroup(ByteReader &buf) } for (uint i = 0; i < group->num_input; i++) { uint8_t rawcargo = buf.ReadByte(); - CargoType cargo = GetCargoTranslation(rawcargo, _cur.grffile); + CargoType cargo = GetCargoTranslation(rawcargo, _cur_gps.grffile); if (!IsValidCargoType(cargo)) { /* The mapped cargo is invalid. This is permitted at this point, * as long as the result is not used. Mark it invalid so this @@ -668,7 +668,7 @@ static void NewSpriteGroup(ByteReader &buf) } for (uint i = 0; i < group->num_output; i++) { uint8_t rawcargo = buf.ReadByte(); - CargoType cargo = GetCargoTranslation(rawcargo, _cur.grffile); + CargoType cargo = GetCargoTranslation(rawcargo, _cur_gps.grffile); if (!IsValidCargoType(cargo)) { /* Mark this result as invalid to use */ group->version = 0xFF; @@ -693,7 +693,7 @@ static void NewSpriteGroup(ByteReader &buf) } } - _cur.spritegroups[setid] = act_group; + _cur_gps.spritegroups[setid] = act_group; } template <> void GrfActionHandler<0x02>::FileScan(ByteReader &) { } diff --git a/src/newgrf/newgrf_act3.cpp b/src/newgrf/newgrf_act3.cpp index 89db8d6868..96fffac525 100644 --- a/src/newgrf/newgrf_act3.cpp +++ b/src/newgrf/newgrf_act3.cpp @@ -39,11 +39,11 @@ static CargoType TranslateCargo(uint8_t feature, uint8_t ctype) if ((feature == GSF_STATIONS || feature == GSF_ROADSTOPS) && ctype == 0xFE) return SpriteGroupCargo::SG_DEFAULT_NA; if (ctype == 0xFF) return SpriteGroupCargo::SG_PURCHASE; - auto cargo_list = GetCargoTranslationTable(*_cur.grffile); + auto cargo_list = GetCargoTranslationTable(*_cur_gps.grffile); /* Check if the cargo type is out of bounds of the cargo translation table */ if (ctype >= cargo_list.size()) { - GrfMsg(1, "TranslateCargo: Cargo type {} out of range (max {}), skipping.", ctype, (unsigned int)_cur.grffile->cargo_list.size() - 1); + GrfMsg(1, "TranslateCargo: Cargo type {} out of range (max {}), skipping.", ctype, (unsigned int)_cur_gps.grffile->cargo_list.size() - 1); return INVALID_CARGO; } @@ -67,7 +67,7 @@ static CargoType TranslateCargo(uint8_t feature, uint8_t ctype) static bool IsValidGroupID(uint16_t groupid, const char *function) { - if (groupid > MAX_SPRITEGROUP || _cur.spritegroups[groupid] == nullptr) { + if (groupid > MAX_SPRITEGROUP || _cur_gps.spritegroups[groupid] == nullptr) { GrfMsg(1, "{}: Spritegroup 0x{:04X} out of range or empty, skipping.", function, groupid); return false; } @@ -99,7 +99,7 @@ static void VehicleMapSpriteGroup(ByteReader &buf, uint8_t feature, uint8_t idco std::vector engines; engines.reserve(idcount); for (uint i = 0; i < idcount; i++) { - Engine *e = GetNewEngine(_cur.grffile, (VehicleType)feature, buf.ReadExtendedByte()); + Engine *e = GetNewEngine(_cur_gps.grffile, (VehicleType)feature, buf.ReadExtendedByte()); if (e == nullptr) { /* No engine could be allocated?!? Deal with it. Okay, * this might look bad. Also make sure this NewGRF @@ -129,9 +129,9 @@ static void VehicleMapSpriteGroup(ByteReader &buf, uint8_t feature, uint8_t idco GrfMsg(7, "VehicleMapSpriteGroup: [{}] Engine {}...", i, engine); if (wagover) { - SetWagonOverrideSprites(engine, cargo_type, _cur.spritegroups[groupid], last_engines); + SetWagonOverrideSprites(engine, cargo_type, _cur_gps.spritegroups[groupid], last_engines); } else { - SetCustomEngineSprites(engine, cargo_type, _cur.spritegroups[groupid]); + SetCustomEngineSprites(engine, cargo_type, _cur_gps.spritegroups[groupid]); } } } @@ -145,10 +145,10 @@ static void VehicleMapSpriteGroup(ByteReader &buf, uint8_t feature, uint8_t idco EngineID engine = engines[i]; if (wagover) { - SetWagonOverrideSprites(engine, SpriteGroupCargo::SG_DEFAULT, _cur.spritegroups[groupid], last_engines); + SetWagonOverrideSprites(engine, SpriteGroupCargo::SG_DEFAULT, _cur_gps.spritegroups[groupid], last_engines); } else { - SetCustomEngineSprites(engine, SpriteGroupCargo::SG_DEFAULT, _cur.spritegroups[groupid]); - SetEngineGRF(engine, _cur.grffile); + SetCustomEngineSprites(engine, SpriteGroupCargo::SG_DEFAULT, _cur_gps.spritegroups[groupid]); + SetEngineGRF(engine, _cur_gps.grffile); } } } @@ -174,15 +174,15 @@ static void CanalMapSpriteGroup(ByteReader &buf, uint8_t idcount) continue; } - _water_feature[cf].grffile = _cur.grffile; - _water_feature[cf].group = _cur.spritegroups[groupid]; + _water_feature[cf].grffile = _cur_gps.grffile; + _water_feature[cf].group = _cur_gps.spritegroups[groupid]; } } static void StationMapSpriteGroup(ByteReader &buf, uint8_t idcount) { - if (_cur.grffile->stations.empty()) { + if (_cur_gps.grffile->stations.empty()) { GrfMsg(1, "StationMapSpriteGroup: No stations defined, skipping"); return; } @@ -203,14 +203,14 @@ static void StationMapSpriteGroup(ByteReader &buf, uint8_t idcount) if (!IsValidCargoType(ctype)) continue; for (auto &station : stations) { - StationSpec *statspec = station >= _cur.grffile->stations.size() ? nullptr : _cur.grffile->stations[station].get(); + StationSpec *statspec = station >= _cur_gps.grffile->stations.size() ? nullptr : _cur_gps.grffile->stations[station].get(); if (statspec == nullptr) { GrfMsg(1, "StationMapSpriteGroup: Station {} undefined, skipping", station); continue; } - statspec->grf_prop.SetSpriteGroup(ctype, _cur.spritegroups[groupid]); + statspec->grf_prop.SetSpriteGroup(ctype, _cur_gps.spritegroups[groupid]); } } @@ -218,7 +218,7 @@ static void StationMapSpriteGroup(ByteReader &buf, uint8_t idcount) if (!IsValidGroupID(groupid, "StationMapSpriteGroup")) return; for (auto &station : stations) { - StationSpec *statspec = station >= _cur.grffile->stations.size() ? nullptr : _cur.grffile->stations[station].get(); + StationSpec *statspec = station >= _cur_gps.grffile->stations.size() ? nullptr : _cur_gps.grffile->stations[station].get(); if (statspec == nullptr) { GrfMsg(1, "StationMapSpriteGroup: Station {} undefined, skipping", station); @@ -230,8 +230,8 @@ static void StationMapSpriteGroup(ByteReader &buf, uint8_t idcount) continue; } - statspec->grf_prop.SetSpriteGroup(SpriteGroupCargo::SG_DEFAULT, _cur.spritegroups[groupid]); - statspec->grf_prop.SetGRFFile(_cur.grffile); + statspec->grf_prop.SetSpriteGroup(SpriteGroupCargo::SG_DEFAULT, _cur_gps.spritegroups[groupid]); + statspec->grf_prop.SetGRFFile(_cur_gps.grffile); statspec->grf_prop.local_id = station; StationClass::Assign(statspec); } @@ -240,7 +240,7 @@ static void StationMapSpriteGroup(ByteReader &buf, uint8_t idcount) static void TownHouseMapSpriteGroup(ByteReader &buf, uint8_t idcount) { - if (_cur.grffile->housespec.empty()) { + if (_cur_gps.grffile->housespec.empty()) { GrfMsg(1, "TownHouseMapSpriteGroup: No houses defined, skipping"); return; } @@ -259,20 +259,20 @@ static void TownHouseMapSpriteGroup(ByteReader &buf, uint8_t idcount) if (!IsValidGroupID(groupid, "TownHouseMapSpriteGroup")) return; for (auto &house : houses) { - HouseSpec *hs = house >= _cur.grffile->housespec.size() ? nullptr : _cur.grffile->housespec[house].get(); + HouseSpec *hs = house >= _cur_gps.grffile->housespec.size() ? nullptr : _cur_gps.grffile->housespec[house].get(); if (hs == nullptr) { GrfMsg(1, "TownHouseMapSpriteGroup: House {} undefined, skipping.", house); continue; } - hs->grf_prop.SetSpriteGroup(0, _cur.spritegroups[groupid]); + hs->grf_prop.SetSpriteGroup(0, _cur_gps.spritegroups[groupid]); } } static void IndustryMapSpriteGroup(ByteReader &buf, uint8_t idcount) { - if (_cur.grffile->industryspec.empty()) { + if (_cur_gps.grffile->industryspec.empty()) { GrfMsg(1, "IndustryMapSpriteGroup: No industries defined, skipping"); return; } @@ -291,20 +291,20 @@ static void IndustryMapSpriteGroup(ByteReader &buf, uint8_t idcount) if (!IsValidGroupID(groupid, "IndustryMapSpriteGroup")) return; for (auto &industry : industries) { - IndustrySpec *indsp = industry >= _cur.grffile->industryspec.size() ? nullptr : _cur.grffile->industryspec[industry].get(); + IndustrySpec *indsp = industry >= _cur_gps.grffile->industryspec.size() ? nullptr : _cur_gps.grffile->industryspec[industry].get(); if (indsp == nullptr) { GrfMsg(1, "IndustryMapSpriteGroup: Industry {} undefined, skipping", industry); continue; } - indsp->grf_prop.SetSpriteGroup(0, _cur.spritegroups[groupid]); + indsp->grf_prop.SetSpriteGroup(0, _cur_gps.spritegroups[groupid]); } } static void IndustrytileMapSpriteGroup(ByteReader &buf, uint8_t idcount) { - if (_cur.grffile->indtspec.empty()) { + if (_cur_gps.grffile->indtspec.empty()) { GrfMsg(1, "IndustrytileMapSpriteGroup: No industry tiles defined, skipping"); return; } @@ -323,14 +323,14 @@ static void IndustrytileMapSpriteGroup(ByteReader &buf, uint8_t idcount) if (!IsValidGroupID(groupid, "IndustrytileMapSpriteGroup")) return; for (auto &indtile : indtiles) { - IndustryTileSpec *indtsp = indtile >= _cur.grffile->indtspec.size() ? nullptr : _cur.grffile->indtspec[indtile].get(); + IndustryTileSpec *indtsp = indtile >= _cur_gps.grffile->indtspec.size() ? nullptr : _cur_gps.grffile->indtspec[indtile].get(); if (indtsp == nullptr) { GrfMsg(1, "IndustrytileMapSpriteGroup: Industry tile {} undefined, skipping", indtile); continue; } - indtsp->grf_prop.SetSpriteGroup(0, _cur.spritegroups[groupid]); + indtsp->grf_prop.SetSpriteGroup(0, _cur_gps.spritegroups[groupid]); } } @@ -356,14 +356,14 @@ static void CargoMapSpriteGroup(ByteReader &buf, uint8_t idcount) } CargoSpec *cs = CargoSpec::Get(cargo_type); - cs->grffile = _cur.grffile; - cs->group = _cur.spritegroups[groupid]; + cs->grffile = _cur_gps.grffile; + cs->group = _cur_gps.spritegroups[groupid]; } } static void ObjectMapSpriteGroup(ByteReader &buf, uint8_t idcount) { - if (_cur.grffile->objectspec.empty()) { + if (_cur_gps.grffile->objectspec.empty()) { GrfMsg(1, "ObjectMapSpriteGroup: No object tiles defined, skipping"); return; } @@ -387,14 +387,14 @@ static void ObjectMapSpriteGroup(ByteReader &buf, uint8_t idcount) } for (auto &object : objects) { - ObjectSpec *spec = object >= _cur.grffile->objectspec.size() ? nullptr : _cur.grffile->objectspec[object].get(); + ObjectSpec *spec = object >= _cur_gps.grffile->objectspec.size() ? nullptr : _cur_gps.grffile->objectspec[object].get(); if (spec == nullptr) { GrfMsg(1, "ObjectMapSpriteGroup: Object {} undefined, skipping", object); continue; } - spec->grf_prop.SetSpriteGroup(OBJECT_SPRITE_GROUP_PURCHASE, _cur.spritegroups[groupid]); + spec->grf_prop.SetSpriteGroup(OBJECT_SPRITE_GROUP_PURCHASE, _cur_gps.spritegroups[groupid]); } } @@ -402,7 +402,7 @@ static void ObjectMapSpriteGroup(ByteReader &buf, uint8_t idcount) if (!IsValidGroupID(groupid, "ObjectMapSpriteGroup")) return; for (auto &object : objects) { - ObjectSpec *spec = object >= _cur.grffile->objectspec.size() ? nullptr : _cur.grffile->objectspec[object].get(); + ObjectSpec *spec = object >= _cur_gps.grffile->objectspec.size() ? nullptr : _cur_gps.grffile->objectspec[object].get(); if (spec == nullptr) { GrfMsg(1, "ObjectMapSpriteGroup: Object {} undefined, skipping", object); @@ -414,8 +414,8 @@ static void ObjectMapSpriteGroup(ByteReader &buf, uint8_t idcount) continue; } - spec->grf_prop.SetSpriteGroup(OBJECT_SPRITE_GROUP_DEFAULT, _cur.spritegroups[groupid]); - spec->grf_prop.SetGRFFile(_cur.grffile); + spec->grf_prop.SetSpriteGroup(OBJECT_SPRITE_GROUP_DEFAULT, _cur_gps.spritegroups[groupid]); + spec->grf_prop.SetGRFFile(_cur_gps.grffile); spec->grf_prop.local_id = object; } } @@ -426,7 +426,7 @@ static void RailTypeMapSpriteGroup(ByteReader &buf, uint8_t idcount) railtypes.reserve(idcount); for (uint i = 0; i < idcount; i++) { uint16_t id = buf.ReadExtendedByte(); - railtypes.push_back(id < RAILTYPE_END ? _cur.grffile->railtype_map[id] : INVALID_RAILTYPE); + railtypes.push_back(id < RAILTYPE_END ? _cur_gps.grffile->railtype_map[id] : INVALID_RAILTYPE); } uint8_t cidcount = buf.ReadByte(); @@ -442,8 +442,8 @@ static void RailTypeMapSpriteGroup(ByteReader &buf, uint8_t idcount) if (railtype != INVALID_RAILTYPE) { RailTypeInfo *rti = &_railtypes[railtype]; - rti->grffile[ctype] = _cur.grffile; - rti->group[ctype] = _cur.spritegroups[groupid]; + rti->grffile[ctype] = _cur_gps.grffile; + rti->group[ctype] = _cur_gps.spritegroups[groupid]; } } } @@ -454,7 +454,7 @@ static void RailTypeMapSpriteGroup(ByteReader &buf, uint8_t idcount) static void RoadTypeMapSpriteGroup(ByteReader &buf, uint8_t idcount, RoadTramType rtt) { - std::array &type_map = (rtt == RTT_TRAM) ? _cur.grffile->tramtype_map : _cur.grffile->roadtype_map; + std::array &type_map = (rtt == RTT_TRAM) ? _cur_gps.grffile->tramtype_map : _cur_gps.grffile->roadtype_map; std::vector roadtypes; roadtypes.reserve(idcount); @@ -476,8 +476,8 @@ static void RoadTypeMapSpriteGroup(ByteReader &buf, uint8_t idcount, RoadTramTyp if (roadtype != INVALID_ROADTYPE) { RoadTypeInfo *rti = &_roadtypes[roadtype]; - rti->grffile[ctype] = _cur.grffile; - rti->group[ctype] = _cur.spritegroups[groupid]; + rti->grffile[ctype] = _cur_gps.grffile; + rti->group[ctype] = _cur_gps.spritegroups[groupid]; } } } @@ -488,7 +488,7 @@ static void RoadTypeMapSpriteGroup(ByteReader &buf, uint8_t idcount, RoadTramTyp static void AirportMapSpriteGroup(ByteReader &buf, uint8_t idcount) { - if (_cur.grffile->airportspec.empty()) { + if (_cur_gps.grffile->airportspec.empty()) { GrfMsg(1, "AirportMapSpriteGroup: No airports defined, skipping"); return; } @@ -507,20 +507,20 @@ static void AirportMapSpriteGroup(ByteReader &buf, uint8_t idcount) if (!IsValidGroupID(groupid, "AirportMapSpriteGroup")) return; for (auto &airport : airports) { - AirportSpec *as = airport >= _cur.grffile->airportspec.size() ? nullptr : _cur.grffile->airportspec[airport].get(); + AirportSpec *as = airport >= _cur_gps.grffile->airportspec.size() ? nullptr : _cur_gps.grffile->airportspec[airport].get(); if (as == nullptr) { GrfMsg(1, "AirportMapSpriteGroup: Airport {} undefined, skipping", airport); continue; } - as->grf_prop.SetSpriteGroup(0, _cur.spritegroups[groupid]); + as->grf_prop.SetSpriteGroup(0, _cur_gps.spritegroups[groupid]); } } static void AirportTileMapSpriteGroup(ByteReader &buf, uint8_t idcount) { - if (_cur.grffile->airtspec.empty()) { + if (_cur_gps.grffile->airtspec.empty()) { GrfMsg(1, "AirportTileMapSpriteGroup: No airport tiles defined, skipping"); return; } @@ -539,20 +539,20 @@ static void AirportTileMapSpriteGroup(ByteReader &buf, uint8_t idcount) if (!IsValidGroupID(groupid, "AirportTileMapSpriteGroup")) return; for (auto &airptile : airptiles) { - AirportTileSpec *airtsp = airptile >= _cur.grffile->airtspec.size() ? nullptr : _cur.grffile->airtspec[airptile].get(); + AirportTileSpec *airtsp = airptile >= _cur_gps.grffile->airtspec.size() ? nullptr : _cur_gps.grffile->airtspec[airptile].get(); if (airtsp == nullptr) { GrfMsg(1, "AirportTileMapSpriteGroup: Airport tile {} undefined, skipping", airptile); continue; } - airtsp->grf_prop.SetSpriteGroup(0, _cur.spritegroups[groupid]); + airtsp->grf_prop.SetSpriteGroup(0, _cur_gps.spritegroups[groupid]); } } static void RoadStopMapSpriteGroup(ByteReader &buf, uint8_t idcount) { - if (_cur.grffile->roadstops.empty()) { + if (_cur_gps.grffile->roadstops.empty()) { GrfMsg(1, "RoadStopMapSpriteGroup: No roadstops defined, skipping"); return; } @@ -573,14 +573,14 @@ static void RoadStopMapSpriteGroup(ByteReader &buf, uint8_t idcount) if (!IsValidCargoType(ctype)) continue; for (auto &roadstop : roadstops) { - RoadStopSpec *roadstopspec = roadstop >= _cur.grffile->roadstops.size() ? nullptr : _cur.grffile->roadstops[roadstop].get(); + RoadStopSpec *roadstopspec = roadstop >= _cur_gps.grffile->roadstops.size() ? nullptr : _cur_gps.grffile->roadstops[roadstop].get(); if (roadstopspec == nullptr) { GrfMsg(1, "RoadStopMapSpriteGroup: Road stop {} undefined, skipping", roadstop); continue; } - roadstopspec->grf_prop.SetSpriteGroup(ctype, _cur.spritegroups[groupid]); + roadstopspec->grf_prop.SetSpriteGroup(ctype, _cur_gps.spritegroups[groupid]); } } @@ -588,7 +588,7 @@ static void RoadStopMapSpriteGroup(ByteReader &buf, uint8_t idcount) if (!IsValidGroupID(groupid, "RoadStopMapSpriteGroup")) return; for (auto &roadstop : roadstops) { - RoadStopSpec *roadstopspec = roadstop >= _cur.grffile->roadstops.size() ? nullptr : _cur.grffile->roadstops[roadstop].get(); + RoadStopSpec *roadstopspec = roadstop >= _cur_gps.grffile->roadstops.size() ? nullptr : _cur_gps.grffile->roadstops[roadstop].get(); if (roadstopspec == nullptr) { GrfMsg(1, "RoadStopMapSpriteGroup: Road stop {} undefined, skipping.", roadstop); @@ -600,8 +600,8 @@ static void RoadStopMapSpriteGroup(ByteReader &buf, uint8_t idcount) continue; } - roadstopspec->grf_prop.SetSpriteGroup(SpriteGroupCargo::SG_DEFAULT, _cur.spritegroups[groupid]); - roadstopspec->grf_prop.SetGRFFile(_cur.grffile); + roadstopspec->grf_prop.SetSpriteGroup(SpriteGroupCargo::SG_DEFAULT, _cur_gps.spritegroups[groupid]); + roadstopspec->grf_prop.SetGRFFile(_cur_gps.grffile); roadstopspec->grf_prop.local_id = roadstop; RoadStopClass::Assign(roadstopspec); } @@ -609,7 +609,7 @@ static void RoadStopMapSpriteGroup(ByteReader &buf, uint8_t idcount) static void BadgeMapSpriteGroup(ByteReader &buf, uint8_t idcount) { - if (_cur.grffile->badge_map.empty()) { + if (_cur_gps.grffile->badge_map.empty()) { GrfMsg(1, "BadgeMapSpriteGroup: No badges defined, skipping"); return; } @@ -629,14 +629,14 @@ static void BadgeMapSpriteGroup(ByteReader &buf, uint8_t idcount) if (ctype >= GSF_END) continue; for (const auto &local_id : local_ids) { - auto found = _cur.grffile->badge_map.find(local_id); - if (found == std::end(_cur.grffile->badge_map)) { + auto found = _cur_gps.grffile->badge_map.find(local_id); + if (found == std::end(_cur_gps.grffile->badge_map)) { GrfMsg(1, "BadgeMapSpriteGroup: Badge {} undefined, skipping", local_id); continue; } auto &badge = *GetBadge(found->second); - badge.grf_prop.SetSpriteGroup(ctype, _cur.spritegroups[groupid]); + badge.grf_prop.SetSpriteGroup(ctype, _cur_gps.spritegroups[groupid]); } } @@ -644,15 +644,15 @@ static void BadgeMapSpriteGroup(ByteReader &buf, uint8_t idcount) if (!IsValidGroupID(groupid, "BadgeMapSpriteGroup")) return; for (auto &local_id : local_ids) { - auto found = _cur.grffile->badge_map.find(local_id); - if (found == std::end(_cur.grffile->badge_map)) { + auto found = _cur_gps.grffile->badge_map.find(local_id); + if (found == std::end(_cur_gps.grffile->badge_map)) { GrfMsg(1, "BadgeMapSpriteGroup: Badge {} undefined, skipping", local_id); continue; } auto &badge = *GetBadge(found->second); - badge.grf_prop.SetSpriteGroup(GSF_END, _cur.spritegroups[groupid]); - badge.grf_prop.SetGRFFile(_cur.grffile); + badge.grf_prop.SetSpriteGroup(GSF_END, _cur_gps.spritegroups[groupid]); + badge.grf_prop.SetGRFFile(_cur_gps.grffile); badge.grf_prop.local_id = local_id; } } @@ -691,12 +691,12 @@ static void FeatureMapSpriteGroup(ByteReader &buf) GrfMsg(6, "FeatureMapSpriteGroup: Adding generic feature callback for feature 0x{:02X}", feature); - AddGenericCallback(feature, _cur.grffile, _cur.spritegroups[groupid]); + AddGenericCallback(feature, _cur_gps.grffile, _cur_gps.spritegroups[groupid]); return; } /* Mark the feature as used by the grf (generic callbacks do not count) */ - SetBit(_cur.grffile->grf_features, feature); + SetBit(_cur_gps.grffile->grf_features, feature); GrfMsg(6, "FeatureMapSpriteGroup: Feature 0x{:02X}, {} ids", feature, idcount); diff --git a/src/newgrf/newgrf_act4.cpp b/src/newgrf/newgrf_act4.cpp index 38c6701d67..6a4fedf3ea 100644 --- a/src/newgrf/newgrf_act4.cpp +++ b/src/newgrf/newgrf_act4.cpp @@ -46,7 +46,7 @@ static void FeatureNewName(ByteReader &buf) * S data new texts, each of them zero-terminated, after * which the next name begins. */ - bool new_scheme = _cur.grffile->grf_version >= 7; + bool new_scheme = _cur_gps.grffile->grf_version >= 7; uint8_t feature = buf.ReadByte(); if (feature >= GSF_END && feature != 0x48) { @@ -86,67 +86,67 @@ static void FeatureNewName(ByteReader &buf) case GSF_SHIPS: case GSF_AIRCRAFT: if (!generic) { - Engine *e = GetNewEngine(_cur.grffile, (VehicleType)feature, id, _cur.grfconfig->flags.Test(GRFConfigFlag::Static)); + Engine *e = GetNewEngine(_cur_gps.grffile, (VehicleType)feature, id, _cur_gps.grfconfig->flags.Test(GRFConfigFlag::Static)); if (e == nullptr) break; - StringID string = AddGRFString(_cur.grffile->grfid, GRFStringID{feature_overlay | e->index.base()}, lang, new_scheme, false, name, e->info.string_id); + StringID string = AddGRFString(_cur_gps.grffile->grfid, GRFStringID{feature_overlay | e->index.base()}, lang, new_scheme, false, name, e->info.string_id); e->info.string_id = string; } else { - AddGRFString(_cur.grffile->grfid, GRFStringID{id}, lang, new_scheme, true, name, STR_UNDEFINED); + AddGRFString(_cur_gps.grffile->grfid, GRFStringID{id}, lang, new_scheme, true, name, STR_UNDEFINED); } break; case GSF_BADGES: { if (!generic) { - auto found = _cur.grffile->badge_map.find(id); - if (found == std::end(_cur.grffile->badge_map)) { + auto found = _cur_gps.grffile->badge_map.find(id); + if (found == std::end(_cur_gps.grffile->badge_map)) { GrfMsg(1, "FeatureNewName: Attempt to name undefined badge 0x{:X}, ignoring", id); } else { Badge &badge = *GetBadge(found->second); - badge.name = AddGRFString(_cur.grffile->grfid, GRFStringID{feature_overlay | id}, lang, true, false, name, STR_UNDEFINED); + badge.name = AddGRFString(_cur_gps.grffile->grfid, GRFStringID{feature_overlay | id}, lang, true, false, name, STR_UNDEFINED); } } else { - AddGRFString(_cur.grffile->grfid, GRFStringID{id}, lang, new_scheme, true, name, STR_UNDEFINED); + AddGRFString(_cur_gps.grffile->grfid, GRFStringID{id}, lang, new_scheme, true, name, STR_UNDEFINED); } break; } default: if (IsInsideMM(id, 0xD000, 0xD400) || IsInsideMM(id, 0xD800, 0x10000)) { - AddGRFString(_cur.grffile->grfid, GRFStringID{id}, lang, new_scheme, true, name, STR_UNDEFINED); + AddGRFString(_cur_gps.grffile->grfid, GRFStringID{id}, lang, new_scheme, true, name, STR_UNDEFINED); break; } switch (GB(id, 8, 8)) { case 0xC4: // Station class name - if (GB(id, 0, 8) >= _cur.grffile->stations.size() || _cur.grffile->stations[GB(id, 0, 8)] == nullptr) { + if (GB(id, 0, 8) >= _cur_gps.grffile->stations.size() || _cur_gps.grffile->stations[GB(id, 0, 8)] == nullptr) { GrfMsg(1, "FeatureNewName: Attempt to name undefined station 0x{:X}, ignoring", GB(id, 0, 8)); } else { - StationClassID class_index = _cur.grffile->stations[GB(id, 0, 8)]->class_index; - StationClass::Get(class_index)->name = AddGRFString(_cur.grffile->grfid, GRFStringID{id}, lang, new_scheme, false, name, STR_UNDEFINED); + StationClassID class_index = _cur_gps.grffile->stations[GB(id, 0, 8)]->class_index; + StationClass::Get(class_index)->name = AddGRFString(_cur_gps.grffile->grfid, GRFStringID{id}, lang, new_scheme, false, name, STR_UNDEFINED); } break; case 0xC5: // Station name - if (GB(id, 0, 8) >= _cur.grffile->stations.size() || _cur.grffile->stations[GB(id, 0, 8)] == nullptr) { + if (GB(id, 0, 8) >= _cur_gps.grffile->stations.size() || _cur_gps.grffile->stations[GB(id, 0, 8)] == nullptr) { GrfMsg(1, "FeatureNewName: Attempt to name undefined station 0x{:X}, ignoring", GB(id, 0, 8)); } else { - _cur.grffile->stations[GB(id, 0, 8)]->name = AddGRFString(_cur.grffile->grfid, GRFStringID{id}, lang, new_scheme, false, name, STR_UNDEFINED); + _cur_gps.grffile->stations[GB(id, 0, 8)]->name = AddGRFString(_cur_gps.grffile->grfid, GRFStringID{id}, lang, new_scheme, false, name, STR_UNDEFINED); } break; case 0xC7: // Airporttile name - if (GB(id, 0, 8) >= _cur.grffile->airtspec.size() || _cur.grffile->airtspec[GB(id, 0, 8)] == nullptr) { + if (GB(id, 0, 8) >= _cur_gps.grffile->airtspec.size() || _cur_gps.grffile->airtspec[GB(id, 0, 8)] == nullptr) { GrfMsg(1, "FeatureNewName: Attempt to name undefined airport tile 0x{:X}, ignoring", GB(id, 0, 8)); } else { - _cur.grffile->airtspec[GB(id, 0, 8)]->name = AddGRFString(_cur.grffile->grfid, GRFStringID{id}, lang, new_scheme, false, name, STR_UNDEFINED); + _cur_gps.grffile->airtspec[GB(id, 0, 8)]->name = AddGRFString(_cur_gps.grffile->grfid, GRFStringID{id}, lang, new_scheme, false, name, STR_UNDEFINED); } break; case 0xC9: // House name - if (GB(id, 0, 8) >= _cur.grffile->housespec.size() || _cur.grffile->housespec[GB(id, 0, 8)] == nullptr) { + if (GB(id, 0, 8) >= _cur_gps.grffile->housespec.size() || _cur_gps.grffile->housespec[GB(id, 0, 8)] == nullptr) { GrfMsg(1, "FeatureNewName: Attempt to name undefined house 0x{:X}, ignoring.", GB(id, 0, 8)); } else { - _cur.grffile->housespec[GB(id, 0, 8)]->building_name = AddGRFString(_cur.grffile->grfid, GRFStringID{id}, lang, new_scheme, false, name, STR_UNDEFINED); + _cur_gps.grffile->housespec[GB(id, 0, 8)]->building_name = AddGRFString(_cur_gps.grffile->grfid, GRFStringID{id}, lang, new_scheme, false, name, STR_UNDEFINED); } break; diff --git a/src/newgrf/newgrf_act5.cpp b/src/newgrf/newgrf_act5.cpp index 751ef0aa97..00a2427b3c 100644 --- a/src/newgrf/newgrf_act5.cpp +++ b/src/newgrf/newgrf_act5.cpp @@ -103,20 +103,20 @@ static void GraphicsNew(ByteReader &buf) uint16_t offset = HasBit(type, 7) ? buf.ReadExtendedByte() : 0; ClrBit(type, 7); // Clear the high bit as that only indicates whether there is an offset. - if ((type == 0x0D) && (num == 10) && _cur.grfconfig->flags.Test(GRFConfigFlag::System)) { + if ((type == 0x0D) && (num == 10) && _cur_gps.grfconfig->flags.Test(GRFConfigFlag::System)) { /* Special not-TTDP-compatible case used in openttd.grf * Missing shore sprites and initialisation of SPR_SHORE_BASE */ GrfMsg(2, "GraphicsNew: Loading 10 missing shore sprites from extra grf."); - LoadNextSprite(SPR_SHORE_BASE + 0, *_cur.file, _cur.nfo_line++); // SLOPE_STEEP_S - LoadNextSprite(SPR_SHORE_BASE + 5, *_cur.file, _cur.nfo_line++); // SLOPE_STEEP_W - LoadNextSprite(SPR_SHORE_BASE + 7, *_cur.file, _cur.nfo_line++); // SLOPE_WSE - LoadNextSprite(SPR_SHORE_BASE + 10, *_cur.file, _cur.nfo_line++); // SLOPE_STEEP_N - LoadNextSprite(SPR_SHORE_BASE + 11, *_cur.file, _cur.nfo_line++); // SLOPE_NWS - LoadNextSprite(SPR_SHORE_BASE + 13, *_cur.file, _cur.nfo_line++); // SLOPE_ENW - LoadNextSprite(SPR_SHORE_BASE + 14, *_cur.file, _cur.nfo_line++); // SLOPE_SEN - LoadNextSprite(SPR_SHORE_BASE + 15, *_cur.file, _cur.nfo_line++); // SLOPE_STEEP_E - LoadNextSprite(SPR_SHORE_BASE + 16, *_cur.file, _cur.nfo_line++); // SLOPE_EW - LoadNextSprite(SPR_SHORE_BASE + 17, *_cur.file, _cur.nfo_line++); // SLOPE_NS + LoadNextSprite(SPR_SHORE_BASE + 0, *_cur_gps.file, _cur_gps.nfo_line++); // SLOPE_STEEP_S + LoadNextSprite(SPR_SHORE_BASE + 5, *_cur_gps.file, _cur_gps.nfo_line++); // SLOPE_STEEP_W + LoadNextSprite(SPR_SHORE_BASE + 7, *_cur_gps.file, _cur_gps.nfo_line++); // SLOPE_WSE + LoadNextSprite(SPR_SHORE_BASE + 10, *_cur_gps.file, _cur_gps.nfo_line++); // SLOPE_STEEP_N + LoadNextSprite(SPR_SHORE_BASE + 11, *_cur_gps.file, _cur_gps.nfo_line++); // SLOPE_NWS + LoadNextSprite(SPR_SHORE_BASE + 13, *_cur_gps.file, _cur_gps.nfo_line++); // SLOPE_ENW + LoadNextSprite(SPR_SHORE_BASE + 14, *_cur_gps.file, _cur_gps.nfo_line++); // SLOPE_SEN + LoadNextSprite(SPR_SHORE_BASE + 15, *_cur_gps.file, _cur_gps.nfo_line++); // SLOPE_STEEP_E + LoadNextSprite(SPR_SHORE_BASE + 16, *_cur_gps.file, _cur_gps.nfo_line++); // SLOPE_EW + LoadNextSprite(SPR_SHORE_BASE + 17, *_cur_gps.file, _cur_gps.nfo_line++); // SLOPE_NS if (_loaded_newgrf_features.shore == SHORE_REPLACE_NONE) _loaded_newgrf_features.shore = SHORE_REPLACE_ONLY_NEW; return; } @@ -124,7 +124,7 @@ static void GraphicsNew(ByteReader &buf) /* Supported type? */ if ((type >= std::size(_action5_types)) || (_action5_types[type].block_type == A5BLOCK_INVALID)) { GrfMsg(2, "GraphicsNew: Custom graphics (type 0x{:02X}) sprite block of length {} (unimplemented, ignoring)", type, num); - _cur.skip_sprites = num; + _cur_gps.skip_sprites = num; return; } @@ -142,7 +142,7 @@ static void GraphicsNew(ByteReader &buf) * This does not make sense, if is allowed */ if ((action5_type->block_type == A5BLOCK_FIXED) && (num < action5_type->min_sprites)) { GrfMsg(1, "GraphicsNew: {} (type 0x{:02X}) count must be at least {}. Only {} were specified. Skipping.", action5_type->name, type, action5_type->min_sprites, num); - _cur.skip_sprites = num; + _cur_gps.skip_sprites = num; return; } @@ -166,16 +166,16 @@ static void GraphicsNew(ByteReader &buf) bool dup_oneway_sprites = ((type == 0x09) && (offset + num <= ONEWAY_SLOPE_N_OFFSET)); for (; num > 0; num--) { - _cur.nfo_line++; - SpriteID load_index = (replace == 0 ? _cur.spriteid++ : replace++); - LoadNextSprite(load_index, *_cur.file, _cur.nfo_line); + _cur_gps.nfo_line++; + SpriteID load_index = (replace == 0 ? _cur_gps.spriteid++ : replace++); + LoadNextSprite(load_index, *_cur_gps.file, _cur_gps.nfo_line); if (dup_oneway_sprites) { DupSprite(load_index, load_index + ONEWAY_SLOPE_N_OFFSET); DupSprite(load_index, load_index + ONEWAY_SLOPE_S_OFFSET); } } - _cur.skip_sprites = skip_num; + _cur_gps.skip_sprites = skip_num; } /* Action 0x05 (SKIP) */ @@ -185,9 +185,9 @@ static void SkipAct5(ByteReader &buf) buf.ReadByte(); /* Skip the sprites of this action */ - _cur.skip_sprites = buf.ReadExtendedByte(); + _cur_gps.skip_sprites = buf.ReadExtendedByte(); - GrfMsg(3, "SkipAct5: Skipping {} sprites", _cur.skip_sprites); + GrfMsg(3, "SkipAct5: Skipping {} sprites", _cur_gps.skip_sprites); } template <> void GrfActionHandler<0x05>::FileScan(ByteReader &buf) { SkipAct5(buf); } diff --git a/src/newgrf/newgrf_act6.cpp b/src/newgrf/newgrf_act6.cpp index 34390adc95..a30dcb2092 100644 --- a/src/newgrf/newgrf_act6.cpp +++ b/src/newgrf/newgrf_act6.cpp @@ -32,7 +32,7 @@ static void CfgApply(ByteReader &buf) * to place where parameter is to be stored. */ /* Preload the next sprite */ - SpriteFile &file = *_cur.file; + SpriteFile &file = *_cur_gps.file; size_t pos = file.GetPos(); uint32_t num = file.GetContainerVersion() >= 2 ? file.ReadDword() : file.ReadWord(); uint8_t type = file.ReadByte(); @@ -47,7 +47,7 @@ static void CfgApply(ByteReader &buf) } /* Get (or create) the override for the next sprite. */ - GRFLocation location(_cur.grfconfig->ident.grfid, _cur.nfo_line + 1); + GRFLocation location(_cur_gps.grfconfig->ident.grfid, _cur_gps.nfo_line + 1); std::vector &preload_sprite = _grf_line_to_action6_sprite_override[location]; /* Load new sprite data if it hasn't already been loaded. */ @@ -85,7 +85,7 @@ static void CfgApply(ByteReader &buf) /* If the parameter is a GRF parameter (not an internal variable) check * if it (and all further sequential parameters) has been defined. */ - if (param_num < 0x80 && (param_num + (param_size - 1) / 4) >= std::size(_cur.grffile->param)) { + if (param_num < 0x80 && (param_num + (param_size - 1) / 4) >= std::size(_cur_gps.grffile->param)) { GrfMsg(2, "CfgApply: Ignoring (param {} not set)", (param_num + (param_size - 1) / 4)); break; } diff --git a/src/newgrf/newgrf_act7_9.cpp b/src/newgrf/newgrf_act7_9.cpp index bb36fc0781..4d08d2e67e 100644 --- a/src/newgrf/newgrf_act7_9.cpp +++ b/src/newgrf/newgrf_act7_9.cpp @@ -117,7 +117,7 @@ uint32_t GetParamVal(uint8_t param, uint32_t *cond_val) { /* First handle variable common with VarAction2 */ uint32_t value; - if (GetGlobalVariable(param - 0x80, &value, _cur.grffile)) return value; + if (GetGlobalVariable(param - 0x80, &value, _cur_gps.grffile)) return value; /* Non-common variable */ @@ -125,9 +125,9 @@ uint32_t GetParamVal(uint8_t param, uint32_t *cond_val) case 0x84: { // GRF loading stage uint32_t res = 0; - if (_cur.stage > GLS_INIT) SetBit(res, 0); - if (_cur.stage == GLS_RESERVE) SetBit(res, 8); - if (_cur.stage == GLS_ACTIVATION) SetBit(res, 9); + if (_cur_gps.stage > GLS_INIT) SetBit(res, 0); + if (_cur_gps.stage == GLS_RESERVE) SetBit(res, 8); + if (_cur_gps.stage == GLS_ACTIVATION) SetBit(res, 9); return res; } @@ -149,7 +149,7 @@ uint32_t GetParamVal(uint8_t param, uint32_t *cond_val) default: /* GRF Parameter */ - if (param < 0x80) return _cur.grffile->GetParam(param); + if (param < 0x80) return _cur_gps.grffile->GetParam(param); /* In-game variable. */ GrfMsg(1, "Unsupported in-game variable 0x{:02X}", param); @@ -189,7 +189,7 @@ static void SkipIf(ByteReader &buf) default: break; } - if (param < 0x80 && std::size(_cur.grffile->param) <= param) { + if (param < 0x80 && std::size(_cur_gps.grffile->param) <= param) { GrfMsg(7, "SkipIf: Param {} undefined, skipping test", param); return; } @@ -237,7 +237,7 @@ static void SkipIf(ByteReader &buf) GRFConfig *c = GetGRFConfig(cond_val, mask); - if (c != nullptr && c->flags.Test(GRFConfigFlag::Static) && !_cur.grfconfig->flags.Test(GRFConfigFlag::Static) && _networking) { + if (c != nullptr && c->flags.Test(GRFConfigFlag::Static) && !_cur_gps.grfconfig->flags.Test(GRFConfigFlag::Static) && _networking) { DisableStaticNewGRFInfluencingNonStaticNewGRFs(*c); c = nullptr; } @@ -304,13 +304,13 @@ static void SkipIf(ByteReader &buf) * the current nfo_line. If no matching label is found, the first matching * label in the file is used. */ const GRFLabel *choice = nullptr; - for (const auto &label : _cur.grffile->labels) { + for (const auto &label : _cur_gps.grffile->labels) { if (label.label != numsprites) continue; /* Remember a goto before the current line */ if (choice == nullptr) choice = &label; /* If we find a label here, this is definitely good */ - if (label.nfo_line > _cur.nfo_line) { + if (label.nfo_line > _cur_gps.nfo_line) { choice = &label; break; } @@ -318,21 +318,21 @@ static void SkipIf(ByteReader &buf) if (choice != nullptr) { GrfMsg(2, "SkipIf: Jumping to label 0x{:X} at line {}, test was true", choice->label, choice->nfo_line); - _cur.file->SeekTo(choice->pos, SEEK_SET); - _cur.nfo_line = choice->nfo_line; + _cur_gps.file->SeekTo(choice->pos, SEEK_SET); + _cur_gps.nfo_line = choice->nfo_line; return; } GrfMsg(2, "SkipIf: Skipping {} sprites, test was true", numsprites); - _cur.skip_sprites = numsprites; - if (_cur.skip_sprites == 0) { + _cur_gps.skip_sprites = numsprites; + if (_cur_gps.skip_sprites == 0) { /* Zero means there are no sprites to skip, so * we use -1 to indicate that all further * sprites should be skipped. */ - _cur.skip_sprites = -1; + _cur_gps.skip_sprites = -1; /* If an action 8 hasn't been encountered yet, disable the grf. */ - if (_cur.grfconfig->status != (_cur.stage < GLS_RESERVE ? GCS_INITIALISED : GCS_ACTIVATED)) { + if (_cur_gps.grfconfig->status != (_cur_gps.stage < GLS_RESERVE ? GCS_INITIALISED : GCS_ACTIVATED)) { DisableGrf(); } } diff --git a/src/newgrf/newgrf_act8.cpp b/src/newgrf/newgrf_act8.cpp index d71365070a..9466efcedb 100644 --- a/src/newgrf/newgrf_act8.cpp +++ b/src/newgrf/newgrf_act8.cpp @@ -24,25 +24,25 @@ static void ScanInfo(ByteReader &buf) uint32_t grfid = buf.ReadDWord(); std::string_view name = buf.ReadString(); - _cur.grfconfig->ident.grfid = grfid; + _cur_gps.grfconfig->ident.grfid = grfid; if (grf_version < 2 || grf_version > 8) { - _cur.grfconfig->flags.Set(GRFConfigFlag::Invalid); - Debug(grf, 0, "{}: NewGRF \"{}\" (GRFID {:08X}) uses GRF version {}, which is incompatible with this version of OpenTTD.", _cur.grfconfig->filename, StrMakeValid(name), std::byteswap(grfid), grf_version); + _cur_gps.grfconfig->flags.Set(GRFConfigFlag::Invalid); + Debug(grf, 0, "{}: NewGRF \"{}\" (GRFID {:08X}) uses GRF version {}, which is incompatible with this version of OpenTTD.", _cur_gps.grfconfig->filename, StrMakeValid(name), std::byteswap(grfid), grf_version); } /* GRF IDs starting with 0xFF are reserved for internal TTDPatch use */ - if (GB(grfid, 0, 8) == 0xFF) _cur.grfconfig->flags.Set(GRFConfigFlag::System); + if (GB(grfid, 0, 8) == 0xFF) _cur_gps.grfconfig->flags.Set(GRFConfigFlag::System); - AddGRFTextToList(_cur.grfconfig->name, 0x7F, grfid, false, name); + AddGRFTextToList(_cur_gps.grfconfig->name, 0x7F, grfid, false, name); if (buf.HasData()) { std::string_view info = buf.ReadString(); - AddGRFTextToList(_cur.grfconfig->info, 0x7F, grfid, true, info); + AddGRFTextToList(_cur_gps.grfconfig->info, 0x7F, grfid, true, info); } /* GLS_INFOSCAN only looks for the action 8, so we can skip the rest of the file */ - _cur.skip_sprites = -1; + _cur_gps.skip_sprites = -1; } /* Action 0x08 */ @@ -59,21 +59,21 @@ static void GRFInfo(ByteReader &buf) uint32_t grfid = buf.ReadDWord(); std::string_view name = buf.ReadString(); - if (_cur.stage < GLS_RESERVE && _cur.grfconfig->status != GCS_UNKNOWN) { + if (_cur_gps.stage < GLS_RESERVE && _cur_gps.grfconfig->status != GCS_UNKNOWN) { DisableGrf(STR_NEWGRF_ERROR_MULTIPLE_ACTION_8); return; } - if (_cur.grffile->grfid != grfid) { - Debug(grf, 0, "GRFInfo: GRFID {:08X} in FILESCAN stage does not match GRFID {:08X} in INIT/RESERVE/ACTIVATION stage", std::byteswap(_cur.grffile->grfid), std::byteswap(grfid)); - _cur.grffile->grfid = grfid; + if (_cur_gps.grffile->grfid != grfid) { + Debug(grf, 0, "GRFInfo: GRFID {:08X} in FILESCAN stage does not match GRFID {:08X} in INIT/RESERVE/ACTIVATION stage", std::byteswap(_cur_gps.grffile->grfid), std::byteswap(grfid)); + _cur_gps.grffile->grfid = grfid; } - _cur.grffile->grf_version = version; - _cur.grfconfig->status = _cur.stage < GLS_RESERVE ? GCS_INITIALISED : GCS_ACTIVATED; + _cur_gps.grffile->grf_version = version; + _cur_gps.grfconfig->status = _cur_gps.stage < GLS_RESERVE ? GCS_INITIALISED : GCS_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.grfconfig->palette & GRFP_USE_MASK) ? "Windows" : "DOS", _cur.grfconfig->version); + 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); } template <> void GrfActionHandler<0x08>::FileScan(ByteReader &buf) { ScanInfo(buf); } diff --git a/src/newgrf/newgrf_acta.cpp b/src/newgrf/newgrf_acta.cpp index b66bd35837..ba4e509bc4 100644 --- a/src/newgrf/newgrf_acta.cpp +++ b/src/newgrf/newgrf_acta.cpp @@ -26,7 +26,7 @@ static bool IsGRMReservedSprite(SpriteID first_sprite, uint16_t num_sprites) { for (const auto &grm_sprite : _grm_sprites) { - if (grm_sprite.first.grfid != _cur.grffile->grfid) continue; + if (grm_sprite.first.grfid != _cur_gps.grffile->grfid) continue; if (grm_sprite.second.first <= first_sprite && grm_sprite.second.first + grm_sprite.second.second >= first_sprite + num_sprites) return true; } return false; @@ -60,15 +60,15 @@ static void SpriteReplace(ByteReader &buf) i, num_sprites, first_sprite, SPR_OPENTTD_BASE); /* Load the sprites at the current location so they will do nothing instead of appearing to work. */ - first_sprite = _cur.spriteid; - _cur.spriteid += num_sprites; + first_sprite = _cur_gps.spriteid; + _cur_gps.spriteid += num_sprites; } } for (uint j = 0; j < num_sprites; j++) { SpriteID load_index = first_sprite + j; - _cur.nfo_line++; - LoadNextSprite(load_index, *_cur.file, _cur.nfo_line); // XXX + _cur_gps.nfo_line++; + LoadNextSprite(load_index, *_cur_gps.file, _cur_gps.nfo_line); // XXX /* Shore sprites now located at different addresses. * So detect when the old ones get replaced. */ @@ -86,12 +86,12 @@ static void SkipActA(ByteReader &buf) for (uint i = 0; i < num_sets; i++) { /* Skip the sprites this replaces */ - _cur.skip_sprites += buf.ReadByte(); + _cur_gps.skip_sprites += buf.ReadByte(); /* But ignore where they go */ buf.ReadWord(); } - GrfMsg(3, "SkipActA: Skipping {} sprites", _cur.skip_sprites); + GrfMsg(3, "SkipActA: Skipping {} sprites", _cur_gps.skip_sprites); } template <> void GrfActionHandler<0x0A>::FileScan(ByteReader &buf) { SkipActA(buf); } diff --git a/src/newgrf/newgrf_actb.cpp b/src/newgrf/newgrf_actb.cpp index a462bbf0c2..53aed45267 100644 --- a/src/newgrf/newgrf_actb.cpp +++ b/src/newgrf/newgrf_actb.cpp @@ -56,12 +56,12 @@ static void GRFLoadError(ByteReader &buf) uint8_t message_id = buf.ReadByte(); /* Skip the error if it isn't valid for the current language. */ - if (!CheckGrfLangID(lang, _cur.grffile->grf_version)) return; + if (!CheckGrfLangID(lang, _cur_gps.grffile->grf_version)) return; /* Skip the error until the activation stage unless bit 7 of the severity * is set. */ - if (!HasBit(severity, 7) && _cur.stage == GLS_INIT) { - GrfMsg(7, "GRFLoadError: Skipping non-fatal GRFLoadError in stage {}", _cur.stage); + if (!HasBit(severity, 7) && _cur_gps.stage == GLS_INIT) { + GrfMsg(7, "GRFLoadError: Skipping non-fatal GRFLoadError in stage {}", _cur_gps.stage); return; } ClrBit(severity, 7); @@ -75,7 +75,7 @@ static void GRFLoadError(ByteReader &buf) DisableGrf(); /* Make sure we show fatal errors, instead of silly infos from before */ - _cur.grfconfig->error.reset(); + _cur_gps.grfconfig->error.reset(); } if (message_id >= lengthof(msgstr) && message_id != 0xFF) { @@ -89,17 +89,17 @@ static void GRFLoadError(ByteReader &buf) } /* For now we can only show one message per newgrf file. */ - if (_cur.grfconfig->error.has_value()) return; + if (_cur_gps.grfconfig->error.has_value()) return; - _cur.grfconfig->error = {sevstr[severity]}; - GRFError *error = &_cur.grfconfig->error.value(); + _cur_gps.grfconfig->error = {sevstr[severity]}; + GRFError *error = &_cur_gps.grfconfig->error.value(); if (message_id == 0xFF) { /* This is a custom error message. */ if (buf.HasData()) { std::string_view message = buf.ReadString(); - error->custom_message = TranslateTTDPatchCodes(_cur.grffile->grfid, lang, true, message, SCC_RAW_STRING_POINTER); + error->custom_message = TranslateTTDPatchCodes(_cur_gps.grffile->grfid, lang, true, message, SCC_RAW_STRING_POINTER); } else { GrfMsg(7, "GRFLoadError: No custom message supplied."); error->custom_message.clear(); @@ -111,7 +111,7 @@ static void GRFLoadError(ByteReader &buf) if (buf.HasData()) { std::string_view data = buf.ReadString(); - error->data = TranslateTTDPatchCodes(_cur.grffile->grfid, lang, true, data); + error->data = TranslateTTDPatchCodes(_cur_gps.grffile->grfid, lang, true, data); } else { GrfMsg(7, "GRFLoadError: No message data supplied."); error->data.clear(); @@ -120,7 +120,7 @@ static void GRFLoadError(ByteReader &buf) /* Only two parameter numbers can be used in the string. */ for (uint i = 0; i < error->param_value.size() && buf.HasData(); i++) { uint param_number = buf.ReadByte(); - error->param_value[i] = _cur.grffile->GetParam(param_number); + error->param_value[i] = _cur_gps.grffile->GetParam(param_number); } } diff --git a/src/newgrf/newgrf_actd.cpp b/src/newgrf/newgrf_actd.cpp index 62bfa546e3..8425f82eb9 100644 --- a/src/newgrf/newgrf_actd.cpp +++ b/src/newgrf/newgrf_actd.cpp @@ -139,11 +139,11 @@ static uint32_t PerformGRM(std::span grm, uint16_t count, uint8_t op, if (op == 6) { /* Return GRFID of set that reserved ID */ - return grm[_cur.grffile->GetParam(target)]; + return grm[_cur_gps.grffile->GetParam(target)]; } /* With an operation of 2 or 3, we want to reserve a specific block of IDs */ - if (op == 2 || op == 3) start = _cur.grffile->GetParam(target); + if (op == 2 || op == 3) start = _cur_gps.grffile->GetParam(target); for (uint i = start; i < std::size(grm); i++) { if (grm[i] == 0) { @@ -161,7 +161,7 @@ static uint32_t PerformGRM(std::span grm, uint16_t count, uint8_t op, /* Got the slot... */ if (op == 0 || op == 3) { GrfMsg(2, "ParamSet: GRM: Reserving {} {} at {}", count, type, start); - for (uint i = 0; i < count; i++) grm[start + i] = _cur.grffile->grfid; + for (uint i = 0; i < count; i++) grm[start + i] = _cur_gps.grffile->grfid; } return start; } @@ -218,7 +218,7 @@ static void ParamSet(ByteReader &buf) * - it OR A PARAMETER WITH HIGHER NUMBER has been set to any value by * an earlier action D */ if (HasBit(oper, 7)) { - if (target < 0x80 && target < std::size(_cur.grffile->param)) { + if (target < 0x80 && target < std::size(_cur_gps.grffile->param)) { GrfMsg(7, "ParamSet: Param {} already defined, skipping", target); return; } @@ -237,26 +237,26 @@ static void ParamSet(ByteReader &buf) uint8_t feature = GB(data, 8, 8); uint16_t count = GB(data, 16, 16); - if (_cur.stage == GLS_RESERVE) { + if (_cur_gps.stage == GLS_RESERVE) { if (feature == 0x08) { /* General sprites */ if (op == 0) { /* Check if the allocated sprites will fit below the original sprite limit */ - if (_cur.spriteid + count >= 16384) { + if (_cur_gps.spriteid + count >= 16384) { GrfMsg(0, "ParamSet: GRM: Unable to allocate {} sprites; try changing NewGRF order", count); DisableGrf(STR_NEWGRF_ERROR_GRM_FAILED); return; } /* Reserve space at the current sprite ID */ - GrfMsg(4, "ParamSet: GRM: Allocated {} sprites at {}", count, _cur.spriteid); - _grm_sprites[GRFLocation(_cur.grffile->grfid, _cur.nfo_line)] = std::make_pair(_cur.spriteid, count); - _cur.spriteid += count; + GrfMsg(4, "ParamSet: GRM: Allocated {} sprites at {}", count, _cur_gps.spriteid); + _grm_sprites[GRFLocation(_cur_gps.grffile->grfid, _cur_gps.nfo_line)] = std::make_pair(_cur_gps.spriteid, count); + _cur_gps.spriteid += count; } } /* Ignore GRM result during reservation */ src1 = 0; - } else if (_cur.stage == GLS_ACTIVATION) { + } else if (_cur_gps.stage == GLS_ACTIVATION) { switch (feature) { case 0x00: // Trains case 0x01: // Road Vehicles @@ -264,13 +264,13 @@ static void ParamSet(ByteReader &buf) case 0x03: // Aircraft if (!_settings_game.vehicle.dynamic_engines) { src1 = PerformGRM({std::begin(_grm_engines) + _engine_offsets[feature], _engine_counts[feature]}, count, op, target, "vehicles"); - if (_cur.skip_sprites == -1) return; + if (_cur_gps.skip_sprites == -1) return; } else { /* GRM does not apply for dynamic engine allocation. */ switch (op) { case 2: case 3: - src1 = _cur.grffile->GetParam(target); + src1 = _cur_gps.grffile->GetParam(target); break; default: @@ -284,12 +284,12 @@ static void ParamSet(ByteReader &buf) switch (op) { case 0: /* Return space reserved during reservation stage */ - src1 = _grm_sprites[GRFLocation(_cur.grffile->grfid, _cur.nfo_line)].first; + src1 = _grm_sprites[GRFLocation(_cur_gps.grffile->grfid, _cur_gps.nfo_line)].first; GrfMsg(4, "ParamSet: GRM: Using pre-allocated sprites at {}", src1); break; case 1: - src1 = _cur.spriteid; + src1 = _cur_gps.spriteid; break; default: @@ -301,7 +301,7 @@ static void ParamSet(ByteReader &buf) case 0x0B: // Cargo /* There are two ranges: one for cargo IDs and one for cargo bitmasks */ src1 = PerformGRM(_grm_cargoes, count, op, target, "cargoes"); - if (_cur.skip_sprites == -1) return; + if (_cur_gps.skip_sprites == -1) return; break; default: GrfMsg(1, "ParamSet: GRM: Unsupported feature 0x{:X}", feature); return; @@ -315,7 +315,7 @@ static void ParamSet(ByteReader &buf) /* Read another GRF File's parameter */ const GRFFile *file = GetFileByGRFID(data); GRFConfig *c = GetGRFConfig(data); - if (c != nullptr && c->flags.Test(GRFConfigFlag::Static) && !_cur.grfconfig->flags.Test(GRFConfigFlag::Static) && _networking) { + if (c != nullptr && c->flags.Test(GRFConfigFlag::Static) && !_cur_gps.grfconfig->flags.Test(GRFConfigFlag::Static) && _networking) { /* Disable the read GRF if it is a static NewGRF. */ DisableStaticNewGRFInfluencingNonStaticNewGRFs(*c); src1 = 0; @@ -420,7 +420,7 @@ static void ParamSet(ByteReader &buf) switch (target) { case 0x8E: // Y-Offset for train sprites - _cur.grffile->traininfo_vehicle_pitch = res; + _cur_gps.grffile->traininfo_vehicle_pitch = res; break; case 0x8F: { // Rail track type cost factors @@ -451,12 +451,12 @@ static void ParamSet(ByteReader &buf) GrfMiscBits bits(res); /* Set train list engine width */ - _cur.grffile->traininfo_vehicle_width = bits.Test(GrfMiscBit::TrainWidth32Pixels) ? VEHICLEINFO_FULL_VEHICLE_WIDTH : TRAININFO_DEFAULT_VEHICLE_WIDTH; + _cur_gps.grffile->traininfo_vehicle_width = bits.Test(GrfMiscBit::TrainWidth32Pixels) ? VEHICLEINFO_FULL_VEHICLE_WIDTH : TRAININFO_DEFAULT_VEHICLE_WIDTH; /* Remove the local flags from the global flags */ bits.Reset(GrfMiscBit::TrainWidth32Pixels); /* Only copy safe bits for static grfs */ - if (_cur.grfconfig->flags.Test(GRFConfigFlag::Static)) { + if (_cur_gps.grfconfig->flags.Test(GRFConfigFlag::Static)) { GrfMiscBits safe_bits = GrfMiscBit::SecondRockyTileSet; _misc_grf_features.Reset(safe_bits); @@ -474,8 +474,8 @@ static void ParamSet(ByteReader &buf) default: if (target < 0x80) { /* Resize (and fill with zeroes) if needed. */ - if (target >= std::size(_cur.grffile->param)) _cur.grffile->param.resize(target + 1); - _cur.grffile->param[target] = res; + if (target >= std::size(_cur_gps.grffile->param)) _cur_gps.grffile->param.resize(target + 1); + _cur_gps.grffile->param[target] = res; } else { GrfMsg(7, "ParamSet: Skipping unknown target 0x{:02X}", target); } diff --git a/src/newgrf/newgrf_acte.cpp b/src/newgrf/newgrf_acte.cpp index 6270fe4559..fdd923ce7b 100644 --- a/src/newgrf/newgrf_acte.cpp +++ b/src/newgrf/newgrf_acte.cpp @@ -30,7 +30,7 @@ static void SafeGRFInhibit(ByteReader &buf) uint32_t grfid = buf.ReadDWord(); /* GRF is unsafe it if tries to deactivate other GRFs */ - if (grfid != _cur.grfconfig->ident.grfid) { + if (grfid != _cur_gps.grfconfig->ident.grfid) { GRFUnsafe(buf); return; } @@ -52,10 +52,10 @@ static void GRFInhibit(ByteReader &buf) GRFConfig *file = GetGRFConfig(grfid); /* Unset activation flag */ - if (file != nullptr && file != _cur.grfconfig) { + if (file != nullptr && file != _cur_gps.grfconfig) { GrfMsg(2, "GRFInhibit: Deactivating file '{}'", file->filename); GRFError *error = DisableGrf(STR_NEWGRF_ERROR_FORCEFULLY_DISABLED, file); - error->data = _cur.grfconfig->GetName(); + error->data = _cur_gps.grfconfig->GetName(); } } } diff --git a/src/newgrf/newgrf_actf.cpp b/src/newgrf/newgrf_actf.cpp index 82503b4fd5..473ab023c6 100644 --- a/src/newgrf/newgrf_actf.cpp +++ b/src/newgrf/newgrf_actf.cpp @@ -27,7 +27,7 @@ static void FeatureTownName(ByteReader &buf) * B num-parts Number of parts in this definition * V parts The parts */ - uint32_t grfid = _cur.grffile->grfid; + uint32_t grfid = _cur_gps.grffile->grfid; GRFTownName *townname = AddGRFTownName(grfid); @@ -37,7 +37,7 @@ static void FeatureTownName(ByteReader &buf) if (HasBit(id, 7)) { /* Final definition */ ClrBit(id, 7); - bool new_scheme = _cur.grffile->grf_version >= 7; + bool new_scheme = _cur_gps.grffile->grf_version >= 7; uint8_t lang = buf.ReadByte(); StringID style = STR_UNDEFINED; diff --git a/src/newgrf/newgrf_internal.h b/src/newgrf/newgrf_internal.h index 642535198a..7f179b0c36 100644 --- a/src/newgrf/newgrf_internal.h +++ b/src/newgrf/newgrf_internal.h @@ -155,7 +155,7 @@ public: } }; -extern GrfProcessingState _cur; +extern GrfProcessingState _cur_gps; struct GRFLocation { uint32_t grfid; diff --git a/src/newgrf/newgrf_stringmapping.cpp b/src/newgrf/newgrf_stringmapping.cpp index 2063325d86..8441689488 100644 --- a/src/newgrf/newgrf_stringmapping.cpp +++ b/src/newgrf/newgrf_stringmapping.cpp @@ -42,7 +42,7 @@ static std::vector _string_to_grf_mapping; void AddStringForMapping(GRFStringID source, std::function &&func) { func(STR_UNDEFINED); - _string_to_grf_mapping.emplace_back(_cur.grffile->grfid, source, std::move(func)); + _string_to_grf_mapping.emplace_back(_cur_gps.grffile->grfid, source, std::move(func)); } /**