mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Deduplicate ResolveReal() for resolvers that don't use real sprite groups.
This may change behaviour when multiple loading/loaded stages are provided, as the various copies checked in different orders, however only one result is expected in these cases anyway.pull/9355/head
parent
c562b4c527
commit
f1328db063
|
@ -57,8 +57,6 @@ struct AirportResolverObject : public ResolverObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override;
|
|
||||||
|
|
||||||
GrfSpecFeature GetFeature() const override;
|
GrfSpecFeature GetFeature() const override;
|
||||||
uint32 GetDebugID() const override;
|
uint32 GetDebugID() const override;
|
||||||
};
|
};
|
||||||
|
@ -219,16 +217,6 @@ void AirportOverrideManager::SetEntitySpec(AirportSpec *as)
|
||||||
return this->st->GetNewGRFVariable(this->ro, variable, parameter, available);
|
return this->st->GetNewGRFVariable(this->ro, variable, parameter, available);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* virtual */ const SpriteGroup *AirportResolverObject::ResolveReal(const RealSpriteGroup *group) const
|
|
||||||
{
|
|
||||||
/* Airport action 2s should always have only 1 "loaded" state, but some
|
|
||||||
* times things don't follow the spec... */
|
|
||||||
if (!group->loaded.empty()) return group->loaded[0];
|
|
||||||
if (!group->loading.empty()) return group->loading[0];
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
GrfSpecFeature AirportResolverObject::GetFeature() const
|
GrfSpecFeature AirportResolverObject::GetFeature() const
|
||||||
{
|
{
|
||||||
return GSF_AIRPORTS;
|
return GSF_AIRPORTS;
|
||||||
|
|
|
@ -49,8 +49,6 @@ struct CanalResolverObject : public ResolverObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override;
|
|
||||||
|
|
||||||
GrfSpecFeature GetFeature() const override;
|
GrfSpecFeature GetFeature() const override;
|
||||||
uint32 GetDebugID() const override;
|
uint32 GetDebugID() const override;
|
||||||
};
|
};
|
||||||
|
@ -108,14 +106,6 @@ struct CanalResolverObject : public ResolverObject {
|
||||||
return UINT_MAX;
|
return UINT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* virtual */ const SpriteGroup *CanalResolverObject::ResolveReal(const RealSpriteGroup *group) const
|
|
||||||
{
|
|
||||||
if (group->loaded.empty()) return nullptr;
|
|
||||||
|
|
||||||
return group->loaded[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
GrfSpecFeature CanalResolverObject::GetFeature() const
|
GrfSpecFeature CanalResolverObject::GetFeature() const
|
||||||
{
|
{
|
||||||
return GSF_CANALS;
|
return GSF_CANALS;
|
||||||
|
|
|
@ -19,22 +19,10 @@ struct CargoResolverObject : public ResolverObject {
|
||||||
|
|
||||||
CargoResolverObject(const CargoSpec *cs, CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
|
CargoResolverObject(const CargoSpec *cs, CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
|
||||||
|
|
||||||
const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override;
|
|
||||||
|
|
||||||
GrfSpecFeature GetFeature() const override;
|
GrfSpecFeature GetFeature() const override;
|
||||||
uint32 GetDebugID() const override;
|
uint32 GetDebugID() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* virtual */ const SpriteGroup *CargoResolverObject::ResolveReal(const RealSpriteGroup *group) const
|
|
||||||
{
|
|
||||||
/* Cargo action 2s should always have only 1 "loaded" state, but some
|
|
||||||
* times things don't follow the spec... */
|
|
||||||
if (!group->loaded.empty()) return group->loaded[0];
|
|
||||||
if (!group->loading.empty()) return group->loading[0];
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
GrfSpecFeature CargoResolverObject::GetFeature() const
|
GrfSpecFeature CargoResolverObject::GetFeature() const
|
||||||
{
|
{
|
||||||
return GSF_CARGOES;
|
return GSF_CARGOES;
|
||||||
|
|
|
@ -63,8 +63,6 @@ struct GenericResolverObject : public ResolverObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override;
|
|
||||||
|
|
||||||
GrfSpecFeature GetFeature() const override
|
GrfSpecFeature GetFeature() const override
|
||||||
{
|
{
|
||||||
return (GrfSpecFeature)this->generic_scope.feature;
|
return (GrfSpecFeature)this->generic_scope.feature;
|
||||||
|
@ -147,14 +145,6 @@ void AddGenericCallback(uint8 feature, const GRFFile *file, const SpriteGroup *g
|
||||||
return UINT_MAX;
|
return UINT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* virtual */ const SpriteGroup *GenericResolverObject::ResolveReal(const RealSpriteGroup *group) const
|
|
||||||
{
|
|
||||||
if (group->loaded.empty()) return nullptr;
|
|
||||||
|
|
||||||
return group->loaded[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic resolver.
|
* Generic resolver.
|
||||||
* @param ai_callback Callback comes from the AI.
|
* @param ai_callback Callback comes from the AI.
|
||||||
|
|
|
@ -58,13 +58,6 @@
|
||||||
return UINT_MAX;
|
return UINT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* virtual */ const SpriteGroup *RailTypeResolverObject::ResolveReal(const RealSpriteGroup *group) const
|
|
||||||
{
|
|
||||||
if (!group->loading.empty()) return group->loading[0];
|
|
||||||
if (!group->loaded.empty()) return group->loaded[0];
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
GrfSpecFeature RailTypeResolverObject::GetFeature() const
|
GrfSpecFeature RailTypeResolverObject::GetFeature() const
|
||||||
{
|
{
|
||||||
return GSF_RAILTYPES;
|
return GSF_RAILTYPES;
|
||||||
|
|
|
@ -49,8 +49,6 @@ struct RailTypeResolverObject : public ResolverObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override;
|
|
||||||
|
|
||||||
GrfSpecFeature GetFeature() const override;
|
GrfSpecFeature GetFeature() const override;
|
||||||
uint32 GetDebugID() const override;
|
uint32 GetDebugID() const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -58,13 +58,6 @@
|
||||||
return UINT_MAX;
|
return UINT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* virtual */ const SpriteGroup *RoadTypeResolverObject::ResolveReal(const RealSpriteGroup *group) const
|
|
||||||
{
|
|
||||||
if (!group->loading.empty()) return group->loading[0];
|
|
||||||
if (!group->loaded.empty()) return group->loaded[0];
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
GrfSpecFeature RoadTypeResolverObject::GetFeature() const
|
GrfSpecFeature RoadTypeResolverObject::GetFeature() const
|
||||||
{
|
{
|
||||||
RoadType rt = GetRoadTypeByLabel(this->roadtype_scope.rti->label, false);
|
RoadType rt = GetRoadTypeByLabel(this->roadtype_scope.rti->label, false);
|
||||||
|
|
|
@ -40,8 +40,6 @@ struct RoadTypeResolverObject : public ResolverObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override;
|
|
||||||
|
|
||||||
GrfSpecFeature GetFeature() const override;
|
GrfSpecFeature GetFeature() const override;
|
||||||
uint32 GetDebugID() const override;
|
uint32 GetDebugID() const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -124,6 +124,9 @@ static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *sc
|
||||||
*/
|
*/
|
||||||
/* virtual */ const SpriteGroup *ResolverObject::ResolveReal(const RealSpriteGroup *group) const
|
/* virtual */ const SpriteGroup *ResolverObject::ResolveReal(const RealSpriteGroup *group) const
|
||||||
{
|
{
|
||||||
|
if (!group->loaded.empty()) return group->loaded[0];
|
||||||
|
if (!group->loading.empty()) return group->loading[0];
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue