summaryrefslogtreecommitdiff
path: root/src/company_base.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-12-24 09:53:15 +0000
committerrubidium <rubidium@openttd.org>2008-12-24 09:53:15 +0000
commitd1bb5e5f3632ada5336cd0408e11a6d17f43a5b7 (patch)
tree04c454a456e353e63a9ba8a438b575b0902b93e0 /src/company_base.h
parent5b26afbd6b0446373a9f21ec80ee8bac82c11f0b (diff)
downloadopenttd-d1bb5e5f3632ada5336cd0408e11a6d17f43a5b7.tar.xz
(svn r14735) -Codechange: remove a bit of bit-waste in the map array (without changing the map array) and make the CompanyIDs contiguous.
-Note: 15 should be enough for now... making it any more means adding more bytes to the map array and thus wasting more bits instead of reducing the bit waste.
Diffstat (limited to 'src/company_base.h')
-rw-r--r--src/company_base.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/company_base.h b/src/company_base.h
index 665cfe08a..b92db880b 100644
--- a/src/company_base.h
+++ b/src/company_base.h
@@ -28,7 +28,7 @@ struct CompanyEconomyEntry {
* 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)
+DECLARE_OLD_POOL(Company, Company, 1, (MAX_COMPANIES + 1) >> 1)
struct Company : PoolItem<Company, CompanyByte, &_Company_pool> {
Company(uint16 name_1 = 0, bool is_ai = false);
@@ -86,7 +86,7 @@ struct Company : PoolItem<Company, CompanyByte, &_Company_pool> {
static inline bool IsValidCompanyID(CompanyID company)
{
- return (uint)company < GetCompanyPoolSize() && GetCompany(company)->IsValid();
+ return company < MAX_COMPANIES && (uint)company < GetCompanyPoolSize() && GetCompany(company)->IsValid();
}
#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())