OpenTTD Source  20241121-master-g67a0fccfad
ObjectSpec Struct Reference

Allow incrementing of ObjectClassID variables. More...

#include <newgrf_object.h>

Inheritance diagram for ObjectSpec:
NewGRFSpecBase< ObjectClassID >

Public Member Functions

bool IsEnabled () const
 Test if this object is enabled. More...
 
Money GetBuildCost () const
 Get the cost for building a structure of this type. More...
 
Money GetClearCost () const
 Get the cost for clearing a structure of this type. More...
 
bool IsEverAvailable () const
 Check whether the object might be available at some point in this game with the current game mode. More...
 
bool WasEverAvailable () const
 Check whether the object was available at some point in the past or present in this game with the current game mode. More...
 
bool IsAvailable () const
 Check whether the object is available at this time. More...
 
uint Index () const
 Gets the index of this spec. More...
 

Static Public Member Functions

static const std::vector< ObjectSpec > & Specs ()
 
static size_t Count ()
 
static const ObjectSpecGet (ObjectType index)
 Get the specification associated with a specific ObjectType. More...
 
static const ObjectSpecGetByTile (TileIndex tile)
 Get the specification associated with a tile. More...
 
static void BindToClasses ()
 Tie all ObjectSpecs to their class.
 

Data Fields

GRFFilePropsBase< 2 > grf_prop
 Properties related the the grf file.
 
AnimationInfo animation
 Information about the animation.
 
StringID name
 The name for this object.
 
uint8_t climate
 In which climates is this object available?
 
uint8_t size
 The size of this objects; low nibble for X, high nibble for Y.
 
uint8_t build_cost_multiplier
 Build cost multiplier per tile.
 
uint8_t clear_cost_multiplier
 Clear cost multiplier per tile.
 
TimerGameCalendar::Date introduction_date
 From when can this object be built.
 
TimerGameCalendar::Date end_of_life_date
 When can't this object be built anymore.
 
ObjectFlags flags
 Flags/settings related to the object.
 
uint16_t callback_mask
 Bitmask of requested/allowed callbacks.
 
uint8_t height
 The height of this structure, in heightlevels; max MAX_TILE_HEIGHT.
 
uint8_t views
 The number of views.
 
uint8_t generate_amount
 Number of objects which are attempted to be generated per 256^2 map during world generation.
 
- Data Fields inherited from NewGRFSpecBase< ObjectClassID >
ObjectClassID class_index
 Class index of this spec, invalid until class is allocated.
 
uint16_t index
 Index within class of this spec, invalid until inserted into class.
 

Detailed Description

Allow incrementing of ObjectClassID variables.

An object that isn't use for transport, industries or houses.

Note
If you change this struct, adopt the initialization of default objects in table/object_land.h

Definition at line 60 of file newgrf_object.h.

Member Function Documentation

◆ Get()

const ObjectSpec * ObjectSpec::Get ( ObjectType  index)
static

Get the specification associated with a specific ObjectType.

Parameters
indexThe object type to fetch.
Returns
The specification.

Definition at line 50 of file newgrf_object.cpp.

References _object_specs, NewGRFSpecBase< ObjectClassID >::index, and NUM_OBJECTS.

Referenced by BuildObject(), CmdBuildObject(), CmdBuildObjectArea(), ObjectPickerCallbacks::FillUsedItems(), GetByTile(), and GetObjectIDAtOffset().

◆ GetBuildCost()

Money ObjectSpec::GetBuildCost ( ) const
inline

Get the cost for building a structure of this type.

Returns
The cost for building.

Definition at line 88 of file newgrf_object.h.

References GetPrice().

◆ GetByTile()

const ObjectSpec * ObjectSpec::GetByTile ( TileIndex  tile)
static

Get the specification associated with a tile.

Parameters
tileThe tile to fetch the data for.
Returns
The specification.

Definition at line 65 of file newgrf_object.cpp.

References Get(), and GetObjectType().

Referenced by AnimateNewObjectTile(), NIHObject::GetGRFID(), NIHObject::GetSpec(), NIHObject::IsInspectable(), NIHObject::Resolve(), and UpdateObjectColours().

◆ GetClearCost()

Money ObjectSpec::GetClearCost ( ) const
inline

Get the cost for clearing a structure of this type.

Returns
The cost for clearing.

Definition at line 94 of file newgrf_object.h.

References GetPrice().

◆ Index()

uint ObjectSpec::Index ( ) const

Gets the index of this spec.

Returns
The index.

Definition at line 103 of file newgrf_object.cpp.

References _object_specs.

◆ IsAvailable()

bool ObjectSpec::IsAvailable ( ) const

Check whether the object is available at this time.

Returns
true if it is available.

Definition at line 93 of file newgrf_object.cpp.

References TimerGameCalendar::date, end_of_life_date, introduction_date, and WasEverAvailable().

◆ IsEnabled()

bool ObjectSpec::IsEnabled ( ) const
inline

Test if this object is enabled.

Returns
True iff this object is enabled.

Definition at line 82 of file newgrf_object.h.

Referenced by IsEverAvailable().

◆ IsEverAvailable()

bool ObjectSpec::IsEverAvailable ( ) const

Check whether the object might be available at some point in this game with the current game mode.

Returns
true if it might be available.

Definition at line 74 of file newgrf_object.cpp.

References _settings_game, climate, flags, GameSettings::game_creation, HasBit(), IsEnabled(), and GameCreationSettings::landscape.

Referenced by ObjectPickerCallbacks::FillUsedItems(), and WasEverAvailable().

◆ WasEverAvailable()

bool ObjectSpec::WasEverAvailable ( ) const

Check whether the object was available at some point in the past or present in this game with the current game mode.

Returns
true if it was ever or is available.

Definition at line 84 of file newgrf_object.cpp.

References TimerGameCalendar::date, introduction_date, and IsEverAvailable().

Referenced by IsAvailable().


The documentation for this struct was generated from the following files: