OpenTTD Source: src/company_func.h Source File

OpenTTD Source 14.1

company_func.h
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #ifndef COMPANY_FUNC_H
11 #define COMPANY_FUNC_H
12
13 #include "command_type.h"
14 #include "company_type.h"
15 #include "gfx_type.h"
16 #include "vehicle_type.h"
17
18 bool MayCompanyTakeOver(CompanyID cbig, CompanyID small);
19 void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner);
20 static const int OWNED_BY_OWNER_IN_PARAMETERS_OFFSET = 2;
21 void SetDParamsForOwnedBy(Owner owner, TileIndex tile);
22 void SetLocalCompany(CompanyID new_company);
23 void ShowBuyCompanyDialog(CompanyID company, bool hostile_takeover);
24 void CompanyAdminUpdate(const Company *company);
25 void CompanyAdminBankrupt(CompanyID company_id);
26 void UpdateLandscapingLimits();
27 void UpdateCompanyLiveries(Company *c);
28
29 Money GetAvailableMoney(CompanyID company);
30 Money GetAvailableMoneyForCommand();
31 bool CheckCompanyHasMoney(CommandCost &cost);
32 void SubtractMoneyFromCompany(const CommandCost &cost);
33 void SubtractMoneyFromCompanyFract(CompanyID company, const CommandCost &cost);
34 CommandCost CheckOwnership(Owner owner, TileIndex tile = 0U);
35 CommandCost CheckTileOwnership(TileIndex tile);
36
37 extern CompanyID _local_company;
38 extern CompanyID _current_company;
39
40 extern Colours _company_colours[MAX_COMPANIES];
41 extern CompanyManagerFace _company_manager_face;
42
47 inline bool IsLocalCompany()
48 {
49 return _local_company == _current_company;
50 }
51
57 inline bool IsInteractiveCompany(CompanyID company)
58 {
59 return company == _local_company;
60 }
61
62 int CompanyServiceInterval(const Company *c, VehicleType type);
63 CompanyID GetFirstPlayableCompanyID();
64
65 #endif /* COMPANY_FUNC_H */
UpdateCompanyLiveries
void UpdateCompanyLiveries(Company *c)
Update liveries for a company.
Definition: company_cmd.cpp:1003
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
SubtractMoneyFromCompany
void SubtractMoneyFromCompany(const CommandCost &cost)
Subtract money from the _current_company, if the company is valid.
Definition: company_cmd.cpp:287
_current_company
CompanyID _current_company
Company currently doing an action.
Definition: company_cmd.cpp:51
_company_colours
Colours _company_colours[MAX_COMPANIES]
NOSAVE: can be determined from company structs.
Definition: company_cmd.cpp:52
_company_manager_face
CompanyManagerFace _company_manager_face
for company manager face storage in openttd.cfg
Definition: company_cmd.cpp:53
CommandCost
Common return value for all commands.
Definition: command_type.h:23
SubtractMoneyFromCompanyFract
void SubtractMoneyFromCompanyFract(CompanyID company, const CommandCost &cost)
Subtract money from a company, including the money fraction.
Definition: company_cmd.cpp:298
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 co...
Definition: company_cmd.cpp:115
GetAvailableMoneyForCommand
Money GetAvailableMoneyForCommand()
This functions returns the money which can be used to execute a command.
Definition: company_cmd.cpp:228
MAX_COMPANIES
@ MAX_COMPANIES
Maximum number of companies.
Definition: company_type.h:23
CompanyManagerFace
uint32_t CompanyManagerFace
Company manager face bits, info see in company_manager_face.h.
Definition: company_type.h:52
CompanyAdminUpdate
void CompanyAdminUpdate(const Company *company)
Called whenever company related information changes in order to notify admins.
Definition: company_cmd.cpp:838
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:50
CompanyServiceInterval
int CompanyServiceInterval(const Company *c, VehicleType type)
Get the service interval for the given company and vehicle type.
Definition: company_cmd.cpp:1198
ShowBuyCompanyDialog
void ShowBuyCompanyDialog(CompanyID company, bool hostile_takeover)
Show the query to buy another company.
Definition: company_gui.cpp:2794
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
command_type.h
GetFirstPlayableCompanyID
CompanyID GetFirstPlayableCompanyID()
Get the index of the first available company.
Definition: company_cmd.cpp:1287
MayCompanyTakeOver
bool MayCompanyTakeOver(CompanyID cbig, CompanyID small)
May company cbig buy company csmall?
Definition: company_cmd.cpp:674
vehicle_type.h
CheckCompanyHasMoney
bool CheckCompanyHasMoney(CommandCost &cost)
Verify whether the company can pay the bill.
Definition: company_cmd.cpp:239
CheckTileOwnership
CommandCost CheckTileOwnership(TileIndex tile)
Check whether the current owner owns the stuff on the given tile.
Definition: company_cmd.cpp:379
OverflowSafeInt< int64_t >
CheckOwnership
CommandCost CheckOwnership(Owner owner, TileIndex tile=0U)
Check whether the current owner owns something.
Definition: company_cmd.cpp:361
IsInteractiveCompany
bool IsInteractiveCompany(CompanyID company)
Is the user representing company?
Definition: company_func.h:57
gfx_type.h
Company
Definition: company_base.h:129
IsLocalCompany
bool IsLocalCompany()
Is the current company the local company?
Definition: company_func.h:47
ChangeOwnershipOfCompanyItems
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
Change the ownership of all the items of a company.
Definition: economy.cpp:334
OWNED_BY_OWNER_IN_PARAMETERS_OFFSET
static const int OWNED_BY_OWNER_IN_PARAMETERS_OFFSET
The index in the parameters for the owner information.
Definition: company_func.h:20
UpdateLandscapingLimits
void UpdateLandscapingLimits()
Update the landscaping limits per company.
Definition: company_cmd.cpp:316
company_type.h
GetAvailableMoney
Money GetAvailableMoney(CompanyID company)
Get the amount of money that a company has available, or INT64_MAX if there is no such valid company.
Definition: company_cmd.cpp:214
SetDParamsForOwnedBy
void SetDParamsForOwnedBy(Owner owner, TileIndex tile)
Set the right DParams for STR_ERROR_OWNED_BY.
Definition: company_cmd.cpp:332