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