2007-03-19 11:27:30 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file newgrf_town.h Functions to handle the town part of NewGRF towns. */
|
2007-03-19 11:27:30 +00:00
|
|
|
|
|
|
|
#ifndef NEWGRF_TOWN_H
|
|
|
|
#define NEWGRF_TOWN_H
|
|
|
|
|
2010-01-15 16:41:15 +00:00
|
|
|
#include "town_type.h"
|
2012-11-10 20:38:46 +00:00
|
|
|
#include "newgrf_spritegroup.h"
|
2010-01-15 16:41:15 +00:00
|
|
|
|
2012-11-10 20:46:39 +00:00
|
|
|
/**
|
|
|
|
* Scope resolver for a town.
|
|
|
|
* @note Currently there is no direct town resolver; we only need to get town
|
|
|
|
* variable results from inside stations, house tiles and industries,
|
|
|
|
* and to check the town's persistent storage.
|
2012-11-10 20:45:59 +00:00
|
|
|
*/
|
2012-11-10 20:38:46 +00:00
|
|
|
struct TownScopeResolver : public ScopeResolver {
|
2012-11-10 20:46:39 +00:00
|
|
|
Town *t; ///< %Town of the scope.
|
|
|
|
bool readonly; ///< When set, persistent storage of the town is read-only,
|
2012-11-10 20:38:46 +00:00
|
|
|
|
|
|
|
TownScopeResolver(ResolverObject *ro, Town *t, bool readonly);
|
|
|
|
|
|
|
|
virtual uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
|
|
|
|
virtual void StorePSA(uint reg, int32 value);
|
|
|
|
};
|
|
|
|
|
2012-11-10 20:46:39 +00:00
|
|
|
/** Resolver of town properties. */
|
2012-11-10 20:38:46 +00:00
|
|
|
struct TownResolverObject : public ResolverObject {
|
2012-11-10 20:46:39 +00:00
|
|
|
TownScopeResolver town_scope; ///< Scope resolver specific for towns.
|
2012-11-10 20:38:46 +00:00
|
|
|
|
|
|
|
TownResolverObject(const struct GRFFile *grffile, Town *t, bool readonly);
|
|
|
|
|
|
|
|
/* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
|
|
|
|
{
|
|
|
|
switch (scope) {
|
|
|
|
case VSG_SCOPE_SELF: return &town_scope;
|
2012-11-10 20:45:59 +00:00
|
|
|
default: return ResolverObject::GetScope(scope, relative);
|
2012-11-10 20:38:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-03-19 11:27:30 +00:00
|
|
|
#endif /* NEWGRF_TOWN_H */
|