(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.
This commit is contained in:
yexo
2010-01-02 15:52:29 +00:00
parent ea75e7da60
commit fe67e85700
9 changed files with 186 additions and 5 deletions

View File

@@ -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"
@@ -20,6 +21,13 @@
#include "table/strings.h"
/* 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);