OpenTTD
|
An object, such as transmitter, on the map. More...
#include <object_base.h>
Public Member Functions | |
Object () | |
Make sure the object isn't zeroed. | |
~Object () | |
Make sure the right destructor is called as well! | |
![]() | |
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 size, 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 Object * | GetByTile (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 | GetTypeCount (ObjectType type) |
Get the count of objects for this type. | |
static void | ResetTypeCounts () |
Resets object counts. | |
![]() | |
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-NULL) 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. |
Data Fields | |
ObjectType | type |
Type of the object. | |
Town * | town |
Town the object is built in. | |
TileArea | location |
Location of the object. | |
Date | build_date |
Date of construction. | |
byte | colour |
Colour of the object, for display purpose. | |
byte | view |
The view setting for this object. | |
![]() | |
Tindex | index |
Index of this pool item. |
Static Protected Attributes | |
static uint16 | counts [NUM_OBJECTS] |
Number of objects per type ingame. |
An object, such as transmitter, on the map.
Definition at line 25 of file object_base.h.
|
inline |
Make sure the object isn't zeroed.
Definition at line 34 of file object_base.h.
|
inlinestatic |
Decrement the count of objects for this type.
type | ObjectType to decrement |
Definition at line 56 of file object_base.h.
References counts, NUM_OBJECTS, and type.
Referenced by ReallyClearObjectTile().
Get the object associated with a tile.
tile | The tile to fetch the object for. |
Definition at line 52 of file object_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >::Get(), and GetObjectIndex().
Referenced by AnimateNewObjectTile(), CmdDeleteTown(), DrawNewObjectTile(), DrawTileLayout(), GetObjectIDAtOffset(), GetObjectType(), ObjectScopeResolver::GetVariable(), and IncreaseAnimationStage().
|
inlinestatic |
Get the count of objects for this type.
type | ObjectType to query |
Definition at line 67 of file object_base.h.
References counts, NUM_OBJECTS, and type.
Referenced by GetCountAndDistanceOfClosestInstance().
|
inlinestatic |
Increment the count of objects for this type.
type | ObjectType to increment |
Definition at line 45 of file object_base.h.
References counts, NUM_OBJECTS, and type.
Referenced by AfterLoadGame(), BuildObject(), and InitializeWindowsAndCaches().
|
inlinestatic |
Resets object counts.
Definition at line 74 of file object_base.h.
References counts.
Referenced by InitializeObjects().