12 #include "../newgrf_house.h" 13 #include "../newgrf_engine.h" 16 #define NIP(prop, base, variable, type, name) { name, (ptrdiff_t)cpp_offsetof(base, variable), cpp_sizeof(base, variable), prop, type } 17 #define NIP_END() { NULL, 0, 0, 0, 0 } 20 #define NIC(cb_id, base, variable, bit) { #cb_id, (ptrdiff_t)cpp_offsetof(base, variable), cpp_sizeof(base, variable), bit, cb_id } 21 #define NIC_END() { NULL, 0, 0, 0, 0 } 24 #define NIV(var, name) { name, var } 25 #define NIV_END() { NULL, 0 } 30 #define NICV(cb_id, bit) NIC(cb_id, Engine, info.callback_mask, bit) 51 NIV(0x40,
"position in consist and length"),
52 NIV(0x41,
"position and length of chain of same vehicles"),
53 NIV(0x42,
"transported cargo types"),
54 NIV(0x43,
"player info"),
55 NIV(0x44,
"aircraft info"),
56 NIV(0x45,
"curvature info"),
57 NIV(0x46,
"motion counter"),
58 NIV(0x47,
"vehicle cargo info"),
59 NIV(0x48,
"vehicle type info"),
60 NIV(0x49,
"year of construction"),
61 NIV(0x4A,
"current rail type info"),
62 NIV(0x4B,
"long date of last service"),
63 NIV(0x4C,
"current max speed"),
64 NIV(0x4D,
"position in articulated vehicle"),
65 NIV(0x60,
"count vehicle id occurrences"),
67 NIV(0x62,
"Curvature/position difference to other vehicle"),
79 uint
Resolve(uint index, uint var, uint param,
bool *avail)
const 97 #define NICS(cb_id, bit) NIC(cb_id, StationSpec, callback_mask, bit) 110 NIV(0x40,
"platform info and relative position"),
111 NIV(0x41,
"platform info and relative position for individually built sections"),
112 NIV(0x42,
"terrain and track type"),
113 NIV(0x43,
"player info"),
114 NIV(0x44,
"path signalling info"),
115 NIV(0x45,
"rail continuation info"),
116 NIV(0x46,
"platform info and relative position from middle"),
117 NIV(0x47,
"platform info and relative position from middle for individually built sections"),
118 NIV(0x48,
"bitmask of accepted cargoes"),
119 NIV(0x49,
"platform info and relative position of same-direction section"),
120 NIV(0x4A,
"current animation frame"),
121 NIV(0x60,
"amount of cargo waiting"),
122 NIV(0x61,
"time since last cargo pickup"),
123 NIV(0x62,
"rating of cargo"),
124 NIV(0x63,
"time spent on route"),
125 NIV(0x64,
"information about last vehicle picking cargo up"),
126 NIV(0x65,
"amount of cargo acceptance"),
127 NIV(0x66,
"animation frame of nearby tile"),
128 NIV(0x67,
"land info of nearby tiles"),
129 NIV(0x68,
"station info of nearby tiles"),
130 NIV(0x69,
"information about cargo accepted in the past"),
135 bool IsInspectable(uint index)
const {
return GetStationSpec(index) != NULL; }
138 const void *
GetSpec(uint index)
const {
return GetStationSpec(index); }
142 uint
Resolve(uint index, uint var, uint param,
bool *avail)
const 159 #define NICH(cb_id, bit) NIC(cb_id, HouseSpec, callback_mask, bit) 180 NIV(0x40,
"construction state of tile and pseudo-random value"),
181 NIV(0x41,
"age of building in years"),
182 NIV(0x42,
"town zone"),
183 NIV(0x43,
"terrain type"),
184 NIV(0x44,
"building counts"),
185 NIV(0x45,
"town expansion bits"),
186 NIV(0x46,
"current animation frame"),
187 NIV(0x47,
"xy coordinate of the building"),
188 NIV(0x60,
"other building counts (old house type)"),
189 NIV(0x61,
"other building counts (new house type)"),
190 NIV(0x62,
"land info of nearby tiles"),
191 NIV(0x63,
"current animation frame of nearby house tile"),
192 NIV(0x64,
"cargo acceptance history of nearby stations"),
193 NIV(0x65,
"distance of nearest house matching a given criterion"),
194 NIV(0x66,
"class and ID of nearby house tile"),
195 NIV(0x67,
"GRFID of nearby house tile"),
207 uint
Resolve(uint index, uint var, uint param,
bool *avail)
const 224 #define NICIT(cb_id, bit) NIC(cb_id, IndustryTileSpec, callback_mask, bit) 225 static const NICallback _nic_industrytiles[] = {
237 static const NIVariable _niv_industrytiles[] = {
238 NIV(0x40,
"construction state of tile"),
239 NIV(0x41,
"ground type"),
240 NIV(0x42,
"current town zone in nearest town"),
241 NIV(0x43,
"relative position"),
242 NIV(0x44,
"animation frame"),
243 NIV(0x60,
"land info of nearby tiles"),
244 NIV(0x61,
"animation stage of nearby tiles"),
245 NIV(0x62,
"get industry or airport tile ID at offset"),
257 uint
Resolve(uint index, uint var, uint param,
bool *avail)
const 264 static const NIFeature _nif_industrytile = {
283 #define NICI(cb_id, bit) NIC(cb_id, IndustrySpec, callback_mask, bit) 302 NIV(0x40,
"waiting cargo 0"),
303 NIV(0x41,
"waiting cargo 1"),
304 NIV(0x42,
"waiting cargo 2"),
305 NIV(0x43,
"distance to closest dry/land tile"),
306 NIV(0x44,
"layout number"),
307 NIV(0x45,
"player info"),
308 NIV(0x46,
"industry construction date"),
309 NIV(0x60,
"get industry tile ID at offset"),
310 NIV(0x61,
"get random tile bits at offset"),
311 NIV(0x62,
"land info of nearby tiles"),
312 NIV(0x63,
"animation stage of nearby tiles"),
313 NIV(0x64,
"distance on nearest industry with given type"),
314 NIV(0x65,
"get town zone and Manhattan distance of closest town"),
315 NIV(0x66,
"get square of Euclidean distance of closes town"),
316 NIV(0x67,
"count of industry and distance of closest instance"),
317 NIV(0x68,
"count of industry and distance of closest instance with layout filter"),
329 uint
Resolve(uint index, uint var, uint param,
bool *avail)
const 341 if (i->
psa == NULL)
return NULL;
356 #define NICO(cb_id, bit) NIC(cb_id, ObjectSpec, callback_mask, bit) 369 NIV(0x40,
"relative position"),
370 NIV(0x41,
"tile information"),
371 NIV(0x42,
"construction date"),
372 NIV(0x43,
"animation counter"),
373 NIV(0x44,
"object founder"),
374 NIV(0x45,
"get town zone and Manhattan distance of closest town"),
375 NIV(0x46,
"get square of Euclidean distance of closes town"),
378 NIV(0x60,
"get object ID at offset"),
379 NIV(0x61,
"get random tile bits at offset"),
380 NIV(0x62,
"land info of nearby tiles"),
381 NIV(0x63,
"animation stage of nearby tiles"),
382 NIV(0x64,
"distance on nearest object with given type"),
394 uint
Resolve(uint index, uint var, uint param,
bool *avail)
const 412 NIV(0x40,
"terrain type"),
413 NIV(0x41,
"enhanced tunnels"),
414 NIV(0x42,
"level crossing status"),
415 NIV(0x43,
"construction date"),
416 NIV(0x44,
"town zone"),
424 const void *
GetSpec(uint index)
const {
return NULL; }
428 uint
Resolve(uint index, uint var, uint param,
bool *avail)
const 447 #define NICAT(cb_id, bit) NIC(cb_id, AirportTileSpec, callback_mask, bit) 448 static const NICallback _nic_airporttiles[] = {
464 uint
Resolve(uint index, uint var, uint param,
bool *avail)
const 471 static const NIFeature _nif_airporttile = {
482 NIV(0x40,
"larger town effect on this town"),
483 NIV(0x41,
"town index"),
484 NIV(0x82,
"population"),
485 NIV(0x94,
"zone radius 0"),
486 NIV(0x96,
"zone radius 1"),
487 NIV(0x98,
"zone radius 2"),
488 NIV(0x9A,
"zone radius 3"),
489 NIV(0x9C,
"zone radius 4"),
490 NIV(0xB6,
"number of buildings"),
498 const void *
GetSpec(uint index)
const {
return NULL; }
504 uint
Resolve(uint index, uint var, uint param,
bool *avail)
const 514 std::list<PersistentStorage *>::iterator iter;
515 for (iter = t->psa_list.begin(); iter != t->psa_list.end(); iter++) {
516 if ((*iter)->grfid == grfid)
return (int32 *)(&(*iter)->storage[0]);
void SetStringParameters(uint index) const
Set the string parameters to write the right data for a STRINGn.
Resolver of town properties.
customize the cargoes the industry produces
uint32 GetGRFID(uint index) const
Get the GRFID of the file that includes this item.
const void * GetInstance(uint index) const
Get the instance given an index.
initialise production level on construction
Called to determine if the given industry can be built on specific area.
uint Resolve(uint index, uint var, uint param, bool *avail) const
Resolve (action2) variable for a given index.
Use callback to select a sprite layout to use.
Resolver object for rail types.
uint GetParent(uint index) const
Get the parent "window_number" of a given instance.
uint GetParent(uint index) const
Get the parent "window_number" of a given instance.
bool IsInspectable(uint index) const
Is the item with the given index inspectable?
bool IsInspectable(uint index) const
Is the item with the given index inspectable?
decides next animation frame
void SetStringParameters(uint index) const
Set the string parameters to write the right data for a STRINGn.
const void * GetSpec(uint index) const
Get (NewGRF) specs given an index.
void SetStringParameters(uint index) const
Set the string parameters to write the right data for a STRINGn.
Called to determine airport tile next animation frame.
Called to determine more text in the fund object window.
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
static Titem * Get(size_t index)
Returns Titem with given index.
uint Resolve(uint index, uint var, uint param, bool *avail) const
Resolve (action2) variable for a given index.
static const AirportTileSpec * GetByTile(TileIndex tile)
Retrieve airport tile spec for the given airport tile.
uint GetParent(uint index) const
Get the parent "window_number" of a given instance.
Called to determine if one can alter the ground below a house tile.
bool IsInspectable(uint index) const
Is the item with the given index inspectable?
Called to determine if the given industry tile can be built on specific tile.
void SetSimpleStringParameters(StringID string, uint32 index) const
Helper to make setting the strings easier.
const void * GetInstance(uint index) const
Get the instance given an index.
Customize the input cargo types of a newly build industry.
static IndustryGfx GetIndustryGfx(TileIndex t)
Get the industry graphics ID for the given industry tile.
GRFFilePropsBase< 2 > grf_prop
Properties related the the grf file.
Builds articulated engines for trains and RVs.
Representation on the NewGRF variables.
Called periodically to determine if a house should be destroyed.
Called to indicate how long the current animation frame should last.
Return the vehicles this given vehicle can be "upgraded" to.
Called monthly on production changes, so it can be adjusted more frequently.
uint Resolve(uint index, uint var, uint param, bool *avail) const
Resolve (action2) variable for a given index.
Called for periodically starting or stopping the animation.
additional text in fund window
Called when the company (or AI) tries to start or stop a vehicle.
const void * GetInstance(uint index) const
Get the instance given an index.
Defines the internal data of a functional industry.
uint GetParent(uint index) const
Get the parent "window_number" of a given instance.
uint32 GetGRFID(uint index) const
Get the GRFID of the file that includes this item.
static uint GetInspectWindowNumber(GrfSpecFeature feature, uint index)
Get the window number for the inspect window given a feature and index.
Tindex index
Index of this pool item.
static StationGfx GetAirportGfx(TileIndex t)
Get the station graphics of this airport tile.
Determine the next animation frame for a house.
uint GetParent(uint index) const
Get the parent "window_number" of a given instance.
Cargo capacity after refit.
check industry construction on given area
change animation when construction state changes
const int32 * GetPSAFirstPosition(uint index, uint32 grfid) const
Gets the first position of the array containing the persistent storage.
Resolver object to be used for houses (feature 07 spritegroups).
Determine whether a wagon can be attached to an already existing train.
Called to determine whether a town building can be destroyed.
Called to determine which cargoes a town building should accept.
Visual effects and wagon power.
Called to indicate how long the current animation frame should last.
uint GetParent(uint index) const
Get the parent "window_number" of a given instance.
GrfSpecFeature GetGrfSpecFeature(TileIndex tile)
Get the GrfSpecFeature associated with the tile.
Determine the cargo "suffixes" for each refit possibility of a cargo.
Callback done for each tile of an object to check the slope.
Vehicle uses custom sound effects.
Use a custom next frame callback.
Determine whether a newstation should be made available to build.
decides amount of cargo acceptance
uint Resolve(uint index, uint var, uint param, bool *avail) const
Resolve (action2) variable for a given index.
uint GetParent(uint index) const
Get the parent "window_number" of a given instance.
void SetStringParameters(uint index) const
Set the string parameters to write the right data for a STRINGn.
Called to determine more text in the fund industry window.
Representation of the available callbacks with information on when they actually apply.
const void * GetSpec(uint index) const
Get (NewGRF) specs given an index.
void SetStringParameters(uint index) const
Set the string parameters to write the right data for a STRINGn.
Called to determine the type (if any) of foundation to draw for house tile.
Callback done for each tile of a station to check the slope.
bool PSAWithParameter() const
Used to decide if the PSA needs a parameter or not.
decides allowance of autosloping
Called to determine the colour of a town building.
Fake town GrfSpecFeature for NewGRF debugging (parent scope)
const void * GetInstance(uint index) const
Get the instance given an index.
static const NIFeature *const _nifeatures[]
Table with all NIFeatures.
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
This callback is called from vehicle purchase lists.
Resolver for industry tiles.
const void * GetSpec(uint index) const
Get (NewGRF) specs given an index.
Called on the Get Tile Description for an house tile.
Customize the output cargo types of a newly build industry.
Called when a cargo type specified in property 20 is accepted.
decides if default foundations need to be drawn
uint Resolve(uint index, uint var, uint param, bool *avail) const
Resolve (action2) variable for a given index.
Called to indicate how long the current animation frame should last.
PersistentStorage * psa
Persistent storage for NewGRF industries.
Customize the animation speed of the station.
Called to play a special sound effect.
Called to determine if the given industry type is available.
Resolver for tiles of an airport.
controls random production change
decides next animation frame
static TownID GetTownIndex(TileIndex t)
Get the index of which town this house/street is attached to.
decides if default foundations need to be drawn
Called to modify various vehicle properties.
Called to determine if industry can alter the ground below industry tile.
Called to determine the type (if any) of foundation to draw for industry tile.
Resolver for a vehicle (chain)
bool IsInspectable(uint index) const
Is the item with the given index inspectable?
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
trigger destruction of building
const void * GetInstance(uint index) const
Get the instance given an index.
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
Show suffix after cargo name.
uint GetPSASize(uint index, uint32 grfid) const
Allows to know the size of the persistent storage.
Called to indicate how long the current animation frame should last.
uint32 GetGRFID(uint index) const
Get the GRFID of the file that includes this item.
IndustryType type
type of industry.
Vehicle length (trains and road vehicles)
decide the colour of the building
Called for periodically starting or stopping the animation.
const void * GetSpec(uint index) const
Get (NewGRF) specs given an index.
const void * GetInstance(uint index) const
Get the instance given an index.
uint32 GetGRFID(uint index) const
Get the GRFID of the file that includes this item.
decides amount of cargo acceptance
bool IsInspectable(uint index) const
Is the item with the given index inspectable?
void SetObjectAtStringParameters(StringID string, uint32 index, TileIndex tile) const
Helper to make setting the strings easier for objects at a specific tile.
TileArea location
Location of the industry.
TYPE storage[SIZE]
Memory to for the storage array.
additional text in industry window
End of the fake features.
Change colour mapping of vehicle.
Class for pooled persistent storage of data.
const void * GetSpec(uint index) const
Get (NewGRF) specs given an index.
const void * GetInstance(uint index) const
Get the instance given an index.
decides allowance of autosloping
GRFFileProps grf_prop
properties related to the grf file
decides next animation frame
static const AirportTileSpec * Get(StationGfx gfx)
Retrieve airport tile spec for the given airport tile.
customize the cargoes the industry requires
additional text in fund window
bool IsInspectable(uint index) const
Is the item with the given index inspectable?
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
const void * GetInstance(uint index) const
Get the instance given an index.
const IndustryTileSpec * GetIndustryTileSpec(IndustryGfx gfx)
Accessor for array _industry_tile_specs.
Called when building a station to customize the tile layout.
Called to determine if a specific colour map should be used for a vehicle instead of the default live...
const void * GetSpec(uint index) const
Get (NewGRF) specs given an index.
#define lengthof(x)
Return the length of an fixed size array.
periodically start/stop the animation
GRFFileProps grf_prop
properties related to the grf file
decide the colour of the building
const void * GetInstance(uint index) const
Get the instance given an index.
Called to determine if the industry can still accept or refuse more cargo arrival.
Add articulated engines (trains and road vehicles)
uint Resolve(uint index, uint var, uint param, bool *avail) const
Resolve (action2) variable for a given index.
Called whenever the construction state of a house changes.
decides slope suitability
bool IsInspectable(uint index) const
Is the item with the given index inspectable?
uint Resolve(uint index, uint var, uint param, bool *avail) const
Resolve (action2) variable for a given index.
Called to determine the colour of an industry.
bool IsInspectable(uint index) const
Is the item with the given index inspectable?
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
industry availability/probability callback
controls monthly random production change
virtual uint32 GetVariable(byte variable, uint32 parameter, bool *available) const
Get a variable value.
Called to determine which cargoes an industry should accept.
Determine whether the house can be built on the specified tile.
TileIndex tile
The base tile of the area.
static const int CBM_NO_BIT
Mask to show no bit needs to be enabled for the callback.
void SetStringParameters(uint index) const
Set the string parameters to write the right data for a STRINGn.
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
uint Resolve(uint index, uint var, uint param, bool *avail) const
Resolve (action2) variable for a given index.
void SetStringParameters(uint index) const
Set the string parameters to write the right data for a STRINGn.
Called for every vehicle every 32 days (not all on same date though).
Called to determine the type (if any) of foundation to draw for an airport tile.
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
Determine the amount of cargo to load per unit of time when using gradual loading.
void SetStringParameters(uint index) const
Set the string parameters to write the right data for a STRINGn.
Refit capacity, the passed vehicle needs to have its ->cargo_type set to the cargo we are refitting t...
#define cpp_lengthof(base, variable)
Gets the length of an array variable within a class.
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
Called to determine industry tile next animation frame.
option out of accepting cargo
static HouseID GetHouseType(TileIndex t)
Get the type of this house, which is an index into the house spec array.
Called for periodically starting or stopping the animation.
static IndustryID GetIndustryIndex(TileIndex t)
Get the industry ID of the given tile.
Helper class to wrap some functionality/queries in.
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
decides next animation frame
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
Availability of station in construction window.
Called to determine station tile next animation frame.
uint32 GetGRFID(uint index) const
Get the GRFID of the file that includes this item.
uint32 GetGRFID(uint index) const
Get the GRFID of the file that includes this item.
Called to query the cargo acceptance of the industry tile.
const void * GetSpec(uint index) const
Get (NewGRF) specs given an index.
static Station * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
Called to indicate how long the current animation frame should last.
uint32 GetGRFID(uint index) const
Get the GRFID of the file that includes this item.
uint GetParent(uint index) const
Get the parent "window_number" of a given instance.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
decides if default foundations need to be drawn
static Object * GetByTile(TileIndex tile)
Get the object associated with a tile.
const void * GetSpec(uint index) const
Get (NewGRF) specs given an index.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Called to determine text to display after cargo name.
A resolver object to be used with feature 0F spritegroups.
GRFFileProps grf_prop
Properties related the the grf file.
EngineID engine_type
The type of engine used for this vehicle.
const struct GRFFile * grffile
grf file that introduced this entity
Representation of the data from a NewGRF property.
Called for periodically starting or stopping the animation.
decides allowance of autosloping
const int32 * GetPSAFirstPosition(uint index, uint32 grfid) const
Gets the first position of the array containing the persistent storage.
void SetStringParameters(uint index) const
Set the string parameters to write the right data for a STRINGn.
uint32 GetGRFID(uint index) const
Get the GRFID of the file that includes this item.
Called to determine the colour of a town building.
Choose a sprite layout to draw, instead of the standard 0-7 range.
static const ObjectSpec * GetByTile(TileIndex tile)
Get the specification associated with a tile.
Called to determine more text in the industry window.
uint32 GetGRFID(uint index) const
Get the GRFID of the file that includes this item.
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
Check slope of new station tiles.
Determine the next animation frame for a house.
Called to determine if one can alter the ground below an object tile.
Called to determine how much cargo a town building produces.
uint GetPSASize(uint index, uint32 grfid) const
Allows to know the size of the persistent storage.
Vehicle length, returns the amount of 1/8's the vehicle is shorter for trains and RVs...
decide whether the house can be built on a given tile
Called to decide how much cargo a town building can accept.
Called to determine industry special effects.
Called when industry is built to set initial production level.
uint Resolve(uint index, uint var, uint param, bool *avail) const
Resolve (action2) variable for a given index.
GRFFileProps grf_prop
properties related the the grf file
Container for all information for a given feature.
const void * GetSpec(uint index) const
Get (NewGRF) specs given an index.
VehicleTypeByte type
Type of vehicle.
Called on production changes, so it can be adjusted.
bool IsInspectable(uint index) const
Is the item with the given index inspectable?
uint GetParent(uint index) const
Get the parent "window_number" of a given instance.
ScopeResolver * GetScope(VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
Get a resolver for the scope.
Visual effects and wagon power (trains, road vehicles and ships)
Called for periodically starting or stopping the animation.
give a custom colour to newly build industries
decides slope suitability
Resolve wagon overrides using TrainCache::cached_override.