OpenTTD Source: src/company_func.h Source File

OpenTTD Source 15.3

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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
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
18bool CheckTakeoverVehicleLimit(CompanyID cbig, CompanyID small);
19void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner);
20std::array<StringParameter, 2> GetParamsForOwnedBy(Owner owner, TileIndex tile);
21void SetLocalCompany(CompanyID new_company);
22void ShowBuyCompanyDialog(CompanyID company, bool hostile_takeover);
23void CompanyAdminUpdate(const Company *company);
24void CompanyAdminBankrupt(CompanyID company_id);
25void UpdateLandscapingLimits();
26void UpdateCompanyLiveries(Company *c);
27
28 Money GetAvailableMoney(CompanyID company);
29 Money GetAvailableMoneyForCommand();
30bool CheckCompanyHasMoney(CommandCost &cost);
31void SubtractMoneyFromCompany(const CommandCost &cost);
32void SubtractMoneyFromCompanyFract(CompanyID company, const CommandCost &cost);
33 CommandCost CheckOwnership(Owner owner, TileIndex tile = {});
34 CommandCost CheckTileOwnership(TileIndex tile);
35
36extern CompanyID _local_company;
37extern CompanyID _current_company;
38
39extern TypedIndexContainer<std::array<Colours, MAX_COMPANIES>, CompanyID> _company_colours;
40extern std::string _company_manager_face;
41 PaletteID GetCompanyPalette(CompanyID company);
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
62int CompanyServiceInterval(const Company *c, VehicleType type);
63 CompanyID GetFirstPlayableCompanyID();
64
65#endif /* COMPANY_FUNC_H */
CommandCost
Common return value for all commands.
Definition command_type.h:24
OverflowSafeInt< int64_t >
TypedIndexContainer
A sort-of mixin that implements 'at(pos)' and 'operator[](pos)' only for a specific type.
Definition convertible_through_base.hpp:38
command_type.h
Types related to commands.
IsInteractiveCompany
bool IsInteractiveCompany(CompanyID company)
Is the user representing company?
Definition company_func.h:57
GetParamsForOwnedBy
std::array< StringParameter, 2 > GetParamsForOwnedBy(Owner owner, TileIndex tile)
Set the right DParams for STR_ERROR_OWNED_BY.
Definition company_cmd.cpp:358
CheckOwnership
CommandCost CheckOwnership(Owner owner, TileIndex tile={})
Check whether the current owner owns something.
Definition company_cmd.cpp:381
ChangeOwnershipOfCompanyItems
void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
Change the ownership of all the items of a company.
Definition economy.cpp:322
_company_manager_face
std::string _company_manager_face
for company manager face storage in openttd.cfg
Definition company_cmd.cpp:58
ShowBuyCompanyDialog
void ShowBuyCompanyDialog(CompanyID company, bool hostile_takeover)
Show the query to buy another company.
Definition company_gui.cpp:2439
_company_colours
TypedIndexContainer< std::array< Colours, MAX_COMPANIES >, CompanyID > _company_colours
NOSAVE: can be determined from company structs.
Definition company_cmd.cpp:57
UpdateCompanyLiveries
void UpdateCompanyLiveries(Company *c)
Update liveries for a company.
Definition company_cmd.cpp:1077
CheckTileOwnership
CommandCost CheckTileOwnership(TileIndex tile)
Check whether the current owner owns the stuff on the given tile.
Definition company_cmd.cpp:404
CompanyServiceInterval
int CompanyServiceInterval(const Company *c, VehicleType type)
Get the service interval for the given company and vehicle type.
Definition company_cmd.cpp:1280
GetCompanyPalette
PaletteID GetCompanyPalette(CompanyID company)
Get the palette for recolouring with a company colour.
Definition company_cmd.cpp:164
CheckCompanyHasMoney
bool CheckCompanyHasMoney(CommandCost &cost)
Verify whether the company can pay the bill.
Definition company_cmd.cpp:263
GetFirstPlayableCompanyID
CompanyID GetFirstPlayableCompanyID()
Get the index of the first available company.
Definition company_cmd.cpp:1354
CheckTakeoverVehicleLimit
bool CheckTakeoverVehicleLimit(CompanyID cbig, CompanyID small)
Can company cbig buy company csmall without exceeding vehicle limits?
Definition company_cmd.cpp:695
GetAvailableMoneyForCommand
Money GetAvailableMoneyForCommand()
This functions returns the money which can be used to execute a command.
Definition company_cmd.cpp:252
CompanyAdminUpdate
void CompanyAdminUpdate(const Company *company)
Called whenever company related information changes in order to notify admins.
Definition company_cmd.cpp:858
SubtractMoneyFromCompany
void SubtractMoneyFromCompany(const CommandCost &cost)
Subtract money from the _current_company, if the company is valid.
Definition company_cmd.cpp:313
SubtractMoneyFromCompanyFract
void SubtractMoneyFromCompanyFract(CompanyID company, const CommandCost &cost)
Subtract money from a company, including the money fraction.
Definition company_cmd.cpp:324
IsLocalCompany
bool IsLocalCompany()
Is the current company the local company?
Definition company_func.h:47
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:238
UpdateLandscapingLimits
void UpdateLandscapingLimits()
Update the landscaping limits per company.
Definition company_cmd.cpp:342
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition company_cmd.cpp:55
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:119
_current_company
CompanyID _current_company
Company currently doing an action.
Definition company_cmd.cpp:56
company_type.h
Types related to companies.
gfx_type.h
Types related to the graphics and/or input devices.
PaletteID
uint32_t PaletteID
The number of the palette.
Definition gfx_type.h:18
Company
Definition company_base.h:127
PoolID< uint8_t, struct CompanyIDTag, 0xF, 0xFF >
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
vehicle_type.h
Types related to vehicles.
VehicleType
VehicleType
Available vehicle types.
Definition vehicle_type.h:22