OpenTTD Source: src/newgrf_airporttiles.h Source File

OpenTTD Source 13.1

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 <http://www.gnu.org/licenses/>.
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_commons.h"
17 #include "newgrf_spritegroup.h"
18 #include "station_base.h"
19
21 struct AirportTileScopeResolver : public ScopeResolver {
22 struct Station *st;
23 byte airport_id;
24 TileIndex tile;
25 const AirportTileSpec *ats;
26
33 AirportTileScopeResolver(ResolverObject &ro, const AirportTileSpec *ats, TileIndex tile, Station *st)
34 : ScopeResolver(ro), st(st), tile(tile), ats(ats)
35 {
36 assert(st != nullptr);
37 this->airport_id = st->airport.type;
38 }
39
40 uint32 GetRandomBits() const override;
41 uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override;
42 };
43
45 struct AirportTileResolverObject : public ResolverObject {
46 AirportTileScopeResolver tiles_scope;
47
48 AirportTileResolverObject(const AirportTileSpec *ats, TileIndex tile, Station *st,
49 CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
50
51 ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override
52 {
53 switch (scope) {
54 case VSG_SCOPE_SELF: return &tiles_scope;
55 default: return ResolverObject::GetScope(scope, relative);
56 }
57 }
58
59 GrfSpecFeature GetFeature() const override;
60 uint32 GetDebugID() const override;
61 };
62
66 struct AirportTileSpec {
67 AnimationInfo animation;
68 StringID name;
69 uint8 callback_mask;
70 uint8 animation_special_flags;
71 bool enabled;
72 GRFFileProps grf_prop;
73
74 static const AirportTileSpec *Get(StationGfx gfx);
75 static const AirportTileSpec *GetByTile(TileIndex tile);
76
77 static void ResetAirportTiles();
78
79 private:
80 static AirportTileSpec tiles[NUM_AIRPORTTILES];
81
82 friend void AirportTileOverrideManager::SetEntitySpec(const AirportTileSpec *airpts);
83 };
84
85 StationGfx GetTranslatedAirportTileID(StationGfx gfx);
86 void AnimateAirportTile(TileIndex tile);
87 void AirportTileAnimationTrigger(Station *st, TileIndex tile, AirpAnimationTrigger trigger, CargoID cargo_type = CT_INVALID);
88 void AirportAnimationTrigger(Station *st, AirpAnimationTrigger trigger, CargoID cargo_type = CT_INVALID);
89 bool DrawNewAirportTile(TileInfo *ti, Station *st, StationGfx gfx, const AirportTileSpec *airts);
90
91 #endif /* NEWGRF_AIRPORTTILES_H */
VarSpriteGroupScope
VarSpriteGroupScope
Definition: newgrf_spritegroup.h:97
ResolverObject::callback_param1
uint32 callback_param1
First parameter (var 10) of the callback.
Definition: newgrf_spritegroup.h:326
StationGfx
byte StationGfx
Copy from station_map.h.
Definition: newgrf_airport.h:20
AirportTileScopeResolver::tile
TileIndex tile
Tile for the callback, only valid for airporttile callbacks.
Definition: newgrf_airporttiles.h:24
AirportTileScopeResolver::GetRandomBits
uint32 GetRandomBits() const override
Get a few random bits.
Definition: newgrf_airporttiles.cpp:202
newgrf_commons.h
TileInfo
Tile information, used while rendering the tile.
Definition: tile_cmd.h:42
AirportTileScopeResolver::GetVariable
uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override
Get a variable value.
Definition: newgrf_airporttiles.cpp:161
Station
Station data structure.
Definition: station_base.h:454
AirportTileScopeResolver::st
struct Station * st
Station of the airport for which the callback is run, or nullptr for build gui.
Definition: newgrf_airporttiles.h:22
ResolverObject
Interface for SpriteGroup-s to access the gamestate.
Definition: newgrf_spritegroup.h:307
AnimationInfo
Information about animation.
Definition: newgrf_animation_type.h:18
TileIndex
The index/ID of a Tile.
Definition: tile_type.h:85
CallbackID
CallbackID
List of implemented NewGRF callbacks.
Definition: newgrf_callbacks.h:20
AirportTileScopeResolver::airport_id
byte airport_id
Type of airport for which the callback is run.
Definition: newgrf_airporttiles.h:23
AirportTileResolverObject::GetDebugID
uint32 GetDebugID() const override
Get an identifier for the item being resolved.
Definition: newgrf_airporttiles.cpp:228
ScopeResolver
Interface to query and set values specific to a single VarSpriteGroupScope (action 2 scope).
Definition: newgrf_spritegroup.h:288
AirportTileSpec::animation_special_flags
uint8 animation_special_flags
Extra flags to influence the animation.
Definition: newgrf_airporttiles.h:70
VSG_SCOPE_SELF
@ VSG_SCOPE_SELF
Resolved object itself.
Definition: newgrf_spritegroup.h:100
AirportTileSpec::ResetAirportTiles
static void ResetAirportTiles()
This function initializes the tile array of AirportTileSpec.
Definition: newgrf_airporttiles.cpp:57
AirportTileSpec
Defines the data structure of each individual tile of an airport.
Definition: newgrf_airporttiles.h:66
ResolverObject::callback_param2
uint32 callback_param2
Second parameter (var 18) of the callback.
Definition: newgrf_spritegroup.h:327
CBID_NO_CALLBACK
@ CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
Definition: newgrf_callbacks.h:22
GRFFileProps
Data related to the handling of grf files.
Definition: newgrf_commons.h:325
AirportTileScopeResolver
Scope resolver for handling the tiles of an airport.
Definition: newgrf_airporttiles.h:21
Station::airport
Airport airport
Tile area the airport covers.
Definition: station_base.h:468
NUM_AIRPORTTILES
static const uint NUM_AIRPORTTILES
Total number of airport tiles.
Definition: airport.h:23
AirportTileSpec::GetByTile
static const AirportTileSpec * GetByTile(TileIndex tile)
Retrieve airport tile spec for the given airport tile.
Definition: newgrf_airporttiles.cpp:49
GetTranslatedAirportTileID
StationGfx GetTranslatedAirportTileID(StationGfx gfx)
Do airporttile gfx ID translation for NewGRFs.
Definition: newgrf_airporttiles.cpp:95
ResolverObject::GetScope
virtual ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
Definition: newgrf_spritegroup.cpp:139
newgrf_spritegroup.h
GrfSpecFeature
GrfSpecFeature
Definition: newgrf.h:66
AirportTileResolverObject::tiles_scope
AirportTileScopeResolver tiles_scope
Scope resolver for the tiles.
Definition: newgrf_airporttiles.h:46
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
station_base.h
AirportTileResolverObject::AirportTileResolverObject
AirportTileResolverObject(const AirportTileSpec *ats, TileIndex tile, Station *st, CallbackID callback=CBID_NO_CALLBACK, uint32 callback_param1=0, uint32 callback_param2=0)
Constructor of the resolver for airport tiles.
Definition: newgrf_airporttiles.cpp:216
AirportTileSpec::callback_mask
uint8 callback_mask
Bitmask telling which grf callback is set.
Definition: newgrf_airporttiles.h:69
AirportTileSpec::enabled
bool enabled
entity still available (by default true). newgrf can disable it, though
Definition: newgrf_airporttiles.h:71
ResolverObject::callback
CallbackID callback
Callback being resolved.
Definition: newgrf_spritegroup.h:325
station_map.h
Airport::type
byte type
Type of this airport,.
Definition: station_base.h:306
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:20
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:33
airport.h
AirportTileResolverObject::GetScope
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0) override
Get a resolver for the scope.
Definition: newgrf_airporttiles.h:51
AirportTileResolverObject
Resolver for tiles of an airport.
Definition: newgrf_airporttiles.h:45
ScopeResolver::ro
ResolverObject & ro
Surrounding resolver object.
Definition: newgrf_spritegroup.h:289
AirpAnimationTrigger
AirpAnimationTrigger
Animation triggers for airport tiles.
Definition: newgrf_animation_type.h:46
AirportTileSpec::name
StringID name
Tile Subname string, land information on this tile will give you "AirportName (TileSubname)".
Definition: newgrf_airporttiles.h:68
CT_INVALID
@ CT_INVALID
Invalid cargo type.
Definition: cargo_type.h:69
AirportTileSpec::Get
static const AirportTileSpec * Get(StationGfx gfx)
Retrieve airport tile spec for the given airport tile.
Definition: newgrf_airporttiles.cpp:36
newgrf_animation_type.h
AirportTileSpec::grf_prop
GRFFileProps grf_prop
properties related the the grf file
Definition: newgrf_airporttiles.h:72
AirportTileResolverObject::GetFeature
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
Definition: newgrf_airporttiles.cpp:223
AirportTileSpec::animation
AnimationInfo animation
Information about the animation.
Definition: newgrf_airporttiles.h:67