2009-08-21 22:21:05 +02: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 18:11:45 +01:00
|
|
|
/** @file ai_scanner.hpp declarations of the class for AI scanner */
|
|
|
|
|
|
|
|
#ifndef AI_SCANNER_HPP
|
|
|
|
#define AI_SCANNER_HPP
|
|
|
|
|
2009-03-15 23:41:57 +01:00
|
|
|
#include "../script/script_scanner.hpp"
|
2009-01-12 18:11:45 +01:00
|
|
|
|
2011-11-30 00:21:52 +01:00
|
|
|
class AIScannerInfo : public ScriptScanner {
|
2009-01-12 18:11:45 +01:00
|
|
|
public:
|
2011-11-30 00:21:52 +01:00
|
|
|
AIScannerInfo();
|
|
|
|
~AIScannerInfo();
|
2009-01-12 18:11:45 +01:00
|
|
|
|
2019-03-03 23:25:13 +01:00
|
|
|
void Initialize() override;
|
2009-01-12 18:11:45 +01:00
|
|
|
|
|
|
|
/**
|
2011-11-30 00:21:52 +01:00
|
|
|
* Select a random AI.
|
|
|
|
* @return A random AI from the pool.
|
2009-01-12 18:11:45 +01:00
|
|
|
*/
|
2010-01-07 01:09:27 +01:00
|
|
|
class AIInfo *SelectRandomAI() const;
|
2009-01-12 18:11:45 +01:00
|
|
|
|
|
|
|
/**
|
2011-11-30 00:21:52 +01:00
|
|
|
* Check if we have an AI by name and version available in our list.
|
2023-05-05 11:01:01 +02:00
|
|
|
* @param name The name of the AI.
|
|
|
|
* @param version The version of the AI, or -1 if you want the latest.
|
2011-11-30 00:21:52 +01:00
|
|
|
* @param force_exact_match Only match name+version, never latest.
|
2019-04-10 23:07:06 +02:00
|
|
|
* @return nullptr if no match found, otherwise the AI that matched.
|
2009-01-12 18:11:45 +01:00
|
|
|
*/
|
2023-05-05 11:01:01 +02:00
|
|
|
class AIInfo *FindInfo(const char *name, int version, bool force_exact_match);
|
2009-01-12 18:11:45 +01:00
|
|
|
|
|
|
|
/**
|
2011-11-30 00:21:52 +01:00
|
|
|
* Set the Dummy AI.
|
2009-01-12 18:11:45 +01:00
|
|
|
*/
|
2011-11-30 00:21:52 +01:00
|
|
|
void SetDummyAI(class AIInfo *info);
|
2009-01-12 18:11:45 +01:00
|
|
|
|
2011-11-30 00:21:52 +01:00
|
|
|
protected:
|
2023-05-05 14:00:00 +02:00
|
|
|
std::string GetScriptName(ScriptInfo *info) override;
|
2019-03-03 23:25:13 +01:00
|
|
|
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 15:52:30 +01:00
|
|
|
|
2009-01-12 18:11:45 +01:00
|
|
|
private:
|
2011-11-30 00:21:52 +01:00
|
|
|
AIInfo *info_dummy; ///< The dummy AI.
|
|
|
|
};
|
2009-01-12 18:11:45 +01:00
|
|
|
|
2011-11-30 00:21:52 +01:00
|
|
|
class AIScannerLibrary : public ScriptScanner {
|
|
|
|
public:
|
2019-03-03 23:25:13 +01:00
|
|
|
void Initialize() override;
|
2011-12-15 20:52:44 +01:00
|
|
|
|
2010-11-19 00:31:06 +01:00
|
|
|
/**
|
2011-11-30 00:21:52 +01: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 23:07:06 +02:00
|
|
|
* @return The library if found, nullptr otherwise.
|
2010-11-19 00:31:06 +01:00
|
|
|
*/
|
2011-11-30 00:21:52 +01:00
|
|
|
class AILibrary *FindLibrary(const char *library, int version);
|
|
|
|
|
|
|
|
protected:
|
2023-05-05 14:00:00 +02:00
|
|
|
std::string GetScriptName(ScriptInfo *info) override;
|
2019-03-03 23:25:13 +01:00
|
|
|
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 18:11:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* AI_SCANNER_HPP */
|