OpenTTD Source: src/company_type.h Source File

OpenTTD Source 15.0-RC2

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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef COMPANY_TYPE_H
11#define COMPANY_TYPE_H
12
13#include "core/base_bitset_type.hpp"
14#include "core/pool_type.hpp"
15
16using CompanyID = PoolID<uint8_t, struct CompanyIDTag, 0xF, 0xFF>;
17
18/* 'Fake' companies used for networks */
19 static constexpr CompanyID COMPANY_INACTIVE_CLIENT{253};
20 static constexpr CompanyID COMPANY_NEW_COMPANY{254};
21 static constexpr CompanyID COMPANY_SPECTATOR{255};
22
23using Owner = CompanyID;
24 static constexpr Owner OWNER_BEGIN = Owner::Begin();
25 static constexpr Owner OWNER_TOWN{0x0F};
26 static constexpr Owner OWNER_NONE{0x10};
27 static constexpr Owner OWNER_WATER{0x11};
28 static constexpr Owner OWNER_DEITY{0x12};
29 static constexpr Owner OWNER_END{0x13};
30 static constexpr Owner INVALID_OWNER = Owner::Invalid();
31
32static const uint8_t MAX_COMPANIES = CompanyID::End().base();
33 static const uint MAX_LENGTH_PRESIDENT_NAME_CHARS = 32;
34 static const uint MAX_LENGTH_COMPANY_NAME_CHARS = 32;
35
36 static const uint MAX_HISTORY_QUARTERS = 24;
37
38 static const uint MIN_COMPETITORS_INTERVAL = 0;
39 static const uint MAX_COMPETITORS_INTERVAL = 500;
40
41typedef Owner CompanyID;
42
43 class CompanyMask : public BaseBitSet<CompanyMask, CompanyID, uint16_t> {
44public:
45 constexpr CompanyMask() : BaseBitSet<CompanyMask, CompanyID, uint16_t>() {}
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;
52
53 struct CompanyManagerFace {
54 uint style = 0;
55 uint32_t bits = 0;
56 std::string style_label;
57};
58
60 enum CompanyRemoveReason : uint8_t {
61 CRR_MANUAL,
62 CRR_AUTOCLEAN,
63 CRR_BANKRUPT,
64
65 CRR_END,
66
67 CRR_NONE = CRR_MANUAL,
68};
69
71 enum CompanyCtrlAction : uint8_t {
72 CCA_NEW,
73 CCA_NEW_AI,
74 CCA_DELETE,
75
76 CCA_END,
77};
78
80 enum CompanyAllowListCtrlAction : uint8_t {
81 CALCA_ADD,
82 CALCA_REMOVE,
83
84 CALCA_END,
85};
86
87#endif /* COMPANY_TYPE_H */
base_bitset_type.hpp
Base for bitset types that accept strong types, i.e.
BaseBitSet
Base for bit set wrapper.
Definition base_bitset_type.hpp:25
CompanyMask
Definition company_type.h:43
MAX_LENGTH_PRESIDENT_NAME_CHARS
static const uint MAX_LENGTH_PRESIDENT_NAME_CHARS
The maximum length of a president name in characters including '\0'.
Definition company_type.h:33
OWNER_DEITY
static constexpr Owner OWNER_DEITY
The object is owned by a superuser / goal script.
Definition company_type.h:28
MAX_LENGTH_COMPANY_NAME_CHARS
static const uint MAX_LENGTH_COMPANY_NAME_CHARS
The maximum length of a company name in characters including '\0'.
Definition company_type.h:34
CompanyCtrlAction
CompanyCtrlAction
The action to do with CMD_COMPANY_CTRL.
Definition company_type.h:71
CCA_NEW_AI
@ CCA_NEW_AI
Create a new AI company.
Definition company_type.h:73
CCA_DELETE
@ CCA_DELETE
Delete a company.
Definition company_type.h:74
CCA_NEW
@ CCA_NEW
Create a new company.
Definition company_type.h:72
CCA_END
@ CCA_END
Sentinel for end.
Definition company_type.h:76
COMPANY_SPECTATOR
static constexpr CompanyID COMPANY_SPECTATOR
The client is spectating.
Definition company_type.h:21
OWNER_END
static constexpr Owner OWNER_END
Last + 1 owner.
Definition company_type.h:29
CompanyAllowListCtrlAction
CompanyAllowListCtrlAction
The action to do with CMD_COMPANY_ALLOW_LIST_CTRL.
Definition company_type.h:80
CALCA_END
@ CALCA_END
Sentinel for end.
Definition company_type.h:84
CALCA_REMOVE
@ CALCA_REMOVE
Remove a public key.
Definition company_type.h:82
CALCA_ADD
@ CALCA_ADD
Create a public key.
Definition company_type.h:81
COMPANY_NEW_COMPANY
static constexpr CompanyID COMPANY_NEW_COMPANY
The client wants a new company.
Definition company_type.h:20
MAX_HISTORY_QUARTERS
static const uint MAX_HISTORY_QUARTERS
The maximum number of quarters kept as performance's history.
Definition company_type.h:36
OWNER_TOWN
static constexpr Owner OWNER_TOWN
A town owns the tile, or a town is expanding.
Definition company_type.h:25
OWNER_BEGIN
static constexpr Owner OWNER_BEGIN
First owner.
Definition company_type.h:24
COMPANY_INACTIVE_CLIENT
static constexpr CompanyID COMPANY_INACTIVE_CLIENT
The client is joining.
Definition company_type.h:19
OWNER_NONE
static constexpr Owner OWNER_NONE
The tile has no ownership.
Definition company_type.h:26
INVALID_OWNER
static constexpr Owner INVALID_OWNER
An invalid owner.
Definition company_type.h:30
OWNER_WATER
static constexpr Owner OWNER_WATER
The tile/execution is done by "water".
Definition company_type.h:27
MIN_COMPETITORS_INTERVAL
static const uint MIN_COMPETITORS_INTERVAL
The minimum interval (in minutes) between competitors.
Definition company_type.h:38
CompanyRemoveReason
CompanyRemoveReason
The reason why the company was removed.
Definition company_type.h:60
CRR_BANKRUPT
@ CRR_BANKRUPT
The company went belly-up.
Definition company_type.h:63
CRR_END
@ CRR_END
Sentinel for end.
Definition company_type.h:65
CRR_AUTOCLEAN
@ CRR_AUTOCLEAN
The company is removed due to autoclean.
Definition company_type.h:62
CRR_NONE
@ CRR_NONE
Dummy reason for actions that don't need one.
Definition company_type.h:67
CRR_MANUAL
@ CRR_MANUAL
The company is manually removed.
Definition company_type.h:61
MAX_COMPETITORS_INTERVAL
static const uint MAX_COMPETITORS_INTERVAL
The maximum interval (in minutes) between competitors.
Definition company_type.h:39
pool_type.hpp
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
CompanyManagerFace
Definition company_type.h:53
CompanyManagerFace::bits
uint32_t bits
Company manager face bits, meaning is dependent on style.
Definition company_type.h:55
CompanyManagerFace::style
uint style
Company manager face style.
Definition company_type.h:54
CompanyManagerFace::style_label
std::string style_label
Face style label.
Definition company_type.h:56
Company
Definition company_base.h:127
PoolID< uint8_t, struct CompanyIDTag, 0xF, 0xFF >