2005-07-24 16:12:37 +02:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 22:21:05 +02:00
|
|
|
/*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-09-30 22:39:50 +02:00
|
|
|
/** @file company_base.h Definition of stuff that is very close to a company, like the company struct itself. */
|
2007-03-21 18:42:43 +01:00
|
|
|
|
2008-09-30 22:39:50 +02:00
|
|
|
#ifndef COMPANY_BASE_H
|
|
|
|
#define COMPANY_BASE_H
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2009-05-22 17:39:22 +02:00
|
|
|
#include "core/pool_type.hpp"
|
2008-01-09 22:05:03 +01:00
|
|
|
#include "road_type.h"
|
|
|
|
#include "rail_type.h"
|
2006-09-15 14:27:00 +02:00
|
|
|
#include "livery.h"
|
2008-01-07 10:19:53 +01:00
|
|
|
#include "autoreplace_type.h"
|
2008-01-09 22:27:39 +01:00
|
|
|
#include "economy_type.h"
|
|
|
|
#include "tile_type.h"
|
2009-05-16 01:55:06 +02:00
|
|
|
#include "settings_type.h"
|
2004-08-20 11:32:32 +02:00
|
|
|
|
2008-09-30 22:39:50 +02:00
|
|
|
struct CompanyEconomyEntry {
|
2007-06-18 23:44:47 +02:00
|
|
|
Money income;
|
|
|
|
Money expenses;
|
2004-08-09 19:04:08 +02:00
|
|
|
int32 delivered_cargo;
|
2008-09-30 22:39:50 +02:00
|
|
|
int32 performance_history; ///< company score (scale 0-1000)
|
2007-06-19 00:49:55 +02:00
|
|
|
Money company_value;
|
2007-03-07 13:11:48 +01:00
|
|
|
};
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2009-05-22 17:13:50 +02:00
|
|
|
typedef Pool<Company, CompanyByte, 1, MAX_COMPANIES> CompanyPool;
|
|
|
|
extern CompanyPool _company_pool;
|
2008-07-18 18:40:29 +02:00
|
|
|
|
2009-05-22 17:13:50 +02:00
|
|
|
|
|
|
|
struct Company : CompanyPool::PoolItem<&_company_pool> {
|
2008-09-30 22:39:50 +02:00
|
|
|
Company(uint16 name_1 = 0, bool is_ai = false);
|
|
|
|
~Company();
|
2008-07-18 18:40:29 +02:00
|
|
|
|
2004-08-09 19:04:08 +02:00
|
|
|
uint32 name_2;
|
|
|
|
uint16 name_1;
|
2008-01-12 20:58:06 +01:00
|
|
|
char *name;
|
2004-08-09 19:04:08 +02:00
|
|
|
|
|
|
|
uint16 president_name_1;
|
|
|
|
uint32 president_name_2;
|
2008-01-12 20:58:06 +01:00
|
|
|
char *president_name;
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2008-09-30 22:39:50 +02:00
|
|
|
CompanyManagerFace face;
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2008-09-30 22:39:50 +02:00
|
|
|
Money money;
|
|
|
|
byte money_fraction;
|
2007-06-18 23:44:47 +02:00
|
|
|
Money current_loan;
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2008-09-30 22:39:50 +02:00
|
|
|
byte colour;
|
2006-09-15 14:27:00 +02:00
|
|
|
Livery livery[LS_END];
|
2008-01-09 22:05:03 +01:00
|
|
|
RailTypes avail_railtypes;
|
|
|
|
RoadTypes avail_roadtypes;
|
2004-08-09 19:04:08 +02:00
|
|
|
byte block_preview;
|
|
|
|
|
2008-04-21 11:27:47 +02:00
|
|
|
uint32 cargo_types; ///< which cargo types were transported the last year
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2009-11-29 20:20:39 +01:00
|
|
|
TileIndex location_of_HQ; ///< northern tile of HQ; INVALID_TILE when there is none
|
2004-08-09 19:04:08 +02:00
|
|
|
TileIndex last_build_coordinate;
|
2004-08-31 18:12:52 +02:00
|
|
|
|
2008-09-30 22:39:50 +02:00
|
|
|
OwnerByte share_owners[4];
|
2004-08-31 18:12:52 +02:00
|
|
|
|
2006-08-20 20:40:57 +02:00
|
|
|
Year inaugurated_year;
|
2004-08-09 19:04:08 +02:00
|
|
|
byte num_valid_stat_ent;
|
2004-08-31 18:12:52 +02:00
|
|
|
|
2009-09-01 14:28:46 +02:00
|
|
|
byte quarters_of_bankruptcy;
|
2008-12-24 01:25:17 +01:00
|
|
|
CompanyMask bankrupt_asked; ///< which companies were asked about buying it?
|
2004-08-09 19:04:08 +02:00
|
|
|
int16 bankrupt_timeout;
|
2007-06-18 23:44:47 +02:00
|
|
|
Money bankrupt_value;
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2006-03-27 00:25:29 +02:00
|
|
|
bool is_ai;
|
2009-01-12 18:11:45 +01:00
|
|
|
|
|
|
|
class AIInstance *ai_instance;
|
|
|
|
class AIInfo *ai_info;
|
2004-08-31 18:12:52 +02:00
|
|
|
|
2008-02-09 03:49:33 +01:00
|
|
|
Money yearly_expenses[3][EXPENSES_END];
|
2008-09-30 22:39:50 +02:00
|
|
|
CompanyEconomyEntry cur_economy;
|
2009-08-03 22:02:25 +02:00
|
|
|
CompanyEconomyEntry old_economy[MAX_HISTORY_MONTHS];
|
2007-03-21 18:42:43 +01:00
|
|
|
EngineRenewList engine_renew_list; ///< Defined later
|
2009-05-16 01:55:06 +02:00
|
|
|
CompanySettings settings; ///< settings specific for each company
|
2008-09-30 22:39:50 +02:00
|
|
|
uint16 *num_engines; ///< caches the number of engines of each type the company owns (no need to save this)
|
2009-06-11 00:05:01 +02:00
|
|
|
|
|
|
|
static FORCEINLINE bool IsValidAiID(size_t index)
|
|
|
|
{
|
2009-06-23 14:11:35 +02:00
|
|
|
const Company *c = Company::GetIfValid(index);
|
2009-06-11 00:05:01 +02:00
|
|
|
return c != NULL && c->is_ai;
|
|
|
|
}
|
|
|
|
|
|
|
|
static FORCEINLINE bool IsValidHumanID(size_t index)
|
|
|
|
{
|
2009-06-23 14:11:35 +02:00
|
|
|
const Company *c = Company::GetIfValid(index);
|
2009-06-11 00:05:01 +02:00
|
|
|
return c != NULL && !c->is_ai;
|
|
|
|
}
|
2009-06-23 14:11:35 +02:00
|
|
|
|
|
|
|
static FORCEINLINE bool IsHumanID(size_t index)
|
|
|
|
{
|
|
|
|
return !Company::Get(index)->is_ai;
|
|
|
|
}
|
2009-09-08 14:27:27 +02:00
|
|
|
|
|
|
|
static void PostDestructor(size_t index);
|
2009-05-17 03:00:56 +02:00
|
|
|
};
|
2008-07-18 18:40:29 +02:00
|
|
|
|
2009-05-22 16:23:36 +02:00
|
|
|
#define FOR_ALL_COMPANIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Company, company_index, var, start)
|
|
|
|
#define FOR_ALL_COMPANIES(var) FOR_ALL_COMPANIES_FROM(var, 0)
|
2008-07-18 18:40:29 +02:00
|
|
|
|
2010-01-24 12:05:26 +01:00
|
|
|
Money CalculateCompanyValue(const Company *c, bool including_loan = true);
|
2006-09-15 14:27:00 +02:00
|
|
|
|
2009-02-25 22:45:14 +01:00
|
|
|
extern uint _next_competitor_start;
|
|
|
|
extern uint _cur_company_tick_index;
|
|
|
|
|
2008-09-30 22:39:50 +02:00
|
|
|
#endif /* COMPANY_BASE_H */
|