2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 /** @file newgrf_town.h Functions to handle the town part of NewGRF towns. */
13 #include "town_type.h"
14 #include "newgrf_spritegroup.h"
17 * Scope resolver for a town.
18 * @note Currently there is no direct town resolver; we only need to get town
19 * variable results from inside stations, house tiles and industries,
20 * and to check the town's persistent storage.
22 struct TownScopeResolver
: public ScopeResolver
{
23 Town
*t
; ///< %Town of the scope.
24 bool readonly
; ///< When set, persistent storage of the town is read-only,
27 * Resolver of a town scope.
28 * @param ro Surrounding resolver.
29 * @param t %Town of the scope.
30 * @param readonly Scope may change persistent storage of the town.
32 TownScopeResolver(ResolverObject
&ro
, Town
*t
, bool readonly
)
33 : ScopeResolver(ro
), t(t
), readonly(readonly
)
37 uint32_t GetVariable(byte variable
, [[maybe_unused
]] uint32_t parameter
, bool *available
) const override
;
38 void StorePSA(uint reg
, int32_t value
) override
;
41 /** Resolver of town properties. */
42 struct TownResolverObject
: public ResolverObject
{
43 TownScopeResolver town_scope
; ///< Scope resolver specific for towns.
45 TownResolverObject(const struct GRFFile
*grffile
, Town
*t
, bool readonly
);
47 ScopeResolver
*GetScope(VarSpriteGroupScope scope
= VSG_SCOPE_SELF
, byte relative
= 0) override
50 case VSG_SCOPE_SELF
: return &town_scope
;
51 default: return ResolverObject::GetScope(scope
, relative
);
56 #endif /* NEWGRF_TOWN_H */