Public Types | Static Public Member Functions

ScriptCompany Class Reference

Class that handles all company related functions. More...

#include <script_company.hpp>

Inheritance diagram for ScriptCompany:
ScriptObject SimpleCountedObject

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 = ::COMPANY_FIRST, COMPANY_LAST = ::MAX_COMPANIES, COMPANY_INVALID = -1, COMPANY_SELF = 254 }
 

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 (Text *name)
 Set the name of your company.
static char * GetName (CompanyID company)
 Get the name of the given company.
static bool SetPresidentName (Text *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.

Detailed Description

Class that handles all company related functions.

ai game

Definition at line 22 of file script_company.hpp.


Member Enumeration Documentation

Different constants related to CompanyID.

Enumerator:
COMPANY_FIRST 

The first available company.

COMPANY_LAST 

The last available company.

COMPANY_INVALID 

An invalid company.

COMPANY_SELF 

Constant that gets resolved to the correct company index for your company.

Definition at line 31 of file script_company.hpp.

Possible genders for company presidents.

Enumerator:
GENDER_MALE 

A male person.

GENDER_FEMALE 

A female person.

GENDER_INVALID 

An invalid gender.

Definition at line 42 of file script_company.hpp.

The range of possible quarters to get company information of.

Enumerator:
CURRENT_QUARTER 

The current quarter.

EARLIEST_QUARTER 

The earliest quarter company information is available for.

Definition at line 25 of file script_company.hpp.


Member Function Documentation

bool ScriptCompany::BuildCompanyHQ ( TileIndex  tile  )  [static]

Build your company's HQ on the given tile.

Parameters:
tile The tile to build your HQ on, this tile is the most nothern tile of your HQ.
Precondition:
ScriptMap::IsValidTile(tile).
Valid ScriptCompanyMode active in scope.
Exceptions:
ScriptError::ERR_AREA_NOT_CLEAR 
ScriptError::ERR_FLAT_LAND_REQUIRED 
Returns:
True if the HQ could be build.
Note:
An HQ can not be removed, only by water or rebuilding; If an HQ is build again, the old one is removed.

Definition at line 230 of file script_company.cpp.

References CMD_BUILD_OBJECT, ScriptObject::DoCommand(), EnforcePrecondition, ScriptObject::GetCompany(), IsValidTile(), OBJECT_HQ, and OWNER_DEITY.

uint32 ScriptCompany::GetAutoRenewMoney ( CompanyID  company  )  [static]

Return the minimum money needed to autorenew an engine for a company.

Parameters:
company The company to get the autorenew money of.
Precondition:
ResolveCompanyID(company) != COMPANY_INVALID.
Returns:
The minimum required money for autorenew to work.

Definition at line 278 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.

Parameters:
company The company to get the autorenew months of.
Precondition:
ResolveCompanyID(company) != COMPANY_INVALID.
Returns:
The months before/after max age of engine.

Definition at line 265 of file script_company.cpp.

References COMPANY_INVALID, and ResolveCompanyID().

bool ScriptCompany::GetAutoRenewStatus ( CompanyID  company  )  [static]

Return whether autorenew is enabled for a company.

Parameters:
company The company to get the autorenew status of.
Precondition:
ResolveCompanyID(company) != COMPANY_INVALID.
Returns:
True if autorenew is enabled.

Definition at line 252 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.

Parameters:
company The company to get the bank balance of.
Precondition:
ResolveCompanyID(company) != COMPANY_INVALID.
Returns:
The actual bank balance.

Definition at line 174 of file script_company.cpp.

References COMPANY_INVALID, and ResolveCompanyID().

Referenced by SetLoanAmount().

TileIndex ScriptCompany::GetCompanyHQ ( CompanyID  company  )  [static]

Return the location of a company's HQ.

Parameters:
company The company the get the HQ of.
Precondition:
ResolveCompanyID(company) != COMPANY_INVALID.
Returns:
The tile of the company's HQ, this tile is the most nothern tile of that HQ, or ScriptMap::TILE_INVALID if there is no HQ yet.

Definition at line 238 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.

Returns:
The amount loaned money.
Postcondition:
GetLoanInterval() is always a multiplier of the return value.

Definition at line 182 of file script_company.cpp.

References COMPANY_INVALID, COMPANY_SELF, and ResolveCompanyID().

Referenced by SetLoanAmount(), and SetMinimumLoanAmount().

Money ScriptCompany::GetLoanInterval (  )  [static]

Gets the interval/loan step.

Returns:
The loan step.
Postcondition:
Return value is always positive.

Definition at line 195 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.

Returns:
The maximum amount your company can loan.
Postcondition:
GetLoanInterval() is always a multiplier of the return value.

Definition at line 190 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.

Parameters:
company The company to get the name for.
Precondition:
ResolveCompanyID(company) != COMPANY_INVALID.
Returns:
The name of the given company.

Definition at line 54 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.

Parameters:
company The company to get the presidents gender off.
Returns:
The gender of the president.

Definition at line 106 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.

Parameters:
company The company to get the president's name for.
Precondition:
ResolveCompanyID(company) != COMPANY_INVALID.
Returns:
The name of the president of the given company.

Definition at line 78 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.

Parameters:
company The company to get the amount of delivered cargo of.
quarter The quarter to get the amount of delivered cargo of.
Precondition:
ResolveCompanyID(company) != COMPANY_INVALID.
quarter <= EARLIEST_QUARTER.
Returns:
The amount of cargo delivered by the given company in the given quarter.

Definition at line 139 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.

Parameters:
company The company to get the value of.
quarter The quarter to get the value of.
Precondition:
ResolveCompanyID(company) != COMPANY_INVALID.
quarter <= EARLIEST_QUARTER.
Returns:
The value of the company in the given quarter.

Definition at line 161 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.

Parameters:
company The company to get the quarterly expenses of.
quarter The quarter to get the expenses of.
Precondition:
ResolveCompanyID(company) != COMPANY_INVALID.
quarter <= EARLIEST_QUARTER.
Returns:
The expenses of the company in the given quarter.

Definition at line 127 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.

Parameters:
company The company to get the quarterly income of.
quarter The quarter to get the income of.
Precondition:
ResolveCompanyID(company) != COMPANY_INVALID.
quarter <= EARLIEST_QUARTER.
Returns:
The bruto income of the company in the given quarter.

Definition at line 115 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.

Parameters:
company The company to get the performance rating of.
quarter The quarter to get the performance rating of.
Precondition:
ResolveCompanyID(company) != COMPANY_INVALID.
quarter <= EARLIEST_QUARTER.
quarter != CURRENT_QUARTER.
Note:
The performance rating is calculated after every quarter, so the value for CURRENT_QUARTER is undefined.
Returns:
The performance rating of the given company in the given quarter.

Definition at line 151 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.

Parameters:
company The company index to check.
Returns:
True if and only if this company is your CompanyID. -game

Definition at line 37 of file script_company.cpp.

References COMPANY_SELF, and ResolveCompanyID().

bool ScriptCompany::SetAutoRenewMoney ( uint32  money  )  [static]

Set the minimum money needed to autorenew an engine for your company.

Parameters:
money The new minimum required money for autorenew to work.
Returns:
True if autorenew money has been modified. -game

Definition at line 273 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.

Parameters:
months The new months between autorenew.
Returns:
True if autorenew months has been modified. -game

Definition at line 260 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.

Parameters:
autorenew The new autorenew status.
Returns:
True if autorenew status has been modified. -game

Definition at line 247 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.

Parameters:
loan The amount to loan (multiplier of GetLoanInterval()).
Precondition:
'loan' must be non-negative.
GetLoanInterval() must be a multiplier of 'loan'.
'loan' must be below GetMaxLoanAmount().
'loan' - GetLoanAmount() + GetBankBalance() must be non-negative.
Valid ScriptCompanyMode active in scope.
Returns:
True if the loan could be set to your requested amount.

Definition at line 200 of file script_company.cpp.

References abs(), CMD_DECREASE_LOAN, CMD_INCREASE_LOAN, COMPANY_SELF, ScriptObject::DoCommand(), EnforcePrecondition, GetBankBalance(), ScriptObject::GetCompany(), GetLoanAmount(), GetLoanInterval(), GetMaxLoanAmount(), and OWNER_DEITY.

Referenced by SetMinimumLoanAmount().

bool ScriptCompany::SetMinimumLoanAmount ( int32  loan  )  [static]

Sets the minimum amount to loan, i.e.

the given amount of loan rounded up.

Parameters:
loan The amount to loan (any positive number).
Precondition:
'loan' must be non-negative.
'loan' must be below GetMaxLoanAmount().
Valid ScriptCompanyMode active in scope.
Returns:
True if we could allocate a minimum of 'loan' loan.

Definition at line 215 of file script_company.cpp.

References EnforcePrecondition, ScriptObject::GetCompany(), GetLoanAmount(), GetLoanInterval(), GetMaxLoanAmount(), OWNER_DEITY, and SetLoanAmount().

bool ScriptCompany::SetName ( Text name  )  [static]

Set the name of your company.

Parameters:
name The new name of the company (can be either a raw string, or a ScriptText object).
Precondition:
name != NULL && len(name) != 0.
Exceptions:
ScriptError::ERR_NAME_IS_NOT_UNIQUE 
Returns:
True if the name was changed.

Definition at line 42 of file script_company.cpp.

References CMD_RENAME_COMPANY, ScriptObject::DoCommand(), EnforcePrecondition, EnforcePreconditionCustomError, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG, Text::GetEncodedText(), MAX_LENGTH_COMPANY_NAME_CHARS, StrEmpty(), and Utf8StringLength().

bool ScriptCompany::SetPresidentGender ( Gender  gender  )  [static]

Set the gender of the president of your company.

Parameters:
gender The new gender for your president.
Precondition:
GetPresidentGender(ScriptCompany.COMPANY_SELF) != gender.
Returns:
True if the gender was changed.
Note:
When successful a random face will be created. -game

Definition at line 94 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 ( Text name  )  [static]

Set the name of your president.

Parameters:
name The new name of the president (can be either a raw string, or a ScriptText object).
Precondition:
name != NULL && len(name) != 0.
Exceptions:
ScriptError::ERR_NAME_IS_NOT_UNIQUE 
Returns:
True if the name was changed.

Definition at line 67 of file script_company.cpp.

References CMD_RENAME_PRESIDENT, ScriptObject::DoCommand(), EnforcePrecondition, Text::GetEncodedText(), and StrEmpty().


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