summaryrefslogtreecommitdiff
path: root/src/company_base.h
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-06-10 22:05:01 +0000
committersmatz <smatz@openttd.org>2009-06-10 22:05:01 +0000
commitbea3fe2b8b2352d471149a4c914f93c58aa11b83 (patch)
tree69bd9a4b24333a7da3f2f3d11af4aafff5c92583 /src/company_base.h
parentbc7e9514d247581e085b80a71dabbd6e635e5ded (diff)
downloadopenttd-bea3fe2b8b2352d471149a4c914f93c58aa11b83.tar.xz
(svn r16559) -Codechange: introduce Company::IsValidAiID() and Company::IsValidHumanID(), don't use IsHumanCompany() where possible
Diffstat (limited to 'src/company_base.h')
-rw-r--r--src/company_base.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/company_base.h b/src/company_base.h
index e1049bad5..6d0f2abd0 100644
--- a/src/company_base.h
+++ b/src/company_base.h
@@ -79,6 +79,18 @@ struct Company : CompanyPool::PoolItem<&_company_pool> {
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)
+
+ static FORCEINLINE bool IsValidAiID(size_t index)
+ {
+ const Company *c = GetIfValid(index);
+ return c != NULL && c->is_ai;
+ }
+
+ static FORCEINLINE bool IsValidHumanID(size_t index)
+ {
+ const Company *c = GetIfValid(index);
+ return c != NULL && !c->is_ai;
+ }
};
#define FOR_ALL_COMPANIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Company, company_index, var, start)
@@ -86,6 +98,12 @@ struct Company : CompanyPool::PoolItem<&_company_pool> {
Money CalculateCompanyValue(const Company *c);
+static inline bool IsHumanCompany(CompanyID company)
+{
+ return !Company::Get(company)->is_ai;
+}
+
+
extern uint _next_competitor_start;
extern uint _cur_company_tick_index;