OpenTTD
Data Structures | Functions
newgrf_industrytiles.cpp File Reference

NewGRF handling of industry tiles. More...

#include "stdafx.h"
#include "debug.h"
#include "landscape.h"
#include "newgrf_industrytiles.h"
#include "newgrf_sound.h"
#include "industry.h"
#include "town.h"
#include "command_func.h"
#include "water.h"
#include "newgrf_animation_base.h"
#include "table/strings.h"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

struct  IndustryAnimationBase
 Helper class for animation control. More...
 

Functions

uint32 GetNearbyIndustryTileInformation (byte parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8)
 Based on newhouses equivalent, but adapted for newindustries. More...
 
uint32 GetRelativePosition (TileIndex tile, TileIndex ind_tile)
 This is the position of the tile relative to the northernmost tile of the industry. More...
 
static const GRFFileGetIndTileGrffile (IndustryGfx gfx)
 Get the associated NewGRF file from the industry graphics. More...
 
static void IndustryDrawTileLayout (const TileInfo *ti, const TileLayoutSpriteGroup *group, byte rnd_colour, byte stage, IndustryGfx gfx)
 
uint16 GetIndustryTileCallback (CallbackID callback, uint32 param1, uint32 param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile)
 
bool DrawNewIndustryTile (TileInfo *ti, Industry *i, IndustryGfx gfx, const IndustryTileSpec *inds)
 
bool IsSlopeRefused (Slope current, Slope refused)
 
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. More...
 
uint16 GetSimpleIndustryCallback (CallbackID callback, uint32 param1, uint32 param2, const IndustryTileSpec *spec, Industry *ind, TileIndex tile, int extra_data)
 
void AnimateNewIndustryTile (TileIndex tile)
 
bool StartStopIndustryTileAnimation (TileIndex tile, IndustryAnimationTrigger iat, uint32 random)
 
bool StartStopIndustryTileAnimation (const Industry *ind, IndustryAnimationTrigger iat)
 
static void DoTriggerIndustryTile (TileIndex tile, IndustryTileTrigger trigger, Industry *ind, uint32 &reseed_industry)
 Trigger random triggers for an industry tile and reseed its random bits. More...
 
static void DoReseedIndustry (Industry *ind, uint32 reseed)
 Reseeds the random bits of an industry. More...
 
void TriggerIndustryTile (TileIndex tile, IndustryTileTrigger trigger)
 Trigger a random trigger for a single industry tile. More...
 
void TriggerIndustry (Industry *ind, IndustryTileTrigger trigger)
 Trigger a random trigger for all industry tiles. More...
 

Detailed Description

NewGRF handling of industry tiles.

Definition in file newgrf_industrytiles.cpp.

Function Documentation

◆ DoReseedIndustry()

static void DoReseedIndustry ( Industry ind,
uint32  reseed 
)
static

Reseeds the random bits of an industry.

Parameters
indIndustry.
reseedBits to reseed.

Definition at line 336 of file newgrf_industrytiles.cpp.

Referenced by TriggerIndustry(), and TriggerIndustryTile().

◆ DoTriggerIndustryTile()

static void DoTriggerIndustryTile ( TileIndex  tile,
IndustryTileTrigger  trigger,
Industry ind,
uint32 &  reseed_industry 
)
static

Trigger random triggers for an industry tile and reseed its random bits.

Parameters
tileIndustry tile to trigger.
triggerTrigger to trigger.
indIndustry of the tile.
[in,out]reseed_industryCollects bits to reseed for the industry.

Definition at line 301 of file newgrf_industrytiles.cpp.

Referenced by TriggerIndustry(), and TriggerIndustryTile().

◆ GetIndTileGrffile()

static const GRFFile* GetIndTileGrffile ( IndustryGfx  gfx)
static

Get the associated NewGRF file from the industry graphics.

Parameters
gfxGraphics to query.
Returns
Grf file associated with the graphics, if any.

Definition at line 125 of file newgrf_industrytiles.cpp.

References GetIndustryTileSpec(), IndustryTileSpec::grf_prop, and GRFFilePropsBase< Tcnt >::grffile.

◆ GetNearbyIndustryTileInformation()

uint32 GetNearbyIndustryTileInformation ( byte  parameter,
TileIndex  tile,
IndustryID  index,
bool  signed_offsets,
bool  grf_version8 
)

Based on newhouses equivalent, but adapted for newindustries.

Parameters
parameterfrom callback. It's in fact a pair of coordinates
tileTileIndex from which the callback was initiated
indexof the industry been queried for
signed_offsetsAre the x and y offset encoded in parameter signed?
grf_version8True, if we are dealing with a new NewGRF which uses GRF version >= 8.
Returns
a construction of bits obeying the newgrf format

Definition at line 36 of file newgrf_industrytiles.cpp.

References GetIndustryIndex(), GetNearbyTile(), GetNearbyTileInformation(), IsTileType(), and MP_INDUSTRY.

Referenced by IndustryTileScopeResolver::GetVariable().

◆ GetRelativePosition()

uint32 GetRelativePosition ( TileIndex  tile,
TileIndex  ind_tile 
)

This is the position of the tile relative to the northernmost tile of the industry.

Format: 00yxYYXX Variable Content x the x offset from the northernmost tile XX same, but stored in a byte instead of a nibble y the y offset from the northernmost tile YY same, but stored in a byte instead of a nibble

Parameters
tileTileIndex of the tile to evaluate
ind_tilenorthernmost tile of the industry

Definition at line 55 of file newgrf_industrytiles.cpp.

Referenced by IndustryTileScopeResolver::GetVariable().

◆ PerformIndustryTileSlopeCheck()

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.

Parameters
ind_base_tileBase tile of the industry.
ind_tileTile to check.
itsTile specification.
typeIndustry type.
gfxGfx of the tile.
itspec_indexLayout.
initial_random_bitsRandom bits of industry after construction
founderIndustry founder
creation_typeThe circumstances the industry is created under.
Returns
Succeeded or failed command.

Definition at line 221 of file newgrf_industrytiles.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index.

Referenced by CheckIfIndustryTilesAreFree().

◆ TriggerIndustry()

void TriggerIndustry ( Industry ind,
IndustryTileTrigger  trigger 
)

Trigger a random trigger for all industry tiles.

Parameters
indIndustry to trigger.
triggerTrigger to trigger.

Definition at line 363 of file newgrf_industrytiles.cpp.

References DoReseedIndustry(), DoTriggerIndustryTile(), Industry::location, TILE_AREA_LOOP, and Industry::TileBelongsToIndustry().

Referenced by TriggerIndustryProduction().

◆ TriggerIndustryTile()

void TriggerIndustryTile ( TileIndex  tile,
IndustryTileTrigger  trigger 
)

Trigger a random trigger for a single industry tile.

Parameters
tileIndustry tile to trigger.
triggerTrigger to trigger.

Definition at line 350 of file newgrf_industrytiles.cpp.

References DoReseedIndustry(), DoTriggerIndustryTile(), and Industry::GetByTile().