Update readme.md
[openttd-joker.git] / src / newgrf_railtype.h
blobcbebdce64f5cbba8730f83770dfe810856f4e25f
1 /* $Id: newgrf_railtype.h 26388 2014-03-03 20:02:31Z frosch $ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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 */
10 /** @file newgrf_railtype.h NewGRF handling of rail types. */
12 #ifndef NEWGRF_RAILTYPE_H
13 #define NEWGRF_RAILTYPE_H
15 #include "rail.h"
16 #include "newgrf_commons.h"
17 #include "newgrf_spritegroup.h"
19 /** Resolver for the railtype scope. */
20 struct RailTypeScopeResolver : public ScopeResolver {
21 TileIndex tile; ///< Tracktile. For track on a bridge this is the southern bridgehead.
22 TileContext context; ///< Are we resolving sprites for the upper halftile, or on a bridge?
24 /**
25 * Constructor of the railtype scope resolvers.
26 * @param ro Surrounding resolver.
27 * @param tile %Tile containing the track. For track on a bridge this is the southern bridgehead.
28 * @param context Are we resolving sprites for the upper halftile, or on a bridge?
30 RailTypeScopeResolver(ResolverObject &ro, TileIndex tile, TileContext context)
31 : ScopeResolver(ro), tile(tile), context(context)
35 /* virtual */ uint32 GetRandomBits() const;
36 /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
39 /** Resolver object for rail types. */
40 struct RailTypeResolverObject : public ResolverObject {
41 RailTypeScopeResolver railtype_scope; ///< Resolver for the railtype scope.
43 RailTypeResolverObject(const RailtypeInfo *rti, TileIndex tile, TileContext context, RailTypeSpriteGroup rtsg, uint32 param1 = 0, uint32 param2 = 0);
45 /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
47 switch (scope) {
48 case VSG_SCOPE_SELF: return &this->railtype_scope;
49 default: return ResolverObject::GetScope(scope, relative);
53 /* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
56 SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context = TCX_NORMAL, uint *num_results = nullptr);
57 SpriteID GetCustomSignalSprite(const RailtypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, SignalState state, bool gui = false);
59 uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile);
61 #endif /* NEWGRF_RAILTYPE_H */