OpenTTD Source 20250222-master-g9a8d9e4e48
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
 

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 30 of file source_type.h.

Constructor & Destructor Documentation

◆ Source() [1/2]

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

Definition at line 38 of file source_type.h.

◆ Source() [2/2]

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

Definition at line 39 of file source_type.h.

Member Function Documentation

◆ IsValid()

constexpr bool Source::IsValid ( ) const
inlineconstexprnoexcept

Definition at line 49 of file source_type.h.

◆ MakeInvalid()

constexpr void Source::MakeInvalid ( )
inlineconstexpr

Definition at line 45 of file source_type.h.

◆ SetIndex() [1/2]

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

Definition at line 47 of file source_type.h.

◆ SetIndex() [2/2]

constexpr void Source::SetIndex ( SourceID  index)
inlineconstexpr

Definition at line 46 of file source_type.h.

◆ ToCompanyID()

constexpr CompanyID Source::ToCompanyID ( ) const
inlineconstexpr

Definition at line 41 of file source_type.h.

◆ ToIndustryID()

constexpr IndustryID Source::ToIndustryID ( ) const
inlineconstexpr

Definition at line 42 of file source_type.h.

◆ ToTownID()

constexpr TownID Source::ToTownID ( ) const
inlineconstexpr

Definition at line 43 of file source_type.h.

Field Documentation

◆ id

SourceID Source::id

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

Definition at line 34 of file source_type.h.

Referenced by SetupSubsidyDecodeParam().

◆ Invalid

constexpr SourceID Source::Invalid = 0xFFFF
staticconstexpr

Invalid/unknown index of source.

Definition at line 32 of file source_type.h.

Referenced by FindSubsidyCargoDestination().

◆ type


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