company_base.h
Go to the documentation of this file.00001
00002
00005 #ifndef COMPANY_BASE_H
00006 #define COMPANY_BASE_H
00007
00008 #include "company_type.h"
00009 #include "oldpool.h"
00010 #include "road_type.h"
00011 #include "rail_type.h"
00012 #include "date_type.h"
00013 #include "engine_type.h"
00014 #include "livery.h"
00015 #include "autoreplace_type.h"
00016 #include "economy_type.h"
00017 #include "tile_type.h"
00018
00019 struct CompanyEconomyEntry {
00020 Money income;
00021 Money expenses;
00022 int32 delivered_cargo;
00023 int32 performance_history;
00024 Money company_value;
00025 };
00026
00027
00028
00029
00030
00031 DECLARE_OLD_POOL(Company, Company, 1, (MAX_COMPANIES + 1) >> 1)
00032
00033 struct Company : PoolItem<Company, CompanyByte, &_Company_pool> {
00034 Company(uint16 name_1 = 0, bool is_ai = false);
00035 ~Company();
00036
00037 uint32 name_2;
00038 uint16 name_1;
00039 char *name;
00040
00041 uint16 president_name_1;
00042 uint32 president_name_2;
00043 char *president_name;
00044
00045 CompanyManagerFace face;
00046
00047 Money money;
00048 byte money_fraction;
00049 Money current_loan;
00050
00051 byte colour;
00052 Livery livery[LS_END];
00053 RailTypes avail_railtypes;
00054 RoadTypes avail_roadtypes;
00055 byte block_preview;
00056
00057 uint32 cargo_types;
00058
00059 TileIndex location_of_HQ;
00060 TileIndex last_build_coordinate;
00061
00062 OwnerByte share_owners[4];
00063
00064 Year inaugurated_year;
00065 byte num_valid_stat_ent;
00066
00067 byte quarters_of_bankrupcy;
00068 CompanyMask bankrupt_asked;
00069 int16 bankrupt_timeout;
00070 Money bankrupt_value;
00071
00072 bool is_ai;
00073
00074 Money yearly_expenses[3][EXPENSES_END];
00075 CompanyEconomyEntry cur_economy;
00076 CompanyEconomyEntry old_economy[24];
00077 EngineRenewList engine_renew_list;
00078 bool engine_renew;
00079 bool renew_keep_length;
00080 int16 engine_renew_months;
00081 uint32 engine_renew_money;
00082 uint16 *num_engines;
00083
00084 inline bool IsValid() const { return this->name_1 != 0; }
00085 };
00086
00087 static inline bool IsValidCompanyID(CompanyID company)
00088 {
00089 return company < MAX_COMPANIES && (uint)company < GetCompanyPoolSize() && GetCompany(company)->IsValid();
00090 }
00091
00092 #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())
00093 #define FOR_ALL_COMPANIES(d) FOR_ALL_COMPANIES_FROM(d, 0)
00094
00095 static inline byte ActiveCompanyCount()
00096 {
00097 const Company *c;
00098 byte count = 0;
00099
00100 FOR_ALL_COMPANIES(c) count++;
00101
00102 return count;
00103 }
00104
00105 Money CalculateCompanyValue(const Company *c);
00106
00107 #endif