|
OpenTTD
|
Functions for NewGRF industries. More...
#include "newgrf_town.h"Go to the source code of this file.
Data Structures | |
| struct | IndustriesScopeResolver |
| Resolver for industry scopes. More... | |
| struct | IndustriesResolverObject |
| Resolver for industries. More... | |
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 has callback CBID_INDUSTRY_PROBABILITY been called. More... | |
Functions | |
| uint16 | GetIndustryCallback (CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile) |
| Perform an industry callback. | |
| 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. | |
| uint32 | GetIndustryProbabilityCallback (IndustryType type, IndustryAvailabilityCallType creation_type, uint32 default_prob) |
| Check with callback CBID_INDUSTRY_PROBABILITY 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) |
| Map the GRF local type to an industry type. | |
| uint32 | GetNearbyIndustryTileInformation (byte parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8) |
| Based on newhouses equivalent, but adapted for newindustries. | |
Functions for NewGRF industries.
Definition in file newgrf_industries.h.
From where has callback CBID_INDUSTRY_PROBABILITY been called.
Definition at line 69 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 59 of file newgrf_industries.h.
| 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 510 of file newgrf_industries.cpp.
References CALLBACK_FAILED, CBID_INDUSTRY_LOCATION, ClosestTownFromTile(), Industry::founder, GetErrorMessageFromLocationCallbackResult(), GetIndustrySpec(), IndustrySpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Industry::location, Industry::psa, Industry::random, Industry::selected_layout, OrthogonalTileArea::tile, Industry::town, Industry::type, and OrthogonalTileArea::w.
Referenced by CreateNewIndustryHelper().
| uint16 GetIndustryCallback | ( | CallbackID | callback, |
| uint32 | param1, | ||
| uint32 | param2, | ||
| Industry * | industry, | ||
| IndustryType | type, | ||
| TileIndex | tile | ||
| ) |
Perform an industry callback.
| callback | The callback to perform. |
| param1 | The first parameter. |
| param2 | The second parameter. |
| industry | The industry to do the callback for. |
| type | The type of industry to do the callback for. |
| tile | The tile associated with the callback. |
Definition at line 493 of file newgrf_industries.cpp.
Referenced by ChangeIndustryProduction(), DoCreateNewIndustry(), IndustryViewWindow::DrawInfo(), BuildIndustryWindow::DrawWidget(), GetCargoSuffix(), GetIndustryProbabilityCallback(), and IndustryTemporarilyRefusesCargo().
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 57 of file newgrf_industries.cpp.
References GetCleanIndustryGfx(), GetIndustryTileSpec(), IndustryTileSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, INVALID_INDUSTRYTILE, GRFFilePropsBase< Tcnt >::local_id, NEW_INDUSTRYTILEOFFSET, GRFFileProps::override, GRFFilePropsBase< Tcnt >::spritegroup, and Industry::TileBelongsToIndustry().
Referenced by IndustriesScopeResolver::GetVariable(), and IndustryTileScopeResolver::GetVariable().
| uint32 GetIndustryProbabilityCallback | ( | IndustryType | type, |
| IndustryAvailabilityCallType | creation_type, | ||
| uint32 | default_prob | ||
| ) |
Check with callback CBID_INDUSTRY_PROBABILITY 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 541 of file newgrf_industries.cpp.
References CALLBACK_FAILED, IndustrySpec::callback_mask, CBID_INDUSTRY_PROBABILITY, CBM_IND_PROBABILITY, ErrorUnknownCallbackResult(), GetIndustryCallback(), GetIndustrySpec(), IndustrySpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, HasBit(), and INVALID_TILE.
Referenced by CmdBuildIndustry(), GetIndustryGamePlayProbability(), GetScaledIndustryGenerationProbability(), and BuildIndustryWindow::OnTick().
| uint32 GetNearbyIndustryTileInformation | ( | byte | parameter, |
| TileIndex | tile, | ||
| IndustryID | index, | ||
| bool | signed_offsets, | ||
| bool | grf_version8 | ||
| ) |
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? |
| grf_version8 | True, if we are dealing with a new NewGRF which uses GRF version >= 8. |
Definition at line 36 of file newgrf_industrytiles.cpp.
References GetIndustryIndex(), GetNearbyTile(), GetNearbyTileInformation(), IsTileType(), and MP_INDUSTRY.
Referenced by IndustriesScopeResolver::GetVariable(), and IndustryTileScopeResolver::GetVariable().
| 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 574 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, Tpool_type, 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(), OrthogonalTileArea::tile, Industry::type, WC_INDUSTRY_VIEW, 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 626 of file newgrf_industries.cpp.
References Industry::accepts_cargo, CALLBACK_FAILED, IndustrySpec::callback_mask, GRFFile::cargo_map, CBID_INDUSTRY_REFUSE_CARGO, CBM_IND_REFUSE_CARGO, ConvertBooleanCallback(), GetIndustryCallback(), GetIndustrySpec(), IndustrySpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, HasBit(), Industry::location, OrthogonalTileArea::tile, and Industry::type.
Referenced by CanCargoServiceIndustry(), and DeliverGoodsToIndustry().
| IndustryType MapNewGRFIndustryType | ( | IndustryType | grf_type, |
| uint32 | grf_id | ||
| ) |
Map the GRF local type to an industry type.
| grf_type | The GRF local type. |
| grf_id | The GRF of the local type. |
Definition at line 41 of file newgrf_industries.cpp.
References GB(), IndustryOverrideManager::GetID(), and HasBit().
Referenced by FinaliseIndustriesArray(), GetCountAndDistanceOfClosestInstance(), and IndustriesScopeResolver::GetVariable().
1.8.1.2