From 62a7948af0ca9eb3b190a54918201e1075edcbbc Mon Sep 17 00:00:00 2001 From: smatz Date: Fri, 22 May 2009 15:13:50 +0000 Subject: (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved --- src/company_base.h | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'src/company_base.h') diff --git a/src/company_base.h b/src/company_base.h index bffe89b11..192a8deba 100644 --- a/src/company_base.h +++ b/src/company_base.h @@ -6,7 +6,7 @@ #define COMPANY_BASE_H #include "company_type.h" -#include "oldpool.h" +#include "core/pool.hpp" #include "road_type.h" #include "rail_type.h" #include "date_type.h" @@ -25,13 +25,11 @@ struct CompanyEconomyEntry { Money company_value; }; -/* The third parameter and the number after >> MUST be the same, - * otherwise more (or less) companies will be allowed to be - * created than what MAX_COMPANIES specifies! - */ -DECLARE_OLD_POOL(Company, Company, 1, (MAX_COMPANIES + 1) >> 1) +typedef Pool CompanyPool; +extern CompanyPool _company_pool; -struct Company : PoolItem { + +struct Company : CompanyPool::PoolItem<&_company_pool> { Company(uint16 name_1 = 0, bool is_ai = false); ~Company(); @@ -81,13 +79,6 @@ struct Company : PoolItem { EngineRenewList engine_renew_list; ///< Defined later CompanySettings settings; ///< settings specific for each company uint16 *num_engines; ///< caches the number of engines of each type the company owns (no need to save this) - - inline bool IsValid() const { return this->name_1 != 0; } - - static inline bool IsValidID(CompanyID company) - { - return company < MAX_COMPANIES && (uint)company < Company::GetPoolSize() && Company::Get(company)->IsValid(); - } }; #define FOR_ALL_COMPANIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Company, company_index, var, start) @@ -95,12 +86,7 @@ struct Company : PoolItem { static inline byte ActiveCompanyCount() { - const Company *c; - byte count = 0; - - FOR_ALL_COMPANIES(c) count++; - - return count; + return (byte)Company::GetNumItems(); } Money CalculateCompanyValue(const Company *c); -- cgit v1.2.3-54-g00ecf