diff options
author | yexo <yexo@openttd.org> | 2010-01-02 15:52:29 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2010-01-02 15:52:29 +0000 |
commit | fe67e85700988303c6e0148fa6212bf3904c8fca (patch) | |
tree | 84c8f9073611d231b11fa755b46c051ccc587ade /src/ai/api/ai_engine.cpp | |
parent | ea75e7da60300bd0b1913a1a19ea554da21a592c (diff) | |
download | openttd-fe67e85700988303c6e0148fa6212bf3904c8fca.tar.xz |
(svn r18687) -Add [NoAI]: AIEngine::IsBuildable to check if you can build a certain engine.
-Change: AIEngine::IsValidEngine will now also return true when you have at least one vehicle of that type even if you can't build it anymore.
Diffstat (limited to 'src/ai/api/ai_engine.cpp')
-rw-r--r-- | src/ai/api/ai_engine.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/ai/api/ai_engine.cpp b/src/ai/api/ai_engine.cpp index 6416c95ff..157ee825d 100644 --- a/src/ai/api/ai_engine.cpp +++ b/src/ai/api/ai_engine.cpp @@ -12,6 +12,7 @@ #include "ai_engine.hpp" #include "ai_cargo.hpp" #include "../../company_func.h" +#include "../../company_base.h" #include "../../strings_func.h" #include "../../settings_type.h" #include "../../rail.h" @@ -22,6 +23,13 @@ /* static */ bool AIEngine::IsValidEngine(EngineID engine_id) { const Engine *e = ::Engine::GetIfValid(engine_id); + return e != NULL && (HasBit(e->company_avail, _current_company) || ::Company::Get(_current_company)->num_engines[engine_id] > 0); + +} + +/* static */ bool AIEngine::IsBuildable(EngineID engine_id) +{ + const Engine *e = ::Engine::GetIfValid(engine_id); return e != NULL && HasBit(e->company_avail, _current_company); } |