OpenTTD
company_base.h
Go to the documentation of this file.
1 /* $Id: company_base.h 27381 2015-08-10 20:24:13Z michi_cc $ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * 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.
6  * 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.
7  * 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/>.
8  */
9 
12 #ifndef COMPANY_BASE_H
13 #define COMPANY_BASE_H
14 
15 #include "road_type.h"
16 #include "livery.h"
17 #include "autoreplace_type.h"
18 #include "tile_type.h"
19 #include "settings_type.h"
20 #include "group.h"
21 
29 };
30 
32  uint32 road[ROADTYPE_END];
33  uint32 signal;
34  uint32 rail[RAILTYPE_END];
35  uint32 water;
36  uint32 station;
37  uint32 airport;
38 
40  uint32 GetRailTotal() const
41  {
42  uint32 total = 0;
43  for (RailType rt = RAILTYPE_BEGIN; rt < RAILTYPE_END; rt++) total += this->rail[rt];
44  return total;
45  }
46 };
47 
50 
51 
54  uint32 name_2;
55  uint16 name_1;
56  char *name;
57 
61 
63 
67 
68  byte colour;
69 
71 
73 
76 
78 
80 
82  CompanyMask bankrupt_asked;
84  Money bankrupt_value;
85 
86  uint32 terraform_limit;
87  uint32 clear_limit;
88  uint32 tree_limit;
89 
94  bool is_ai;
95 
100 
101  CompanyProperties() : name(NULL), president_name(NULL) {}
102 
104  {
105  free(this->name);
106  free(this->president_name);
107  }
108 };
109 
111  Company(uint16 name_1 = 0, bool is_ai = false);
112  ~Company();
113 
114  Livery livery[LS_END];
116 
117  class AIInstance *ai_instance;
118  class AIInfo *ai_info;
119 
124 
126 
132  static inline bool IsValidAiID(size_t index)
133  {
134  const Company *c = Company::GetIfValid(index);
135  return c != NULL && c->is_ai;
136  }
137 
144  static inline bool IsValidHumanID(size_t index)
145  {
146  const Company *c = Company::GetIfValid(index);
147  return c != NULL && !c->is_ai;
148  }
149 
157  static inline bool IsHumanID(size_t index)
158  {
159  return !Company::Get(index)->is_ai;
160  }
161 
162  static void PostDestructor(size_t index);
163 };
164 
165 #define FOR_ALL_COMPANIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Company, company_index, var, start)
166 #define FOR_ALL_COMPANIES(var) FOR_ALL_COMPANIES_FROM(var, 0)
167 
168 Money CalculateCompanyValue(const Company *c, bool including_loan = true);
169 
170 extern uint _next_competitor_start;
171 extern uint _cur_company_tick_index;
172 
173 #endif /* COMPANY_BASE_H */