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 |
Functions related to companies.
Definition in file company_func.h.
Change the ownership of all the items of a company.
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(), Town::exclusive_counter, Town::exclusivity, 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, Vehicle::InvalidateNewGRFCache(), IsCompanyBuildableVehicleType(), Vehicle::IsEngineCountable(), IsLevelCrossingTile(), Vehicle::IsPrimaryVehicle(), IsTileOwner(), IsTileType(), MapSize(), MarkWholeScreenDirty(), max(), MP_RAILWAY, NetworkClientsToSpectators(), FreeUnitIDGenerator::NextID(), BaseStation::owner, 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.
cost | [inout] Money to pay, is changed to an error if the company does not have enough money. |
true
if the company has enough money, else it returns false
. Definition at line 188 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 | |||
) |
Check whether the current owner owns something.
If that isn't the case an appropriate error will be given.
owner | the owner of the thing to check. | |
tile | optional tile to get the right town. |
Definition at line 304 of file company_cmd.cpp.
References GetNameOfOwner(), OWNER_END, OWNER_TOWN, and return_cmd_error.
Referenced by CanRemoveRoadWithStop(), CheckAllowRemoveRoad(), CheckAllowRemoveTunnelBridge(), CheckFlatLandRoadStop(), CmdAutofillTimetable(), CmdAutoreplaceVehicle(), CmdBuildObject(), CmdBuildRoad(), CmdChangeServiceInt(), CmdChangeTimetable(), CmdCloneOrder(), CmdCloneVehicle(), CmdDeleteOrder(), CmdForceTrainProceed(), CmdInsertOrder(), CmdModifyOrder(), CmdMoveOrder(), CmdMoveRailVehicle(), CmdOpenCloseAirport(), CmdOrderRefit(), CmdRefitVehicle(), CmdRenameStation(), CmdRenameVehicle(), CmdRenameWaypoint(), CmdReverseTrainDirection(), CmdSellVehicle(), CmdSetTimetableStart(), CmdSetVehicleOnTime(), CmdSkipToOrder(), CmdStartStopVehicle(), CmdTurnRoadVeh(), IsValidTileForWaypoint(), RemoveAirport(), RemoveDock(), RemoveFromRailBaseStation(), RemoveRailStation(), RemoveRoadStop(), and Vehicle::SendToDepot().
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.
tile | the tile to check. |
Definition at line 322 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.
company | The company data changed of. |
Definition at line 767 of file company_cmd.cpp.
References _network_server, and NetworkAdminCompanyUpdate().
Referenced by CmdBuyShareInCompany(), CmdRenameCompany(), CmdRenamePresident(), CmdSellShareInCompany(), and CmdSetCompanyColour().
Set the right DParams to get the name of an owner.
owner | the owner to get the name of. | |
tile | optional tile to get the right town. |
Definition at line 275 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?
company | Company where interaction is needed with. |
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?
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().
May company cbig buy company csmall?
true
if it is allowed. Definition at line 615 of file company_cmd.cpp.
References _settings_game, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Company::group_all, VehicleSettings::max_aircraft, VehicleSettings::max_roadveh, VehicleSettings::max_ships, VehicleSettings::max_trains, GroupStatistics::num_vehicle, and GameSettings::vehicle.
Referenced by CmdBuyCompany(), CmdBuyShareInCompany(), and HandleBankruptcyTakeover().
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.
new_company | the new company |
Definition at line 96 of file company_cmd.cpp.
References COMPANY_SPECTATOR, DeleteConstructionWindows(), DESTTYPE_TEAM, InvalidateWindowClassesData(), InvalidateWindowData(), IsLocalCompany(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), MarkWholeScreenDirty(), OWNER_NONE, WC_SEND_NETWORK_MSG, and WC_SIGN_LIST.
Referenced by ChangeOwnershipOfCompanyItems(), ClickChangeCompanyCheat(), CmdCompanyCtrl(), GenerateWorld(), LoadIntroGame(), NetworkClientsToSpectators(), NetworkServerDoMove(), ClientNetworkGameSocketHandler::Receive_SERVER_CLIENT_INFO(), ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(), and ClientNetworkGameSocketHandler::Receive_SERVER_MOVE().
void ShowBuyCompanyDialog | ( | CompanyID | company | ) |
Show the query to buy another company.
company | The company to buy. |
Definition at line 2528 of file company_gui.cpp.
Referenced by HandleBankruptcyTakeover().
void SubtractMoneyFromCompany | ( | CommandCost | cost | ) |
Subtract money from the _current_company, if the company is valid.
cost | Money to pay. |
Definition at line 235 of file company_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), and SubtractMoneyFromAnyCompany().
Referenced by ChangeOwnershipOfCompanyItems(), CmdGiveMoney(), CompaniesGenStatistics(), CompaniesPayInterest(), DoCommand(), and DoCommandPInternal().
void SubtractMoneyFromCompanyFract | ( | CompanyID | company, | |
CommandCost | cst | |||
) |
Subtract money from a company, including the money fraction.
company | Company paying the bill. | |
cst | Cost of a command. |
Definition at line 246 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().
Referenced by Train::OnNewDay(), Ship::OnNewDay(), RoadVehicle::OnNewDay(), and Aircraft::OnNewDay().
void UpdateLandscapingLimits | ( | ) |
Update the landscaping limits per company.
Definition at line 259 of file company_cmd.cpp.
References _settings_game, ConstructionSettings::clear_frame_burst, CompanyProperties::clear_limit, ConstructionSettings::clear_per_64k_frames, GameSettings::construction, min(), ConstructionSettings::terraform_frame_burst, CompanyProperties::terraform_limit, ConstructionSettings::terraform_per_64k_frames, ConstructionSettings::tree_frame_burst, CompanyProperties::tree_limit, and ConstructionSettings::tree_per_64k_frames.
Referenced by StateGameLoop().