OpenTTD Source: src/newgrf_airporttiles.cpp Source File

OpenTTD Source 15.0-RC2

newgrf_airporttiles.cpp
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#include "stdafx.h"
11#include "debug.h"
12#include "newgrf_airporttiles.h"
13#include "newgrf_badge.h"
14#include "newgrf_spritegroup.h"
15#include "newgrf_sound.h"
16#include "station_base.h"
17#include "water.h"
18#include "landscape.h"
19#include "company_base.h"
20#include "town.h"
21#include "newgrf_animation_base.h"
22
23#include "table/strings.h"
24#include "table/airporttiles.h"
25
26#include "safeguards.h"
27
28extern uint32_t GetRelativePosition(TileIndex tile, TileIndex ind_tile);
29
30 AirportTileSpec AirportTileSpec::tiles[NUM_AIRPORTTILES];
31
32 AirportTileOverrideManager _airporttile_mngr(NEW_AIRPORTTILE_OFFSET, NUM_AIRPORTTILES, INVALID_AIRPORTTILE);
33
39/* static */ const AirportTileSpec *AirportTileSpec::Get(StationGfx gfx)
40{
41 /* should be assert(gfx < lengthof(tiles)), but that gives compiler warnings
42 * since it's always true if the following holds: */
43 static_assert(std::numeric_limits<StationGfx>::max() + 1 == lengthof(tiles));
44 return &AirportTileSpec::tiles[gfx];
45}
46
52/* static */ const AirportTileSpec *AirportTileSpec::GetByTile(TileIndex tile)
53{
54 return AirportTileSpec::Get(GetAirportGfx(tile));
55}
56
60 void AirportTileSpec::ResetAirportTiles()
61{
62 auto insert = std::copy(std::begin(_origin_airporttile_specs), std::end(_origin_airporttile_specs), std::begin(AirportTileSpec::tiles));
63 std::fill(insert, std::end(AirportTileSpec::tiles), AirportTileSpec{});
64
65 /* Reset any overrides that have been set. */
66 _airporttile_mngr.ResetOverride();
67}
68
69void AirportTileOverrideManager::SetEntitySpec(AirportTileSpec &&airpts)
70{
71 StationGfx airpt_id = this->AddEntityID(airpts.grf_prop.local_id, airpts.grf_prop.grfid, airpts.grf_prop.subst_id);
72
73 if (airpt_id == this->invalid_id) {
74 GrfMsg(1, "AirportTile.SetEntitySpec: Too many airport tiles allocated. Ignoring.");
75 return;
76 }
77
78 AirportTileSpec::tiles[airpt_id] = std::move(airpts);
79
80 /* Now add the overrides. */
81 for (int i = 0; i < this->max_offset; i++) {
82 AirportTileSpec *overridden_airpts = &AirportTileSpec::tiles[i];
83
84 if (this->entity_overrides[i] != AirportTileSpec::tiles[airpt_id].grf_prop.local_id || this->grfid_overrides[i] != AirportTileSpec::tiles[airpt_id].grf_prop.grfid) continue;
85
86 overridden_airpts->grf_prop.override_id = airpt_id;
87 overridden_airpts->enabled = false;
88 this->entity_overrides[i] = this->invalid_id;
89 this->grfid_overrides[i] = 0;
90 }
91}
92
98 StationGfx GetTranslatedAirportTileID(StationGfx gfx)
99{
100 const AirportTileSpec *it = AirportTileSpec::Get(gfx);
101 return it->grf_prop.override_id == INVALID_AIRPORTTILE ? gfx : it->grf_prop.override_id;
102}
103
112 static uint32_t GetNearbyAirportTileInformation(uint8_t parameter, TileIndex tile, StationID index, bool grf_version8)
113{
114 if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required
115 bool is_same_airport = (IsTileType(tile, MP_STATION) && IsAirport(tile) && GetStationIndex(tile) == index);
116
117 return GetNearbyTileInformation(tile, grf_version8) | (is_same_airport ? 1 : 0) << 8;
118}
119
120
129 static uint32_t GetAirportTileIDAtOffset(TileIndex tile, const Station *st, uint32_t cur_grfid)
130{
131 if (!st->TileBelongsToAirport(tile)) {
132 return 0xFFFF;
133 }
134
135 StationGfx gfx = GetAirportGfx(tile);
136 const AirportTileSpec *ats = AirportTileSpec::Get(gfx);
137
138 if (gfx < NEW_AIRPORTTILE_OFFSET) { // Does it belongs to an old type?
139 /* It is an old tile. We have to see if it's been overridden */
140 if (ats->grf_prop.override_id == INVALID_AIRPORTTILE) { // has it been overridden?
141 return 0xFF << 8 | gfx; // no. Tag FF + the gfx id of that tile
142 }
143 /* Overridden */
144 const AirportTileSpec *tile_ovr = AirportTileSpec::Get(ats->grf_prop.override_id);
145
146 if (tile_ovr->grf_prop.grfid == cur_grfid) {
147 return tile_ovr->grf_prop.local_id; // same grf file
148 } else {
149 return 0xFFFE; // not the same grf file
150 }
151 }
152 /* Not an 'old type' tile */
153 if (ats->grf_prop.HasSpriteGroups()) {
154 if (ats->grf_prop.grfid == cur_grfid) { // same airport, same grf ?
155 return ats->grf_prop.local_id;
156 } else {
157 return 0xFFFE; // Defined in another grf file
158 }
159 }
160 /* The tile has no spritegroup */
161 return 0xFF << 8 | ats->grf_prop.subst_id; // so just give it the substitute
162}
163
164/* virtual */ uint32_t AirportTileScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const
165{
166 assert(this->st != nullptr);
167
168 switch (variable) {
169 /* Terrain type */
170 case 0x41: return GetTerrainType(this->tile);
171
172 /* Current town zone of the tile in the nearest town */
173 case 0x42: return to_underlying(GetTownRadiusGroup(ClosestTownFromTile(this->tile, UINT_MAX), this->tile));
174
175 /* Position relative to most northern airport tile. */
176 case 0x43: return GetRelativePosition(this->tile, this->st->airport.tile);
177
178 /* Animation frame of tile */
179 case 0x44: return GetAnimationFrame(this->tile);
180
181 /* Land info of nearby tiles */
182 case 0x60: return GetNearbyAirportTileInformation(parameter, this->tile, this->st->index, this->ro.grffile->grf_version >= 8);
183
184 /* Animation stage of nearby tiles */
185 case 0x61: {
186 TileIndex tile = GetNearbyTile(parameter, this->tile);
187 if (this->st->TileBelongsToAirport(tile)) {
188 return GetAnimationFrame(tile);
189 }
190 return UINT_MAX;
191 }
192
193 /* Get airport tile ID at offset */
194 case 0x62: return GetAirportTileIDAtOffset(GetNearbyTile(parameter, this->tile), this->st, this->ro.grffile->grfid);
195
196 case 0x7A: return GetBadgeVariableResult(*this->ro.grffile, this->ats->badges, parameter);
197 }
198
199 Debug(grf, 1, "Unhandled airport tile variable 0x{:X}", variable);
200
201 available = false;
202 return UINT_MAX;
203}
204
205/* virtual */ uint32_t AirportTileScopeResolver::GetRandomBits() const
206{
207 return (this->st == nullptr ? 0 : this->st->random_bits) | (this->tile == INVALID_TILE ? 0 : GetStationTileRandomBits(this->tile) << 16);
208}
209
219AirportTileResolverObject::AirportTileResolverObject(const AirportTileSpec *ats, TileIndex tile, Station *st,
220 CallbackID callback, uint32_t callback_param1, uint32_t callback_param2)
221 : ResolverObject(ats->grf_prop.grffile, callback, callback_param1, callback_param2),
222 tiles_scope(*this, ats, tile, st),
223 airport_scope(*this, tile, st, st != nullptr ? AirportSpec::Get(st->airport.type) : nullptr, st != nullptr ? st->airport.layout : 0)
224{
225 this->root_spritegroup = ats->grf_prop.GetSpriteGroup(st != nullptr);
226}
227
228 GrfSpecFeature AirportTileResolverObject::GetFeature() const
229{
230 return GSF_AIRPORTTILES;
231}
232
233uint32_t AirportTileResolverObject::GetDebugID() const
234{
235 return this->tiles_scope.ats->grf_prop.local_id;
236}
237
238static uint16_t GetAirportTileCallback(CallbackID callback, uint32_t param1, uint32_t param2, const AirportTileSpec *ats, Station *st, TileIndex tile, std::span<int32_t> regs100 = {})
239{
240 AirportTileResolverObject object(ats, tile, st, callback, param1, param2);
241 return object.ResolveCallback(regs100);
242}
243
244static void AirportDrawTileLayout(const TileInfo *ti, const DrawTileSpriteSpan &dts, Colours colour)
245{
246 SpriteID image = dts.ground.sprite;
247 SpriteID pal = dts.ground.pal;
248
249 if (GB(image, 0, SPRITE_WIDTH) != 0) {
250 if (image == SPR_FLAT_WATER_TILE && IsTileOnWater(ti->tile)) {
251 DrawWaterClassGround(ti);
252 } else {
253 DrawGroundSprite(image, GroundSpritePaletteTransform(image, pal, GetColourPalette(colour)));
254 }
255 }
256
257 DrawNewGRFTileSeq(ti, &dts, TO_BUILDINGS, 0, GetColourPalette(colour));
258}
259
260bool DrawNewAirportTile(TileInfo *ti, Station *st, const AirportTileSpec *airts)
261{
262 if (ti->tileh != SLOPE_FLAT) {
263 bool draw_old_one = true;
264 if (airts->callback_mask.Test(AirportTileCallbackMask::DrawFoundations)) {
265 /* Called to determine the type (if any) of foundation to draw */
266 uint32_t callback_res = GetAirportTileCallback(CBID_AIRPTILE_DRAW_FOUNDATIONS, 0, 0, airts, st, ti->tile);
267 if (callback_res != CALLBACK_FAILED) draw_old_one = ConvertBooleanCallback(airts->grf_prop.grffile, CBID_AIRPTILE_DRAW_FOUNDATIONS, callback_res);
268 }
269
270 if (draw_old_one) DrawFoundation(ti, FOUNDATION_LEVELED);
271 }
272
273 AirportTileResolverObject object(airts, ti->tile, st);
274 const auto *group = object.Resolve<TileLayoutSpriteGroup>();
275 if (group == nullptr) {
276 return false;
277 }
278
279 auto processor = group->ProcessRegisters(object, nullptr);
280 auto dts = processor.GetLayout();
281 AirportDrawTileLayout(ti, dts, Company::Get(st->owner)->colour);
282 return true;
283}
284
285/* Simple wrapper for GetAirportTileCallback to keep the animation unified. */
286static uint16_t GetSimpleAirportTileCallback(CallbackID callback, uint32_t param1, uint32_t param2, const AirportTileSpec *ats, Station *st, TileIndex tile, int)
287{
288 return GetAirportTileCallback(callback, param1, param2, ats, st, tile);
289}
290
292 struct AirportTileAnimationBase : public AnimationBase<AirportTileAnimationBase, AirportTileSpec, Station, int, GetSimpleAirportTileCallback, TileAnimationFrameAnimationHelper<Station>> {
293 static constexpr CallbackID cb_animation_speed = CBID_AIRPTILE_ANIMATION_SPEED;
294 static constexpr CallbackID cb_animation_next_frame = CBID_AIRPTILE_ANIMATION_NEXT_FRAME;
295
296 static constexpr AirportTileCallbackMask cbm_animation_speed = AirportTileCallbackMask::AnimationSpeed;
297 static constexpr AirportTileCallbackMask cbm_animation_next_frame = AirportTileCallbackMask::AnimationNextFrame;
298};
299
300void AnimateAirportTile(TileIndex tile)
301{
302 const AirportTileSpec *ats = AirportTileSpec::GetByTile(tile);
303 if (ats == nullptr) return;
304
305 AirportTileAnimationBase::AnimateTile(ats, Station::GetByTile(tile), tile, HasBit(ats->animation_special_flags, 0));
306}
307
308static bool DoTriggerAirportTileAnimation(Station *st, TileIndex tile, AirportAnimationTrigger trigger, uint32_t random, uint32_t var18_extra = 0)
309{
310 const AirportTileSpec *ats = AirportTileSpec::GetByTile(tile);
311 if (!ats->animation.triggers.Test(trigger)) return false;
312
313 AirportTileAnimationBase::ChangeAnimationFrame(CBID_AIRPTILE_ANIMATION_TRIGGER, ats, st, tile, random, to_underlying(trigger) | var18_extra);
314 return true;
315}
316
317bool TriggerAirportTileAnimation(Station *st, TileIndex tile, AirportAnimationTrigger trigger)
318{
319 return DoTriggerAirportTileAnimation(st, tile, trigger, Random());
320}
321
322bool TriggerAirportAnimation(Station *st, AirportAnimationTrigger trigger, CargoType cargo_type)
323{
324 if (st->airport.tile == INVALID_TILE) return false;
325
326 bool ret = true;
327 uint32_t random = Random();
328 for (TileIndex tile : st->airport) {
329 if (!st->TileBelongsToAirport(tile)) continue;
330
331 const AirportTileSpec *ats = AirportTileSpec::GetByTile(tile);
332 if (ats->grf_prop.grffile == nullptr) continue;
333
334 uint8_t var18_extra = 0;
335 if (IsValidCargoType(cargo_type)) {
336 var18_extra |= ats->grf_prop.grffile->cargo_map[cargo_type] << 8;
337 }
338
339 if (DoTriggerAirportTileAnimation(st, tile, trigger, random, var18_extra)) {
340 SB(random, 0, 16, Random());
341 } else {
342 ret = false;
343 }
344 }
345 return ret;
346}
INVALID_AIRPORTTILE
static const uint INVALID_AIRPORTTILE
id for an invalid airport tile
Definition airport.h:25
NEW_AIRPORTTILE_OFFSET
static const uint NEW_AIRPORTTILE_OFFSET
offset of first newgrf airport tile
Definition airport.h:24
NUM_AIRPORTTILES
static const uint NUM_AIRPORTTILES
Total number of airport tiles.
Definition airport.h:23
airporttiles.h
Tables with airporttile defaults.
_origin_airporttile_specs
static const AirportTileSpec _origin_airporttile_specs[]
All default airport tiles.
Definition airporttiles.h:24
SB
constexpr T SB(T &x, const uint8_t s, const uint8_t n, const U d)
Set n bits in x starting at bit s to d.
Definition bitmath_func.hpp:58
GB
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Definition bitmath_func.hpp:32
HasBit
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition bitmath_func.hpp:103
CargoType
uint8_t CargoType
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:21
IsValidCargoType
bool IsValidCargoType(CargoType cargo)
Test whether cargo type is not INVALID_CARGO.
Definition cargo_type.h:104
AirportTileOverrideManager
Definition newgrf_commons.h:274
BaseBitSet::Test
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Definition base_bitset_type.hpp:141
OverrideManagerBase::invalid_id
uint16_t invalid_id
ID used to detected invalid entities.
Definition newgrf_commons.h:206
OverrideManagerBase::ResetOverride
void ResetOverride()
Resets the override, which is used while initializing game.
Definition newgrf_commons.cpp:79
OverrideManagerBase::max_offset
uint16_t max_offset
what is the length of the original entity's array of specs
Definition newgrf_commons.h:203
OverrideManagerBase::AddEntityID
virtual uint16_t AddEntityID(uint16_t grf_local_id, uint32_t grfid, uint16_t substitute_id)
Reserves a place in the mapping array for an entity to be installed.
Definition newgrf_commons.cpp:110
company_base.h
Definition of stuff that is very close to a company, like the company struct itself.
debug.h
Functions related to debugging.
Debug
#define Debug(category, level, format_string,...)
Output a line of debugging information.
Definition debug.h:37
to_underlying
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
Definition enum_type.hpp:17
SpriteID
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition gfx_type.h:17
DrawFoundation
void DrawFoundation(TileInfo *ti, Foundation f)
Draw foundation f at tile ti.
Definition landscape.cpp:428
landscape.h
Functions related to OTTD's landscape.
BorderFlag::Random
@ Random
Randomise borders.
GrfSpecFeature
GrfSpecFeature
Definition newgrf.h:68
StationGfx
uint8_t StationGfx
Copy from station_map.h.
Definition newgrf_airport.h:23
GetTranslatedAirportTileID
StationGfx GetTranslatedAirportTileID(StationGfx gfx)
Do airporttile gfx ID translation for NewGRFs.
Definition newgrf_airporttiles.cpp:98
GetRelativePosition
uint32_t GetRelativePosition(TileIndex tile, TileIndex ind_tile)
This is the position of the tile relative to the northernmost tile of the industry.
Definition newgrf_industrytiles.cpp:54
GetAirportTileIDAtOffset
static uint32_t GetAirportTileIDAtOffset(TileIndex tile, const Station *st, uint32_t cur_grfid)
Make an analysis of a tile and check whether it belongs to the same airport, and/or the same grf file...
Definition newgrf_airporttiles.cpp:129
GetNearbyAirportTileInformation
static uint32_t GetNearbyAirportTileInformation(uint8_t parameter, TileIndex tile, StationID index, bool grf_version8)
Based on newhouses/newindustries equivalent, but adapted for airports.
Definition newgrf_airporttiles.cpp:112
newgrf_airporttiles.h
NewGRF handling of airport tiles.
newgrf_animation_base.h
Function implementations related to NewGRF animation.
GetBadgeVariableResult
uint32_t GetBadgeVariableResult(const GRFFile &grffile, std::span< const BadgeID > badges, uint32_t parameter)
Test for a matching badge in a list of badges, returning the number of matching bits.
Definition newgrf_badge.cpp:225
newgrf_badge.h
Functions related to NewGRF badges.
AirportTileCallbackMask
AirportTileCallbackMask
Callback masks for airport tiles.
Definition newgrf_callbacks.h:427
AirportTileCallbackMask::DrawFoundations
@ DrawFoundations
decides if default foundations need to be drawn
AirportTileCallbackMask::AnimationNextFrame
@ AnimationNextFrame
decides next animation frame
AirportTileCallbackMask::AnimationSpeed
@ AnimationSpeed
decides animation speed
CallbackID
CallbackID
List of implemented NewGRF callbacks.
Definition newgrf_callbacks.h:22
CBID_AIRPTILE_DRAW_FOUNDATIONS
@ CBID_AIRPTILE_DRAW_FOUNDATIONS
Called to determine the type (if any) of foundation to draw for an airport tile.
Definition newgrf_callbacks.h:235
CBID_AIRPTILE_ANIMATION_TRIGGER
@ CBID_AIRPTILE_ANIMATION_TRIGGER
Called for periodically starting or stopping the animation.
Definition newgrf_callbacks.h:238
CBID_AIRPTILE_ANIMATION_SPEED
@ CBID_AIRPTILE_ANIMATION_SPEED
Called to indicate how long the current animation frame should last.
Definition newgrf_callbacks.h:244
CBID_AIRPTILE_ANIMATION_NEXT_FRAME
@ CBID_AIRPTILE_ANIMATION_NEXT_FRAME
Called to determine airport tile next animation frame.
Definition newgrf_callbacks.h:241
CALLBACK_FAILED
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Definition newgrf_callbacks.h:439
GetNearbyTileInformation
uint32_t GetNearbyTileInformation(TileIndex tile, bool grf_version8)
Common part of station var 0x67, house var 0x62, indtile var 0x60, industry var 0x62.
Definition newgrf_commons.cpp:434
ConvertBooleanCallback
bool ConvertBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
Converts a callback result into a boolean.
Definition newgrf_commons.cpp:543
GetTerrainType
uint32_t GetTerrainType(TileIndex tile, TileContext context)
Function used by houses (and soon industries) to get information on type of "terrain" the tile it is ...
Definition newgrf_commons.cpp:336
GetNearbyTile
TileIndex GetNearbyTile(uint8_t parameter, TileIndex tile, bool signed_offsets, Axis axis)
Get the tile at the given offset.
Definition newgrf_commons.cpp:411
newgrf_sound.h
Functions related to NewGRF provided sounds.
newgrf_spritegroup.h
Action 2 handling.
safeguards.h
A number of safeguards to prevent using unsafe methods.
SLOPE_FLAT
@ SLOPE_FLAT
a flat tile
Definition slope_type.h:49
FOUNDATION_LEVELED
@ FOUNDATION_LEVELED
The tile is leveled up to a flat slope.
Definition slope_type.h:95
GetColourPalette
static PaletteID GetColourPalette(Colours colour)
Get recolour palette for a colour.
Definition sprite.h:188
DrawNewGRFTileSeq
void DrawNewGRFTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, uint32_t stage, PaletteID default_palette)
Draw NewGRF industrytile or house sprite layout.
Definition sprite.h:130
GroundSpritePaletteTransform
PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.
Definition sprite.h:174
SPRITE_WIDTH
static constexpr uint8_t SPRITE_WIDTH
number of bits for the sprite number
Definition sprites.h:1549
station_base.h
Base classes/functions for stations.
IsAirport
bool IsAirport(Tile t)
Is this station tile an airport?
Definition station_map.h:157
GetStationTileRandomBits
uint8_t GetStationTileRandomBits(Tile t)
Get the random bits of a station tile.
Definition station_map.h:702
GetStationIndex
StationID GetStationIndex(Tile t)
Get StationID from a tile.
Definition station_map.h:28
GetAirportGfx
StationGfx GetAirportGfx(Tile t)
Get the station graphics of this airport tile.
Definition station_map.h:332
AirportAnimationTrigger
AirportAnimationTrigger
Animation triggers for airport tiles.
Definition station_type.h:103
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
lengthof
#define lengthof(array)
Return the length of an fixed size array.
Definition stdafx.h:271
AirportSpec
Defines the data structure for an airport.
Definition newgrf_airport.h:109
AirportTileAnimationBase
Helper class for animation control.
Definition newgrf_airporttiles.cpp:292
AirportTileResolverObject
Resolver for tiles of an airport.
Definition newgrf_airporttiles.h:47
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
AirportTileResolverObject::AirportTileResolverObject
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.
Definition newgrf_airporttiles.cpp:219
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::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::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
AnimationBase
Helper class for a unified approach to NewGRF animation.
Definition newgrf_animation_base.h:43
AnimationBase< AirportTileAnimationBase, AirportTileSpec, Station, int, GetSimpleAirportTileCallback, TileAnimationFrameAnimationHelper< Station > >::AnimateTile
static void AnimateTile(const AirportTileSpec *spec, Station *obj, TileIndex tile, bool random_animation, int extra_data=0)
Animate a single tile.
Definition newgrf_animation_base.h:52
AnimationBase< AirportTileAnimationBase, AirportTileSpec, Station, int, GetSimpleAirportTileCallback, TileAnimationFrameAnimationHelper< Station > >::ChangeAnimationFrame
static void ChangeAnimationFrame(CallbackID cb, const AirportTileSpec *spec, Station *obj, TileIndex tile, uint32_t random_bits, uint32_t trigger, int extra_data=0)
Check a callback to determine what the next animation step is and execute that step.
Definition newgrf_animation_base.h:131
BaseStation::owner
Owner owner
The owner of this station.
Definition base_station_base.h:68
BaseStation::GetByTile
static BaseStation * GetByTile(TileIndex tile)
Get the base station belonging to a specific tile.
Definition base_station_base.h:160
BaseStation::random_bits
uint16_t random_bits
Random bits assigned to this station.
Definition base_station_base.h:76
DrawTileSpriteSpan
Ground palette sprite of a tile, together with its sprite layout.
Definition sprite.h:67
DrawTileSprites::ground
PalSpriteID ground
Palette and sprite for the ground.
Definition sprite.h:53
GRFFilePropsBase::grffile
const struct GRFFile * grffile
grf file that introduced this entity
Definition newgrf_commons.h:318
GRFFilePropsBase::local_id
uint16_t local_id
id defined by the grf file for this entity
Definition newgrf_commons.h:316
GRFFilePropsBase::grfid
uint32_t grfid
grfid that introduced this entity.
Definition newgrf_commons.h:317
GRFFile::cargo_map
std::array< uint8_t, NUM_CARGO > cargo_map
Inverse cargo translation table (CargoType -> local ID)
Definition newgrf.h:136
OrthogonalTileArea::tile
TileIndex tile
The base tile of the area.
Definition tilearea_type.h:19
PalSpriteID::sprite
SpriteID sprite
The 'real' sprite.
Definition gfx_type.h:23
PalSpriteID::pal
PaletteID pal
The palette (use PAL_NONE) if not needed)
Definition gfx_type.h:24
PoolID< uint16_t, struct StationIDTag, 64000, 0xFFFF >
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(auto index)
Returns Titem with given index.
Definition pool_type.hpp:387
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition pool_type.hpp:286
ResolverObject
Interface for SpriteGroup-s to access the gamestate.
Definition newgrf_spritegroup.h:288
ResolverObject::grffile
const GRFFile * grffile
GRFFile the resolved SpriteGroup belongs to.
Definition newgrf_spritegroup.h:352
ResolverObject::root_spritegroup
const SpriteGroup * root_spritegroup
Root SpriteGroup to use for resolving.
Definition newgrf_spritegroup.h:353
ScopeResolver::ro
ResolverObject & ro
Surrounding resolver object.
Definition newgrf_spritegroup.h:270
StandardGRFFileProps::GetSpriteGroup
const struct SpriteGroup * GetSpriteGroup(bool entity_exists) const
Get the standard sprite group.
Definition newgrf_commons.h:394
StandardGRFFileProps::HasSpriteGroups
bool HasSpriteGroups() const
Check whether the entity has sprite groups.
Definition newgrf_commons.h:385
Station
Station data structure.
Definition station_base.h:500
Station::airport
Airport airport
Tile area the airport covers.
Definition station_base.h:514
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
SubstituteGRFFileProps::override_id
uint16_t override_id
id of the entity been replaced by
Definition newgrf_commons.h:469
TileInfo
Tile information, used while rendering the tile.
Definition tile_cmd.h:30
TileInfo::tileh
Slope tileh
Slope of the tile.
Definition tile_cmd.h:31
TileInfo::tile
TileIndex tile
Tile index.
Definition tile_cmd.h:32
TileLayoutSpriteGroup
Action 2 sprite layout for houses, industry tiles, objects and airport tiles.
Definition newgrf_spritegroup.h:236
TileLayoutSpriteGroup::ProcessRegisters
SpriteLayoutProcessor ProcessRegisters(const ResolverObject &object, uint8_t *stage) const
Process registers and the construction stage into the sprite layout.
Definition newgrf_spritegroup.cpp:290
IsTileType
static bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Definition tile_map.h:150
GetAnimationFrame
uint8_t GetAnimationFrame(Tile t)
Get the current animation frame.
Definition tile_map.h:250
INVALID_TILE
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition tile_type.h:95
MP_STATION
@ MP_STATION
A tile of a station.
Definition tile_type.h:53
town.h
Base of the town class.
ClosestTownFromTile
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
Definition town_cmd.cpp:3952
GetTownRadiusGroup
HouseZone GetTownRadiusGroup(const Town *t, TileIndex tile)
Returns the bit corresponding to the town zone of the specified tile.
Definition town_cmd.cpp:2507
TO_BUILDINGS
@ TO_BUILDINGS
company buildings - depots, stations, HQ, ...
Definition transparency.h:28
DrawGroundSprite
void DrawGroundSprite(SpriteID image, PaletteID pal, const SubSprite *sub, int extra_offs_x, int extra_offs_y)
Draws a ground sprite for the current tile.
Definition viewport.cpp:579
water.h
Functions related to water (management)
IsTileOnWater
bool IsTileOnWater(Tile t)
Tests if the tile was built on water.
Definition water_map.h:138