2009-01-12 17:11:45 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
/** @file ai_scanner.hpp declarations of the class for AI scanner */
|
|
|
|
|
|
|
|
#ifndef AI_SCANNER_HPP
|
|
|
|
#define AI_SCANNER_HPP
|
|
|
|
|
2009-03-15 22:41:57 +00:00
|
|
|
#include "../script/script_scanner.hpp"
|
2009-02-03 18:08:07 +00:00
|
|
|
#include "../core/string_compare_type.hpp"
|
2009-01-12 17:11:45 +00:00
|
|
|
#include <map>
|
|
|
|
|
2009-03-15 22:41:57 +00:00
|
|
|
class AIScanner : public ScriptScanner {
|
2009-01-12 17:11:45 +00:00
|
|
|
public:
|
|
|
|
AIScanner();
|
|
|
|
~AIScanner();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Import a library inside the Squirrel VM.
|
|
|
|
*/
|
|
|
|
bool ImportLibrary(const char *library, const char *class_name, int version, HSQUIRRELVM vm, class AIController *controller);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register a library to be put in the available list.
|
|
|
|
*/
|
|
|
|
void RegisterLibrary(class AILibrary *library);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register an AI to be put in the available list.
|
|
|
|
*/
|
|
|
|
void RegisterAI(class AIInfo *info);
|
|
|
|
|
|
|
|
void SetDummyAI(class AIInfo *info) { this->info_dummy = info; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Select a Random AI.
|
|
|
|
*/
|
|
|
|
class AIInfo *SelectRandomAI();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find an AI by name.
|
|
|
|
*/
|
2009-01-13 01:46:46 +00:00
|
|
|
class AIInfo *FindInfo(const char *name, int version);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the list of available AIs for the console.
|
|
|
|
*/
|
|
|
|
char *GetAIConsoleList(char *p, const char *last);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the list of all registered AIs.
|
|
|
|
*/
|
|
|
|
const AIInfoList *GetAIInfoList() { return &this->info_list; }
|
|
|
|
|
2009-01-20 16:49:10 +00:00
|
|
|
/**
|
|
|
|
* Get the list of the newest version of all registered AIs.
|
|
|
|
*/
|
|
|
|
const AIInfoList *GetUniqueAIInfoList() { return &this->info_single_list; }
|
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
/**
|
|
|
|
* Rescan the AI dir for scripts.
|
|
|
|
*/
|
|
|
|
void RescanAIDir();
|
|
|
|
|
2009-01-17 16:53:32 +00:00
|
|
|
#if defined(ENABLE_NETWORK)
|
2009-10-04 20:51:50 +00:00
|
|
|
bool HasAI(const struct ContentInfo *ci, bool md5sum);
|
2009-01-17 16:53:32 +00:00
|
|
|
#endif
|
2009-01-12 17:11:45 +00:00
|
|
|
private:
|
2009-02-03 18:08:07 +00:00
|
|
|
typedef std::map<const char *, class AILibrary *, StringCompare> AILibraryList;
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Scan the AI dir for scripts.
|
|
|
|
*/
|
|
|
|
void ScanAIDir();
|
|
|
|
|
|
|
|
AIInfo *info_dummy;
|
2009-01-15 18:15:12 +00:00
|
|
|
AIInfoList info_list;
|
2009-01-15 18:24:49 +00:00
|
|
|
AIInfoList info_single_list;
|
2009-01-12 17:11:45 +00:00
|
|
|
AILibraryList library_list;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* AI_SCANNER_HPP */
|