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_info.hpp AIInfo keeps track of all information of an AI, like Author, Description, ... */
|
|
|
|
|
2010-12-22 11:46:41 +00:00
|
|
|
#ifndef AI_INFO_HPP
|
|
|
|
#define AI_INFO_HPP
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2009-03-15 22:41:57 +00:00
|
|
|
#include "../script/script_info.hpp"
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2010-07-31 22:16:34 +00:00
|
|
|
/** All static information from an AI like name, version, etc. */
|
2011-11-29 23:21:52 +00:00
|
|
|
class AIInfo : public ScriptInfo {
|
2009-01-12 17:11:45 +00:00
|
|
|
public:
|
2009-12-06 20:22:21 +00:00
|
|
|
AIInfo();
|
2009-01-12 17:11:45 +00:00
|
|
|
~AIInfo();
|
|
|
|
|
2011-11-29 23:21:52 +00:00
|
|
|
/**
|
|
|
|
* Register the functions of this class.
|
|
|
|
*/
|
|
|
|
static void RegisterAPI(Squirrel *engine);
|
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
/**
|
|
|
|
* Create an AI, using this AIInfo as start-template.
|
|
|
|
*/
|
|
|
|
static SQInteger Constructor(HSQUIRRELVM vm);
|
2010-07-31 22:16:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a dummy-AI.
|
|
|
|
*/
|
2009-01-12 17:11:45 +00:00
|
|
|
static SQInteger DummyConstructor(HSQUIRRELVM vm);
|
|
|
|
|
2009-02-13 01:44:56 +00:00
|
|
|
/**
|
|
|
|
* Check if we can start this AI.
|
|
|
|
*/
|
2009-02-13 02:11:54 +00:00
|
|
|
bool CanLoadFromVersion(int version) const;
|
2009-02-13 01:44:56 +00:00
|
|
|
|
2009-04-21 19:13:32 +00:00
|
|
|
/**
|
|
|
|
* Use this AI as a random AI.
|
|
|
|
*/
|
|
|
|
bool UseAsRandomAI() const { return this->use_as_random; }
|
|
|
|
|
2009-08-18 18:51:42 +00:00
|
|
|
/**
|
|
|
|
* Get the API version this AI is written for.
|
|
|
|
*/
|
|
|
|
const char *GetAPIVersion() const { return this->api_version; }
|
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
private:
|
2011-11-29 23:26:35 +00:00
|
|
|
int min_loadable_version; ///< The AI can load savegame data if the version is equal or greater than this.
|
|
|
|
bool use_as_random; ///< Should this AI be used when the user wants a "random AI"?
|
|
|
|
const char *api_version; ///< API version used by this AI.
|
2009-01-12 17:11:45 +00:00
|
|
|
};
|
|
|
|
|
2010-07-31 22:16:34 +00:00
|
|
|
/** All static information from an AI library like name, version, etc. */
|
2011-11-29 23:21:52 +00:00
|
|
|
class AILibrary : public ScriptInfo {
|
2009-01-12 17:11:45 +00:00
|
|
|
public:
|
2011-11-29 23:21:52 +00:00
|
|
|
AILibrary() : ScriptInfo(), category(NULL) {};
|
2009-01-15 18:15:12 +00:00
|
|
|
~AILibrary();
|
2009-01-15 15:56:10 +00:00
|
|
|
|
2011-11-29 23:21:52 +00:00
|
|
|
/**
|
|
|
|
* Register the functions of this class.
|
|
|
|
*/
|
|
|
|
static void RegisterAPI(Squirrel *engine);
|
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
/**
|
|
|
|
* Create an AI, using this AIInfo as start-template.
|
|
|
|
*/
|
|
|
|
static SQInteger Constructor(HSQUIRRELVM vm);
|
|
|
|
|
2009-01-15 15:56:10 +00:00
|
|
|
/**
|
|
|
|
* Get the category this library is in.
|
|
|
|
*/
|
2009-02-13 02:11:54 +00:00
|
|
|
const char *GetCategory() const { return this->category; }
|
2009-01-15 15:56:10 +00:00
|
|
|
|
|
|
|
private:
|
2010-08-01 19:36:56 +00:00
|
|
|
const char *category; ///< The category this library is in.
|
2009-01-12 17:11:45 +00:00
|
|
|
};
|
|
|
|
|
2010-12-22 11:46:41 +00:00
|
|
|
#endif /* AI_INFO_HPP */
|