Functions | Variables

company_func.h File Reference

Functions related to companies. More...

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

Go to the source code of this file.

Functions

bool MayCompanyTakeOver (CompanyID cbig, CompanyID small)
 May company cbig buy company csmall?
void ChangeOwnershipOfCompanyItems (Owner old_owner, Owner new_owner)
 Change the ownership of all the items of a company.
void GetNameOfOwner (Owner owner, TileIndex tile)
 Set the right DParams to get the name of an owner.
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.
void ShowBuyCompanyDialog (CompanyID company)
 Show the query to buy another company.
void CompanyAdminUpdate (const Company *company)
 Called whenever company related information changes in order to notify admins.
void CompanyAdminBankrupt (CompanyID company_id)
void UpdateLandscapingLimits ()
 Update the landscaping limits per company.
bool CheckCompanyHasMoney (CommandCost &cost)
 Verify whether the company can pay the bill.
void SubtractMoneyFromCompany (CommandCost cost)
 Subtract money from the _current_company, if the company is valid.
void SubtractMoneyFromCompanyFract (CompanyID company, CommandCost cost)
 Subtract money from a company, including the money fraction.
CommandCost CheckOwnership (Owner owner, TileIndex tile=0)
 Check whether the current owner owns something.
CommandCost CheckTileOwnership (TileIndex tile)
 Check whether the current owner owns the stuff on the given tile.
static bool IsLocalCompany ()
 Is the current company the local company?
static bool IsInteractiveCompany (CompanyID company)
 Is the user representing company?

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

void ChangeOwnershipOfCompanyItems ( Owner  old_owner,
Owner  new_owner 
)

Change the ownership of all the items of a company.

Parameters:
old_owner The company that gets removed.
new_owner The company to merge to, or INVALID_OWNER to remove the company.

Definition at line 282 of file economy.cpp.

References _current_company, _local_company, _networking, AddTrackToSignalBuffer(), Subsidy::awarded, Vehicle::cargo_payment, Backup< T >::Change(), ChangeTileOwner(), ChangeWindowOwner(), ClrBit(), CMD_SELL_SHARE_IN_COMPANY, Vehicle::colourmap, GroupStatistics::CountEngine(), GroupStatistics::CountVehicle(), DC_BANKRUPT, DC_EXEC, DoCommand(), FOR_ALL_VEHICLES, FOR_ALL_WAYPOINTS, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetTrackBits(), HasBit(), HasSignalOnTrack(), HasSignals(), Town::have_ratings, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_OWNER, IsCompanyBuildableVehicleType(), Vehicle::IsEngineCountable(), IsLevelCrossingTile(), Vehicle::IsPrimaryVehicle(), IsTileOwner(), IsTileType(), MapSize(), MarkWholeScreenDirty(), max(), MP_RAILWAY, NetworkClientsToSpectators(), FreeUnitIDGenerator::NextID(), CargoPayment::owner, Group::owner, Vehicle::owner, OWNER_NONE, Vehicle::Previous(), Town::ratings, RebuildSubsidisedSourceAndDestinationCache(), RemoveAllEngineReplacementForCompany(), RemoveFirstTrack(), Backup< T >::Restore(), SetBit(), SetLocalCompany(), CompanyProperties::share_owners, SubtractMoneyFromCompany(), TRACK_BIT_NONE, BaseVehicle::type, Vehicle::unitnumber, GroupStatistics::UpdateAutoreplace(), UpdateLevelCrossing(), UpdateSignalsInBuffer(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by CmdCompanyCtrl(), and ResetLandscapeConfirmationCallback().

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 187 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().

Referenced by CmdCloneVehicle(), DoCommand(), and DoCommandPInternal().

CommandCost CheckOwnership ( Owner  owner,
TileIndex  tile 
)
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:
tile the tile to check.
Returns:
A succeeded command iff it's owned by the current company, else a failed command.

Definition at line 320 of file company_cmd.cpp.

References GetNameOfOwner(), GetTileOwner(), IsLocalCompany(), OWNER_END, and return_cmd_error.

Referenced by CheckAllowRemoveTunnelBridge(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdConvertRail(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), CmdRenameDepot(), and RemoveLock().

void CompanyAdminUpdate ( const Company company  ) 

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

Parameters:
company The company data changed of.

Definition at line 765 of file company_cmd.cpp.

References _network_server, and NetworkAdminCompanyUpdate().

Referenced by CmdBuyShareInCompany(), CmdRenameCompany(), CmdRenamePresident(), CmdSellShareInCompany(), and CmdSetCompanyColour().

void GetNameOfOwner ( Owner  owner,
TileIndex  tile 
)

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

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

Definition at line 273 of file company_cmd.cpp.

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

Referenced by CheckOwnership(), CheckTileOwnership(), and LandInfoWindow::OnInit().

static bool IsInteractiveCompany ( CompanyID  company  )  [inline, static]

Is the user representing company?

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

Definition at line 54 of file company_func.h.

Referenced by EnginesDailyLoop(), and HandleBankruptcyTakeover().

static bool IsLocalCompany (  )  [inline, static]

Is the current company the local company?

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

Definition at line 44 of file company_func.h.

Referenced by CheckTileOwnership(), CmdBuildVehicle(), CmdSellRailWagon(), CmdSetAutoReplace(), DoCommandP(), HandleKeypress(), HandleMouseEvents(), InputLoop(), NetworkExecuteLocalCommandQueue(), SetLocalCompany(), and StateGameLoop().

bool MayCompanyTakeOver ( CompanyID  cbig,
CompanyID  csmall 
)
void SetLocalCompany ( CompanyID  new_company  ) 
void ShowBuyCompanyDialog ( CompanyID  company  ) 

Show the query to buy another company.

Parameters:
company The company to buy.

Definition at line 2523 of file company_gui.cpp.

Referenced by HandleBankruptcyTakeover().

void SubtractMoneyFromCompany ( CommandCost  cost  ) 
void SubtractMoneyFromCompanyFract ( CompanyID  company,
CommandCost  cst 
)

Subtract money from a company, including the money fraction.

Parameters:
company Company paying the bill.
cst Cost of a command.

Definition at line 245 of file company_cmd.cpp.

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

void UpdateLandscapingLimits (  )