You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
2.6 KiB
C
108 lines
2.6 KiB
C
19 years ago
|
/* $Id$ */
|
||
|
|
||
16 years ago
|
/** @file company_base.h Definition of stuff that is very close to a company, like the company struct itself. */
|
||
18 years ago
|
|
||
16 years ago
|
#ifndef COMPANY_BASE_H
|
||
|
#define COMPANY_BASE_H
|
||
20 years ago
|
|
||
16 years ago
|
#include "company_type.h"
|
||
16 years ago
|
#include "oldpool.h"
|
||
17 years ago
|
#include "road_type.h"
|
||
|
#include "rail_type.h"
|
||
17 years ago
|
#include "date_type.h"
|
||
17 years ago
|
#include "engine_type.h"
|
||
18 years ago
|
#include "livery.h"
|
||
17 years ago
|
#include "autoreplace_type.h"
|
||
17 years ago
|
#include "economy_type.h"
|
||
|
#include "tile_type.h"
|
||
20 years ago
|
|
||
16 years ago
|
struct CompanyEconomyEntry {
|
||
18 years ago
|
Money income;
|
||
|
Money expenses;
|
||
20 years ago
|
int32 delivered_cargo;
|
||
16 years ago
|
int32 performance_history; ///< company score (scale 0-1000)
|
||
18 years ago
|
Money company_value;
|
||
18 years ago
|
};
|
||
20 years ago
|
|
||
16 years ago
|
/* The third parameter and the number after >> MUST be the same,
|
||
16 years ago
|
* otherwise more (or less) companies will be allowed to be
|
||
|
* created than what MAX_COMPANIES specifies!
|
||
16 years ago
|
*/
|
||
16 years ago
|
DECLARE_OLD_POOL(Company, Company, 1, MAX_COMPANIES >> 1)
|
||
16 years ago
|
|
||
16 years ago
|
struct Company : PoolItem<Company, CompanyByte, &_Company_pool> {
|
||
|
Company(uint16 name_1 = 0, bool is_ai = false);
|
||
|
~Company();
|
||
16 years ago
|
|
||
20 years ago
|
uint32 name_2;
|
||
|
uint16 name_1;
|
||
17 years ago
|
char *name;
|
||
20 years ago
|
|
||
|
uint16 president_name_1;
|
||
|
uint32 president_name_2;
|
||
17 years ago
|
char *president_name;
|
||
20 years ago
|
|
||
16 years ago
|
CompanyManagerFace face;
|
||
20 years ago
|
|
||
16 years ago
|
Money money;
|
||
|
byte money_fraction;
|
||
18 years ago
|
Money current_loan;
|
||
20 years ago
|
|
||
16 years ago
|
byte colour;
|
||
18 years ago
|
Livery livery[LS_END];
|
||
17 years ago
|
RailTypes avail_railtypes;
|
||
|
RoadTypes avail_roadtypes;
|
||
20 years ago
|
byte block_preview;
|
||
|
|
||
17 years ago
|
uint32 cargo_types; ///< which cargo types were transported the last year
|
||
20 years ago
|
|
||
16 years ago
|
TileIndex location_of_HQ;
|
||
20 years ago
|
TileIndex last_build_coordinate;
|
||
20 years ago
|
|
||
16 years ago
|
OwnerByte share_owners[4];
|
||
20 years ago
|
|
||
18 years ago
|
Year inaugurated_year;
|
||
20 years ago
|
byte num_valid_stat_ent;
|
||
20 years ago
|
|
||
20 years ago
|
byte quarters_of_bankrupcy;
|
||
16 years ago
|
byte bankrupt_asked; ///< which companies were asked about buying it?
|
||
20 years ago
|
int16 bankrupt_timeout;
|
||
18 years ago
|
Money bankrupt_value;
|
||
20 years ago
|
|
||
19 years ago
|
bool is_ai;
|
||
20 years ago
|
|
||
17 years ago
|
Money yearly_expenses[3][EXPENSES_END];
|
||
16 years ago
|
CompanyEconomyEntry cur_economy;
|
||
|
CompanyEconomyEntry old_economy[24];
|
||
18 years ago
|
EngineRenewList engine_renew_list; ///< Defined later
|
||
19 years ago
|
bool engine_renew;
|
||
19 years ago
|
bool renew_keep_length;
|
||
19 years ago
|
int16 engine_renew_months;
|
||
|
uint32 engine_renew_money;
|
||
16 years ago
|
uint16 *num_engines; ///< caches the number of engines of each type the company owns (no need to save this)
|
||
16 years ago
|
|
||
|
inline bool IsValid() const { return this->name_1 != 0; }
|
||
18 years ago
|
};
|
||
20 years ago
|
|
||
16 years ago
|
static inline bool IsValidCompanyID(CompanyID company)
|
||
16 years ago
|
{
|
||
16 years ago
|
return (uint)company < GetCompanyPoolSize() && GetCompany(company)->IsValid();
|
||
16 years ago
|
}
|
||
|
|
||
16 years ago
|
#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)
|
||
16 years ago
|
|
||
16 years ago
|
static inline byte ActiveCompanyCount()
|
||
18 years ago
|
{
|
||
16 years ago
|
const Company *c;
|
||
18 years ago
|
byte count = 0;
|
||
|
|
||
16 years ago
|
FOR_ALL_COMPANIES(c) count++;
|
||
18 years ago
|
|
||
|
return count;
|
||
|
}
|
||
19 years ago
|
|
||
16 years ago
|
Money CalculateCompanyValue(const Company *c);
|
||
18 years ago
|
|
||
16 years ago
|
#endif /* COMPANY_BASE_H */
|