OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
21 #include "table/strings.h"
36 if (parameter != 0) tile =
GetNearbyTile(parameter, tile, signed_offsets);
58 return ((y & 0xF) << 20) | ((x & 0xF) << 16) | (y << 8) | x;
81 this->
industry ==
nullptr ? (IndustryID)INVALID_INDUSTRY : this->
industry->
index,
true, this->ro.grffile->grf_version >= 8);
96 DEBUG(grf, 1,
"Unhandled industry tile variable 0x%X", variable);
139 CallbackID callback, uint32 callback_param1, uint32 callback_param2)
141 indtile_scope(*this, indus, tile),
142 ind_scope(*this, tile, indus, indus->type),
150 return GSF_INDUSTRYTILES;
172 DrawWaterClassGround(ti);
181 uint16 GetIndustryTileCallback(
CallbackID callback, uint32 param1, uint32 param2, IndustryGfx gfx_id,
Industry *industry,
TileIndex tile)
187 return object.ResolveCallback();
193 bool draw_old_one =
true;
206 if (group ==
nullptr || group->type != SGT_TILELAYOUT)
return false;
211 IndustryDrawTileLayout(ti, tlgroup, i->
random_colour, stage, gfx);
215 extern bool IsSlopeRefused(
Slope current,
Slope refused);
233 ind.
index = INVALID_INDUSTRY;
237 ind.
random = initial_random_bits;
240 uint16 callback_res = GetIndustryTileCallback(
CBID_INDTILE_SHAPE_CHECK, 0, creation_type << 8 | (uint32)layout_index, gfx, &ind, ind_tile);
256 return GetIndustryTileCallback(callback, param1, param2, spec -
GetIndustryTileSpec(0), ind, tile);
268 void AnimateNewIndustryTile(
TileIndex tile)
271 if (itspec ==
nullptr)
return;
289 uint32 random = Random();
292 if (StartStopIndustryTileAnimation(tile, iat, random)) {
293 SB(random, 0, 16, Random());
324 if (group ==
nullptr)
return;
330 byte new_random_bits = Random();
347 if (reseed == 0 || ind ==
nullptr)
return;
349 uint16 random_bits = Random();
351 ind->
random |= random_bits & reseed;
361 uint32 reseed_industry = 0;
374 uint32 reseed_industry = 0;
Industry * industry
Industry owning the tiles.
uint32 TileIndex
The index/ID of a Tile.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
static IndustryGfx GetIndustryGfx(TileIndex t)
Get the industry graphics ID for the given industry tile.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
Tile information, used while rendering the tile.
@ SPRITE_WIDTH
number of bits for the sprite number
static void DoReseedIndustry(Industry *ind, uint32 reseed)
Reseeds the random bits of an industry.
static void ChangeAnimationFrame(CallbackID cb, const IndustryTileSpec *spec, Industry *obj, TileIndex tile, uint32 random_bits, uint32 trigger, int extra_data=0)
Check a callback to determine what the next animation step is and execute that step.
Tindex index
Index of this pool item.
SpriteID sprite
The 'real' sprite.
Interface for SpriteGroup-s to access the gamestate.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
const GRFFile * grffile
GRFFile the resolved SpriteGroup belongs to.
uint32 GetRandomBits() const override
Get a few random bits.
static const GRFFile * GetIndTileGrffile(IndustryGfx gfx)
Get the associated NewGRF file from the industry graphics.
IndustryAnimationTrigger
Animation triggers of the industries.
const DrawTileSprites * ProcessRegisters(uint8 *stage) const
Process registers and the construction stage into the sprite layout.
@ INDTILE_SPECIAL_NEXTFRAME_RANDOMBITS
Callback 0x26 needs random bits.
@ CBID_INDTILE_ANIM_START_STOP
Called for periodically starting or stopping the animation.
@ CBID_INDTILE_DRAW_FOUNDATIONS
Called to determine the type (if any) of foundation to draw for industry tile.
static void AnimateTile(const IndustryTileSpec *spec, Industry *obj, TileIndex tile, bool random_animation, int extra_data=0)
Animate a single tile.
@ MP_INDUSTRY
Part of an industry.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
static void SetIndustryRandomBits(TileIndex tile, byte bits)
Set the random bits for this tile.
CallbackID
List of implemented NewGRF callbacks.
@ VSG_SCOPE_PARENT
Related object of the resolved one.
Defines the internal data of a functional industry.
bool ConvertBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
Converts a callback result into a boolean.
Owner
Enum for all companies/owners.
void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
Trigger a random trigger for all industry tiles.
uint32 reseed[VSG_END]
Collects bits to rerandomise while triggering triggers.
@ VSG_SCOPE_SELF
Resolved object itself.
static uint TileX(TileIndex tile)
Get the X component of a tile.
HouseZonesBits GetTownRadiusGroup(const Town *t, TileIndex tile)
Returns the bit corresponding to the town zone of the specified tile.
Slope tileh
Slope of the tile.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
static bool IsTileOnWater(TileIndex t)
Tests if the tile was built on water.
PalSpriteID ground
Palette and sprite for the ground.
IndustryTileSpecialFlags special_flags
Bitmask of extra flags used by the tile.
static byte GetAnimationFrame(TileIndex t)
Get the current animation frame.
static void DrawNewGRFTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, uint32 stage, PaletteID default_palette)
Draw NewGRF industrytile or house sprite layout.
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
Common return value for all commands.
uint16 random
Random value used for randomisation of all kinds of things.
TileArea location
Location of the industry.
#define TILE_AREA_LOOP(var, ta)
A loop which iterates over the tiles of a TileArea.
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
IndustryType type
type of industry.
Resolver for industry tiles.
#define DEBUG(name, level,...)
Output a line of debugging information.
const SpriteGroup * root_spritegroup
Root SpriteGroup to use for resolving.
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
uint16 w
The width of the area.
@ CBM_INDT_DRAW_FOUNDATIONS
decides if default foundations need to be drawn
static void DoTriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger, Industry *ind, uint32 &reseed_industry)
Trigger random triggers for an industry tile and reseed its random bits.
CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, size_t layout_index, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type)
Check the slope of a tile of a new industry.
uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override
Get a variable value.
CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, const GRFFile *grffile, StringID default_error)
Get the error message from a shape/location/slope check callback result.
IndustryTileResolverObject(IndustryGfx gfx, TileIndex tile, Industry *indus, CallbackID callback=CBID_NO_CALLBACK, uint32 callback_param1=0, uint32 callback_param2=0)
Constructor of the industry tiles scope resolver.
uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8)
Based on newhouses equivalent, but adapted for newindustries.
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
Slope slopes_refused
slope pattern on which this tile cannot be built
Slope GetTileSlope(TileIndex tile, int *h)
Return the slope of a given tile inside the map.
@ SPRITE_MODIFIER_CUSTOM_SPRITE
Set when a sprite originates from an Action 1.
Ground palette sprite of a tile, together with its sprite layout.
uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8)
Common part of station var 0x67, house var 0x62, indtile var 0x60, industry var 0x62.
IndustryAvailabilityCallType
From where has callback CBID_INDUSTRY_PROBABILITY been called.
Slope
Enumeration for the slope-type.
uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile)
This is the position of the tile relative to the northernmost tile of the industry.
static byte GetIndustryConstructionStage(TileIndex tile)
Returns the industry construction stage of the specified tile.
GRFFileProps grf_prop
properties related to the grf file
uint32 GetIndustryIDAtOffset(TileIndex tile, const Industry *i, uint32 cur_grfid)
Make an analysis of a tile and check for its belonging to the same industry, and/or the same grf file...
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
@ CBM_INDT_ANIM_NEXT_FRAME
decides next animation frame
@ TO_INDUSTRIES
industries
static PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.
Helper class for animation control.
@ CBM_INDT_ANIM_SPEED
decides animation speed
void DrawFoundation(TileInfo *ti, Foundation f)
Draw foundation f at tile ti.
@ CBID_INDTILE_ANIM_NEXT_FRAME
Called to determine industry tile next animation frame.
virtual const SpriteGroup * Resolve(ResolverObject &object) const
Base sprite group resolver.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
const struct SpriteGroup * spritegroup[Tcnt]
pointer to the different sprites of the entity
AnimationInfo animation
Information about the animation (is it looping, how many loops etc)
Owner founder
Founder of the industry.
const IndustryTileSpec * GetIndustryTileSpec(IndustryGfx gfx)
Accessor for array _industry_tile_specs.
TileIndex tile
The base tile of the area.
uint32 PaletteID
The number of the palette.
IndustryTileCallbackMask
Callback masks for industry tiles.
static IndustryID GetIndustryIndex(TileIndex t)
Get the industry ID of the given tile.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
@ FOUNDATION_LEVELED
The tile is leveled up to a flat slope.
void TriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger)
Trigger a random trigger for a single industry tile.
static byte GetIndustryTriggers(TileIndex tile)
Get the activated triggers bits for this industry tile Used for grf callbacks.
uint16 triggers
The triggers that trigger animation.
uint8 callback_mask
Bitmask of industry tile callbacks that have to be called.
Helper class for a unified approach to NewGRF animation.
byte random_colour
randomized colour of the industry, for display purpose
TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets, Axis axis)
Get the tile at the given offset.
uint32 GetTriggers() const override
Get the triggers.
TileIndex tile
Tile being resolved.
static byte GetIndustryRandomBits(TileIndex tile)
Get the random bits for this tile.
static void SetIndustryTriggers(TileIndex tile, byte triggers)
Set the activated triggers bits for this industry tile Used for grf callbacks.
uint16 local_id
id defined by the grf file for this entity
PaletteID pal
The palette (use PAL_NONE) if not needed)
TileIndex tile
Tile index.
@ CBID_RANDOM_TRIGGER
Set when calling a randomizing trigger (almost undocumented).
ResolverObject & ro
Surrounding resolver object.
const struct GRFFile * grffile
grf file that introduced this entity
@ CBID_INDTILE_ANIMATION_SPEED
Called to indicate how long the current animation frame should last.
Defines the data structure of each individual tile of an industry.
IndustryTileTrigger
Available industry tile triggers.
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.
uint32 GetTerrainType(TileIndex tile, TileContext context)
Function used by houses (and soon industries) to get information on type of "terrain" the tile it is ...
Dynamic data of a loaded NewGRF.
@ CBID_INDTILE_SHAPE_CHECK
Called to determine if the given industry tile can be built on specific tile.
Action 2 sprite layout for houses, industry tiles, objects and airport tiles.
uint32 GetDebugID() const override
Get an identifier for the item being resolved.
bool TileBelongsToIndustry(TileIndex tile) const
Check if a given tile belongs to this industry.