Files
@ r18358:e21717cc4b4c
Branch filter:
Location: cpp/openttd-patchpack/source/src/ai/ai_info.hpp - annotation
r18358:e21717cc4b4c
5.3 KiB
text/x-c++hdr
(svn r23204) -Fix (r23201): if you rename a constant, then also rename it in the helper scripts that use it
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | r10696:8dfe83e30d01 r10696:8dfe83e30d01 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r16851:b5784600e35e r16851:b5784600e35e r10696:8dfe83e30d01 r14500:437319d09620 r14500:437319d09620 r10696:8dfe83e30d01 r11026:6b3e7fbb46ae r11380:8edd3e28a734 r10696:8dfe83e30d01 r15598:7c4c457ebe78 r10696:8dfe83e30d01 r18323:39c61b16c682 r18323:39c61b16c682 r18323:39c61b16c682 r18323:39c61b16c682 r18323:39c61b16c682 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r15612:c4c9adbab3f3 r11026:6b3e7fbb46ae r15598:7c4c457ebe78 r10696:8dfe83e30d01 r15612:c4c9adbab3f3 r15612:c4c9adbab3f3 r15612:c4c9adbab3f3 r15612:c4c9adbab3f3 r15612:c4c9adbab3f3 r15612:c4c9adbab3f3 r15612:c4c9adbab3f3 r15612:c4c9adbab3f3 r15612:c4c9adbab3f3 r15612:c4c9adbab3f3 r15612:c4c9adbab3f3 r15612:c4c9adbab3f3 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10840:7a608f4ad153 r10840:7a608f4ad153 r15612:c4c9adbab3f3 r10696:8dfe83e30d01 r15598:7c4c457ebe78 r11380:8edd3e28a734 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r11380:8edd3e28a734 r10696:8dfe83e30d01 r11380:8edd3e28a734 r15612:c4c9adbab3f3 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r15598:7c4c457ebe78 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r17616:3ed8a6b01283 r17616:3ed8a6b01283 r17616:3ed8a6b01283 r17616:3ed8a6b01283 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r13879:b9c13f7998cb r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r15598:7c4c457ebe78 r15598:7c4c457ebe78 r15598:7c4c457ebe78 r15598:7c4c457ebe78 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r11380:8edd3e28a734 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r11119:63ffa1a1ddd6 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10724:cec22216aab8 r10724:cec22216aab8 r11119:63ffa1a1ddd6 r10724:cec22216aab8 r10724:cec22216aab8 r11118:0461c8a427c2 r11118:0461c8a427c2 r11119:63ffa1a1ddd6 r11118:0461c8a427c2 r11118:0461c8a427c2 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r11026:6b3e7fbb46ae r11026:6b3e7fbb46ae r11026:6b3e7fbb46ae r11026:6b3e7fbb46ae r11026:6b3e7fbb46ae r10696:8dfe83e30d01 r10696:8dfe83e30d01 r11119:63ffa1a1ddd6 r10696:8dfe83e30d01 r11720:a2a7bf20700e r11720:a2a7bf20700e r11720:a2a7bf20700e r11720:a2a7bf20700e r11720:a2a7bf20700e r12738:a48207b124c5 r12738:a48207b124c5 r12738:a48207b124c5 r12738:a48207b124c5 r12738:a48207b124c5 r10696:8dfe83e30d01 r15612:c4c9adbab3f3 r15612:c4c9adbab3f3 r15612:c4c9adbab3f3 r15612:c4c9adbab3f3 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r15598:7c4c457ebe78 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10758:7527fde7a84f r10762:c26063cf0293 r10758:7527fde7a84f r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r15598:7c4c457ebe78 r15598:7c4c457ebe78 r15598:7c4c457ebe78 r15598:7c4c457ebe78 r15598:7c4c457ebe78 r10696:8dfe83e30d01 r10758:7527fde7a84f r10758:7527fde7a84f r10758:7527fde7a84f r10758:7527fde7a84f r11119:63ffa1a1ddd6 r10758:7527fde7a84f r10758:7527fde7a84f r15612:c4c9adbab3f3 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r14500:437319d09620 r16851:b5784600e35e | /* $Id$ */
/*
* 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/>.
*/
/** @file ai_info.hpp AIInfo keeps track of all information of an AI, like Author, Description, ... */
#ifndef AI_INFO_HPP
#define AI_INFO_HPP
#ifdef ENABLE_AI
#include <list>
#include "../core/smallmap_type.hpp"
#include "../script/script_info.hpp"
/** Bitmask of flags for AI settings. */
enum AIConfigFlags {
AICONFIG_NONE = 0x0, ///< No flags set.
AICONFIG_RANDOM = 0x1, ///< When randomizing the AI, pick any value between min_value and max_value when on custom difficulty setting.
AICONFIG_BOOLEAN = 0x2, ///< This value is a boolean (either 0 (false) or 1 (true) ).
AICONFIG_INGAME = 0x4, ///< This setting can be changed while the AI is running.
AICONFIG_AI_DEVELOPER = 0x8, ///< This setting will only be visible when the ai development tools are active.
};
typedef SmallMap<int, char *> LabelMapping; ///< Map-type used to map the setting numbers to labels.
/** Info about a single AI setting. */
struct AIConfigItem {
const char *name; ///< The name of the configuration setting.
const char *description; ///< The description of the configuration setting.
int min_value; ///< The minimal value this configuration setting can have.
int max_value; ///< The maximal value this configuration setting can have.
int custom_value; ///< The default value on custom difficulty setting.
int easy_value; ///< The default value on easy difficulty setting.
int medium_value; ///< The default value on medium difficulty setting.
int hard_value; ///< The default value on hard difficulty setting.
int random_deviation; ///< The maximum random deviation from the default value.
int step_size; ///< The step size in the gui.
AIConfigFlags flags; ///< Flags for the configuration setting.
LabelMapping *labels; ///< Text labels for the integer values.
};
extern AIConfigItem _start_date_config;
typedef std::list<AIConfigItem> AIConfigItemList; ///< List of AIConfig items.
/** Base class that holds some basic information about AIs and AI libraries. */
class AIFileInfo : public ScriptFileInfo {
public:
/**
* Process the creation of a FileInfo object.
*/
static SQInteger Constructor(HSQUIRRELVM vm, AIFileInfo *info);
protected:
class AIScanner *base; ///< AIScanner object that was used to scan this AI (library) info.
};
/** All static information from an AI like name, version, etc. */
class AIInfo : public AIFileInfo {
public:
/**
* Get the class name, so the script code can create the right code.
* @return The class name.
*/
static const char *GetClassName() { return "AIInfo"; }
AIInfo();
~AIInfo();
/**
* Create an AI, using this AIInfo as start-template.
*/
static SQInteger Constructor(HSQUIRRELVM vm);
/**
* Create a dummy-AI.
*/
static SQInteger DummyConstructor(HSQUIRRELVM vm);
/**
* Get the settings of the AI.
*/
bool GetSettings();
/**
* Get the config list for this AI.
*/
const AIConfigItemList *GetConfigList() const;
/**
* Get the description of a certain ai config option.
*/
const AIConfigItem *GetConfigItem(const char *name) const;
/**
* Check if we can start this AI.
*/
bool CanLoadFromVersion(int version) const;
/**
* Set a setting.
*/
SQInteger AddSetting(HSQUIRRELVM vm);
/**
* Add labels for a setting.
*/
SQInteger AddLabels(HSQUIRRELVM vm);
/**
* Get the default value for a setting.
*/
int GetSettingDefaultValue(const char *name) const;
/**
* Use this AI as a random AI.
*/
bool UseAsRandomAI() const { return this->use_as_random; }
/**
* Get the API version this AI is written for.
*/
const char *GetAPIVersion() const { return this->api_version; }
private:
AIConfigItemList config_list; ///< List of settings from this AI.
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.
};
/** All static information from an AI library like name, version, etc. */
class AILibrary : public AIFileInfo {
public:
AILibrary() : AIFileInfo(), category(NULL) {};
~AILibrary();
/**
* Create an AI, using this AIInfo as start-template.
*/
static SQInteger Constructor(HSQUIRRELVM vm);
/**
* Import a library in the current AI. This function can be used by AIs
* by calling import.
* @param vm The squirrel vm of the calling AI.
*/
static SQInteger Import(HSQUIRRELVM vm);
/**
* Get the category this library is in.
*/
const char *GetCategory() const { return this->category; }
private:
const char *category; ///< The category this library is in.
};
#endif /* ENABLE_AI */
#endif /* AI_INFO_HPP */
|