mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Pass avail(able) as reference instead of pointer since they are never nullptr (#12696)
parent
ba47d1ca2b
commit
29ce013eda
|
@ -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).
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -53,7 +53,7 @@ TemporaryStorageArray<int32_t, 0x110> _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) {
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
@ -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<uint16_t>(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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -32,7 +32,7 @@ struct Waypoint final : SpecializedStation<Waypoint, true> {
|
|||
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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue