OpenTTD Source 20260108-master-g8ba1860eaa
Subsidy Struct Reference

Struct about subsidies, offered and awarded. More...

#include <subsidy_base.h>

Inheritance diagram for Subsidy:
Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_subsidy_pool >

Public Member Functions

 Subsidy (SubsidyID index, CargoType cargo_type=INVALID_CARGO, Source src={}, Source dst={}, uint16_t remaining=0)
 
 ~Subsidy ()
 (Empty) destructor has to be defined else operator delete might be called with nullptr parameter
 
bool IsAwarded () const
 Tests whether this subsidy has been awarded to someone.
 
void AwardTo (CompanyID company)
 Marks subsidy as awarded, creates news and AI event.
 
- Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_subsidy_pool >
 PoolItem (Tindex index)
 Construct the item.
 
void * operator new (size_t)=delete
 Do not use new PoolItem, but rather PoolItem::Create.
 
void * operator new (size_t size, Tindex index)=delete
 Do not use new (index) PoolItem(...), but rather PoolItem::CreateAtIndex(index, ...).
 
void * operator new (size_t, void *ptr)=delete
 Do not use new (address) PoolItem(...).
 
void operator delete (void *p, size_t size)
 Marks Titem as free.
 

Data Fields

CargoType cargo_type = INVALID_CARGO
 Cargo type involved in this subsidy, INVALID_CARGO for invalid subsidy.
 
uint16_t remaining = 0
 Remaining months when this subsidy is valid.
 
CompanyID awarded = CompanyID::Invalid()
 Subsidy is awarded to this company; CompanyID::Invalid() if it's not awarded to anyone.
 
Source src {}
 Source of subsidised path.
 
Source dst {}
 Destination of subsidised path.
 
- Data Fields inherited from Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_subsidy_pool >
const Tindex index
 Index of this pool item.
 

Additional Inherited Members

- Public Types inherited from Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_subsidy_pool >
typedef struct Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache > Pool
 Type of the pool this item is going to be part of.
 
- Static Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_subsidy_pool >
static T * Create (Targs &&... args)
 Creates a new T-object in the associated pool.
 
static T * CreateAtIndex (Tindex index, Targs &&... args)
 Creates a new T-object in the associated 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 (auto index)
 Tests whether given index can be used to get valid (non-nullptr) Titem.
 
static Titem * Get (auto index)
 Returns Titem with given index.
 
static Titem * GetIfValid (auto 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.
 

Detailed Description

Struct about subsidies, offered and awarded.

Definition at line 23 of file subsidy_base.h.

Constructor & Destructor Documentation

◆ Subsidy()

Subsidy::Subsidy ( SubsidyID  index,
CargoType  cargo_type = INVALID_CARGO,
Source  src = {},
Source  dst = {},
uint16_t  remaining = 0 
)
inline

Definition at line 30 of file subsidy_base.h.

◆ ~Subsidy()

Subsidy::~Subsidy ( )
inline

(Empty) destructor has to be defined else operator delete might be called with nullptr parameter

Definition at line 36 of file subsidy_base.h.

Member Function Documentation

◆ AwardTo()

◆ IsAwarded()

bool Subsidy::IsAwarded ( ) const
inline

Tests whether this subsidy has been awarded to someone.

Returns
is this subsidy awarded?

Definition at line 42 of file subsidy_base.h.

Referenced by AwardTo(), SubsidyListWindow::CountLines(), and SubsidyListWindow::DrawWidget().

Field Documentation

◆ awarded

CompanyID Subsidy::awarded = CompanyID::Invalid()

Subsidy is awarded to this company; CompanyID::Invalid() if it's not awarded to anyone.

Definition at line 26 of file subsidy_base.h.

Referenced by AwardTo(), and SubsidyListWindow::DrawWidget().

◆ cargo_type

CargoType Subsidy::cargo_type = INVALID_CARGO

Cargo type involved in this subsidy, INVALID_CARGO for invalid subsidy.

Definition at line 24 of file subsidy_base.h.

Referenced by AwardTo(), CreateSubsidy(), and SubsidyListWindow::DrawWidget().

◆ dst

Source Subsidy::dst {}

Destination of subsidised path.

Definition at line 28 of file subsidy_base.h.

Referenced by AwardTo(), CreateSubsidy(), and SubsidyListWindow::DrawWidget().

◆ remaining

uint16_t Subsidy::remaining = 0

Remaining months when this subsidy is valid.

Definition at line 25 of file subsidy_base.h.

Referenced by AwardTo(), and SubsidyListWindow::DrawWidget().

◆ src

Source Subsidy::src {}

Source of subsidised path.

Definition at line 27 of file subsidy_base.h.

Referenced by AwardTo(), CreateSubsidy(), and SubsidyListWindow::DrawWidget().


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