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"

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.
uint32 GetRelativePosition (TileIndex tile, TileIndex ind_tile)
 This is the position of the tile relative to the northernmost tile of the industry.
static uint32 IndustryTileGetVariable (const ResolverObject *object, byte variable, uint32 parameter, bool *available)
static const SpriteGroupIndustryTileResolveReal (const ResolverObject *object, const RealSpriteGroup *group)
static uint32 IndustryTileGetRandomBits (const ResolverObject *object)
static uint32 IndustryTileGetTriggers (const ResolverObject *object)
static void IndustryTileSetTriggers (const ResolverObject *object, int triggers)
void IndustryTileStorePSA (ResolverObject *object, uint pos, int32 value)
 Store a value into the persistent storage of the object's parent.
static void NewIndustryTileResolver (ResolverObject *res, IndustryGfx gfx, TileIndex tile, Industry *indus)
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.
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.
static void DoReseedIndustry (Industry *ind, uint32 reseed)
 Reseeds the random bits of an industry.
void TriggerIndustryTile (TileIndex tile, IndustryTileTrigger trigger)
 Trigger a random trigger for a single industry tile.
void TriggerIndustry (Industry *ind, IndustryTileTrigger trigger)
 Trigger a random trigger for all industry tiles.
void GetIndustryTileResolver (ResolverObject *ro, uint index)
 Resolve a industry tile's spec and such so we can get a variable.

Detailed Description

NewGRF handling of industry tiles.

Definition in file newgrf_industrytiles.cpp.


Function Documentation

static void DoReseedIndustry ( Industry ind,
uint32  reseed 
) [static]

Reseeds the random bits of an industry.

Parameters:
ind Industry.
reseed Bits to reseed.

Definition at line 397 of file newgrf_industrytiles.cpp.

References Industry::random.

Referenced by TriggerIndustry(), and TriggerIndustryTile().

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:
tile Industry tile to trigger.
trigger Trigger to trigger.
ind Industry of the tile.
[in,out] reseed_industry Collects bits to reseed for the industry.

Definition at line 363 of file newgrf_industrytiles.cpp.

References GetIndustryGfx(), GetIndustryRandomBits(), GetIndustryTileSpec(), IndustryTileSpec::grf_prop, IsTileType(), IsValidTile(), MarkTileDirtyByTile(), MP_INDUSTRY, ResolverObject::reseed, SpriteGroup::Resolve(), SetIndustryRandomBits(), and GRFFilePropsBase< Tcnt >::spritegroup.

Referenced by TriggerIndustry(), and TriggerIndustryTile().

void GetIndustryTileResolver ( ResolverObject ro,
uint  index 
)

Resolve a industry tile's spec and such so we can get a variable.

Parameters:
ro The resolver object to fill.
index The industry tile to get the data from.

Definition at line 440 of file newgrf_industrytiles.cpp.

References Industry::GetByTile(), and GetIndustryGfx().

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

Based on newhouses equivalent, but adapted for newindustries.

Parameters:
parameter from callback. It's in fact a pair of coordinates
tile TileIndex from which the callback was initiated
index of the industry been queried for
signed_offsets Are the x and y offset encoded in parameter signed?
grf_version8 True, 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 34 of file newgrf_industrytiles.cpp.

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

Referenced by IndustryGetVariable().

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:
tile TileIndex of the tile to evaluate
ind_tile northernmost tile of the industry

Definition at line 53 of file newgrf_industrytiles.cpp.

References TileX(), and TileY().

void IndustryTileStorePSA ( ResolverObject object,
uint  pos,
int32  value 
)
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_tile Base tile of the industry.
ind_tile Tile to check.
its Tile specification.
type Industry type.
gfx Gfx of the tile.
itspec_index Layout.
initial_random_bits Random bits of industry after construction
founder Industry founder
creation_type The circumstances the industry is created under.
Returns:
Suceeded or failed command.

Definition at line 283 of file newgrf_industrytiles.cpp.

References CALLBACK_FAILED, CBID_INDTILE_SHAPE_CHECK, Industry::founder, GetErrorMessageFromLocationCallbackResult(), GetTileSlope(), IndustryTileSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Industry::location, Industry::random, return_cmd_error, IndustryTileSpec::slopes_refused, TileArea::tile, Industry::type, and TileArea::w.

Referenced by CheckIfIndustryTilesAreFree().

void TriggerIndustry ( Industry ind,
IndustryTileTrigger  trigger 
)

Trigger a random trigger for all industry tiles.

Parameters:
ind Industry to trigger.
trigger Trigger to trigger.

Definition at line 424 of file newgrf_industrytiles.cpp.

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

Referenced by TriggerIndustryProduction().

void TriggerIndustryTile ( TileIndex  tile,
IndustryTileTrigger  trigger 
)

Trigger a random trigger for a single industry tile.

Parameters:
tile Industry tile to trigger.
trigger Trigger to trigger.

Definition at line 411 of file newgrf_industrytiles.cpp.

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