summaryrefslogtreecommitdiff
path: root/src/ai/ai_core.cpp
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/ai/ai_core.cpp
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/ai/ai_core.cpp')
-rw-r--r--src/ai/ai_core.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp
index 0eb4fe29d..b89d2064f 100644
--- a/src/ai/ai_core.cpp
+++ b/src/ai/ai_core.cpp
@@ -64,7 +64,7 @@
const Company *c;
FOR_ALL_COMPANIES(c) {
- if (!IsHumanCompany(c->index)) {
+ if (c->is_ai) {
_current_company = c->index;
c->ai_instance->GameLoop();
}
@@ -74,8 +74,7 @@
* Effectively collecting garbage once every two months per AI. */
if ((AI::frame_counter & 255) == 0) {
CompanyID cid = (CompanyID)GB(AI::frame_counter, 8, 4);
- Company *com = Company::GetIfValid(cid);
- if (com != NULL && !IsHumanCompany(cid)) com->ai_instance->CollectGarbage();
+ if (Company::IsValidAiID(cid)) Company::Get(cid)->ai_instance->CollectGarbage();
}
_current_company = OWNER_NONE;
@@ -109,7 +108,7 @@
const Company *c;
FOR_ALL_COMPANIES(c) {
- if (!IsHumanCompany(c->index)) AI::Stop(c->index);
+ if (c->is_ai) AI::Stop(c->index);
}
}
@@ -179,7 +178,7 @@
}
/* Only AIs can have an event-queue */
- if (!Company::IsValidID(company) || IsHumanCompany(company)) {
+ if (!Company::IsValidAiID(company)) {
event->Release();
return;
}