OpenTTD
|
Functions related to companies. More...
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? | |
int | CompanyServiceInterval (const Company *c, VehicleType type) |
Get the service interval for the given company and vehicle type. |
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 289 of file economy.cpp.
References _current_company, _local_company, _networking, AddTrackToSignalBuffer(), Subsidy::awarded, Vehicle::cargo_payment, Backup< T >::Change(), ChangeTileOwner(), ChangeWindowOwner(), ClearCargoDeliveryMonitoring(), ClearCargoPickupMonitoring(), ClrBit(), CMD_CHANGE_SERVICE_INT, CMD_SELL_SHARE_IN_COMPANY, Vehicle::colourmap, Goal::company, StoryPage::company, CompanyServiceInterval(), 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_COMPANY, INVALID_OWNER, Vehicle::InvalidateNewGRFCache(), IsCompanyBuildableVehicleType(), Vehicle::IsEngineCountable(), IsLevelCrossingTile(), Vehicle::IsPrimaryVehicle(), IsTileOwner(), IsTileType(), MapSize(), MarkWholeScreenDirty(), max(), MP_RAILWAY, NetworkClientsToSpectators(), FreeUnitIDGenerator::NextID(), CargoPayment::owner, BaseStation::owner, Group::owner, Vehicle::owner, OWNER_NONE, Vehicle::Previous(), RATING_INITIAL, Town::ratings, RebuildSubsidisedSourceAndDestinationCache(), RemoveAllEngineReplacementForCompany(), RemoveFirstTrack(), Backup< T >::Restore(), VehicleDefaultSettings::servint_aircraft, VehicleDefaultSettings::servint_ispercent, VehicleDefaultSettings::servint_roadveh, VehicleDefaultSettings::servint_ships, VehicleDefaultSettings::servint_trains, SetBit(), SetLocalCompany(), Company::settings, CompanyProperties::share_owners, SubtractMoneyFromCompany(), Vehicle::tile, TRACK_BIT_NONE, BaseVehicle::type, Vehicle::unitnumber, GroupStatistics::UpdateAutoreplace(), UpdateLevelCrossing(), UpdateSignalsInBuffer(), VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, and CompanySettings::vehicle.
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 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().
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 310 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(), CmdBuildSingleRail(), 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 328 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 774 of file company_cmd.cpp.
References _network_server, and NetworkAdminCompanyUpdate().
Referenced by CmdBuyShareInCompany(), CmdRenameCompany(), CmdRenamePresident(), CmdSellShareInCompany(), and CmdSetCompanyColour().
int CompanyServiceInterval | ( | const Company * | c, |
VehicleType | type | ||
) |
Get the service interval for the given company and vehicle type.
c | The company, or NULL for client-default settings. |
type | The vehicle type to get the interval for. |
Definition at line 1154 of file company_cmd.cpp.
References _settings_client, ClientSettings::company, VehicleDefaultSettings::servint_aircraft, VehicleDefaultSettings::servint_roadveh, VehicleDefaultSettings::servint_ships, VehicleDefaultSettings::servint_trains, Company::settings, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, and CompanySettings::vehicle.
Referenced by AfterLoadVehicles(), ChangeOwnershipOfCompanyItems(), and CmdChangeServiceInt().
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 281 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().
|
inlinestatic |
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 55 of file company_func.h.
References _local_company.
Referenced by EnginesDailyLoop(), and HandleBankruptcyTakeover().
|
inlinestatic |
Is the current company the local company?
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 CheckTileOwnership(), CmdBuildVehicle(), CmdSetAutoReplace(), DoCommandP(), HandleKeypress(), HandleMouseEvents(), InputLoop(), NetworkExecuteLocalCommandQueue(), SetLocalCompany(), and StateGameLoop().
May company cbig buy company csmall?
true
if it is allowed. Definition at line 622 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, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, 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 102 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 2572 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 241 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(), CmdChangeBankBalance(), 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 252 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 Ship::OnNewDay(), Aircraft::OnNewDay(), RoadVehicle::OnNewDay(), and Train::OnNewDay().
void UpdateLandscapingLimits | ( | ) |
Update the landscaping limits per company.
Definition at line 265 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().