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-01-12 17:11:45 +00:00
|
|
|
|
2011-11-29 23:21:52 +00:00
|
|
|
class AIScannerInfo : public ScriptScanner {
|
2009-01-12 17:11:45 +00:00
|
|
|
public:
|
2011-11-29 23:21:52 +00:00
|
|
|
AIScannerInfo();
|
|
|
|
~AIScannerInfo();
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-11-29 23:21:52 +00:00
|
|
|
/* virtual */ void Initialize(const char *name);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
2011-11-29 23:21:52 +00:00
|
|
|
* Select a random AI.
|
|
|
|
* @return A random AI from the pool.
|
2009-01-12 17:11:45 +00:00
|
|
|
*/
|
2010-01-07 00:09:27 +00:00
|
|
|
class AIInfo *SelectRandomAI() const;
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
2011-11-29 23:21:52 +00:00
|
|
|
* Check if we have an AI by name and version available in our list.
|
|
|
|
* @param nameParam The name of the AI.
|
|
|
|
* @param versionParam The versionof the AI, or -1 if you want the latest.
|
|
|
|
* @param force_exact_match Only match name+version, never latest.
|
|
|
|
* @return NULL if no match found, otherwise the AI that matched.
|
2009-01-12 17:11:45 +00:00
|
|
|
*/
|
2011-11-29 23:21:52 +00:00
|
|
|
class AIInfo *FindInfo(const char *nameParam, int versionParam, bool force_exact_match);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
2011-11-29 23:21:52 +00:00
|
|
|
* Set the Dummy AI.
|
2009-01-12 17:11:45 +00:00
|
|
|
*/
|
2011-11-29 23:21:52 +00:00
|
|
|
void SetDummyAI(class AIInfo *info);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-11-29 23:21:52 +00:00
|
|
|
protected:
|
|
|
|
/* virtual */ void GetScriptName(ScriptInfo *info, char *name, int len);
|
|
|
|
/* virtual */ const char *GetFileName() const { return PATHSEP "info.nut"; }
|
|
|
|
/* virtual */ Subdirectory GetDirectory() const { return AI_DIR; }
|
|
|
|
/* virtual */ const char *GetScannerName() const { return "AIs"; }
|
|
|
|
/* virtual */ void RegisterAPI(class Squirrel *engine);
|
2011-01-03 14:52:30 +00:00
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
private:
|
2011-11-29 23:21:52 +00:00
|
|
|
AIInfo *info_dummy; ///< The dummy AI.
|
|
|
|
};
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-11-29 23:21:52 +00:00
|
|
|
class AIScannerLibrary : public ScriptScanner {
|
|
|
|
public:
|
2010-11-18 23:31:06 +00:00
|
|
|
/**
|
2011-11-29 23:21:52 +00:00
|
|
|
* Find a library in the pool.
|
|
|
|
* @param library The library name to find.
|
|
|
|
* @param version The version the library should have.
|
|
|
|
* @return The library if found, NULL otherwise.
|
2010-11-18 23:31:06 +00:00
|
|
|
*/
|
2011-11-29 23:21:52 +00:00
|
|
|
class AILibrary *FindLibrary(const char *library, int version);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/* virtual */ void GetScriptName(ScriptInfo *info, char *name, int len);
|
|
|
|
/* virtual */ const char *GetFileName() const { return PATHSEP "library.nut"; }
|
|
|
|
/* virtual */ Subdirectory GetDirectory() const { return AI_LIBRARY_DIR; }
|
|
|
|
/* virtual */ const char *GetScannerName() const { return "AI Libraries"; }
|
|
|
|
/* virtual */ void RegisterAPI(class Squirrel *engine);
|
2009-01-12 17:11:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* AI_SCANNER_HPP */
|