OpenTTD
Functions | Variables
company_func.h File Reference

Functions related to companies. More...

#include "command_type.h"
#include "company_type.h"
#include "gfx_type.h"
#include "vehicle_type.h"

Go to the source code of this file.

Functions

bool MayCompanyTakeOver (CompanyID cbig, CompanyID small)
 May company cbig buy company csmall? More...
 
void ChangeOwnershipOfCompanyItems (Owner old_owner, Owner new_owner)
 Change the ownership of all the items of a company. More...
 
void GetNameOfOwner (Owner owner, TileIndex tile)
 Set the right DParams to get the name of an owner. More...
 
void SetLocalCompany (CompanyID new_company)
 Sets the local company and updates the settings that are set on a per-company basis to reflect the core's state in the GUI. More...
 
void ShowBuyCompanyDialog (CompanyID company)
 Show the query to buy another company. More...
 
void CompanyAdminUpdate (const Company *company)
 Called whenever company related information changes in order to notify admins. More...
 
void CompanyAdminBankrupt (CompanyID company_id)
 
void UpdateLandscapingLimits ()
 Update the landscaping limits per company. More...
 
bool CheckCompanyHasMoney (CommandCost &cost)
 Verify whether the company can pay the bill. More...
 
void SubtractMoneyFromCompany (CommandCost cost)
 Subtract money from the _current_company, if the company is valid. More...
 
void SubtractMoneyFromCompanyFract (CompanyID company, CommandCost cost)
 Subtract money from a company, including the money fraction. More...
 
CommandCost CheckOwnership (Owner owner, TileIndex tile=0)
 Check whether the current owner owns something. More...
 
CommandCost CheckTileOwnership (TileIndex tile)
 Check whether the current owner owns the stuff on the given tile. More...
 
static bool IsLocalCompany ()
 Is the current company the local company? More...
 
static bool IsInteractiveCompany (CompanyID company)
 Is the user representing company? More...
 
int CompanyServiceInterval (const Company *c, VehicleType type)
 Get the service interval for the given company and vehicle type. More...
 

Variables

CompanyByte _local_company
 Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
 
CompanyByte _current_company
 Company currently doing an action.
 
Colours _company_colours [MAX_COMPANIES]
 NOSAVE: can be determined from company structs.
 
CompanyManagerFace _company_manager_face
 for company manager face storage in openttd.cfg
 

Detailed Description

Functions related to companies.

Definition in file company_func.h.

Function Documentation

◆ ChangeOwnershipOfCompanyItems()

void ChangeOwnershipOfCompanyItems ( Owner  old_owner,
Owner  new_owner 
)

Change the ownership of all the items of a company.

Parameters
old_ownerThe company that gets removed.
new_ownerThe company to merge to, or INVALID_OWNER to remove the company.

Definition at line 289 of file economy.cpp.

References _current_company.

◆ CheckCompanyHasMoney()

bool CheckCompanyHasMoney ( CommandCost cost)

Verify whether the company can pay the bill.

Parameters
cost[inout] Money to pay, is changed to an error if the company does not have enough money.
Returns
Function returns true if the company has enough money, else it returns false.

Definition at line 194 of file company_cmd.cpp.

References CommandCost::GetCost(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), CommandCost::MakeError(), CompanyProperties::money, and SetDParam().

◆ CheckOwnership()

CommandCost CheckOwnership ( Owner  owner,
TileIndex  tile 
)

Check whether the current owner owns something.

If that isn't the case an appropriate error will be given.

Parameters
ownerthe owner of the thing to check.
tileoptional tile to get the right town.
Precondition
if tile == 0 then the owner can't be OWNER_TOWN.
Returns
A succeeded command iff it's owned by the current company, else a failed command.

Definition at line 310 of file company_cmd.cpp.

Referenced by CanRemoveRoadWithStop(), CmdAutofillTimetable(), CmdAutoreplaceVehicle(), CmdChangeServiceInt(), CmdChangeTimetable(), CmdCloneOrder(), CmdCloneVehicle(), CmdDeleteOrder(), CmdForceTrainProceed(), CmdInsertOrder(), CmdMoveOrder(), CmdMoveRailVehicle(), CmdOpenCloseAirport(), CmdOrderRefit(), CmdRefitVehicle(), CmdRenameStation(), CmdRenameVehicle(), CmdRenameWaypoint(), CmdReverseTrainDirection(), CmdSellVehicle(), CmdSetTimetableStart(), CmdSetVehicleOnTime(), CmdSkipToOrder(), CmdStartStopVehicle(), CmdTurnRoadVeh(), RemoveAirport(), RemoveDock(), RemoveRoadStop(), and Vehicle::SendToDepot().

