OpenTTD Source 20241224-master-gf74b0cf984
Object Struct Reference

An object, such as transmitter, on the map. More...

#include <object_base.h>

Inheritance diagram for Object:
Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >

Public Member Functions

 Object ()
 Make sure the object isn't zeroed.
 
 ~Object ()
 Make sure the right destructor is called as well!
 
- Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >
void * operator new (size_t size)
 Allocates space for new Titem.
 
void * operator new (size_t size, size_t index)
 Allocates space for new Titem with given index.
 
void * operator new (size_t, void *ptr)
 Allocates space for new Titem at given memory address.
 
void operator delete (void *p)
 Marks Titem as free.
 

Static Public Member Functions

static ObjectGetByTile (TileIndex tile)
 Get the object associated with a tile.
 
static void IncTypeCount (ObjectType type)
 Increment the count of objects for this type.
 
static void DecTypeCount (ObjectType type)
 Decrement the count of objects for this type.
 
static uint16_t GetTypeCount (ObjectType type)
 Get the count of objects for this type.
 
static void ResetTypeCounts ()
 Resets object counts.
 
- Static Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >
static bool CanAllocateItem (size_t n=1)
 Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
 
static bool CleaningPool ()
 Returns current state of pool cleaning - yes or no.
 
static bool IsValidID (size_t index)
 Tests whether given index can be used to get valid (non-nullptr) Titem.
 
static Titem * Get (size_t index)
 Returns Titem with given index.
 
static Titem * GetIfValid (size_t index)
 Returns Titem with given index.
 
static size_t GetPoolSize ()
 Returns first unused index.
 
static size_t GetNumItems ()
 Returns number of valid items in the pool.
 
static void PostDestructor (size_t index)
 Dummy function called after destructor of each member.
 
static Pool::IterateWrapper< Titem > Iterate (size_t from=0)
 Returns an iterable ensemble of all valid Titem.
 

Data Fields

ObjectType type
 Type of the object.
 
Towntown
 Town the object is built in.
 
TileArea location
 Location of the object.
 
TimerGameCalendar::Date build_date
 Date of construction.
 
uint8_t colour
 Colour of the object, for display purpose.
 
uint8_t view
 The view setting for this object.
 
- Data Fields inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >
Tindex index
 Index of this pool item.
 

Static Protected Attributes

static uint16_t counts [NUM_OBJECTS]
 Number of objects per type ingame.
 

Additional Inherited Members

- Public Types inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >
typedef struct Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero > Pool
 Type of the pool this item is going to be part of.
 

Detailed Description

An object, such as transmitter, on the map.

Definition at line 23 of file object_base.h.

Constructor & Destructor Documentation

◆ Object()

Object::Object ( )
inline

Make sure the object isn't zeroed.

Definition at line 32 of file object_base.h.

◆ ~Object()

Object::~Object ( )
inline

Make sure the right destructor is called as well!

Definition at line 34 of file object_base.h.

Member Function Documentation

◆ DecTypeCount()

static void Object::DecTypeCount ( ObjectType  type)
inlinestatic

Decrement the count of objects for this type.

Parameters
typeObjectType to decrement
Precondition
type < NUM_OBJECTS

Definition at line 54 of file object_base.h.

References counts, NUM_OBJECTS, and type.

Referenced by ReallyClearObjectTile().

◆ GetByTile()

◆ GetTypeCount()

static uint16_t Object::GetTypeCount ( ObjectType  type)
inlinestatic

Get the count of objects for this type.

Parameters
typeObjectType to query
Precondition
type < NUM_OBJECTS

Definition at line 65 of file object_base.h.

References counts, NUM_OBJECTS, and type.

Referenced by GetCountAndDistanceOfClosestInstance().

◆ IncTypeCount()

static void Object::IncTypeCount ( ObjectType  type)
inlinestatic

Increment the count of objects for this type.

Parameters
typeObjectType to increment
Precondition
type < NUM_OBJECTS

Definition at line 43 of file object_base.h.

References counts, NUM_OBJECTS, and type.

Referenced by AfterLoadGame(), BuildObject(), and InitializeWindowsAndCaches().

◆ ResetTypeCounts()

static void Object::ResetTypeCounts ( )
inlinestatic

Resets object counts.

Definition at line 72 of file object_base.h.

References counts.

Referenced by InitializeObjects().

Field Documentation

◆ build_date

TimerGameCalendar::Date Object::build_date

Date of construction.

Definition at line 27 of file object_base.h.

Referenced by AfterLoadGame(), BuildObject(), and ObjectScopeResolver::GetVariable().

◆ colour

uint8_t Object::colour

Colour of the object, for display purpose.

Definition at line 28 of file object_base.h.

Referenced by BuildObject(), DrawTileLayout(), and ObjectScopeResolver::GetVariable().

◆ counts

uint16_t Object::counts
staticprotected

Number of objects per type ingame.

Definition at line 78 of file object_base.h.

Referenced by DecTypeCount(), GetTypeCount(), IncTypeCount(), and ResetTypeCounts().

◆ location

◆ town

Town* Object::town

◆ type

◆ view

uint8_t Object::view

The view setting for this object.

Definition at line 29 of file object_base.h.

Referenced by BuildObject(), GetObjectIDAtOffset(), and ObjectScopeResolver::GetVariable().


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