summaryrefslogtreecommitdiff
path: root/src/script/api/script_engine.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-08-21 19:53:08 +0000
committerfrosch <frosch@openttd.org>2012-08-21 19:53:08 +0000
commit9f9cad1ac9faa674fc6bafdf3df41c5ea3fa3c15 (patch)
tree4d57c47943c5a4dfd7d94b3692f311ccd3e30ba0 /src/script/api/script_engine.cpp
parent4563c50c91e7a66d90fd35ecb84cebd2560beec5 (diff)
downloadopenttd-9f9cad1ac9faa674fc6bafdf3df41c5ea3fa3c15.tar.xz
(svn r24492) -Add: [NoGo] Useful behaviour for GSEngine::IsValidEngine and GSEngine::IsBuildable when outside GSCompanyMode scope.
Diffstat (limited to 'src/script/api/script_engine.cpp')
-rw-r--r--src/script/api/script_engine.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/script/api/script_engine.cpp b/src/script/api/script_engine.cpp
index adad559c5..a34d0910f 100644
--- a/src/script/api/script_engine.cpp
+++ b/src/script/api/script_engine.cpp
@@ -23,7 +23,12 @@
/* static */ bool ScriptEngine::IsValidEngine(EngineID engine_id)
{
const Engine *e = ::Engine::GetIfValid(engine_id);
- return e != NULL && (::IsEngineBuildable(engine_id, e->type, ScriptObject::GetCompany()) || (ScriptObject::GetCompany() != OWNER_DEITY && ::Company::Get(ScriptObject::GetCompany())->group_all[e->type].num_engines[engine_id] > 0));
+ if (e == NULL || !e->IsEnabled()) return false;
+
+ /* AIs have only access to engines they can purchase or still have in use.
+ * Deity has access to all engined that will be or were available ever. */
+ CompanyID company = ScriptObject::GetCompany();
+ return company == OWNER_DEITY || ::IsEngineBuildable(engine_id, e->type, company) || ::Company::Get(company)->group_all[e->type].num_engines[engine_id] > 0;
}
/* static */ bool ScriptEngine::IsBuildable(EngineID engine_id)