◆ CheckTileOwnership()

CommandCost CheckTileOwnership ( TileIndex  tile)

Check whether the current owner owns the stuff on the given tile.

If that isn't the case an appropriate error will be given.

Parameters
tilethe tile to check.
Returns
A succeeded command iff it's owned by the current company, else a failed command.

Definition at line 328 of file company_cmd.cpp.

References GetTileOwner().

Referenced by CmdConvertRail(), CmdRenameDepot(), and RemoveLock().

◆ CompanyAdminUpdate()

void CompanyAdminUpdate ( const Company company)

Called whenever company related information changes in order to notify admins.

Parameters
companyThe company data changed of.

Definition at line 774 of file company_cmd.cpp.

References _network_server, and NetworkAdminCompanyUpdate().

Referenced by CmdRenameCompany(), and CmdRenamePresident().

◆ CompanyServiceInterval()

int CompanyServiceInterval ( const Company c,
VehicleType  type 
)

Get the service interval for the given company and vehicle type.

Parameters
cThe company, or NULL for client-default settings.
typeThe vehicle type to get the interval for.
Returns
The service interval.

Definition at line 1154 of file company_cmd.cpp.

References _settings_client, ClientSettings::company, Company::settings, and CompanySettings::vehicle.

Referenced by CmdChangeServiceInt(), and IsInteractiveCompany().

◆ GetNameOfOwner()

void GetNameOfOwner ( Owner  owner,
TileIndex  tile 
)

Set the right DParams to get the name of an owner.

Parameters
ownerthe owner to get the name of.
tileoptional tile to get the right town.
Precondition
if tile == 0, then owner can't be OWNER_TOWN.

Definition at line 281 of file company_cmd.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), OWNER_TOWN, and SetDParam().

◆ IsInteractiveCompany()

static bool IsInteractiveCompany ( CompanyID  company)
inlinestatic

Is the user representing company?

Parameters
companyCompany where interaction is needed with.
Returns
Gives true if the user can answer questions interactively as representative of company, else false

Definition at line 55 of file company_func.h.

References _local_company, and CompanyServiceInterval().

◆ IsLocalCompany()

static bool IsLocalCompany ( )
inlinestatic

Is the current company the local company?

Returns
true of the current company is the local company, false otherwise.

Definition at line 45 of file company_func.h.

References _current_company.

Referenced by DoCommandP().

◆ MayCompanyTakeOver()

bool MayCompanyTakeOver ( CompanyID  cbig,
CompanyID  csmall 
)

◆ SetLocalCompany()

void SetLocalCompany ( CompanyID  new_company)

Sets the local company and updates the settings that are set on a per-company basis to reflect the core's state in the GUI.

Parameters
new_companythe new company
Precondition
Company::IsValidID(new_company) || new_company == COMPANY_SPECTATOR || new_company == OWNER_NONE

Definition at line 102 of file company_cmd.cpp.

Referenced by ClickChangeCompanyCheat(), GenerateWorld(), and NetworkServerDoMove().

◆ ShowBuyCompanyDialog()

void ShowBuyCompanyDialog ( CompanyID  company)

Show the query to buy another company.

Parameters
companyThe company to buy.

Definition at line 2574 of file company_gui.cpp.

◆ SubtractMoneyFromCompany()

void SubtractMoneyFromCompany ( CommandCost  cost)

Subtract money from the _current_company, if the company is valid.

Parameters
costMoney to pay.

Definition at line 241 of file company_cmd.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), and SubtractMoneyFromAnyCompany().

◆ SubtractMoneyFromCompanyFract()

void SubtractMoneyFromCompanyFract ( CompanyID  company,
CommandCost  cst 
)

Subtract money from a company, including the money fraction.

Parameters
companyCompany paying the bill.
cstCost of a command.

Definition at line 252 of file company_cmd.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), CommandCost::GetCost(), and CompanyProperties::money_fraction.

◆ UpdateLandscapingLimits()

void UpdateLandscapingLimits ( )

Update the landscaping limits per company.

Definition at line 265 of file company_cmd.cpp.

Referenced by StateGameLoop().