OpenTTD Source 20250312-master-gcdcc6b491d
company_type.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_TYPE_H
11#define COMPANY_TYPE_H
12
13#include "core/enum_type.hpp"
14#include "core/pool_type.hpp"
15
17
18/* 'Fake' companies used for networks */
19static constexpr CompanyID COMPANY_INACTIVE_CLIENT{253};
20static constexpr CompanyID COMPANY_NEW_COMPANY{254};
21static constexpr CompanyID COMPANY_SPECTATOR{255};
22
23using Owner = CompanyID;
24static constexpr Owner OWNER_BEGIN = Owner::Begin();
25static constexpr Owner OWNER_TOWN{0x0F};
26static constexpr Owner OWNER_NONE{0x10};
27static constexpr Owner OWNER_WATER{0x11};
28static constexpr Owner OWNER_DEITY{0x12};
29static constexpr Owner OWNER_END{0x13};
30static constexpr Owner INVALID_OWNER = Owner::Invalid();
31
32static const uint8_t MAX_COMPANIES = CompanyID::End().base();
33static const uint MAX_LENGTH_PRESIDENT_NAME_CHARS = 32;
34static const uint MAX_LENGTH_COMPANY_NAME_CHARS = 32;
35
36static const uint MAX_HISTORY_QUARTERS = 24;
37
38static const uint MIN_COMPETITORS_INTERVAL = 0;
39static const uint MAX_COMPETITORS_INTERVAL = 500;
40
41typedef Owner CompanyID;
42
43class CompanyMask : public BaseBitSet<CompanyMask, CompanyID, uint16_t> {
44public:
46 static constexpr size_t DecayValueType(CompanyID value) { return value.base(); }
47
48 constexpr auto operator <=>(const CompanyMask &) const noexcept = default;
49};
50
51struct Company;
52typedef uint32_t CompanyManagerFace;
53
64
73
81
82#endif /* COMPANY_TYPE_H */
Base for bit set wrapper.
static const uint MAX_LENGTH_PRESIDENT_NAME_CHARS
The maximum length of a president name in characters including '\0'.
static constexpr Owner OWNER_DEITY
The object is owned by a superuser / goal script.
static const uint MAX_LENGTH_COMPANY_NAME_CHARS
The maximum length of a company name in characters including '\0'.
CompanyCtrlAction
The action to do with CMD_COMPANY_CTRL.
@ CCA_NEW_AI
Create a new AI company.
@ CCA_DELETE
Delete a company.
@ CCA_NEW
Create a new company.
@ CCA_END
Sentinel for end.
static constexpr CompanyID COMPANY_SPECTATOR
The client is spectating.
static constexpr Owner OWNER_END
Last + 1 owner.
CompanyAllowListCtrlAction
The action to do with CMD_COMPANY_ALLOW_LIST_CTRL.
@ CALCA_END
Sentinel for end.
@ CALCA_REMOVE
Remove a public key.
@ CALCA_ADD
Create a public key.
static constexpr CompanyID COMPANY_NEW_COMPANY
The client wants a new company.
static const uint MAX_HISTORY_QUARTERS
The maximum number of quarters kept as performance's history.
static constexpr Owner OWNER_TOWN
A town owns the tile, or a town is expanding.
uint32_t CompanyManagerFace
Company manager face bits, info see in company_manager_face.h.
static constexpr Owner OWNER_BEGIN
First owner.
static constexpr CompanyID COMPANY_INACTIVE_CLIENT
The client is joining.
static constexpr Owner OWNER_NONE
The tile has no ownership.
static constexpr Owner INVALID_OWNER
An invalid owner.
static constexpr Owner OWNER_WATER
The tile/execution is done by "water".
static const uint MIN_COMPETITORS_INTERVAL
The minimum interval (in minutes) between competitors.
CompanyRemoveReason
The reason why the company was removed.
@ CRR_BANKRUPT
The company went belly-up.
@ CRR_END
Sentinel for end.
@ CRR_AUTOCLEAN
The company is removed due to autoclean.
@ CRR_NONE
Dummy reason for actions that don't need one.
@ CRR_MANUAL
The company is manually removed.
static const uint MAX_COMPETITORS_INTERVAL
The maximum interval (in minutes) between competitors.
Type (helpers) for enums.
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...