OpenTTD Source 20261112-master-gbcbec5e63f
newgrf_industrytiles.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
9
10#include "stdafx.h"
11#include "debug.h"
12#include "landscape.h"
13#include "newgrf_badge.h"
15#include "industry.h"
16#include "town.h"
17#include "water.h"
19
20#include "table/strings.h"
21
22#include "safeguards.h"
23
33uint32_t GetNearbyIndustryTileInformation(uint8_t parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8)
34{
35 if (parameter != 0) tile = GetNearbyTile(parameter, tile, signed_offsets); // only perform if it is required
36 bool is_same_industry = (IsTileType(tile, TileType::Industry) && GetIndustryIndex(tile) == index);
37
38 return GetNearbyTileInformation(tile, grf_version8) | (is_same_industry ? 1 : 0) << 8;
39}
40
53uint32_t GetRelativePosition(TileIndex tile, TileIndex ind_tile)
54{
55 uint8_t x = TileX(tile) - TileX(ind_tile);
56 uint8_t y = TileY(tile) - TileY(ind_tile);
57
58 return ((y & 0xF) << 20) | ((x & 0xF) << 16) | (y << 8) | x;
59}
60
61/* virtual */ uint32_t IndustryTileScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const
62{
63 switch (variable) {
64 /* Construction state of the tile: a value between 0 and 3 */
65 case 0x40: return (IsTileType(this->tile, TileType::Industry)) ? GetIndustryConstructionStage(this->tile) : 0;
66
67 /* Terrain type */
68 case 0x41: return GetTerrainType(this->tile);
69
70 /* Current town zone of the tile in the nearest town */
71 case 0x42: return to_underlying(GetTownRadiusGroup(ClosestTownFromTile(this->tile, UINT_MAX), this->tile));
72
73 /* Relative position */
74 case 0x43: return GetRelativePosition(this->tile, this->industry->location.tile);
75
76 /* Animation frame. Like house variable 46 but can contain anything 0..FF. */
77 case 0x44: return IsTileType(this->tile, TileType::Industry) ? GetAnimationFrame(this->tile) : 0;
78
79 /* Land info of nearby tiles */
80 case 0x60: return GetNearbyIndustryTileInformation(parameter, this->tile,
81 this->industry == nullptr ? (IndustryID)IndustryID::Invalid() : this->industry->index, true, this->ro.grffile->grf_version >= 8);
82
83 /* Animation stage of nearby tiles */
84 case 0x61: {
85 TileIndex tile = GetNearbyTile(parameter, this->tile);
87 return GetAnimationFrame(tile);
88 }
89 return UINT_MAX;
90 }
91
92 /* Get industry tile ID at offset */
93 case 0x62: return GetIndustryIDAtOffset(GetNearbyTile(parameter, this->tile), this->industry, this->ro.grffile->grfid);
94
95 case 0x7A: return GetBadgeVariableResult(*this->ro.grffile, GetIndustryTileSpec(GetIndustryGfx(this->tile))->badges, parameter);
96 }
97
98 this->ro.UnhandledVariable(variable);
99
100 available = false;
101 return UINT_MAX;
102}
103
104/* virtual */ uint32_t IndustryTileScopeResolver::GetRandomBits() const
105{
106 assert(this->industry != nullptr && IsValidTile(this->tile));
107 assert(this->industry->index == IndustryID::Invalid() || IsTileType(this->tile, TileType::Industry));
108
109 return (this->industry->index != IndustryID::Invalid()) ? GetIndustryRandomBits(this->tile) : 0;
110}
111
113{
114 assert(this->industry != nullptr && IsValidTile(this->tile));
115 assert(this->industry->index == IndustryID::Invalid() || IsTileType(this->tile, TileType::Industry));
116 if (this->industry->index == IndustryID::Invalid()) return 0;
117 return GetIndustryRandomTriggers(this->tile).base();
118}
119
125static const GRFFile *GetIndTileGrffile(IndustryGfx gfx)
126{
127 const IndustryTileSpec *its = GetIndustryTileSpec(gfx);
128 return (its != nullptr) ? its->grf_prop.grffile : nullptr;
129}
130
143 indtile_scope(*this, indus, tile),
144 ind_scope(*this, tile, indus, indus->type),
145 gfx(gfx)
146{
147 this->root_spritegroup = GetIndustryTileSpec(gfx)->grf_prop.GetSpriteGroup(indus->index != IndustryID::Invalid());
148}
149
154
159
160static void IndustryDrawTileLayout(const TileInfo *ti, const DrawTileSpriteSpan &dts, Colours rnd_colour, uint8_t stage)
161{
162 SpriteID image = dts.ground.sprite;
163 PaletteID pal = dts.ground.pal;
164
165 if (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) image += stage;
166 if (HasBit(pal, SPRITE_MODIFIER_CUSTOM_SPRITE)) pal += stage;
167
168 if (GB(image, 0, SPRITE_WIDTH) != 0) {
169 /* If the ground sprite is the default flat water sprite, draw also canal/river borders
170 * Do not do this if the tile's WaterClass is 'land'. */
171 if (image == SPR_FLAT_WATER_TILE && IsTileOnWater(ti->tile)) {
172 DrawWaterClassGround(ti);
173 } else {
174 DrawGroundSprite(image, GroundSpritePaletteTransform(image, pal, GetColourPalette(rnd_colour)));
175 }
176 }
177
179}
180
181uint16_t GetIndustryTileCallback(CallbackID callback, uint32_t param1, uint32_t param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile, std::span<int32_t> regs100)
182{
183 assert(industry != nullptr && IsValidTile(tile));
184 assert(industry->index == IndustryID::Invalid() || IsTileType(tile, TileType::Industry));
185
186 IndustryTileResolverObject object(gfx_id, tile, industry, callback, param1, param2);
187 return object.ResolveCallback(regs100);
188}
189
190bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const IndustryTileSpec *inds)
191{
192 if (ti->tileh != SLOPE_FLAT) {
193 bool draw_old_one = true;
195 /* Called to determine the type (if any) of foundation to draw for industry tile */
196 uint32_t callback_res = GetIndustryTileCallback(CBID_INDTILE_DRAW_FOUNDATIONS, 0, 0, gfx, i, ti->tile);
197 if (callback_res != CALLBACK_FAILED) draw_old_one = ConvertBooleanCallback(inds->grf_prop.grffile, CBID_INDTILE_DRAW_FOUNDATIONS, callback_res);
198 }
199
200 if (draw_old_one) DrawFoundation(ti, Foundation::Leveled);
201 }
202
203 IndustryTileResolverObject object(gfx, ti->tile, i);
204
205 const auto *group = object.Resolve<TileLayoutSpriteGroup>();
206 if (group == nullptr) return false;
207
208 /* Limit the building stage to the number of stages supplied. */
209 uint8_t stage = GetIndustryConstructionStage(ti->tile);
210 auto processor = group->ProcessRegisters(object, &stage);
211 auto dts = processor.GetLayout();
212 IndustryDrawTileLayout(ti, dts, i->random_colour, stage);
213 return true;
214}
215
216extern bool IsSlopeRefused(Slope current, Slope refused);
217
231CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, size_t layout_index, uint16_t initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type)
232{
233 Industry ind(IndustryID::Invalid());
234 ind.location.tile = ind_base_tile;
235 ind.location.w = 0;
236 ind.type = type;
237 ind.random = initial_random_bits;
238 ind.founder = founder;
239
240 std::array<int32_t, 16> regs100;
241 uint16_t callback_res = GetIndustryTileCallback(CBID_INDTILE_SHAPE_CHECK, 0, to_underlying(creation_type) << 8 | static_cast<uint32_t>(layout_index), gfx, &ind, ind_tile, regs100);
242 if (callback_res == CALLBACK_FAILED) {
243 if (!IsSlopeRefused(GetTileSlope(ind_tile), its->slopes_refused)) return CommandCost();
244 return CommandCost(STR_ERROR_SITE_UNSUITABLE);
245 }
246 if (its->grf_prop.grffile->grf_version < 7) {
247 if (callback_res != 0) return CommandCost();
248 return CommandCost(STR_ERROR_SITE_UNSUITABLE);
249 }
250
251 return GetErrorMessageFromLocationCallbackResult(callback_res, regs100, its->grf_prop.grffile, STR_ERROR_SITE_UNSUITABLE);
252}
253
254/* Simple wrapper for GetHouseCallback to keep the animation unified. */
255uint16_t GetSimpleIndustryCallback(CallbackID callback, uint32_t param1, uint32_t param2, const IndustryTileSpec *spec, Industry *ind, TileIndex tile, int)
256{
257 return GetIndustryTileCallback(callback, param1, param2, spec - GetIndustryTileSpec(0), ind, tile);
258}
259
261struct IndustryAnimationBase : public AnimationBase<IndustryAnimationBase, IndustryTileSpec, Industry, int, GetSimpleIndustryCallback, TileAnimationFrameAnimationHelper<Industry> > {
262 static constexpr CallbackID cb_animation_speed = CBID_INDTILE_ANIMATION_SPEED;
263 static constexpr CallbackID cb_animation_next_frame = CBID_INDTILE_ANIMATION_NEXT_FRAME;
264
265 static constexpr IndustryTileCallbackMask cbm_animation_speed = IndustryTileCallbackMask::AnimationSpeed;
266 static constexpr IndustryTileCallbackMask cbm_animation_next_frame = IndustryTileCallbackMask::AnimationNextFrame;
267};
268
269void AnimateNewIndustryTile(TileIndex tile)
270{
272 if (itspec == nullptr) return;
273
275}
276
277static bool DoTriggerIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32_t random, uint32_t var18_extra = 0)
278{
280 if (!itspec->animation.triggers.Test(iat)) return false;
281
283 return true;
284}
285
286bool TriggerIndustryTileAnimation_ConstructionStageChanged(TileIndex tile, bool first_call)
287{
289 return DoTriggerIndustryTileAnimation(tile, iat, Random(), first_call ? 0x100 : 0);
290}
291
292bool TriggerIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat)
293{
295 return DoTriggerIndustryTileAnimation(tile, iat, Random());
296}
297
298bool TriggerIndustryAnimation(const Industry *ind, IndustryAnimationTrigger iat)
299{
300 bool ret = true;
301 uint32_t random = Random();
302 for (TileIndex tile : ind->location) {
303 if (ind->TileBelongsToIndustry(tile)) {
304 if (DoTriggerIndustryTileAnimation(tile, iat, random)) {
305 SB(random, 0, 16, Random());
306 } else {
307 ret = false;
308 }
309 }
310 }
311
312 return ret;
313}
314
322static void DoTriggerIndustryTileRandomisation(TileIndex tile, IndustryRandomTrigger trigger, Industry *ind, uint32_t &reseed_industry)
323{
324 assert(IsValidTile(tile) && IsTileType(tile, TileType::Industry));
325
326 IndustryGfx gfx = GetIndustryGfx(tile);
327 const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx);
328
329 if (!itspec->grf_prop.HasSpriteGroups()) return;
330
331 IndustryTileResolverObject object(gfx, tile, ind, CBID_RANDOM_TRIGGER);
332 auto waiting_random_triggers = GetIndustryRandomTriggers(tile);
333 waiting_random_triggers.Set(trigger);
334 SetIndustryRandomTriggers(tile, waiting_random_triggers); // store now for var 5F
335 object.SetWaitingRandomTriggers(waiting_random_triggers);
336
337 object.ResolveRerandomisation();
338
339 /* Store remaining triggers. */
340 waiting_random_triggers.Reset(object.GetUsedRandomTriggers());
341 SetIndustryRandomTriggers(tile, waiting_random_triggers);
342
343 /* Rerandomise tile bits */
344 uint8_t new_random_bits = Random();
345 uint8_t random_bits = GetIndustryRandomBits(tile);
346 random_bits &= ~object.reseed[VarSpriteGroupScope::Self];
347 random_bits |= new_random_bits & object.reseed[VarSpriteGroupScope::Self];
348 SetIndustryRandomBits(tile, random_bits);
350
351 reseed_industry |= object.reseed[VarSpriteGroupScope::Parent];
352}
353
359static void DoReseedIndustry(Industry *ind, uint32_t reseed)
360{
361 if (reseed == 0 || ind == nullptr) return;
362
363 uint16_t random_bits = Random();
364 ind->random &= reseed;
365 ind->random |= random_bits & reseed;
366}
367
374{
375 uint32_t reseed_industry = 0;
376 Industry *ind = Industry::GetByTile(tile);
377 DoTriggerIndustryTileRandomisation(tile, trigger, ind, reseed_industry);
378 DoReseedIndustry(ind, reseed_industry);
379}
380
387{
388 uint32_t reseed_industry = 0;
389 for (TileIndex tile : ind->location) {
390 if (ind->TileBelongsToIndustry(tile)) {
391 DoTriggerIndustryTileRandomisation(tile, trigger, ind, reseed_industry);
392 }
393 }
394 DoReseedIndustry(ind, reseed_industry);
395}
396
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.
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr Tstorage base() const noexcept
Retrieve the raw value behind this bit set.
Common return value for all commands.
uint16_t w
The width of the area.
TileIndex tile
The base tile of the area.
Functions related to debugging.
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23).
Definition enum_type.hpp:21
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition gfx_type.h:17
uint32_t PaletteID
The number of the palette.
Definition gfx_type.h:18
Colours
One of 16 base colours used for companies and windows/widgets.
Definition gfx_type.h:283
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
Base of all industries.
const IndustryTileSpec * GetIndustryTileSpec(IndustryGfx gfx)
Accessor for array _industry_tile_specs.
uint8_t GetIndustryRandomBits(Tile tile)
Get the random bits for this tile.
IndustryGfx GetIndustryGfx(Tile t)
Get the industry graphics ID for the given industry tile.
IndustryID GetIndustryIndex(Tile t)
Get the industry ID of the given tile.
void SetIndustryRandomBits(Tile tile, uint8_t bits)
Set the random bits for this tile.
void SetIndustryRandomTriggers(Tile tile, IndustryRandomTriggers triggers)
Set the activated triggers bits for this industry tile Used for grf callbacks.
IndustryRandomTriggers GetIndustryRandomTriggers(Tile tile)
Get the activated triggers bits for this industry tile Used for grf callbacks.
uint8_t GetIndustryConstructionStage(Tile tile)
Returns the industry construction stage of the specified tile.
IndustryRandomTrigger
Available industry random triggers.
EnumBitSet< IndustryRandomTrigger, uint8_t > IndustryRandomTriggers
Bitset of IndustryRandomTrigger elements.
IndustryAnimationTrigger
Animation triggers of the industries.
@ ConstructionStageChanged
Trigger whenever the construction stage changes.
@ NextFrameRandomBits
Callback 0x26 needs random bits.
void DrawFoundation(TileInfo *ti, Foundation f)
Draw foundation f at tile ti.
Functions related to OTTD's landscape.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition map_func.h:429
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition map_func.h:419
GrfSpecFeature
Definition newgrf.h:81
@ IndustryTiles
Industry tiles feature.
Definition newgrf.h:91
uint32_t GetRelativePosition(TileIndex tile, TileIndex ind_tile)
This is the position of the tile relative to the northernmost tile of the industry.
Function implementations related to NewGRF animation.
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.
Functions related to NewGRF badges.
CallbackID
List of implemented NewGRF callbacks.
@ CBID_INDTILE_ANIMATION_SPEED
Called to indicate how long the current animation frame should last.
@ CBID_INDTILE_SHAPE_CHECK
Called to determine if the given industry tile can be built on specific tile.
@ CBID_INDTILE_DRAW_FOUNDATIONS
Called to determine the type (if any) of foundation to draw for industry tile.
@ CBID_RANDOM_TRIGGER
Set when calling a randomizing trigger (almost undocumented).
@ CBID_INDTILE_ANIMATION_TRIGGER
Called for periodically starting or stopping the animation.
@ CBID_INDTILE_ANIMATION_NEXT_FRAME
Called to determine industry tile next animation frame.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
IndustryTileCallbackMask
Callback masks for industry tiles.
@ DrawFoundations
decides if default foundations need to be drawn
@ AnimationNextFrame
decides next animation frame
@ AnimationSpeed
decides animation speed
CommandCost GetErrorMessageFromLocationCallbackResult(uint16_t cb_res, std::span< const int32_t > textstack, const GRFFile *grffile, StringID default_error)
Get the error message from a shape/location/slope check callback result.
uint32_t GetNearbyTileInformation(TileIndex tile, bool grf_version8)
Common part of station var 0x67, house var 0x62, indtile var 0x60, industry var 0x62,...
bool ConvertBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
Converts a callback result into a boolean.
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 ...
TileIndex GetNearbyTile(uint8_t parameter, TileIndex tile, bool signed_offsets, Axis axis)
Get the tile at the given offset.
uint32_t GetIndustryIDAtOffset(TileIndex tile, const Industry *i, GrfID cur_grfid)
Make an analysis of a tile and check for its belonging to the same industry, and/or the same grf file...
IndustryAvailabilityCallType
From where has callback CBID_INDUSTRY_PROBABILITY been called.
uint32_t GetNearbyIndustryTileInformation(uint8_t parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8)
Based on newhouses equivalent, but adapted for newindustries.
void TriggerIndustryTileRandomisation(TileIndex tile, IndustryRandomTrigger trigger)
Trigger a random trigger for a single industry tile.
static void DoTriggerIndustryTileRandomisation(TileIndex tile, IndustryRandomTrigger trigger, Industry *ind, uint32_t &reseed_industry)
Trigger random triggers for an industry tile and reseed its random bits.
uint32_t GetRelativePosition(TileIndex tile, TileIndex ind_tile)
This is the position of the tile relative to the northernmost tile of the industry.
CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, size_t layout_index, uint16_t initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type)
Check the slope of a tile of a new industry.
static const GRFFile * GetIndTileGrffile(IndustryGfx gfx)
Get the associated NewGRF file from the industry graphics.
void TriggerIndustryRandomisation(Industry *ind, IndustryRandomTrigger trigger)
Trigger a random trigger for all industry tiles.
static void DoReseedIndustry(Industry *ind, uint32_t reseed)
Reseeds the random bits of an industry.
uint32_t GetNearbyIndustryTileInformation(uint8_t parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8)
Based on newhouses equivalent, but adapted for newindustries.
NewGRF handling of industry tiles.
@ Parent
Related object of the resolved one.
@ Self
Resolved object itself.
A number of safeguards to prevent using unsafe methods.
Slope
Enumeration for the slope-type.
Definition slope_type.h:53
@ SLOPE_FLAT
a flat tile
Definition slope_type.h:54
@ Leveled
The tile is leveled up to a flat slope.
Definition slope_type.h:121
static PaletteID GetColourPalette(Colours colour)
Get recolour palette for a colour.
Definition sprite.h:221
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:159
PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.
Definition sprite.h:207
static const SpriteID SPR_FLAT_WATER_TILE
Definition sprites.h:685
static constexpr uint8_t SPRITE_MODIFIER_CUSTOM_SPRITE
these masks change the colours of the palette for a sprite.
Definition sprites.h:1732
static constexpr uint8_t SPRITE_WIDTH
number of bits for the sprite number
Definition sprites.h:1722
Definition of base types and functions in a cross-platform compatible way.
Helper class for a unified approach to NewGRF animation.
static void ChangeAnimationFrame(CallbackID cb, const IndustryTileSpec *spec, Industry *obj, TileIndex tile, uint32_t random_bits, uint32_t trigger, int extra_data={})
static void AnimateTile(const IndustryTileSpec *spec, Industry *obj, TileIndex tile, bool random_animation, int extra_data={})
Ground palette sprite of a tile, together with its sprite layout.
Definition sprite.h:76
PalSpriteID ground
Palette and sprite for the ground.
Definition sprite.h:56
const struct GRFFile * grffile
grf file that introduced this entity
uint16_t local_id
id defined by the grf file for this entity
Dynamic data of a loaded NewGRF.
Definition newgrf.h:126
uint8_t grf_version
GRF version (See https://newgrf-specs.tt-wiki.net/wiki/Version_numbers#GRF_version).
Definition newgrf.h:129
Helper class for animation control.
Resolver for industry tiles.
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
IndustriesScopeResolver ind_scope
Scope resolver for the industry owning the tile.
uint32_t GetDebugID() const override
Get an identifier for the item being resolved.
IndustryTileScopeResolver indtile_scope
Scope resolver for the industry tile.
IndustryTileResolverObject(IndustryGfx gfx, TileIndex tile, Industry *indus, CallbackID callback=CBID_NO_CALLBACK, uint32_t callback_param1=0, uint32_t callback_param2=0)
Constructor of the industry tiles scope resolver.
uint32_t GetRandomBits() const override
Get a few random bits.
Industry * industry
Industry owning the tiles.
uint32_t GetVariable(uint8_t variable, uint32_t parameter, bool &available) const override
Get a variable value.
TileIndex tile
Tile being resolved.
uint32_t GetRandomTriggers() const override
Get the triggers.
Defines the data structure of each individual tile of an industry.
IndustryTileSpecialFlags special_flags
Bitmask of extra flags used by the tile.
Slope slopes_refused
slope pattern on which this tile cannot be built
AnimationInfo< IndustryAnimationTriggers > animation
Information about the animation (is it looping, how many loops etc).
SubstituteGRFFileProps grf_prop
properties related to the grf file
IndustryTileCallbackMasks callback_mask
Bitmask of industry tile callbacks that have to be called.
Defines the internal data of a functional industry.
Definition industry.h:64
IndustryType type
type of industry.
Definition industry.h:117
Colours random_colour
randomized colour of the industry, for display purpose
Definition industry.h:119
uint16_t random
Random value used for randomisation of all kinds of things.
Definition industry.h:136
Owner founder
Founder of the industry.
Definition industry.h:128
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
Definition industry.h:253
TileArea location
Location of the industry.
Definition industry.h:108
bool TileBelongsToIndustry(TileIndex tile) const
Check if a given tile belongs to this industry.
Definition industry.h:150
SpriteID sprite
The 'real' sprite.
Definition gfx_type.h:23
PaletteID pal
The palette (use PAL_NONE) if not needed).
Definition gfx_type.h:24
uint32_t callback_param2
Second parameter (var 18) of the callback.
CallbackID callback
Callback being resolved.
uint32_t callback_param1
First parameter (var 10) of the callback.
const SpriteGroup * root_spritegroup
Root SpriteGroup to use for resolving.
ResolverObject & ro
Surrounding resolver object.
Specialization of ResolverObject with type-safe access to RandomTriggers.
const struct SpriteGroup * GetSpriteGroup(bool entity_exists) const
Get the standard sprite group.
bool HasSpriteGroups() const
Check whether the entity has sprite groups.
Tile information, used while rendering the tile.
Definition tile_cmd.h:34
Slope tileh
Slope of the tile.
Definition tile_cmd.h:35
TileIndex tile
Tile index.
Definition tile_cmd.h:36
Action 2 sprite layout for houses, industry tiles, objects and airport tiles.
static bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Definition tile_map.h:150
uint8_t GetAnimationFrame(Tile t)
Get the current animation frame.
Definition tile_map.h:250
bool IsValidTile(Tile tile)
Checks if a tile is valid.
Definition tile_map.h:161
Slope GetTileSlope(TileIndex tile)
Return the slope of a given tile inside the map.
Definition tile_map.h:279
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
@ Industry
Part of an industry.
Definition tile_type.h:57
Base of the town class.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
HouseZone GetTownRadiusGroup(const Town *t, TileIndex tile)
Returns the bit corresponding to the town zone of the specified tile.
@ Industries
industries
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:580
Functions related to water management.
bool IsTileOnWater(Tile t)
Tests if the tile was built on water.
Definition water_map.h:140