23 #include "table/strings.h" 38 if (parameter != 0) tile =
GetNearbyTile(parameter, tile, signed_offsets);
60 return ((y & 0xF) << 20) | ((x & 0xF) << 16) | (y << 8) | x;
83 this->
industry == NULL ? (IndustryID)INVALID_INDUSTRY : this->
industry->
index,
true, this->ro.grffile->grf_version >= 8);
98 DEBUG(grf, 1,
"Unhandled industry tile variable 0x%X", variable);
141 CallbackID callback, uint32 callback_param1, uint32 callback_param2)
143 indtile_scope(*this, indus, tile),
144 ind_scope(*this, tile, indus, indus->type)
163 DrawWaterClassGround(ti);
178 return object.ResolveCallback();
184 bool draw_old_one =
true;
197 if (group == NULL || group->type != SGT_TILELAYOUT)
return false;
202 IndustryDrawTileLayout(ti, tlgroup, i->
random_colour, stage, gfx);
206 extern bool IsSlopeRefused(
Slope current,
Slope refused);
224 ind.
index = INVALID_INDUSTRY;
228 ind.
random = initial_random_bits;
231 uint16 callback_res = GetIndustryTileCallback(
CBID_INDTILE_SHAPE_CHECK, 0, creation_type << 8 | itspec_index, gfx, &ind, ind_tile);
259 void AnimateNewIndustryTile(
TileIndex tile)
262 if (itspec == NULL)
return;
280 uint32 random = Random();
283 if (StartStopIndustryTileAnimation(tile, iat, random)) {
284 SB(random, 0, 16, Random());
315 if (group == NULL)
return;
321 byte new_random_bits = Random();
338 if (reseed == 0 || ind == NULL)
return;
340 uint16 random_bits = Random();
352 uint32 reseed_industry = 0;
365 uint32 reseed_industry = 0;
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 PaletteID
The number of the palette.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Tile information, used while rendering the tile.
IndustryAnimationTrigger
Animation triggers of the industries.
uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile)
This is the position of the tile relative to the northernmost tile of the industry.
uint16 triggers
The triggers that trigger animation.
ResolverObject & ro
Surrounding resolver object.
OwnerByte founder
Founder of the industry.
static byte GetAnimationFrame(TileIndex t)
Get the current animation frame.
Functions related to debugging.
Called to determine if the given industry tile can be built on specific tile.
static void DrawNewGRFTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, uint32 stage, PaletteID default_palette)
Draw NewGRF industrytile or house sprite layout.
Interface for SpriteGroup-s to access the gamestate.
uint32 GetTerrainType(TileIndex tile, TileContext context)
Function used by houses (and soon industries) to get information on type of "terrain" the tile it is ...
Slope tileh
Slope of the tile.
static IndustryGfx GetIndustryGfx(TileIndex t)
Get the industry graphics ID for the given industry tile.
static void DoTriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger, Industry *ind, uint32 &reseed_industry)
Trigger random triggers for an industry tile and reseed its random bits.
Called for periodically starting or stopping the animation.
static uint TileX(TileIndex tile)
Get the X component of a tile.
CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type)
Check the slope of a tile of a new industry.
Defines the internal data of a functional industry.
Tindex index
Index of this pool item.
uint16 random
Random value used for randomisation of all kinds of things.
Common return value for all commands.
Called to indicate how long the current animation frame should last.
uint32 reseed[VSG_END]
Collects bits to rerandomise while triggering triggers.
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.
uint16 w
The width of the area.
CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, const GRFFile *grffile, StringID default_error)
Get the error message from a shape/location/slope check callback result.
byte random_colour
randomized colour of the industry, for display purpose
static void AnimateTile(const IndustryTileSpec *spec, Industry *obj, TileIndex tile, bool random_animation, int extra_data=0)
Animate a single tile.
void DrawFoundation(TileInfo *ti, Foundation f)
Draw foundation f at tile ti.
static void SetIndustryRandomBits(TileIndex tile, byte bits)
Set the random bits for this tile.
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.
IndustryTileSpecialFlags special_flags
Bitmask of extra flags used by the tile.
const SpriteGroup * root_spritegroup
Root SpriteGroup to use for resolving.
Slope GetTileSlope(TileIndex tile, int *h)
Return the slope of a given tile inside the map.
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
Slope slopes_refused
slope pattern on which this tile cannot be built
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold...
Resolver for industry tiles.
virtual const SpriteGroup * Resolve(ResolverObject &object) const
Base sprite group resolver.
TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets, Axis axis)
Get the tile at the given offset.
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a give tiletype.
const DrawTileSprites * ProcessRegisters(uint8 *stage) const
Process registers and the construction stage into the sprite layout.
TileIndex tile
Tile index.
The tile is leveled up to a flat slope.
Ground palette sprite of a tile, together with its sprite layout.
IndustryTileTrigger
Available industry tile triggers.
static byte GetIndustryConstructionStage(TileIndex tile)
Returns the industry construction stage of the specified tile.
decides if default foundations need to be drawn
bool ConvertBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
Converts a callback result into a boolean.
Called to determine the type (if any) of foundation to draw for industry tile.
IndustryTileCallbackMask
Callback masks for industry tiles.
uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8)
Based on newhouses equivalent, but adapted for newindustries.
#define TILE_AREA_LOOP(var, ta)
A loop which iterates over the tiles of a TileArea.
Definition of base types and functions in a cross-platform compatible way.
Function implementations related to NewGRF animation.
void TriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger)
Trigger a random trigger for a single industry tile.
A number of safeguards to prevent using unsafe methods.
IndustryType type
type of industry.
uint32 waiting_triggers
Waiting triggers to be used by any rerandomisation. (scope independent)
static PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.
uint32 GetRandomBits() const
Get a few random bits.
TileArea location
Location of the industry.
static void DoReseedIndustry(Industry *ind, uint32 reseed)
Reseeds the random bits of an industry.
Set when a sprite originates from an Action 1.
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...
uint32 GetVariable(byte variable, uint32 parameter, bool *available) const
Get a variable value.
GRFFileProps grf_prop
properties related to the grf file
const IndustryTileSpec * GetIndustryTileSpec(IndustryGfx gfx)
Accessor for array _industry_tile_specs.
IndustryAvailabilityCallType
From where has callback CBID_INDUSTRY_PROBABILITY been called.
Industry * industry
Industry owning the tiles.
number of bits for the sprite number
HouseZonesBits GetTownRadiusGroup(const Town *t, TileIndex tile)
Returns the bit corresponding to the town zone of the specified tile.
NewGRF handling of industry tiles.
const struct SpriteGroup * spritegroup[Tcnt]
pointer to the different sprites of the entity
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
#define DEBUG(name, level,...)
Output a line of debugging information.
uint8 callback_mask
Bitmask of industry tile callbacks that have to be called.
TileIndex tile
The base tile of the area.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset)
Mark a tile given by its index dirty for repaint.
const GRFFile * grffile
GRFFile the resolved SpriteGroup belongs to.
void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
Trigger a random trigger for all industry tiles.
Helper class for animation control.
PalSpriteID ground
Palette and sprite for the ground.
TileIndex tile
Tile being resolved.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8)
Common part of station var 0x67, house var 0x62, indtile var 0x60, industry var 0x62.
uint32 TileIndex
The index/ID of a Tile.
Helper class for a unified approach to NewGRF animation.
AnimationInfo animation
Information about the animation (is it looping, how many loops etc)
Called to determine industry tile next animation frame.
uint32 GetRemainingTriggers() const
Returns the waiting triggers that did not trigger any rerandomisation.
static IndustryID GetIndustryIndex(TileIndex t)
Get the industry ID of the given tile.
Related object of the resolved one.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
decides next animation frame
CallbackID callback
Callback being resolved.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Slope
Enumeration for the slope-type.
static byte GetIndustryRandomBits(TileIndex tile)
Get the random bits for this tile.
Functions related to OTTD's landscape.
Functions related to commands.
Callback 0x26 needs random bits.
static void SetIndustryTriggers(TileIndex tile, byte triggers)
Set the activated triggers bits for this industry tile Used for grf callbacks.
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.
static const GRFFile * GetIndTileGrffile(IndustryGfx gfx)
Get the associated NewGRF file from the industry graphics.
const struct GRFFile * grffile
grf file that introduced this entity
CallbackID
List of implemented NewGRF callbacks.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Functions related to NewGRF provided sounds.
Set when calling a randomizing trigger (almost undocumented).
bool TileBelongsToIndustry(TileIndex tile) const
Check if a given tile belongs to this industry.
Defines the data structure of each individual tile of an industry.
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
Owner
Enum for all companies/owners.
static byte GetIndustryTriggers(TileIndex tile)
Get the activated triggers bits for this industry tile Used for grf callbacks.
Functions related to water (management)
static bool IsTileOnWater(TileIndex t)
Tests if the tile was built on water.
SpriteID sprite
The 'real' sprite.
Action 2 sprite layout for houses, industry tiles, objects and airport tiles.
uint32 GetTriggers() const
Get the triggers.
Dynamic data of a loaded NewGRF.
PaletteID pal
The palette (use PAL_NONE) if not needed)