GSCompany Class Reference

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


Public Types

enum  Quarter {
  CURRENT_QUARTER,
  EARLIEST_QUARTER
}
 The range of possible quarters to get company information of. More...
enum  CompanyID {
  COMPANY_FIRST,
  COMPANY_LAST,
  COMPANY_INVALID,
  COMPANY_SELF
}
 Different constants related to CompanyID. More...
enum  Gender {
  GENDER_MALE,
  GENDER_FEMALE,
  GENDER_INVALID
}
 Possible genders for company presidents. More...
enum  ExpensesType {
  EXPENSES_CONSTRUCTION,
  EXPENSES_NEW_VEHICLES,
  EXPENSES_TRAIN_RUN,
  EXPENSES_ROADVEH_RUN,
  EXPENSES_AIRCRAFT_RUN,
  EXPENSES_SHIP_RUN,
  EXPENSES_PROPERTY,
  EXPENSES_TRAIN_INC,
  EXPENSES_ROADVEH_INC,
  EXPENSES_AIRCRAFT_INC,
  EXPENSES_SHIP_INC,
  EXPENSES_LOAN_INT,
  EXPENSES_OTHER,
  EXPENSES_INVALID
}
 Types of expenses. More...

Static Public Member Functions

static CompanyID ResolveCompanyID (CompanyID company)
 Resolved the given company index to the correct index for the company.
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 Gender GetPresidentGender (CompanyID company)
 Get the gender of the president of the given company.
static bool SetLoanAmount (Money loan)
 Sets the amount to loan.
static bool SetMinimumLoanAmount (Money 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 bool ChangeBankBalance (CompanyID company, Money delta, ExpensesType expenses_type)
 Changes the bank balance by a delta value.
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 GetAutoRenewStatus (CompanyID company)
 Return whether autorenew is enabled for a company.
static int16 GetAutoRenewMonths (CompanyID company)
 Return the number of months before/after max age to autorenew an engine for a company.
static Money GetAutoRenewMoney (CompanyID company)
 Return the minimum money needed to autorenew an engine for a company.


Detailed Description

Class that handles all company related functions.

Member Enumeration Documentation

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.

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.

Possible genders for company presidents.

Enumerator:
GENDER_MALE  A male person.
GENDER_FEMALE  A female person.
GENDER_INVALID  An invalid gender.

Types of expenses.

Enumerator:
EXPENSES_CONSTRUCTION  Construction costs.
EXPENSES_NEW_VEHICLES  New vehicles.
EXPENSES_TRAIN_RUN  Running costs trains.
EXPENSES_ROADVEH_RUN  Running costs road vehicles.
EXPENSES_AIRCRAFT_RUN  Running costs aircrafts.
EXPENSES_SHIP_RUN  Running costs ships.
EXPENSES_PROPERTY  Property costs.
EXPENSES_TRAIN_INC  Income from trains.
EXPENSES_ROADVEH_INC  Income from road vehicles.
EXPENSES_AIRCRAFT_INC  Income from aircrafts.
EXPENSES_SHIP_INC  Income from ships.
EXPENSES_LOAN_INT  Interest payments over the loan.
EXPENSES_OTHER  Other expenses.
EXPENSES_INVALID  Invalid expense type.


Member Function Documentation

static CompanyID GSCompany::ResolveCompanyID ( 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.

Parameters:
company The company index to resolve.
Returns:
The resolved company index.

static bool GSCompany::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 GSText object).
Precondition:
name != NULL && len(name) != 0.
Exceptions:
GSError::ERR_NAME_IS_NOT_UNIQUE 
Returns:
True if the name was changed.

static char* GSCompany::GetName ( 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.

static bool GSCompany::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 GSText object).
Precondition:
name != NULL && len(name) != 0.
Exceptions:
GSError::ERR_NAME_IS_NOT_UNIQUE 
Returns:
True if the name was changed.

static char* GSCompany::GetPresidentName ( 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.

static Gender GSCompany::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.

static bool GSCompany::SetLoanAmount ( Money  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 GSCompanyMode active in scope.

Returns:
True if the loan could be set to your requested amount.

static bool GSCompany::SetMinimumLoanAmount ( Money  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 GSCompanyMode active in scope.

Returns:
True if we could allocate a minimum of 'loan' loan.

static Money GSCompany::GetLoanAmount (  )  [static]

Gets the amount your company have loaned.

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

static Money GSCompany::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.

static Money GSCompany::GetLoanInterval (  )  [static]

Gets the interval/loan step.

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

static Money GSCompany::GetBankBalance ( 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.

static bool GSCompany::ChangeBankBalance ( CompanyID  company,
Money  delta,
ExpensesType  expenses_type 
) [static]

Changes the bank balance by a delta value.

This method does not affect the loan but instead allows a GS to give or take money from a company.

Parameters:
company The company to change the bank balance of.
delta Amount of money to give or take from the bank balance. A positive value adds money to the bank balance.
expenses_type The account in the finances window that will register the cost.
Returns:
True, if the bank balance was changed.
Precondition:
No GSCompanyMode active in scope.

ResolveCompanyID(company) != COMPANY_INVALID.

delta >= -2**31

delta < 2**31

Note:
You need to create your own news message to inform about costs/gifts that you create using this command.

static Money GSCompany::GetQuarterlyIncome ( CompanyID  company,
uint32  quarter 
) [static]

Get the income of the company in the given quarter.

Note that this function only considers recurring income from vehicles; it does not include one-time income from selling stuff.

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 gross income of the company in the given quarter.

static Money GSCompany::GetQuarterlyExpenses ( CompanyID  company,
uint32  quarter 
) [static]

Get the expenses of the company in the given quarter.

Note that this function only considers recurring expenses from vehicle running cost, maintenance and interests; it does not include one-time expenses from construction and buying stuff.

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.

static int32 GSCompany::GetQuarterlyCargoDelivered ( 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.

static int32 GSCompany::GetQuarterlyPerformanceRating ( 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.

static Money GSCompany::GetQuarterlyCompanyValue ( 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.

static bool GSCompany::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 northern tile of your HQ.
Precondition:
GSMap::IsValidTile(tile).

Valid GSCompanyMode active in scope.

Exceptions:
GSError::ERR_AREA_NOT_CLEAR 
GSError::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.

static TileIndex GSCompany::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 northern tile of that HQ, or GSMap::TILE_INVALID if there is no HQ yet.

static bool GSCompany::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.

static int16 GSCompany::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.

static Money GSCompany::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.


Generated on Sun Dec 24 12:50:17 2017 for OpenTTD Game API by  doxygen 1.5.6