diff --git a/src/base_station_base.h b/src/base_station_base.h index f2e2e58843..0c0ad22770 100644 --- a/src/base_station_base.h +++ b/src/base_station_base.h @@ -113,7 +113,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> { * @param available will return false if ever the variable asked for does not exist * @return the value stored in the corresponding variable */ - virtual uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint8_t variable, uint8_t parameter, bool *available) const = 0; + virtual uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint8_t variable, uint8_t parameter, bool &available) const = 0; /** * Update the coordinated of the sign (as shown in the viewport). diff --git a/src/newgrf_airport.cpp b/src/newgrf_airport.cpp index dca77bb3c7..1471f417e2 100644 --- a/src/newgrf_airport.cpp +++ b/src/newgrf_airport.cpp @@ -154,14 +154,14 @@ void AirportOverrideManager::SetEntitySpec(AirportSpec *as) } } -/* virtual */ uint32_t AirportScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const +/* virtual */ uint32_t AirportScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const { switch (variable) { case 0x40: return this->layout; } if (this->st == nullptr) { - *available = false; + available = false; return UINT_MAX; } diff --git a/src/newgrf_airport.h b/src/newgrf_airport.h index 21ca905e37..5ac58bc72d 100644 --- a/src/newgrf_airport.h +++ b/src/newgrf_airport.h @@ -167,7 +167,7 @@ struct AirportScopeResolver : public ScopeResolver { } uint32_t GetRandomBits() const override; - uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const override; + uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override; void StorePSA(uint pos, int32_t value) override; }; diff --git a/src/newgrf_airporttiles.cpp b/src/newgrf_airporttiles.cpp index d2a34fb28d..a4adf748a8 100644 --- a/src/newgrf_airporttiles.cpp +++ b/src/newgrf_airporttiles.cpp @@ -159,7 +159,7 @@ static uint32_t GetAirportTileIDAtOffset(TileIndex tile, const Station *st, uint return 0xFF << 8 | ats->grf_prop.subst_id; // so just give it the substitute } -/* virtual */ uint32_t AirportTileScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const +/* virtual */ uint32_t AirportTileScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const { assert(this->st != nullptr); @@ -194,7 +194,7 @@ static uint32_t GetAirportTileIDAtOffset(TileIndex tile, const Station *st, uint Debug(grf, 1, "Unhandled airport tile variable 0x{:X}", variable); - *available = false; + available = false; return UINT_MAX; } diff --git a/src/newgrf_airporttiles.h b/src/newgrf_airporttiles.h index 53f10bab44..34b3669128 100644 --- a/src/newgrf_airporttiles.h +++ b/src/newgrf_airporttiles.h @@ -38,7 +38,7 @@ struct AirportTileScopeResolver : public ScopeResolver { } uint32_t GetRandomBits() const override; - uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const override; + uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override; }; /** Resolver for tiles of an airport. */ diff --git a/src/newgrf_canal.cpp b/src/newgrf_canal.cpp index 4425ee00ff..b3e725b0d7 100644 --- a/src/newgrf_canal.cpp +++ b/src/newgrf_canal.cpp @@ -30,7 +30,7 @@ struct CanalScopeResolver : public ScopeResolver { } uint32_t GetRandomBits() const override; - uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const override; + uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override; }; /** Resolver object for canals. */ @@ -59,7 +59,7 @@ struct CanalResolverObject : public ResolverObject { return IsTileType(this->tile, MP_WATER) ? GetWaterTileRandomBits(this->tile) : 0; } -/* virtual */ uint32_t CanalScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const +/* virtual */ uint32_t CanalScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const { switch (variable) { /* Height of tile */ @@ -102,7 +102,7 @@ struct CanalResolverObject : public ResolverObject { Debug(grf, 1, "Unhandled canal variable 0x{:02X}", variable); - *available = false; + available = false; return UINT_MAX; } diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index e19ccba54b..18ce097972 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -169,7 +169,7 @@ public: * @param avail Return whether the variable is available. * @return The resolved variable's value. */ - virtual uint Resolve(uint index, uint var, uint param, bool *avail) const = 0; + virtual uint Resolve(uint index, uint var, uint param, bool &avail) const = 0; /** * Used to decide if the PSA needs a parameter or not. @@ -449,7 +449,7 @@ struct NewGRFInspectWindow : Window { for (const NIVariable *niv = nif->variables; niv->name != nullptr; niv++) { bool avail = true; uint param = HasVariableParameter(niv->var) ? NewGRFInspectWindow::var60params[GetFeatureNum(this->window_number)][niv->var - 0x60] : 0; - uint value = nih->Resolve(index, niv->var, param, &avail); + uint value = nih->Resolve(index, niv->var, param, avail); if (!avail) continue; diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index 4a5abcdce0..b5659581bd 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -412,7 +412,7 @@ static uint32_t PositionHelper(const Vehicle *v, bool consecutive) return chain_before | chain_after << 8 | (chain_before + chain_after + consecutive) << 16; } -static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, uint8_t variable, uint32_t parameter, bool *available) +static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, uint8_t variable, uint32_t parameter, bool &available) { /* Calculated vehicle parameters */ switch (variable) { @@ -935,11 +935,11 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec Debug(grf, 1, "Unhandled vehicle variable 0x{:X}, type 0x{:X}", variable, (uint)v->type); - *available = false; + available = false; return UINT_MAX; } -/* virtual */ uint32_t VehicleScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const +/* virtual */ uint32_t VehicleScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const { if (this->v == nullptr) { /* Vehicle does not exist, so we're in a purchase list */ @@ -968,7 +968,7 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec case 0xF2: return 0; // Cargo subtype } - *available = false; + available = false; return UINT_MAX; } @@ -1398,7 +1398,7 @@ void FillNewGRFVehicleCache(const Vehicle *v) /* Only resolve when the cache isn't valid. */ if (HasBit(v->grf_cache.cache_valid, cache_entry[1])) continue; bool stub; - ro.GetScope(VSG_SCOPE_SELF)->GetVariable(cache_entry[0], 0, &stub); + ro.GetScope(VSG_SCOPE_SELF)->GetVariable(cache_entry[0], 0, stub); } /* Make sure really all bits are set. */ diff --git a/src/newgrf_engine.h b/src/newgrf_engine.h index a2795a8d2c..88e8e41303 100644 --- a/src/newgrf_engine.h +++ b/src/newgrf_engine.h @@ -39,7 +39,7 @@ struct VehicleScopeResolver : public ScopeResolver { void SetVehicle(const Vehicle *v) { this->v = v; } uint32_t GetRandomBits() const override; - uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const override; + uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override; uint32_t GetTriggers() const override; }; diff --git a/src/newgrf_generic.cpp b/src/newgrf_generic.cpp index 30e3d840fe..f633715fa8 100644 --- a/src/newgrf_generic.cpp +++ b/src/newgrf_generic.cpp @@ -41,7 +41,7 @@ struct GenericScopeResolver : public ScopeResolver { { } - uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const override; + uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override; private: bool ai_callback; ///< Callback comes from the AI. @@ -118,7 +118,7 @@ void AddGenericCallback(uint8_t feature, const GRFFile *file, const SpriteGroup _gcl[feature].push_front(GenericCallback(file, group)); } -/* virtual */ uint32_t GenericScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const +/* virtual */ uint32_t GenericScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const { if (this->ai_callback) { switch (variable) { @@ -140,7 +140,7 @@ void AddGenericCallback(uint8_t feature, const GRFFile *file, const SpriteGroup Debug(grf, 1, "Unhandled generic feature variable 0x{:02X}", variable); - *available = false; + available = false; return UINT_MAX; } diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp index cd90684a53..5cc41c6049 100644 --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -370,7 +370,7 @@ static uint32_t GetDistanceFromNearbyHouse(uint8_t parameter, TileIndex tile, Ho /** * @note Used by the resolver to get values for feature 07 deterministic spritegroups. */ -/* virtual */ uint32_t HouseScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const +/* virtual */ uint32_t HouseScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const { if (this->tile == INVALID_TILE) { /* House does not yet exist, nor is it being planned to exist. Provide some default values intead. */ @@ -394,7 +394,7 @@ static uint32_t GetDistanceFromNearbyHouse(uint8_t parameter, TileIndex tile, Ho } Debug(grf, 1, "Unhandled house variable 0x{:X}", variable); - *available = false; + available = false; return UINT_MAX; } @@ -512,7 +512,7 @@ static uint32_t GetDistanceFromNearbyHouse(uint8_t parameter, TileIndex tile, Ho Debug(grf, 1, "Unhandled house variable 0x{:X}", variable); - *available = false; + available = false; return UINT_MAX; } diff --git a/src/newgrf_house.h b/src/newgrf_house.h index a56b5390e8..954417b7a7 100644 --- a/src/newgrf_house.h +++ b/src/newgrf_house.h @@ -44,7 +44,7 @@ struct HouseScopeResolver : public ScopeResolver { } uint32_t GetRandomBits() const override; - uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const override; + uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override; uint32_t GetTriggers() const override; }; diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 7ad754f8d5..bd8fe0084b 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -156,7 +156,7 @@ static uint32_t GetCountAndDistanceOfClosestInstance(uint8_t param_setID, uint8_ return count << 16 | GB(closest_dist, 0, 16); } -/* virtual */ uint32_t IndustriesScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const +/* virtual */ uint32_t IndustriesScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const { if (this->ro.callback == CBID_INDUSTRY_LOCATION) { /* Variables available during construction check. */ @@ -202,7 +202,7 @@ static uint32_t GetCountAndDistanceOfClosestInstance(uint8_t param_setID, uint8_ if (this->industry == nullptr) { Debug(grf, 1, "Unhandled variable 0x{:X} (no available industry) in callback 0x{:x}", variable, this->ro.callback); - *available = false; + available = false; return UINT_MAX; } @@ -411,7 +411,7 @@ static uint32_t GetCountAndDistanceOfClosestInstance(uint8_t param_setID, uint8_ Debug(grf, 1, "Unhandled industry variable 0x{:X}", variable); - *available = false; + available = false; return UINT_MAX; } diff --git a/src/newgrf_industries.h b/src/newgrf_industries.h index 827302ec5d..f4ac7dab0a 100644 --- a/src/newgrf_industries.h +++ b/src/newgrf_industries.h @@ -33,7 +33,7 @@ struct IndustriesScopeResolver : public ScopeResolver { } uint32_t GetRandomBits() const override; - uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const override; + uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override; uint32_t GetTriggers() const override; void StorePSA(uint pos, int32_t value) override; }; diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp index f4c6ce5aeb..bafd2a5731 100644 --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -58,7 +58,7 @@ uint32_t GetRelativePosition(TileIndex tile, TileIndex ind_tile) return ((y & 0xF) << 20) | ((x & 0xF) << 16) | (y << 8) | x; } -/* virtual */ uint32_t IndustryTileScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const +/* virtual */ uint32_t IndustryTileScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const { switch (variable) { /* Construction state of the tile: a value between 0 and 3 */ @@ -95,7 +95,7 @@ uint32_t GetRelativePosition(TileIndex tile, TileIndex ind_tile) Debug(grf, 1, "Unhandled industry tile variable 0x{:X}", variable); - *available = false; + available = false; return UINT_MAX; } diff --git a/src/newgrf_industrytiles.h b/src/newgrf_industrytiles.h index 538c0b7675..e9431edf00 100644 --- a/src/newgrf_industrytiles.h +++ b/src/newgrf_industrytiles.h @@ -31,7 +31,7 @@ struct IndustryTileScopeResolver : public ScopeResolver { } uint32_t GetRandomBits() const override; - uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const override; + uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override; uint32_t GetTriggers() const override; }; diff --git a/src/newgrf_object.cpp b/src/newgrf_object.cpp index 8491c98382..14046a469b 100644 --- a/src/newgrf_object.cpp +++ b/src/newgrf_object.cpp @@ -254,7 +254,7 @@ static uint32_t GetCountAndDistanceOfClosestInstance(uint8_t local_id, uint32_t } /** Used by the resolver to get values for feature 0F deterministic spritegroups. */ -/* virtual */ uint32_t ObjectScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const +/* virtual */ uint32_t ObjectScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const { /* We get the town from the object, or we calculate the closest * town if we need to when there's no object. */ @@ -361,7 +361,7 @@ static uint32_t GetCountAndDistanceOfClosestInstance(uint8_t local_id, uint32_t unhandled: Debug(grf, 1, "Unhandled object variable 0x{:X}", variable); - *available = false; + available = false; return UINT_MAX; } diff --git a/src/newgrf_object.h b/src/newgrf_object.h index 2308d100ed..799896f309 100644 --- a/src/newgrf_object.h +++ b/src/newgrf_object.h @@ -126,7 +126,7 @@ struct ObjectScopeResolver : public ScopeResolver { } uint32_t GetRandomBits() const override; - uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const override; + uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override; }; /** A resolver object to be used with feature 0F spritegroups. */ diff --git a/src/newgrf_railtype.cpp b/src/newgrf_railtype.cpp index 25f6ea6c19..f6ca99148d 100644 --- a/src/newgrf_railtype.cpp +++ b/src/newgrf_railtype.cpp @@ -23,7 +23,7 @@ return GB(tmp, 0, 2); } -/* virtual */ uint32_t RailTypeScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const +/* virtual */ uint32_t RailTypeScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const { if (this->tile == INVALID_TILE) { switch (variable) { @@ -55,7 +55,7 @@ Debug(grf, 1, "Unhandled rail type tile variable 0x{:X}", variable); - *available = false; + available = false; return UINT_MAX; } diff --git a/src/newgrf_railtype.h b/src/newgrf_railtype.h index 3995409e9f..ca48a40c8d 100644 --- a/src/newgrf_railtype.h +++ b/src/newgrf_railtype.h @@ -32,7 +32,7 @@ struct RailTypeScopeResolver : public ScopeResolver { } uint32_t GetRandomBits() const override; - uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const override; + uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override; }; /** Resolver object for rail types. */ diff --git a/src/newgrf_roadstop.cpp b/src/newgrf_roadstop.cpp index d8f6b196df..7e4e9be24a 100644 --- a/src/newgrf_roadstop.cpp +++ b/src/newgrf_roadstop.cpp @@ -64,7 +64,7 @@ uint32_t RoadStopScopeResolver::GetTriggers() const return this->st == nullptr ? 0 : this->st->waiting_triggers; } -uint32_t RoadStopScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const +uint32_t RoadStopScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const { auto get_road_type_variable = [&](RoadTramType rtt) -> uint32_t { RoadType rt; @@ -196,7 +196,7 @@ uint32_t RoadStopScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] u if (this->st != nullptr) return this->st->GetNewGRFVariable(this->ro, variable, parameter, available); - *available = false; + available = false; return UINT_MAX; } diff --git a/src/newgrf_roadstop.h b/src/newgrf_roadstop.h index 89111b5c62..e0b1a38ab6 100644 --- a/src/newgrf_roadstop.h +++ b/src/newgrf_roadstop.h @@ -92,7 +92,7 @@ struct RoadStopScopeResolver : public ScopeResolver { uint32_t GetRandomBits() const override; uint32_t GetTriggers() const override; - uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const override; + uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override; }; /** Road stop resolver. */ diff --git a/src/newgrf_roadtype.cpp b/src/newgrf_roadtype.cpp index eeae364e0b..11aaa8ffde 100644 --- a/src/newgrf_roadtype.cpp +++ b/src/newgrf_roadtype.cpp @@ -23,7 +23,7 @@ return GB(tmp, 0, 2); } -/* virtual */ uint32_t RoadTypeScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const +/* virtual */ uint32_t RoadTypeScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const { if (this->tile == INVALID_TILE) { switch (variable) { @@ -55,7 +55,7 @@ Debug(grf, 1, "Unhandled road type tile variable 0x{:X}", variable); - *available = false; + available = false; return UINT_MAX; } diff --git a/src/newgrf_roadtype.h b/src/newgrf_roadtype.h index 40d5166c56..9f0566837a 100644 --- a/src/newgrf_roadtype.h +++ b/src/newgrf_roadtype.h @@ -33,7 +33,7 @@ struct RoadTypeScopeResolver : public ScopeResolver { } uint32_t GetRandomBits() const override; - uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const override; + uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override; }; /** Resolver object for road types. */ diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp index 4dc4f72c45..95d10d6308 100644 --- a/src/newgrf_spritegroup.cpp +++ b/src/newgrf_spritegroup.cpp @@ -53,7 +53,7 @@ TemporaryStorageArray _temp_store; } } -static inline uint32_t GetVariable(const ResolverObject &object, ScopeResolver *scope, uint8_t variable, uint32_t parameter, bool *available) +static inline uint32_t GetVariable(const ResolverObject &object, ScopeResolver *scope, uint8_t variable, uint32_t parameter, bool &available) { uint32_t value; switch (variable) { @@ -103,10 +103,10 @@ static inline uint32_t GetVariable(const ResolverObject &object, ScopeResolver * * @param[out] available Set to false, in case the variable does not exist. * @return Value */ -/* virtual */ uint32_t ScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const +/* virtual */ uint32_t ScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const { Debug(grf, 1, "Unhandled scope variable 0x{:X}", variable); - *available = false; + available = false; return UINT_MAX; } @@ -205,9 +205,9 @@ const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject &object) con /* Note: 'last_value' and 'reseed' are shared between the main chain and the procedure */ } else if (adjust.variable == 0x7B) { - value = GetVariable(object, scope, adjust.parameter, last_value, &available); + value = GetVariable(object, scope, adjust.parameter, last_value, available); } else { - value = GetVariable(object, scope, adjust.variable, adjust.parameter, &available); + value = GetVariable(object, scope, adjust.variable, adjust.parameter, available); } if (!available) { diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h index 7ca6d01ec0..cda6f4b3a3 100644 --- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -294,7 +294,7 @@ struct ScopeResolver { virtual uint32_t GetRandomBits() const; virtual uint32_t GetTriggers() const; - virtual uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const; + virtual uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const; virtual void StorePSA(uint reg, int32_t value); }; diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index a53983e56c..af67fbf648 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -267,7 +267,7 @@ TownScopeResolver *StationResolverObject::GetTown() return &*this->town_scope; } -/* virtual */ uint32_t StationScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const +/* virtual */ uint32_t StationScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const { if (this->st == nullptr) { /* Station does not exist, so we're in a purchase list or the land slope check callback. */ @@ -295,7 +295,7 @@ TownScopeResolver *StationResolverObject::GetTown() case 0xFA: return ClampTo(TimerGameCalendar::date - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR); // Build date, clamped to a 16 bit value } - *available = false; + available = false; return UINT_MAX; } @@ -404,7 +404,7 @@ TownScopeResolver *StationResolverObject::GetTown() return this->st->GetNewGRFVariable(this->ro, variable, parameter, available); } -uint32_t Station::GetNewGRFVariable(const ResolverObject &object, uint8_t variable, uint8_t parameter, bool *available) const +uint32_t Station::GetNewGRFVariable(const ResolverObject &object, uint8_t variable, uint8_t parameter, bool &available) const { switch (variable) { case 0x48: { // Accepted cargo types @@ -466,11 +466,11 @@ uint32_t Station::GetNewGRFVariable(const ResolverObject &object, uint8_t variab Debug(grf, 1, "Unhandled station variable 0x{:X}", variable); - *available = false; + available = false; return UINT_MAX; } -uint32_t Waypoint::GetNewGRFVariable(const ResolverObject &, uint8_t variable, [[maybe_unused]] uint8_t parameter, bool *available) const +uint32_t Waypoint::GetNewGRFVariable(const ResolverObject &, uint8_t variable, [[maybe_unused]] uint8_t parameter, bool &available) const { switch (variable) { case 0x48: return 0; // Accepted cargo types @@ -498,7 +498,7 @@ uint32_t Waypoint::GetNewGRFVariable(const ResolverObject &, uint8_t variable, [ Debug(grf, 1, "Unhandled station variable 0x{:X}", variable); - *available = false; + available = false; return UINT_MAX; } diff --git a/src/newgrf_station.h b/src/newgrf_station.h index 225fd0fd51..5c244a270e 100644 --- a/src/newgrf_station.h +++ b/src/newgrf_station.h @@ -43,7 +43,7 @@ struct StationScopeResolver : public ScopeResolver { uint32_t GetRandomBits() const override; uint32_t GetTriggers() const override; - uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const override; + uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override; }; /** Station resolver. */ diff --git a/src/newgrf_town.cpp b/src/newgrf_town.cpp index fb4f2e1ae1..d144d56561 100644 --- a/src/newgrf_town.cpp +++ b/src/newgrf_town.cpp @@ -15,10 +15,10 @@ #include "safeguards.h" -/* virtual */ uint32_t TownScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const +/* virtual */ uint32_t TownScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const { if (this->t == nullptr) { - *available = false; + available = false; return UINT_MAX; } @@ -119,7 +119,7 @@ Debug(grf, 1, "Unhandled town variable 0x{:X}", variable); - *available = false; + available = false; return UINT_MAX; } diff --git a/src/newgrf_town.h b/src/newgrf_town.h index 7c9bc3729e..b8bdb1f061 100644 --- a/src/newgrf_town.h +++ b/src/newgrf_town.h @@ -34,7 +34,7 @@ struct TownScopeResolver : public ScopeResolver { { } - uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool *available) const override; + uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override; void StorePSA(uint reg, int32_t value) override; }; diff --git a/src/station_base.h b/src/station_base.h index 5b73de95ef..155e2fe420 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -516,7 +516,7 @@ public: return IsAirportTile(tile) && GetStationIndex(tile) == this->index; } - uint32_t GetNewGRFVariable(const ResolverObject &object, uint8_t variable, uint8_t parameter, bool *available) const override; + uint32_t GetNewGRFVariable(const ResolverObject &object, uint8_t variable, uint8_t parameter, bool &available) const override; void GetTileArea(TileArea *ta, StationType type) const override; }; diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h index 836cec3445..1be431a939 100644 --- a/src/table/newgrf_debug_data.h +++ b/src/table/newgrf_debug_data.h @@ -78,7 +78,7 @@ class NIHVehicle : public NIHelper { void SetStringParameters(uint index) const override { this->SetSimpleStringParameters(STR_VEHICLE_NAME, index); } uint32_t GetGRFID(uint index) const override { return Vehicle::Get(index)->GetGRFID(); } - uint Resolve(uint index, uint var, uint param, bool *avail) const override + uint Resolve(uint index, uint var, uint param, bool &avail) const override { Vehicle *v = Vehicle::Get(index); VehicleResolverObject ro(v->engine_type, v, VehicleResolverObject::WO_CACHED); @@ -143,7 +143,7 @@ class NIHStation : public NIHelper { void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); } uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetStationSpec(index)->grf_prop.grffile->grfid : 0; } - uint Resolve(uint index, uint var, uint param, bool *avail) const override + uint Resolve(uint index, uint var, uint param, bool &avail) const override { StationResolverObject ro(GetStationSpec(index), Station::GetByTile(index), index); return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail); @@ -208,7 +208,7 @@ class NIHHouse : public NIHelper { void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_TOWN_NAME, GetTownIndex(index), index); } uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? HouseSpec::Get(GetHouseType(index))->grf_prop.grffile->grfid : 0; } - uint Resolve(uint index, uint var, uint param, bool *avail) const override + uint Resolve(uint index, uint var, uint param, bool &avail) const override { HouseResolverObject ro(GetHouseType(index), index, Town::GetByTile(index)); return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail); @@ -258,7 +258,7 @@ class NIHIndustryTile : public NIHelper { void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_INDUSTRY_NAME, GetIndustryIndex(index), index); } uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grffile->grfid : 0; } - uint Resolve(uint index, uint var, uint param, bool *avail) const override + uint Resolve(uint index, uint var, uint param, bool &avail) const override { IndustryTileResolverObject ro(GetIndustryGfx(index), index, Industry::GetByTile(index)); return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail); @@ -371,7 +371,7 @@ class NIHIndustry : public NIHelper { void SetStringParameters(uint index) const override { this->SetSimpleStringParameters(STR_INDUSTRY_NAME, index); } uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile->grfid : 0; } - uint Resolve(uint index, uint var, uint param, bool *avail) const override + uint Resolve(uint index, uint var, uint param, bool &avail) const override { Industry *i = Industry::Get(index); IndustriesResolverObject ro(i->location.tile, i, i->type); @@ -434,7 +434,7 @@ class NIHObject : public NIHelper { void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_OBJECT, INVALID_STRING_ID, index); } uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? ObjectSpec::GetByTile(index)->grf_prop.grffile->grfid : 0; } - uint Resolve(uint index, uint var, uint param, bool *avail) const override + uint Resolve(uint index, uint var, uint param, bool &avail) const override { ObjectResolverObject ro(ObjectSpec::GetByTile(index), Object::GetByTile(index), index); return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail); @@ -468,7 +468,7 @@ class NIHRailType : public NIHelper { void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE, INVALID_STRING_ID, index); } uint32_t GetGRFID(uint) const override { return 0; } - uint Resolve(uint index, uint var, uint param, bool *avail) const override + uint Resolve(uint index, uint var, uint param, bool &avail) const override { /* There is no unique GRFFile for the tile. Multiple GRFs can define different parts of the railtype. * However, currently the NewGRF Debug GUI does not display variables depending on the GRF (like 0x7F) anyway. */ @@ -504,7 +504,7 @@ class NIHAirportTile : public NIHelper { void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); } uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grffile->grfid : 0; } - uint Resolve(uint index, uint var, uint param, bool *avail) const override + uint Resolve(uint index, uint var, uint param, bool &avail) const override { AirportTileResolverObject ro(AirportTileSpec::GetByTile(index), index, Station::GetByTile(index)); return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail); @@ -545,7 +545,7 @@ class NIHAirport : public NIHelper { void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, index, Station::Get(index)->airport.tile); } uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? AirportSpec::Get(Station::Get(index)->airport.type)->grf_prop.grffile->grfid : 0; } - uint Resolve(uint index, uint var, uint param, bool *avail) const override + uint Resolve(uint index, uint var, uint param, bool &avail) const override { Station *st = Station::Get(index); AirportResolverObject ro(st->airport.tile, st, st->airport.type, st->airport.layout); @@ -592,7 +592,7 @@ class NIHTown : public NIHelper { uint32_t GetGRFID(uint) const override { return 0; } bool PSAWithParameter() const override { return true; } - uint Resolve(uint index, uint var, uint param, bool *avail) const override + uint Resolve(uint index, uint var, uint param, bool &avail) const override { TownResolverObject ro(nullptr, Town::Get(index), true); return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail); @@ -636,7 +636,7 @@ class NIHRoadType : public NIHelper { void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_ROAD_TYPE, INVALID_STRING_ID, index); } uint32_t GetGRFID(uint) const override { return 0; } - uint Resolve(uint index, uint var, uint param, bool *avail) const override + uint Resolve(uint index, uint var, uint param, bool &avail) const override { /* There is no unique GRFFile for the tile. Multiple GRFs can define different parts of the railtype. * However, currently the NewGRF Debug GUI does not display variables depending on the GRF (like 0x7F) anyway. */ @@ -702,7 +702,7 @@ class NIHRoadStop : public NIHelper { void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); } uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetRoadStopSpec(index)->grf_prop.grffile->grfid : 0; } - uint Resolve(uint index, uint var, uint32_t param, bool *avail) const override + uint Resolve(uint index, uint var, uint32_t param, bool &avail) const override { int view = GetRoadStopDir(index); if (IsDriveThroughStopTile(index)) view += 4; diff --git a/src/waypoint_base.h b/src/waypoint_base.h index f431958e6e..5e13f6e134 100644 --- a/src/waypoint_base.h +++ b/src/waypoint_base.h @@ -32,7 +32,7 @@ struct Waypoint final : SpecializedStation { return IsRailWaypointTile(tile) && GetStationIndex(tile) == this->index; } - uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint8_t variable, uint8_t parameter, bool *available) const override; + uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint8_t variable, uint8_t parameter, bool &available) const override; void GetTileArea(TileArea *ta, StationType type) const override;