(svn r16559) -Codechange: introduce Company::IsValidAiID() and Company::IsValidHumanID(), don't use IsHumanCompany() where possible

This commit is contained in:
smatz
2009-06-10 22:05:01 +00:00
parent 0b66eb938f
commit a2567c84a0
14 changed files with 47 additions and 38 deletions

View File

@@ -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;
}