OpenTTD Source 20260206-master-g4d4e37dbf1
Object Struct Reference

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

#include <object_base.h>

Inheritance diagram for Object:

Public Member Functions

 Object (ObjectID index)
 Object (ObjectID index, ObjectType type, Town *town, TileArea location, TimerGameCalendar::Date build_date, uint8_t view)
 ~Object ()
 Make sure the right destructor is called as well!

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.

Data Fields

ObjectType type = INVALID_OBJECT_TYPE
 Type of the object.
Towntown = nullptr
 Town the object is built in.
TileArea location {INVALID_TILE, 0, 0}
 Location of the object.
TimerGameCalendar::Date build_date {}
 Date of construction.
uint8_t colour = 0
 Colour of the object, for display purpose.
uint8_t view = 0
 The view setting for this object.

Static Protected Attributes

static std::array< uint16_t, NUM_OBJECTScounts
 Number of objects per type ingame.

Detailed Description

An object, such as transmitter, on the map.

Definition at line 23 of file object_base.h.

Constructor & Destructor Documentation

◆ Object() [1/2]

Object::Object ( ObjectID index)
inline

Definition at line 31 of file object_base.h.

◆ Object() [2/2]

Object::Object ( ObjectID index,
ObjectType type,
Town * town,
TileArea location,
TimerGameCalendar::Date build_date,
uint8_t view )
inline

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 35 of file object_base.h.

Member Function Documentation

◆ DecTypeCount()

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 55 of file object_base.h.

References counts, NUM_OBJECTS, and type.

Referenced by ReallyClearObjectTile().

◆ GetByTile()

Object * Object::GetByTile ( TileIndex tile)
static

Get the object associated with a tile.

Parameters
tileThe tile to fetch the object for.
Returns
The object.

Definition at line 55 of file object_cmd.cpp.

References GetObjectIndex().

Referenced by AnimateNewObjectTile(), CmdDeleteTown(), DrawNewObjectTile(), DrawTileLayout(), NIHObject::GetInstance(), GetObjectIDAtOffset(), GetObjectType(), NIHObject::GetParent(), ObjectScopeResolver::GetVariable(), IncreaseCompanyHQSize(), and NIHObject::Resolve().

◆ GetTypeCount()

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 66 of file object_base.h.

References counts, NUM_OBJECTS, and type.

Referenced by GetCountAndDistanceOfClosestInstance().

◆ IncTypeCount()

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 44 of file object_base.h.

References counts, NUM_OBJECTS, and type.

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

◆ ResetTypeCounts()

void Object::ResetTypeCounts ( )
inlinestatic

Resets object counts.

Definition at line 73 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().

◆ colour

uint8_t Object::colour = 0

Colour of the object, for display purpose.

Definition at line 28 of file object_base.h.

Referenced by BuildObject(), and DrawTileLayout().

◆ counts

std::array< uint16_t, NUM_OBJECTS > Object::counts
staticprotected

Number of objects per type ingame.

Definition at line 79 of file object_base.h.

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

◆ location

TileArea Object::location {INVALID_TILE, 0, 0}

Location of the object.

Definition at line 26 of file object_base.h.

Referenced by AfterLoadGame(), IncreaseCompanyHQSize(), ReallyClearObjectTile(), and TriggerObjectAnimation().

◆ town

Town* Object::town = nullptr

Town the object is built in.

Definition at line 25 of file object_base.h.

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

◆ type

◆ view

uint8_t Object::view = 0

The view setting for this object.

Definition at line 29 of file object_base.h.

Referenced by GetObjectIDAtOffset().


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