Class that handles all company related functions. More...
#include <script_company.hpp>
Public Types | |
enum | Quarter { CURRENT_QUARTER = 0, EARLIEST_QUARTER = MAX_HISTORY_QUARTERS } |
The range of possible quarters to get company information of. More... | |
enum | CompanyID { COMPANY_FIRST = 0, COMPANY_LAST = ::MAX_COMPANIES, COMPANY_SELF = 254, COMPANY_INVALID = -1 } |
Different constants related to CompanyID. More... | |
enum | Gender { GENDER_MALE, GENDER_FEMALE, GENDER_INVALID = -1 } |
Possible genders for company presidents. More... | |
Static Public Member Functions | |
static CompanyID | ResolveCompanyID (CompanyID company) |
Resolved the given company index to the correct index for the company. | |
static bool | IsMine (CompanyID company) |
Check if a CompanyID is your CompanyID, to ease up checks. | |
static bool | SetName (const char *name) |
Set the name of your company. | |
static char * | GetName (CompanyID company) |
Get the name of the given company. | |
static bool | SetPresidentName (const char *name) |
Set the name of your president. | |
static char * | GetPresidentName (CompanyID company) |
Get the name of the president of the given company. | |
static bool | SetPresidentGender (Gender gender) |
Set the gender of the president of your company. | |
static Gender | GetPresidentGender (CompanyID company) |
Get the gender of the president of the given company. | |
static bool | SetLoanAmount (int32 loan) |
Sets the amount to loan. | |
static bool | SetMinimumLoanAmount (int32 loan) |
Sets the minimum amount to loan, i.e. | |
static Money | GetLoanAmount () |
Gets the amount your company have loaned. | |
static Money | GetMaxLoanAmount () |
Gets the maximum amount your company can loan. | |
static Money | GetLoanInterval () |
Gets the interval/loan step. | |
static Money | GetBankBalance (CompanyID company) |
Gets the bank balance. | |
static Money | GetQuarterlyIncome (CompanyID company, uint32 quarter) |
Get the income of the company in the given quarter. | |
static Money | GetQuarterlyExpenses (CompanyID company, uint32 quarter) |
Get the expenses of the company in the given quarter. | |
static int32 | GetQuarterlyCargoDelivered (CompanyID company, uint32 quarter) |
Get the amount of cargo delivered by the given company in the given quarter. | |
static int32 | GetQuarterlyPerformanceRating (CompanyID company, uint32 quarter) |
Get the performance rating of the given company in the given quarter. | |
static Money | GetQuarterlyCompanyValue (CompanyID company, uint32 quarter) |
Get the value of the company in the given quarter. | |
static bool | BuildCompanyHQ (TileIndex tile) |
Build your company's HQ on the given tile. | |
static TileIndex | GetCompanyHQ (CompanyID company) |
Return the location of a company's HQ. | |
static bool | SetAutoRenewStatus (bool autorenew) |
Set whether autorenew is enabled for your company. | |
static bool | GetAutoRenewStatus (CompanyID company) |
Return whether autorenew is enabled for a company. | |
static bool | SetAutoRenewMonths (int16 months) |
Set the number of months before/after max age to autorenew an engine for your company. | |
static int16 | GetAutoRenewMonths (CompanyID company) |
Return the number of months before/after max age to autorenew an engine for a company. | |
static bool | SetAutoRenewMoney (uint32 money) |
Set the minimum money needed to autorenew an engine for your company. | |
static uint32 | GetAutoRenewMoney (CompanyID company) |
Return the minimum money needed to autorenew an engine for a company. |
Class that handles all company related functions.
ai
Definition at line 21 of file script_company.hpp.
Different constants related to CompanyID.
Definition at line 30 of file script_company.hpp.
Possible genders for company presidents.
GENDER_MALE |
A male person. |
GENDER_FEMALE |
A female person. |
GENDER_INVALID |
An invalid gender. |
Definition at line 38 of file script_company.hpp.
The range of possible quarters to get company information of.
CURRENT_QUARTER |
The current quarter. |
EARLIEST_QUARTER |
The earliest quarter company information is available for. |
Definition at line 24 of file script_company.hpp.
bool ScriptCompany::BuildCompanyHQ | ( | TileIndex | tile | ) | [static] |
Build your company's HQ on the given tile.
tile | The tile to build your HQ on, this tile is the most nothern tile of your HQ. |
Definition at line 214 of file script_company.cpp.
References CMD_BUILD_OBJECT, ScriptObject::DoCommand(), EnforcePrecondition, IsValidTile(), and OBJECT_HQ.
uint32 ScriptCompany::GetAutoRenewMoney | ( | CompanyID | company | ) | [static] |
Return the minimum money needed to autorenew an engine for a company.
company | The company to get the autorenew money of. |
Definition at line 261 of file script_company.cpp.
References COMPANY_INVALID, and ResolveCompanyID().
int16 ScriptCompany::GetAutoRenewMonths | ( | CompanyID | company | ) | [static] |
Return the number of months before/after max age to autorenew an engine for a company.
company | The company to get the autorenew months of. |
Definition at line 248 of file script_company.cpp.
References COMPANY_INVALID, and ResolveCompanyID().
bool ScriptCompany::GetAutoRenewStatus | ( | CompanyID | company | ) | [static] |
Return whether autorenew is enabled for a company.
company | The company to get the autorenew status of. |
Definition at line 235 of file script_company.cpp.
References COMPANY_INVALID, and ResolveCompanyID().
Money ScriptCompany::GetBankBalance | ( | ScriptCompany::CompanyID | company | ) | [static] |
Gets the bank balance.
In other words, the amount of money the given company can spent.
company | The company to get the bank balance of. |
Definition at line 163 of file script_company.cpp.
References COMPANY_INVALID, and ResolveCompanyID().
Referenced by SetLoanAmount().
Return the location of a company's HQ.
company | The company the get the HQ of. |
Definition at line 221 of file script_company.cpp.
References COMPANY_INVALID, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), INVALID_TILE, and ResolveCompanyID().
Money ScriptCompany::GetLoanAmount | ( | ) | [static] |
Gets the amount your company have loaned.
Definition at line 171 of file script_company.cpp.
References _current_company.
Referenced by SetLoanAmount(), and SetMinimumLoanAmount().
Money ScriptCompany::GetLoanInterval | ( | ) | [static] |
Gets the interval/loan step.
Definition at line 181 of file script_company.cpp.
References LOAN_INTERVAL.
Referenced by SetLoanAmount(), and SetMinimumLoanAmount().
Money ScriptCompany::GetMaxLoanAmount | ( | ) | [static] |
Gets the maximum amount your company can loan.
Definition at line 176 of file script_company.cpp.
References Economy::max_loan.
Referenced by SetLoanAmount(), and SetMinimumLoanAmount().
char * ScriptCompany::GetName | ( | ScriptCompany::CompanyID | company | ) | [static] |
Get the name of the given company.
company | The company to get the name for. |
Definition at line 47 of file script_company.cpp.
References COMPANY_INVALID, ResolveCompanyID(), and SetDParam().
ScriptCompany::Gender ScriptCompany::GetPresidentGender | ( | CompanyID | company | ) | [static] |
Get the gender of the president of the given company.
company | The company to get the presidents gender off. |
Definition at line 95 of file script_company.cpp.
References COMPANY_INVALID, GENDER_FEMALE, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetCompanyManagerFaceBits(), HasBit(), and ResolveCompanyID().
Referenced by SetPresidentGender().
char * ScriptCompany::GetPresidentName | ( | ScriptCompany::CompanyID | company | ) | [static] |
Get the name of the president of the given company.
company | The company to get the president's name for. |
Definition at line 67 of file script_company.cpp.
References COMPANY_INVALID, ResolveCompanyID(), and SetDParam().
int32 ScriptCompany::GetQuarterlyCargoDelivered | ( | ScriptCompany::CompanyID | company, | |
uint32 | quarter | |||
) | [static] |
Get the amount of cargo delivered by the given company in the given quarter.
company | The company to get the amount of delivered cargo of. | |
quarter | The quarter to get the amount of delivered cargo of. |
Definition at line 128 of file script_company.cpp.
References COMPANY_INVALID, CURRENT_QUARTER, EARLIEST_QUARTER, and ResolveCompanyID().
Money ScriptCompany::GetQuarterlyCompanyValue | ( | ScriptCompany::CompanyID | company, | |
uint32 | quarter | |||
) | [static] |
Get the value of the company in the given quarter.
company | The company to get the value of. | |
quarter | The quarter to get the value of. |
Definition at line 150 of file script_company.cpp.
References CalculateCompanyValue(), COMPANY_INVALID, CURRENT_QUARTER, EARLIEST_QUARTER, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), and ResolveCompanyID().
Money ScriptCompany::GetQuarterlyExpenses | ( | ScriptCompany::CompanyID | company, | |
uint32 | quarter | |||
) | [static] |
Get the expenses of the company in the given quarter.
company | The company to get the quarterly expenses of. | |
quarter | The quarter to get the expenses of. |
Definition at line 116 of file script_company.cpp.
References COMPANY_INVALID, CURRENT_QUARTER, EARLIEST_QUARTER, and ResolveCompanyID().
Money ScriptCompany::GetQuarterlyIncome | ( | ScriptCompany::CompanyID | company, | |
uint32 | quarter | |||
) | [static] |
Get the income of the company in the given quarter.
company | The company to get the quarterly income of. | |
quarter | The quarter to get the income of. |
Definition at line 104 of file script_company.cpp.
References COMPANY_INVALID, CURRENT_QUARTER, EARLIEST_QUARTER, and ResolveCompanyID().
int32 ScriptCompany::GetQuarterlyPerformanceRating | ( | ScriptCompany::CompanyID | company, | |
uint32 | quarter | |||
) | [static] |
Get the performance rating of the given company in the given quarter.
company | The company to get the performance rating of. | |
quarter | The quarter to get the performance rating of. |
Definition at line 140 of file script_company.cpp.
References COMPANY_INVALID, CURRENT_QUARTER, EARLIEST_QUARTER, and ResolveCompanyID().
bool ScriptCompany::IsMine | ( | ScriptCompany::CompanyID | company | ) | [static] |
Check if a CompanyID is your CompanyID, to ease up checks.
company | The company index to check. |
Definition at line 34 of file script_company.cpp.
References COMPANY_SELF, and ResolveCompanyID().
ScriptCompany::CompanyID ScriptCompany::ResolveCompanyID | ( | ScriptCompany::CompanyID | company | ) | [static] |
Resolved the given company index to the correct index for the company.
If the company index was COMPANY_SELF it will be resolved to the index of your company. If the company with the given index does not exist it will return COMPANY_INVALID.
company | The company index to resolve. |
Definition at line 27 of file script_company.cpp.
References _current_company, and COMPANY_SELF.
Referenced by GetAutoRenewMoney(), GetAutoRenewMonths(), GetAutoRenewStatus(), GetBankBalance(), GetCompanyHQ(), ScriptInfrastructure::GetInfrastructurePieceCount(), ScriptInfrastructure::GetMonthlyInfrastructureCosts(), ScriptInfrastructure::GetMonthlyRailCosts(), ScriptInfrastructure::GetMonthlyRoadCosts(), GetName(), ScriptTile::GetOwner(), GetPresidentGender(), GetPresidentName(), GetQuarterlyCargoDelivered(), GetQuarterlyCompanyValue(), GetQuarterlyExpenses(), GetQuarterlyIncome(), GetQuarterlyPerformanceRating(), ScriptInfrastructure::GetRailPieceCount(), ScriptTown::GetRating(), ScriptInfrastructure::GetRoadPieceCount(), and IsMine().
bool ScriptCompany::SetAutoRenewMoney | ( | uint32 | money | ) | [static] |
Set the minimum money needed to autorenew an engine for your company.
money | The new minimum required money for autorenew to work. |
Definition at line 256 of file script_company.cpp.
References CMD_CHANGE_COMPANY_SETTING, ScriptObject::DoCommand(), and GetCompanySettingIndex().
bool ScriptCompany::SetAutoRenewMonths | ( | int16 | months | ) | [static] |
Set the number of months before/after max age to autorenew an engine for your company.
months | The new months between autorenew. |
Definition at line 243 of file script_company.cpp.
References CMD_CHANGE_COMPANY_SETTING, ScriptObject::DoCommand(), and GetCompanySettingIndex().
bool ScriptCompany::SetAutoRenewStatus | ( | bool | autorenew | ) | [static] |
Set whether autorenew is enabled for your company.
autorenew | The new autorenew status. |
Definition at line 230 of file script_company.cpp.
References CMD_CHANGE_COMPANY_SETTING, ScriptObject::DoCommand(), and GetCompanySettingIndex().
bool ScriptCompany::SetLoanAmount | ( | int32 | loan | ) | [static] |
Sets the amount to loan.
loan | The amount to loan (multiplier of GetLoanInterval()). |
Definition at line 186 of file script_company.cpp.
References abs(), CMD_DECREASE_LOAN, CMD_INCREASE_LOAN, COMPANY_SELF, ScriptObject::DoCommand(), EnforcePrecondition, GetBankBalance(), GetLoanAmount(), GetLoanInterval(), and GetMaxLoanAmount().
Referenced by SetMinimumLoanAmount().
bool ScriptCompany::SetMinimumLoanAmount | ( | int32 | loan | ) | [static] |
Sets the minimum amount to loan, i.e.
the given amount of loan rounded up.
loan | The amount to loan (any positive number). |
Definition at line 200 of file script_company.cpp.
References EnforcePrecondition, GetLoanAmount(), GetLoanInterval(), GetMaxLoanAmount(), and SetLoanAmount().
bool ScriptCompany::SetName | ( | const char * | name | ) | [static] |
Set the name of your company.
name | The new name of the company. |
ScriptError::ERR_NAME_IS_NOT_UNIQUE |
Definition at line 39 of file script_company.cpp.
References CMD_RENAME_COMPANY, ScriptObject::DoCommand(), EnforcePrecondition, EnforcePreconditionCustomError, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG, MAX_LENGTH_COMPANY_NAME_CHARS, StrEmpty(), and Utf8StringLength().
bool ScriptCompany::SetPresidentGender | ( | Gender | gender | ) | [static] |
Set the gender of the president of your company.
gender | The new gender for your president. |
Definition at line 83 of file script_company.cpp.
References CMD_SET_COMPANY_MANAGER_FACE, COMPANY_SELF, ScriptObject::DoCommand(), EnforcePrecondition, ETHNICITY_BLACK, GENDER_FEMALE, GENDER_MALE, GetPresidentGender(), and RandomCompanyManagerFaceBits().
bool ScriptCompany::SetPresidentName | ( | const char * | name | ) | [static] |
Set the name of your president.
name | The new name of the president. |
ScriptError::ERR_NAME_IS_NOT_UNIQUE |
Definition at line 60 of file script_company.cpp.
References CMD_RENAME_PRESIDENT, ScriptObject::DoCommand(), EnforcePrecondition, and StrEmpty().