Functions for NewGRF industries. More...
#include "command_type.h"
#include "company_type.h"
#include "newgrf_spritegroup.h"
Go to the source code of this file.
Enumerations | |
enum | IndustryTrigger { INDUSTRY_TRIGGER_TILELOOP_PROCESS = 1, INDUSTRY_TRIGGER_256_TICKS = 2, INDUSTRY_TRIGGER_CARGO_DELIVERY = 4 } |
When should the industry(tile) be triggered for random bits? More... | |
enum | IndustryAvailabilityCallType { IACT_MAPGENERATION, IACT_RANDOMCREATION, IACT_USERCREATION, IACT_PROSPECTCREATION } |
From where is callback CBID_INDUSTRY_AVAILABLE been called. More... | |
Functions | |
uint32 | IndustryGetVariable (const ResolverObject *object, byte variable, byte parameter, bool *available) |
This function implements the industries variables that newGRF defines. | |
uint16 | GetIndustryCallback (CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile) |
uint32 | GetIndustryIDAtOffset (TileIndex new_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. | |
void | IndustryProductionCallback (Industry *ind, int reason) |
Get the industry production callback and apply it to the industry. | |
CommandCost | CheckIfCallBackAllowsCreation (TileIndex tile, IndustryType type, uint layout, uint32 seed, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type) |
Check that the industry callback allows creation of the industry. | |
bool | CheckIfCallBackAllowsAvailability (IndustryType type, IndustryAvailabilityCallType creation_type) |
Check with callback CBM_IND_AVAILABLE whether the industry can be built. | |
bool | IndustryTemporarilyRefusesCargo (Industry *ind, CargoID cargo_type) |
Check whether an industry temporarily refuses to accept a certain cargo. | |
IndustryType | MapNewGRFIndustryType (IndustryType grf_type, uint32 grf_id) |
uint32 | GetNearbyIndustryTileInformation (byte parameter, TileIndex tile, IndustryID index, bool signed_offsets=true) |
Based on newhouses equivalent, but adapted for newindustries. |
Functions for NewGRF industries.
Definition in file newgrf_industries.h.
From where is callback CBID_INDUSTRY_AVAILABLE been called.
Definition at line 30 of file newgrf_industries.h.
enum IndustryTrigger |
When should the industry(tile) be triggered for random bits?
INDUSTRY_TRIGGER_TILELOOP_PROCESS |
Triggered each tile loop. |
INDUSTRY_TRIGGER_256_TICKS |
Triggered (whole industry) each 256 ticks. |
INDUSTRY_TRIGGER_CARGO_DELIVERY |
Triggered on cargo delivery. |
Definition at line 20 of file newgrf_industries.h.
bool CheckIfCallBackAllowsAvailability | ( | IndustryType | type, | |
IndustryAvailabilityCallType | creation_type | |||
) |
Check with callback CBM_IND_AVAILABLE whether the industry can be built.
type | Industry type to check. | |
creation_type | Reason to construct a new industry. |
true
is returned. Otherwise, false
is returned. Definition at line 515 of file newgrf_industries.cpp.
References CALLBACK_FAILED, IndustrySpec::callback_mask, CBID_INDUSTRY_AVAILABLE, CBM_IND_AVAILABLE, GetIndustrySpec(), HasBit(), and INVALID_TILE.
Referenced by AIIndustryType::CanBuildIndustry(), AIIndustryType::CanProspectIndustry(), CmdBuildIndustry(), GetIndustryGamePlayProbability(), GetScaledIndustryGenerationProbability(), and BuildIndustryWindow::OnTick().
CommandCost CheckIfCallBackAllowsCreation | ( | TileIndex | tile, | |
IndustryType | type, | |||
uint | layout, | |||
uint32 | seed, | |||
uint16 | initial_random_bits, | |||
Owner | founder, | |||
IndustryAvailabilityCallType | creation_type | |||
) |
Check that the industry callback allows creation of the industry.
tile | Tile to build the industry. | |
type | Type of industry to build. | |
layout | Layout number. | |
seed | Seed for the random generator. | |
initial_random_bits | The random bits the industry is going to have after construction. | |
founder | Industry founder | |
creation_type | The circumstances the industry is created under. |
Definition at line 464 of file newgrf_industries.cpp.
References CALLBACK_FAILED, CBID_INDUSTRY_LOCATION, ClosestTownFromTile(), Industry::founder, GetGRFStringID(), GetIndustrySpec(), IndustrySpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, Industry::location, PrepareTextRefStackUsage(), Industry::random, SpriteGroup::Resolve(), return_cmd_error, Industry::selected_layout, TileArea::tile, Industry::town, Industry::type, and TileArea::w.
Referenced by CreateNewIndustryHelper().
Make an analysis of a tile and check for its belonging to the same industry, and/or the same grf file.
tile | TileIndex of the tile to query | |
i | Industry to which to compare the tile to | |
cur_grfid | GRFID of the current callback chain |
Definition at line 54 of file newgrf_industries.cpp.
References GetCleanIndustryGfx(), GetIndustryIndex(), GetIndustryTileSpec(), IndustryTileSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_INDUSTRYTILE, IsTileType(), GRFFilePropsBase< Tcnt >::local_id, MP_INDUSTRY, NEW_INDUSTRYTILEOFFSET, GRFFileProps::override, and GRFFilePropsBase< Tcnt >::spritegroup.
Referenced by IndustryGetVariable().
uint32 GetNearbyIndustryTileInformation | ( | byte | parameter, | |
TileIndex | tile, | |||
IndustryID | index, | |||
bool | signed_offsets | |||
) |
Based on newhouses equivalent, but adapted for newindustries.
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? |
Definition at line 38 of file newgrf_industrytiles.cpp.
References GetIndustryIndex(), GetNearbyTileInformation(), IsTileType(), and MP_INDUSTRY.
Referenced by IndustryGetVariable().
uint32 IndustryGetVariable | ( | const ResolverObject * | object, | |
byte | variable, | |||
byte | parameter, | |||
bool * | available | |||
) |
This function implements the industries variables that newGRF defines.
object | the object that we want to query | |
variable | that is queried | |
parameter | unused | |
available | will return false if ever the variable asked for does not exist |
Definition at line 166 of file newgrf_industries.cpp.
References Industry::accepts_cargo, IndustrySpec::behaviour, IndustrySpec::callback_mask, CBM_IND_PRODUCTION_256_TICKS, CBM_IND_PRODUCTION_CARGO_ARRIVAL, Clamp(), ClosestTownFromTile(), Livery::colour1, Livery::colour2, Industry::construction_date, Industry::construction_type, Industry::counter, DAYS_TILL_ORIGINAL_BASE_YEAR, DEBUG, DistanceManhattan(), DistanceSquare(), Industry::founder, GB(), GetAnimationFrame(), Industry::GetByTile(), GetClosestWaterDistance(), GetCountAndDistanceOfClosestInstance(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), GetIndustryIDAtOffset(), GetIndustryRandomBits(), GetIndustrySpec(), GetNearbyIndustryTileInformation(), GetRegister(), GetTownRadiusGroup(), IndustrySpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, ResolverObject::grffile, TileArea::h, HasBit(), Industry::incoming_cargo_waiting, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INDUSTRYBEH_BUILT_ONWATER, INDUSTRYBEH_PROD_MULTI_HNDLING, INVALID_INDUSTRYTILE, INVALID_TILE, CompanyProperties::is_ai, IsTileType(), Industry::last_cargo_accepted_at, Industry::last_month_pct_transported, Industry::last_month_production, Industry::last_month_transported, Industry::last_prod_year, Industry::location, min(), MP_INDUSTRY, ORIGINAL_BASE_YEAR, Industry::prod_level, Industry::produced_cargo, Industry::produced_cargo_waiting, Industry::production_rate, Industry::psa, Industry::random_colour, ResolverObject::scope, Industry::selected_layout, Industry::this_month_production, Industry::this_month_transported, TileArea::tile, Industry::town, TownGetVariable(), Industry::type, TileArea::w, and Industry::was_cargo_delivered.
void IndustryProductionCallback | ( | Industry * | ind, | |
int | reason | |||
) |
Get the industry production callback and apply it to the industry.
ind | the industry this callback has to be called for | |
reason | the reason it is called (0 = incoming cargo, 1 = periodic tick callback) |
Definition at line 538 of file newgrf_industries.cpp.
References IndustrySpec::behaviour, Clamp(), GetIndustrySpec(), IndustrySpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, Industry::incoming_cargo_waiting, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INDUSTRYBEH_PROD_MULTI_HNDLING, INDUSTRYBEH_PRODCALLBACK_RANDOM, Industry::location, max(), IndustrySpec::name, Industry::prod_level, Industry::produced_cargo_waiting, SpriteGroup::Resolve(), SB(), SetDParam(), SetDParamStr(), SetWindowDirty(), ShowErrorMessage(), GRFFilePropsBase< Tcnt >::spritegroup, TileArea::tile, Industry::type, and WL_WARNING.
Referenced by TriggerIndustryProduction().
Check whether an industry temporarily refuses to accept a certain cargo.
ind | The industry to query. | |
cargo_type | The cargo to get information about. |
Definition at line 602 of file newgrf_industries.cpp.
References Industry::accepts_cargo, IndustrySpec::callback_mask, CBID_INDUSTRY_REFUSE_CARGO, CBM_IND_REFUSE_CARGO, GetIndustrySpec(), IndustrySpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, HasBit(), Industry::location, TileArea::tile, and Industry::type.
Referenced by CanCargoServiceIndustry(), DeliverGoodsToIndustry(), and AIIndustry::IsCargoAccepted().