OpenTTD Source 20250331-master-g3c15e0c889
Source Struct Reference

A location from where cargo can come from (or go to). More...

#include <source_type.h>

Public Member Functions

 Source (ConvertibleThroughBase auto id, SourceType type)
 
 Source (SourceID id, SourceType type)
 
constexpr CompanyID ToCompanyID () const
 
constexpr IndustryID ToIndustryID () const
 
constexpr TownID ToTownID () const
 
constexpr void MakeInvalid ()
 
constexpr void SetIndex (SourceID index)
 
constexpr void SetIndex (ConvertibleThroughBase auto index)
 
constexpr bool IsValid () const noexcept
 
auto operator<=> (const Source &source) const =default
 
NewsReference GetNewsReference () const
 Get the NewsReference for a subsidy Source.
 
StringID GetFormat () const
 Get the format string for a subsidy Source.
 

Data Fields

SourceID id
 Index of industry/town/HQ, Source::Invalid if unknown/invalid.
 
SourceType type
 Type of source_id.
 

Static Public Attributes

static constexpr SourceID Invalid = 0xFFFF
 Invalid/unknown index of source.
 

Detailed Description

A location from where cargo can come from (or go to).

Specifically industries, towns and headquarters.

Definition at line 32 of file source_type.h.

Constructor & Destructor Documentation

◆ Source() [1/2]

Source::Source ( ConvertibleThroughBase auto  id,
SourceType  type 
)
inline

Definition at line 40 of file source_type.h.

◆ Source() [2/2]

Source::Source ( SourceID  id,
SourceType  type 
)
inline

Definition at line 41 of file source_type.h.

Member Function Documentation

◆ GetFormat()

StringID Source::GetFormat ( ) const

Get the format string for a subsidy Source.

Returns
The format string.

Definition at line 56 of file subsidy.cpp.

References Industry, Town, and type.

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

◆ GetNewsReference()

NewsReference Source::GetNewsReference ( ) const

Get the NewsReference for a subsidy Source.

Returns
NewsReference.

Definition at line 43 of file subsidy.cpp.

References Industry, and Town.

Referenced by Subsidy::AwardTo(), and CreateSubsidy().

◆ IsValid()

constexpr bool Source::IsValid ( ) const
inlineconstexprnoexcept

Definition at line 51 of file source_type.h.

◆ MakeInvalid()

constexpr void Source::MakeInvalid ( )
inlineconstexpr

Definition at line 47 of file source_type.h.

◆ SetIndex() [1/2]

constexpr void Source::SetIndex ( ConvertibleThroughBase auto  index)
inlineconstexpr

Definition at line 49 of file source_type.h.

◆ SetIndex() [2/2]

constexpr void Source::SetIndex ( SourceID  index)
inlineconstexpr

Definition at line 48 of file source_type.h.

◆ ToCompanyID()

constexpr CompanyID Source::ToCompanyID ( ) const
inlineconstexpr

Definition at line 43 of file source_type.h.

◆ ToIndustryID()

constexpr IndustryID Source::ToIndustryID ( ) const
inlineconstexpr

Definition at line 44 of file source_type.h.

◆ ToTownID()

constexpr TownID Source::ToTownID ( ) const
inlineconstexpr

Definition at line 45 of file source_type.h.

Field Documentation

◆ id

SourceID Source::id

Index of industry/town/HQ, Source::Invalid if unknown/invalid.

Definition at line 36 of file source_type.h.

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

◆ Invalid

constexpr SourceID Source::Invalid = 0xFFFF
staticconstexpr

Invalid/unknown index of source.

Definition at line 34 of file source_type.h.

Referenced by FindSubsidyCargoDestination().

◆ type


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