OpenTTD Source: src/newgrf_airporttiles.h Source File

OpenTTD Source 15.3

newgrf_airporttiles.h
Go to the documentation of this file.
1/*
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef NEWGRF_AIRPORTTILES_H
11#define NEWGRF_AIRPORTTILES_H
12
13#include "airport.h"
14#include "station_map.h"
15#include "newgrf_animation_type.h"
16#include "newgrf_badge_type.h"
17#include "newgrf_callbacks.h"
18#include "newgrf_commons.h"
19#include "newgrf_spritegroup.h"
20#include "station_base.h"
21
23 struct AirportTileScopeResolver : public ScopeResolver {
24 struct Station *st;
25 uint8_t airport_id;
26 TileIndex tile;
27 const AirportTileSpec *ats;
28
35 AirportTileScopeResolver(ResolverObject &ro, const AirportTileSpec *ats, TileIndex tile, Station *st)
36 : ScopeResolver(ro), st(st), tile(tile), ats(ats)
37 {
38 assert(st != nullptr);
39 this->airport_id = st->airport.type;
40 }
41
42 uint32_t GetRandomBits() const override;
43 uint32_t GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override;
44};
45
47 struct AirportTileResolverObject : public ResolverObject {
48 AirportTileScopeResolver tiles_scope;
49 AirportScopeResolver airport_scope;
50
51 AirportTileResolverObject(const AirportTileSpec *ats, TileIndex tile, Station *st,
52 CallbackID callback = CBID_NO_CALLBACK, uint32_t callback_param1 = 0, uint32_t callback_param2 = 0);
53
54 ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, uint8_t relative = 0) override
55 {
56 switch (scope) {
57 case VSG_SCOPE_SELF: return &tiles_scope;
58 case VSG_SCOPE_PARENT: return &airport_scope;
59 default: return ResolverObject::GetScope(scope, relative);
60 }
61 }
62
63 GrfSpecFeature GetFeature() const override;
64 uint32_t GetDebugID() const override;
65};
66
70 struct AirportTileSpec {
71 AnimationInfo<AirportAnimationTriggers> animation;
72 StringID name;
73 AirportTileCallbackMasks callback_mask;
74 uint8_t animation_special_flags;
75 bool enabled;
76 SubstituteGRFFileProps grf_prop;
77 std::vector<BadgeID> badges;
78
79 static const AirportTileSpec *Get(StationGfx gfx);
80 static const AirportTileSpec *GetByTile(TileIndex tile);
81
82 static void ResetAirportTiles();
83
84private:
85 static AirportTileSpec tiles[NUM_AIRPORTTILES];
86
87 friend void AirportTileOverrideManager::SetEntitySpec(AirportTileSpec &&airpts);
88};
89
90void AnimateAirportTile(TileIndex tile);
91bool TriggerAirportTileAnimation(Station *st, TileIndex tile, AirportAnimationTrigger trigger);
92bool TriggerAirportAnimation(Station *st, AirportAnimationTrigger trigger, CargoType cargo_type = INVALID_CARGO);
93bool DrawNewAirportTile(TileInfo *ti, Station *st, const AirportTileSpec *airts);
94
95#endif /* NEWGRF_AIRPORTTILES_H */
airport.h
Various declarations for airports.
NUM_AIRPORTTILES
static const uint NUM_AIRPORTTILES
Total number of airport tiles.
Definition airport.h:23
CargoType
uint8_t CargoType
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:21
EnumBitSet< AirportTileCallbackMask, uint8_t >
GrfSpecFeature
GrfSpecFeature
Definition newgrf.h:68
StationGfx
uint8_t StationGfx
Copy from station_map.h.
Definition newgrf_airport.h:23
newgrf_animation_type.h
Definitions related to NewGRF animation.
newgrf_badge_type.h
Types related to NewGRF badges.
newgrf_callbacks.h
Callbacks that NewGRFs could implement.
CallbackID
CallbackID
List of implemented NewGRF callbacks.
Definition newgrf_callbacks.h:22
CBID_NO_CALLBACK
@ CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
Definition newgrf_callbacks.h:24
newgrf_commons.h
This file simplifies and embeds a common mechanism of loading/saving and mapping of grf entities.
newgrf_spritegroup.h
Action 2 handling.
VarSpriteGroupScope
VarSpriteGroupScope
Definition newgrf_spritegroup.h:82
VSG_SCOPE_SELF
@ VSG_SCOPE_SELF
Resolved object itself.
Definition newgrf_spritegroup.h:85
VSG_SCOPE_PARENT
@ VSG_SCOPE_PARENT
Related object of the resolved one.
Definition newgrf_spritegroup.h:86
station_base.h
Base classes/functions for stations.
station_map.h
Maps accessors for stations.
AirportAnimationTrigger
AirportAnimationTrigger
Animation triggers for airport tiles.
Definition station_type.h:103
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition strings_type.h:19
AirportScopeResolver
Resolver for the airport scope.
Definition newgrf_airport.h:157
AirportTileResolverObject
Resolver for tiles of an airport.
Definition newgrf_airporttiles.h:47
AirportTileResolverObject::GetScope
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, uint8_t relative=0) override
Get a resolver for the scope.
Definition newgrf_airporttiles.h:54
AirportTileResolverObject::airport_scope
AirportScopeResolver airport_scope
Scope resolver for the airport owning the tile.
Definition newgrf_airporttiles.h:49
AirportTileResolverObject::tiles_scope
AirportTileScopeResolver tiles_scope
Scope resolver for the tiles.
Definition newgrf_airporttiles.h:48
AirportTileResolverObject::GetFeature
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
Definition newgrf_airporttiles.cpp:228
AirportTileResolverObject::GetDebugID
uint32_t GetDebugID() const override
Get an identifier for the item being resolved.
Definition newgrf_airporttiles.cpp:233
AirportTileScopeResolver
Scope resolver for handling the tiles of an airport.
Definition newgrf_airporttiles.h:23
AirportTileScopeResolver::airport_id
uint8_t airport_id
Type of airport for which the callback is run.
Definition newgrf_airporttiles.h:25
AirportTileScopeResolver::st
struct Station * st
Station of the airport for which the callback is run, or nullptr for build gui.
Definition newgrf_airporttiles.h:24
AirportTileScopeResolver::GetVariable
uint32_t GetVariable(uint8_t variable, uint32_t parameter, bool &available) const override
Get a variable value.
Definition newgrf_airporttiles.cpp:164
AirportTileScopeResolver::AirportTileScopeResolver
AirportTileScopeResolver(ResolverObject &ro, const AirportTileSpec *ats, TileIndex tile, Station *st)
Constructor of the scope resolver specific for airport tiles.
Definition newgrf_airporttiles.h:35
AirportTileScopeResolver::tile
TileIndex tile
Tile for the callback, only valid for airporttile callbacks.
Definition newgrf_airporttiles.h:26
AirportTileScopeResolver::GetRandomBits
uint32_t GetRandomBits() const override
Get a few random bits.
Definition newgrf_airporttiles.cpp:205
AirportTileSpec
Defines the data structure of each individual tile of an airport.
Definition newgrf_airporttiles.h:70
AirportTileSpec::enabled
bool enabled
entity still available (by default true). newgrf can disable it, though
Definition newgrf_airporttiles.h:75
AirportTileSpec::Get
static const AirportTileSpec * Get(StationGfx gfx)
Retrieve airport tile spec for the given airport tile.
Definition newgrf_airporttiles.cpp:39
AirportTileSpec::grf_prop
SubstituteGRFFileProps grf_prop
properties related the the grf file
Definition newgrf_airporttiles.h:76
AirportTileSpec::name
StringID name
Tile Subname string, land information on this tile will give you "AirportName (TileSubname)".
Definition newgrf_airporttiles.h:72
AirportTileSpec::animation
AnimationInfo< AirportAnimationTriggers > animation
Information about the animation.
Definition newgrf_airporttiles.h:71
AirportTileSpec::GetByTile
static const AirportTileSpec * GetByTile(TileIndex tile)
Retrieve airport tile spec for the given airport tile.
Definition newgrf_airporttiles.cpp:52
AirportTileSpec::ResetAirportTiles
static void ResetAirportTiles()
This function initializes the tile array of AirportTileSpec.
Definition newgrf_airporttiles.cpp:60
AirportTileSpec::animation_special_flags
uint8_t animation_special_flags
Extra flags to influence the animation.
Definition newgrf_airporttiles.h:74
AirportTileSpec::callback_mask
AirportTileCallbackMasks callback_mask
Bitmask telling which grf callback is set.
Definition newgrf_airporttiles.h:73
Airport::type
uint8_t type
Type of this airport,.
Definition station_base.h:375
AnimationInfo
Information about animation.
Definition newgrf_animation_type.h:21
ResolverObject
Interface for SpriteGroup-s to access the gamestate.
Definition newgrf_spritegroup.h:288
ResolverObject::callback_param2
uint32_t callback_param2
Second parameter (var 18) of the callback.
Definition newgrf_spritegroup.h:342
ResolverObject::callback
CallbackID callback
Callback being resolved.
Definition newgrf_spritegroup.h:340
ResolverObject::callback_param1
uint32_t callback_param1
First parameter (var 10) of the callback.
Definition newgrf_spritegroup.h:341
ResolverObject::GetScope
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, uint8_t relative=0)
Get a resolver for the scope.
Definition newgrf_spritegroup.cpp:133
ScopeResolver
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope).
Definition newgrf_spritegroup.h:269
ScopeResolver::ro
ResolverObject & ro
Surrounding resolver object.
Definition newgrf_spritegroup.h:270
Station
Station data structure.
Definition station_base.h:520
Station::airport
Airport airport
Tile area the airport covers.
Definition station_base.h:534
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
SubstituteGRFFileProps
NewGRF entities which can replace default entities.
Definition newgrf_commons.h:464
TileInfo
Tile information, used while rendering the tile.
Definition tile_cmd.h:30