2010-07-22 16:50:58 +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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file newgrf_railtype.h NewGRF handling of rail types. */
|
|
|
|
|
2010-02-07 22:22:54 +00:00
|
|
|
#ifndef NEWGRF_RAILTYPE_H
|
|
|
|
#define NEWGRF_RAILTYPE_H
|
|
|
|
|
|
|
|
#include "rail.h"
|
2010-08-09 07:10:42 +00:00
|
|
|
#include "newgrf_commons.h"
|
2012-11-10 20:41:45 +00:00
|
|
|
#include "newgrf_spritegroup.h"
|
|
|
|
|
2022-06-12 08:00:31 +00:00
|
|
|
struct TraceRestrictProgram;
|
|
|
|
|
2012-11-10 20:46:39 +00:00
|
|
|
/** Resolver for the railtype scope. */
|
2012-11-10 20:41:45 +00:00
|
|
|
struct RailTypeScopeResolver : public ScopeResolver {
|
|
|
|
TileIndex tile; ///< Tracktile. For track on a bridge this is the southern bridgehead.
|
|
|
|
TileContext context; ///< Are we resolving sprites for the upper halftile, or on a bridge?
|
2022-06-15 18:03:13 +00:00
|
|
|
CustomSignalSpriteContext signal_context;
|
2020-01-26 12:45:51 +00:00
|
|
|
const RailtypeInfo *rti;
|
2022-06-12 08:00:31 +00:00
|
|
|
const TraceRestrictProgram *prog;
|
2012-11-10 20:41:45 +00:00
|
|
|
|
2018-03-11 13:19:41 +00:00
|
|
|
/**
|
|
|
|
* Constructor of the railtype scope resolvers.
|
|
|
|
* @param ro Surrounding resolver.
|
|
|
|
* @param tile %Tile containing the track. For track on a bridge this is the southern bridgehead.
|
|
|
|
* @param context Are we resolving sprites for the upper halftile, or on a bridge?
|
2022-06-15 18:03:13 +00:00
|
|
|
* @param signal_context Signal context.
|
2018-03-11 13:19:41 +00:00
|
|
|
*/
|
2022-06-15 18:03:13 +00:00
|
|
|
RailTypeScopeResolver(ResolverObject &ro, const RailtypeInfo *rti, TileIndex tile, TileContext context, CustomSignalSpriteContext signal_context, const TraceRestrictProgram *prog)
|
|
|
|
: ScopeResolver(ro), tile(tile), context(context), signal_context(signal_context), rti(rti), prog(prog)
|
2018-03-11 13:19:41 +00:00
|
|
|
{
|
|
|
|
}
|
2012-11-10 20:41:45 +00:00
|
|
|
|
2019-03-03 22:25:13 +00:00
|
|
|
uint32 GetRandomBits() const override;
|
2022-01-24 01:17:35 +00:00
|
|
|
uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override;
|
2012-11-10 20:41:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Resolver object for rail types. */
|
|
|
|
struct RailTypeResolverObject : public ResolverObject {
|
2012-11-10 20:46:39 +00:00
|
|
|
RailTypeScopeResolver railtype_scope; ///< Resolver for the railtype scope.
|
2012-11-10 20:41:45 +00:00
|
|
|
|
2022-06-15 18:03:13 +00:00
|
|
|
RailTypeResolverObject(const RailtypeInfo *rti, TileIndex tile, TileContext context, RailTypeSpriteGroup rtsg, uint32 param1 = 0, uint32 param2 = 0, CustomSignalSpriteContext signal_context = CSSC_GUI, const TraceRestrictProgram *prog = nullptr);
|
2012-11-10 20:41:45 +00:00
|
|
|
|
2019-03-03 22:25:13 +00:00
|
|
|
ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
|
2012-11-10 20:41:45 +00:00
|
|
|
{
|
|
|
|
switch (scope) {
|
|
|
|
case VSG_SCOPE_SELF: return &this->railtype_scope;
|
2012-11-10 20:45:59 +00:00
|
|
|
default: return ResolverObject::GetScope(scope, relative);
|
2012-11-10 20:41:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-26 12:45:51 +00:00
|
|
|
GrfSpecFeature GetFeature() const override;
|
|
|
|
uint32 GetDebugID() const override;
|
2012-11-10 20:41:45 +00:00
|
|
|
};
|
2010-02-07 22:22:54 +00:00
|
|
|
|
2021-08-19 23:49:48 +00:00
|
|
|
struct CustomSignalSpriteResult {
|
2021-08-21 00:07:41 +00:00
|
|
|
PalSpriteID sprite;
|
2021-08-19 23:49:48 +00:00
|
|
|
bool restricted_valid;
|
|
|
|
};
|
|
|
|
|
2019-04-10 21:07:06 +00:00
|
|
|
SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context = TCX_NORMAL, uint *num_results = nullptr);
|
2022-06-18 22:37:35 +00:00
|
|
|
CustomSignalSpriteResult GetCustomSignalSprite(const RailtypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, uint8 aspect, CustomSignalSpriteContext context, uint8 style, const TraceRestrictProgram *prog = nullptr);
|
2010-02-07 22:22:54 +00:00
|
|
|
|
2021-01-10 13:37:40 +00:00
|
|
|
RailType GetRailTypeTranslation(uint8 railtype, const GRFFile *grffile);
|
2010-02-07 22:22:54 +00:00
|
|
|
uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile);
|
|
|
|
|
|
|
|
#endif /* NEWGRF_RAILTYPE_H */
|