2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
/** @file company_base.h Definition of stuff that is very close to a company, like the company struct itself. */
|
2007-03-21 17:42:43 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
#ifndef COMPANY_BASE_H
|
|
|
|
#define COMPANY_BASE_H
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-09-30 20:51:04 +00:00
|
|
|
#include "company_type.h"
|
2008-07-18 16:40:29 +00:00
|
|
|
#include "oldpool.h"
|
2008-01-09 21:05:03 +00:00
|
|
|
#include "road_type.h"
|
|
|
|
#include "rail_type.h"
|
2007-12-26 13:50:40 +00:00
|
|
|
#include "date_type.h"
|
2008-03-31 00:17:39 +00:00
|
|
|
#include "engine_type.h"
|
2006-09-15 12:27:00 +00:00
|
|
|
#include "livery.h"
|
2008-01-07 09:19:53 +00:00
|
|
|
#include "autoreplace_type.h"
|
2008-01-09 21:27:39 +00:00
|
|
|
#include "economy_type.h"
|
|
|
|
#include "tile_type.h"
|
2004-08-20 09:32:32 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
struct CompanyEconomyEntry {
|
2007-06-18 21:44:47 +00:00
|
|
|
Money income;
|
|
|
|
Money expenses;
|
2004-08-09 17:04:08 +00:00
|
|
|
int32 delivered_cargo;
|
2008-09-30 20:39:50 +00:00
|
|
|
int32 performance_history; ///< company score (scale 0-1000)
|
2007-06-18 22:49:55 +00:00
|
|
|
Money company_value;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-08-10 19:00:33 +00:00
|
|
|
/* The third parameter and the number after >> MUST be the same,
|
2008-09-30 20:39:50 +00:00
|
|
|
* otherwise more (or less) companies will be allowed to be
|
|
|
|
* created than what MAX_COMPANIES specifies!
|
2008-08-10 19:00:33 +00:00
|
|
|
*/
|
2008-09-30 20:39:50 +00:00
|
|
|
DECLARE_OLD_POOL(Company, Company, 1, MAX_COMPANIES >> 1)
|
2008-07-18 16:40:29 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
struct Company : PoolItem<Company, CompanyByte, &_Company_pool> {
|
|
|
|
Company(uint16 name_1 = 0, bool is_ai = false);
|
|
|
|
~Company();
|
2008-07-18 16:40:29 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
uint32 name_2;
|
|
|
|
uint16 name_1;
|
2008-01-12 19:58:06 +00:00
|
|
|
char *name;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
uint16 president_name_1;
|
|
|
|
uint32 president_name_2;
|
2008-01-12 19:58:06 +00:00
|
|
|
char *president_name;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
CompanyManagerFace face;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
Money money;
|
|
|
|
byte money_fraction;
|
2007-06-18 21:44:47 +00:00
|
|
|
Money current_loan;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
byte colour;
|
2006-09-15 12:27:00 +00:00
|
|
|
Livery livery[LS_END];
|
2008-01-09 21:05:03 +00:00
|
|
|
RailTypes avail_railtypes;
|
|
|
|
RoadTypes avail_roadtypes;
|
2004-08-09 17:04:08 +00:00
|
|
|
byte block_preview;
|
|
|
|
|
2008-04-21 09:27:47 +00:00
|
|
|
uint32 cargo_types; ///< which cargo types were transported the last year
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-08-25 16:10:34 +00:00
|
|
|
TileIndex location_of_HQ;
|
2004-08-09 17:04:08 +00:00
|
|
|
TileIndex last_build_coordinate;
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
OwnerByte share_owners[4];
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2006-08-20 18:40:57 +00:00
|
|
|
Year inaugurated_year;
|
2004-08-09 17:04:08 +00:00
|
|
|
byte num_valid_stat_ent;
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
byte quarters_of_bankrupcy;
|
2008-09-30 20:39:50 +00:00
|
|
|
byte bankrupt_asked; ///< which companies were asked about buying it?
|
2004-08-09 17:04:08 +00:00
|
|
|
int16 bankrupt_timeout;
|
2007-06-18 21:44:47 +00:00
|
|
|
Money bankrupt_value;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-03-26 22:25:29 +00:00
|
|
|
bool is_ai;
|
2004-08-31 16:12:52 +00:00
|
|
|
|
2008-02-09 02:49:33 +00:00
|
|
|
Money yearly_expenses[3][EXPENSES_END];
|
2008-09-30 20:39:50 +00:00
|
|
|
CompanyEconomyEntry cur_economy;
|
|
|
|
CompanyEconomyEntry old_economy[24];
|
2007-03-21 17:42:43 +00:00
|
|
|
EngineRenewList engine_renew_list; ///< Defined later
|
2005-08-06 16:07:22 +00:00
|
|
|
bool engine_renew;
|
2005-11-07 23:20:47 +00:00
|
|
|
bool renew_keep_length;
|
2005-08-06 16:07:22 +00:00
|
|
|
int16 engine_renew_months;
|
|
|
|
uint32 engine_renew_money;
|
2008-09-30 20:39:50 +00:00
|
|
|
uint16 *num_engines; ///< caches the number of engines of each type the company owns (no need to save this)
|
2008-07-18 16:40:29 +00:00
|
|
|
|
|
|
|
inline bool IsValid() const { return this->name_1 != 0; }
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
static inline bool IsValidCompanyID(CompanyID company)
|
2008-07-18 16:40:29 +00:00
|
|
|
{
|
2008-09-30 20:39:50 +00:00
|
|
|
return (uint)company < GetCompanyPoolSize() && GetCompany(company)->IsValid();
|
2008-07-18 16:40:29 +00:00
|
|
|
}
|
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
#define FOR_ALL_COMPANIES_FROM(d, start) for (d = GetCompany(start); d != NULL; d = (d->index + 1U < GetCompanyPoolSize()) ? GetCompany(d->index + 1U) : NULL) if (d->IsValid())
|
|
|
|
#define FOR_ALL_COMPANIES(d) FOR_ALL_COMPANIES_FROM(d, 0)
|
2008-07-18 16:40:29 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
static inline byte ActiveCompanyCount()
|
2006-10-12 11:42:57 +00:00
|
|
|
{
|
2008-09-30 20:39:50 +00:00
|
|
|
const Company *c;
|
2006-10-12 11:42:57 +00:00
|
|
|
byte count = 0;
|
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
FOR_ALL_COMPANIES(c) count++;
|
2006-10-12 11:42:57 +00:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
2006-01-31 22:16:15 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
Money CalculateCompanyValue(const Company *c);
|
2006-09-15 12:27:00 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
#endif /* COMPANY_BASE_H */
|