diff options
author | Peter Nelson <peter1138@openttd.org> | 2021-06-04 12:52:00 +0100 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2021-06-12 08:05:59 +0100 |
commit | f1328db063fe0808a55e7ed76304491b84916146 (patch) | |
tree | 1affc16bd7abdaea4fcc143316a54c29497402de /src | |
parent | c562b4c52754ea51418f5b4ecc46a36e14f849f0 (diff) | |
download | openttd-f1328db063fe0808a55e7ed76304491b84916146.tar.xz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/newgrf_airport.cpp | 12 | ||||
-rw-r--r-- | src/newgrf_canal.cpp | 10 | ||||
-rw-r--r-- | src/newgrf_cargo.cpp | 12 | ||||
-rw-r--r-- | src/newgrf_generic.cpp | 10 | ||||
-rw-r--r-- | src/newgrf_railtype.cpp | 7 | ||||
-rw-r--r-- | src/newgrf_railtype.h | 2 | ||||
-rw-r--r-- | src/newgrf_roadtype.cpp | 7 | ||||
-rw-r--r-- | src/newgrf_roadtype.h | 2 | ||||
-rw-r--r-- | src/newgrf_spritegroup.cpp | 3 |
9 files changed, 3 insertions, 62 deletions
diff --git a/src/newgrf_airport.cpp b/src/newgrf_airport.cpp index 86b65fd0e..df400145d 100644 --- a/src/newgrf_airport.cpp +++ b/src/newgrf_airport.cpp @@ -57,8 +57,6 @@ struct AirportResolverObject : public ResolverObject { } } - const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override; - GrfSpecFeature GetFeature() const override; uint32 GetDebugID() const override; }; @@ -219,16 +217,6 @@ void AirportOverrideManager::SetEntitySpec(AirportSpec *as) 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 { return GSF_AIRPORTS; diff --git a/src/newgrf_canal.cpp b/src/newgrf_canal.cpp index 6b3c9b3d4..2977c96a8 100644 --- a/src/newgrf_canal.cpp +++ b/src/newgrf_canal.cpp @@ -49,8 +49,6 @@ struct CanalResolverObject : public ResolverObject { } } - const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override; - GrfSpecFeature GetFeature() const override; uint32 GetDebugID() const override; }; @@ -108,14 +106,6 @@ struct CanalResolverObject : public ResolverObject { 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 { return GSF_CANALS; diff --git a/src/newgrf_cargo.cpp b/src/newgrf_cargo.cpp index 105a2b252..70b1a18d9 100644 --- a/src/newgrf_cargo.cpp +++ b/src/newgrf_cargo.cpp @@ -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); - const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override; - GrfSpecFeature GetFeature() 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 { return GSF_CARGOES; diff --git a/src/newgrf_generic.cpp b/src/newgrf_generic.cpp index 0a138f1d6..c59964714 100644 --- a/src/newgrf_generic.cpp +++ b/src/newgrf_generic.cpp @@ -63,8 +63,6 @@ struct GenericResolverObject : public ResolverObject { } } - const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override; - GrfSpecFeature GetFeature() const override { return (GrfSpecFeature)this->generic_scope.feature; @@ -147,14 +145,6 @@ void AddGenericCallback(uint8 feature, const GRFFile *file, const SpriteGroup *g return UINT_MAX; } - -/* virtual */ const SpriteGroup *GenericResolverObject::ResolveReal(const RealSpriteGroup *group) const -{ - if (group->loaded.empty()) return nullptr; - - return group->loaded[0]; -} - /** * Generic resolver. * @param ai_callback Callback comes from the AI. diff --git a/src/newgrf_railtype.cpp b/src/newgrf_railtype.cpp index 407acc984..95d891f24 100644 --- a/src/newgrf_railtype.cpp +++ b/src/newgrf_railtype.cpp @@ -58,13 +58,6 @@ 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 { return GSF_RAILTYPES; diff --git a/src/newgrf_railtype.h b/src/newgrf_railtype.h index c38211738..d33504e36 100644 --- a/src/newgrf_railtype.h +++ b/src/newgrf_railtype.h @@ -49,8 +49,6 @@ struct RailTypeResolverObject : public ResolverObject { } } - const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override; - GrfSpecFeature GetFeature() const override; uint32 GetDebugID() const override; }; diff --git a/src/newgrf_roadtype.cpp b/src/newgrf_roadtype.cpp index 9243bf77e..4f3b61290 100644 --- a/src/newgrf_roadtype.cpp +++ b/src/newgrf_roadtype.cpp @@ -58,13 +58,6 @@ 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 { RoadType rt = GetRoadTypeByLabel(this->roadtype_scope.rti->label, false); diff --git a/src/newgrf_roadtype.h b/src/newgrf_roadtype.h index 0e0869793..748d62e82 100644 --- a/src/newgrf_roadtype.h +++ b/src/newgrf_roadtype.h @@ -40,8 +40,6 @@ struct RoadTypeResolverObject : public ResolverObject { } } - const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override; - GrfSpecFeature GetFeature() const override; uint32 GetDebugID() const override; }; diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp index 29080894e..d5376116e 100644 --- a/src/newgrf_spritegroup.cpp +++ b/src/newgrf_spritegroup.cpp @@ -124,6 +124,9 @@ static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *sc */ /* 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; } |