Class that handles all subsidy related functions. More...
#include <script_subsidy.hpp>
Public Types | |
enum | SubsidyParticipantType { SPT_INDUSTRY = 0, SPT_TOWN = 1, SPT_INVALID = 0xFF } |
Enumeration for source and destination of a subsidy. More... | |
Static Public Member Functions | |
static bool | IsValidSubsidy (SubsidyID subsidy_id) |
Check whether this is a valid SubsidyID. | |
static bool | IsAwarded (SubsidyID subsidy_id) |
Checks whether this subsidy is already awarded to some company. | |
static bool | Create (CargoID cargo_type, SubsidyParticipantType from_type, uint16 from_id, SubsidyParticipantType to_type, uint16 to_id) |
Create a new subsidy. | |
static ScriptCompany::CompanyID | GetAwardedTo (SubsidyID subsidy_id) |
Get the company index of the company this subsidy is awarded to. | |
static int32 | GetExpireDate (SubsidyID subsidy_id) |
Get the date this subsidy expires. | |
static CargoID | GetCargoType (SubsidyID subsidy_id) |
Get the cargo type that has to be transported in order to be awarded this subsidy. | |
static SubsidyParticipantType | GetSourceType (SubsidyID subsidy_id) |
Returns the type of source of subsidy. | |
static int32 | GetSourceIndex (SubsidyID subsidy_id) |
Return the source IndustryID/TownID the subsidy is for. | |
static SubsidyParticipantType | GetDestinationType (SubsidyID subsidy_id) |
Returns the type of destination of subsidy. | |
static int32 | GetDestinationIndex (SubsidyID subsidy_id) |
Return the destination IndustryID/TownID the subsidy is for. |
Class that handles all subsidy related functions.
ai game
Definition at line 21 of file script_subsidy.hpp.
Enumeration for source and destination of a subsidy.
SPT_INDUSTRY |
Subsidy participant is an industry. |
SPT_TOWN |
Subsidy participant is a town. |
SPT_INVALID |
Invalid/unknown participant type. |
Definition at line 27 of file script_subsidy.hpp.
bool ScriptSubsidy::Create | ( | CargoID | cargo_type, | |
SubsidyParticipantType | from_type, | |||
uint16 | from_id, | |||
SubsidyParticipantType | to_type, | |||
uint16 | to_id | |||
) | [static] |
Create a new subsidy.
cargo_type | The type of cargo to cary for the subsidy. | |
from_type | The type of the subsidy on the 'from' side. | |
from_id | The ID of the 'from' side. | |
to_type | The type of the subsidy on the 'to' side. | |
to_id | The ID of the 'to' side. |
Definition at line 33 of file script_subsidy.cpp.
References CMD_CREATE_SUBSIDY, ScriptObject::DoCommand(), EnforcePrecondition, ScriptCargo::IsValidCargo(), ScriptIndustry::IsValidIndustry(), ScriptTown::IsValidTown(), SPT_INDUSTRY, and SPT_TOWN.
ScriptCompany::CompanyID ScriptSubsidy::GetAwardedTo | ( | SubsidyID | subsidy_id | ) | [static] |
Get the company index of the company this subsidy is awarded to.
subsidy_id | The SubsidyID to check. |
Definition at line 44 of file script_subsidy.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_subsidy_pool >::Get(), and IsAwarded().
Get the cargo type that has to be transported in order to be awarded this subsidy.
subsidy_id | The SubsidyID to check. |
Definition at line 66 of file script_subsidy.cpp.
References IsValidSubsidy().
int32 ScriptSubsidy::GetDestinationIndex | ( | SubsidyID | subsidy_id | ) | [static] |
Return the destination IndustryID/TownID the subsidy is for.
subsidy_id | the SubsidyID to check. |
Definition at line 94 of file script_subsidy.cpp.
References IsValidSubsidy().
ScriptSubsidy::SubsidyParticipantType ScriptSubsidy::GetDestinationType | ( | SubsidyID | subsidy_id | ) | [static] |
Returns the type of destination of subsidy.
subsidy_id | The SubsidyID to check. |
Definition at line 87 of file script_subsidy.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_subsidy_pool >::Get(), and IsValidSubsidy().
int32 ScriptSubsidy::GetExpireDate | ( | SubsidyID | subsidy_id | ) | [static] |
Get the date this subsidy expires.
In case the subsidy is already awarded, return the date the subsidy expires, else, return the date the offer expires.
subsidy_id | The SubsidyID to check. |
Definition at line 51 of file script_subsidy.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_subsidy_pool >::Get(), ScriptDate::GetCurrentDate(), ScriptDate::GetDate(), ScriptDate::GetMonth(), ScriptDate::GetYear(), and IsValidSubsidy().
int32 ScriptSubsidy::GetSourceIndex | ( | SubsidyID | subsidy_id | ) | [static] |
Return the source IndustryID/TownID the subsidy is for.
subsidy_id | The SubsidyID to check. |
Definition at line 80 of file script_subsidy.cpp.
References IsValidSubsidy().
ScriptSubsidy::SubsidyParticipantType ScriptSubsidy::GetSourceType | ( | SubsidyID | subsidy_id | ) | [static] |
Returns the type of source of subsidy.
subsidy_id | The SubsidyID to check. |
Definition at line 73 of file script_subsidy.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_subsidy_pool >::Get(), and IsValidSubsidy().
bool ScriptSubsidy::IsAwarded | ( | SubsidyID | subsidy_id | ) | [static] |
Checks whether this subsidy is already awarded to some company.
subsidy_id | The SubsidyID to check. |
Definition at line 26 of file script_subsidy.cpp.
References IsValidSubsidy().
Referenced by GetAwardedTo().
bool ScriptSubsidy::IsValidSubsidy | ( | SubsidyID | subsidy_id | ) | [static] |
Check whether this is a valid SubsidyID.
subsidy_id | The SubsidyID to check. |
Definition at line 21 of file script_subsidy.cpp.
Referenced by GetCargoType(), GetDestinationIndex(), GetDestinationType(), GetExpireDate(), GetSourceIndex(), GetSourceType(), and IsAwarded().