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
|
|
|
|
2019-03-03 22:25:13 +00:00
|
|
|
void Initialize() override;
|
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.
|
2013-01-08 22:46:42 +00:00
|
|
|
* @param versionParam The version of the AI, or -1 if you want the latest.
|
2011-11-29 23:21:52 +00:00
|
|
|
* @param force_exact_match Only match name+version, never latest.
|
2019-04-10 21:07:06 +00:00
|
|
|
* @return nullptr 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:
|
2019-03-03 22:25:13 +00:00
|
|
|
void GetScriptName(ScriptInfo *info, char *name, const char *last) override;
|
|
|
|
const char *GetFileName() const override { return PATHSEP "info.nut"; }
|
|
|
|
Subdirectory GetDirectory() const override { return AI_DIR; }
|
|
|
|
const char *GetScannerName() const override { return "AIs"; }
|
|
|
|
void RegisterAPI(class Squirrel *engine) override;
|
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:
|
2019-03-03 22:25:13 +00:00
|
|
|
void Initialize() override;
|
2011-12-15 19:52:44 +00:00
|
|
|
|
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.
|
2019-04-10 21:07:06 +00:00
|
|
|
* @return The library if found, nullptr 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:
|
2019-03-03 22:25:13 +00:00
|
|
|
void GetScriptName(ScriptInfo *info, char *name, const char *last) override;
|
|
|
|
const char *GetFileName() const override { return PATHSEP "library.nut"; }
|
|
|
|
Subdirectory GetDirectory() const override { return AI_LIBRARY_DIR; }
|
|
|
|
const char *GetScannerName() const override { return "AI Libraries"; }
|
|
|
|
void RegisterAPI(class Squirrel *engine) override;
|
2009-01-12 17:11:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* AI_SCANNER_HPP */
|