Files
@ r25895:573b0b525189
Branch filter:
Location: cpp/openttd-patchpack/source/src/company_base.h - annotation
r25895:573b0b525189
7.6 KiB
text/x-c
Fix: [Actions] changelog assumed major.minor.patch versioning (#9482)
We now use major.minor versioning, so it failed to pick up the
correct information.
We now use major.minor versioning, so it failed to pick up the
correct information.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r11908:0875f47fab11 r18145:767c15d9debd r24214:a65c412aafcc r10208:ef8fcc3dc4ca r18961:b2e758c9533f r10208:ef8fcc3dc4ca r18961:b2e758c9533f r18961:b2e758c9533f r18961:b2e758c9533f r18961:b2e758c9533f r18961:b2e758c9533f r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r18555:e36b5e99bb12 r18555:e36b5e99bb12 r18555:e36b5e99bb12 r18555:e36b5e99bb12 r18555:e36b5e99bb12 r18555:e36b5e99bb12 r18555:e36b5e99bb12 r19063:6deb502206fb r19063:6deb502206fb r19063:6deb502206fb r19063:6deb502206fb r19063:6deb502206fb r19063:6deb502206fb r19063:6deb502206fb r19063:6deb502206fb r23698:1872cc5b7dd7 r23698:1872cc5b7dd7 r23698:1872cc5b7dd7 r18555:e36b5e99bb12 r18555:e36b5e99bb12 r22201:5ce5b50935d0 r11967:df0600d2c7e7 r10208:ef8fcc3dc4ca r11967:df0600d2c7e7 r15328:95a3e6ee8244 r15328:95a3e6ee8244 r15644:2b6f32650781 r22550:5a1c0341c400 r24214:a65c412aafcc r10208:ef8fcc3dc4ca r22550:5a1c0341c400 r15644:2b6f32650781 r24214:a65c412aafcc r10208:ef8fcc3dc4ca r15643:20875bb0d1bd r10208:ef8fcc3dc4ca r15644:2b6f32650781 r15645:b579711f0ab7 r15643:20875bb0d1bd r10208:ef8fcc3dc4ca r15643:20875bb0d1bd r15328:95a3e6ee8244 r17330:ddf80ef4b607 r10208:ef8fcc3dc4ca r15645:b579711f0ab7 r15643:20875bb0d1bd r10208:ef8fcc3dc4ca r23674:a5bafa1a02c5 r10208:ef8fcc3dc4ca r15644:2b6f32650781 r10208:ef8fcc3dc4ca r19676:06a3abb35e22 r15644:2b6f32650781 r15643:20875bb0d1bd r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r16982:4a4e85b95d1e r16982:4a4e85b95d1e r19231:55e444acd766 r16982:4a4e85b95d1e r15645:b579711f0ab7 r15645:b579711f0ab7 r15645:b579711f0ab7 r15645:b579711f0ab7 r15645:b579711f0ab7 r10696:8dfe83e30d01 r23023:7b8669afd1db r17689:d8869b8d77b1 r17689:d8869b8d77b1 r17689:d8869b8d77b1 r15328:95a3e6ee8244 r25676:fd25b87e3539 r25676:fd25b87e3539 r25676:fd25b87e3539 r25676:fd25b87e3539 r25676:fd25b87e3539 r22934:0a8259209a75 r22934:0a8259209a75 r24214:a65c412aafcc r22934:0a8259209a75 r22934:0a8259209a75 r22934:0a8259209a75 r25676:fd25b87e3539 r15328:95a3e6ee8244 r15328:95a3e6ee8244 r25676:fd25b87e3539 r15328:95a3e6ee8244 r15328:95a3e6ee8244 r15328:95a3e6ee8244 r22866:31c85ef6ecbd r15643:20875bb0d1bd r15328:95a3e6ee8244 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10208:ef8fcc3dc4ca r18146:ad1a95532d6a r18145:767c15d9debd r12138:e93d2e409e78 r18555:e36b5e99bb12 r18555:e36b5e99bb12 r15606:aa81fc543ca1 r15606:aa81fc543ca1 r15606:aa81fc543ca1 r15606:aa81fc543ca1 r15606:aa81fc543ca1 r18782:6453522c2154 r12138:e93d2e409e78 r12210:fd25f54f9ba0 r23607:36c15679007d r12138:e93d2e409e78 r12138:e93d2e409e78 r15606:aa81fc543ca1 r15645:b579711f0ab7 r15606:aa81fc543ca1 r15606:aa81fc543ca1 r15606:aa81fc543ca1 r15606:aa81fc543ca1 r18782:6453522c2154 r12138:e93d2e409e78 r12210:fd25f54f9ba0 r23607:36c15679007d r12138:e93d2e409e78 r12210:fd25f54f9ba0 r15606:aa81fc543ca1 r15645:b579711f0ab7 r15606:aa81fc543ca1 r15606:aa81fc543ca1 r15606:aa81fc543ca1 r15606:aa81fc543ca1 r15606:aa81fc543ca1 r18782:6453522c2154 r12210:fd25f54f9ba0 r12210:fd25f54f9ba0 r12210:fd25f54f9ba0 r12969:5e7f0342aa53 r12969:5e7f0342aa53 r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r14343:06e07ad1f03a r10208:ef8fcc3dc4ca r11230:fd38dc6041aa r11230:fd38dc6041aa r11230:fd38dc6041aa r10208:ef8fcc3dc4ca | /*
* This file is part of OpenTTD.
* 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.
* 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.
* 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/>.
*/
/** @file company_base.h Definition of stuff that is very close to a company, like the company struct itself. */
#ifndef COMPANY_BASE_H
#define COMPANY_BASE_H
#include "road_type.h"
#include "livery.h"
#include "autoreplace_type.h"
#include "tile_type.h"
#include "settings_type.h"
#include "group.h"
#include <string>
/** Statistics about the economy. */
struct CompanyEconomyEntry {
Money income; ///< The amount of income.
Money expenses; ///< The amount of expenses.
CargoArray delivered_cargo; ///< The amount of delivered cargo.
int32 performance_history; ///< Company score (scale 0-1000)
Money company_value; ///< The value of the company.
};
struct CompanyInfrastructure {
uint32 road[ROADTYPE_END]; ///< Count of company owned track bits for each road type.
uint32 signal; ///< Count of company owned signals.
uint32 rail[RAILTYPE_END]; ///< Count of company owned track bits for each rail type.
uint32 water; ///< Count of company owned track bits for canals.
uint32 station; ///< Count of company owned station tiles.
uint32 airport; ///< Count of company owned airports.
/** Get total sum of all owned track bits. */
uint32 GetRailTotal() const
{
uint32 total = 0;
for (RailType rt = RAILTYPE_BEGIN; rt < RAILTYPE_END; rt++) total += this->rail[rt];
return total;
}
uint32 GetRoadTotal() const;
uint32 GetTramTotal() const;
};
typedef Pool<Company, CompanyID, 1, MAX_COMPANIES> CompanyPool;
extern CompanyPool _company_pool;
/** Statically loadable part of Company pool item */
struct CompanyProperties {
uint32 name_2; ///< Parameter of #name_1.
StringID name_1; ///< Name of the company if the user did not change it.
std::string name; ///< Name of the company if the user changed it.
StringID president_name_1; ///< Name of the president if the user did not change it.
uint32 president_name_2; ///< Parameter of #president_name_1
std::string president_name; ///< Name of the president if the user changed it.
CompanyManagerFace face; ///< Face description of the president.
Money money; ///< Money owned by the company.
byte money_fraction; ///< Fraction of money of the company, too small to represent in #money.
Money current_loan; ///< Amount of money borrowed from the bank.
byte colour; ///< Company colour.
byte block_preview; ///< Number of quarters that the company is not allowed to get new exclusive engine previews (see CompaniesGenStatistics).
TileIndex location_of_HQ; ///< Northern tile of HQ; #INVALID_TILE when there is none.
TileIndex last_build_coordinate; ///< Coordinate of the last build thing by this company.
Owner share_owners[4]; ///< Owners of the 4 shares of the company. #INVALID_OWNER if nobody has bought them yet.
Year inaugurated_year; ///< Year of starting the company.
byte months_of_bankruptcy; ///< Number of months that the company is unable to pay its debts
CompanyMask bankrupt_asked; ///< which companies were asked about buying it?
int16 bankrupt_timeout; ///< If bigger than \c 0, amount of time to wait for an answer on an offer to buy this company.
Money bankrupt_value;
uint32 terraform_limit; ///< Amount of tileheights we can (still) terraform (times 65536).
uint32 clear_limit; ///< Amount of tiles we can (still) clear (times 65536).
uint32 tree_limit; ///< Amount of trees we can (still) plant (times 65536).
/**
* If \c true, the company is (also) controlled by the computer (a NoAI program).
* @note It is possible that the user is also participating in such a company.
*/
bool is_ai;
Money yearly_expenses[3][EXPENSES_END]; ///< Expenses of the company for the last three years, in every #ExpensesType category.
CompanyEconomyEntry cur_economy; ///< Economic data of the company of this quarter.
CompanyEconomyEntry old_economy[MAX_HISTORY_QUARTERS]; ///< Economic data of the company of the last #MAX_HISTORY_QUARTERS quarters.
byte num_valid_stat_ent; ///< Number of valid statistical entries in #old_economy.
Livery livery[LS_END];
EngineRenewList engine_renew_list; ///< Engine renewals of this company.
CompanySettings settings; ///< settings specific for each company
// TODO: Change some of these member variables to use relevant INVALID_xxx constants
CompanyProperties()
: name_2(0), name_1(0), president_name_1(0), president_name_2(0),
face(0), money(0), money_fraction(0), current_loan(0), colour(0), block_preview(0),
location_of_HQ(0), last_build_coordinate(0), share_owners(), inaugurated_year(0),
months_of_bankruptcy(0), bankrupt_asked(0), bankrupt_timeout(0), bankrupt_value(0),
terraform_limit(0), clear_limit(0), tree_limit(0), is_ai(false), engine_renew_list(nullptr) {}
};
struct Company : CompanyProperties, CompanyPool::PoolItem<&_company_pool> {
Company(uint16 name_1 = 0, bool is_ai = false);
~Company();
RailTypes avail_railtypes; ///< Rail types available to this company.
RoadTypes avail_roadtypes; ///< Road types available to this company.
class AIInstance *ai_instance;
class AIInfo *ai_info;
GroupStatistics group_all[VEH_COMPANY_END]; ///< NOSAVE: Statistics for the ALL_GROUP group.
GroupStatistics group_default[VEH_COMPANY_END]; ///< NOSAVE: Statistics for the DEFAULT_GROUP group.
CompanyInfrastructure infrastructure; ///< NOSAVE: Counts of company owned infrastructure.
/**
* Is this company a valid company, controlled by the computer (a NoAI program)?
* @param index Index in the pool.
* @return \c true if it is a valid, computer controlled company, else \c false.
*/
static inline bool IsValidAiID(size_t index)
{
const Company *c = Company::GetIfValid(index);
return c != nullptr && c->is_ai;
}
/**
* Is this company a valid company, not controlled by a NoAI program?
* @param index Index in the pool.
* @return \c true if it is a valid, human controlled company, else \c false.
* @note If you know that \a index refers to a valid company, you can use #IsHumanID() instead.
*/
static inline bool IsValidHumanID(size_t index)
{
const Company *c = Company::GetIfValid(index);
return c != nullptr && !c->is_ai;
}
/**
* Is this company a company not controlled by a NoAI program?
* @param index Index in the pool.
* @return \c true if it is a human controlled company, else \c false.
* @pre \a index must be a valid CompanyID.
* @note If you don't know whether \a index refers to a valid company, you should use #IsValidHumanID() instead.
*/
static inline bool IsHumanID(size_t index)
{
return !Company::Get(index)->is_ai;
}
static void PostDestructor(size_t index);
};
Money CalculateCompanyValue(const Company *c, bool including_loan = true);
extern uint _next_competitor_start;
extern uint _cur_company_tick_index;
#endif /* COMPANY_BASE_H */
|