Files
@ r28035:f86971abe639
Branch filter:
Location: cpp/openttd-patchpack/source/src/ai/ai.hpp - annotation
r28035:f86971abe639
4.9 KiB
text/x-c++hdr
Update: Translations from eints
english (au): 3 changes by krysclarke
russian: 3 changes by Ln-Wolf
finnish: 3 changes by hpiirai
turkish: 4 changes by BeratSJ
french: 3 changes by ottdfevr
portuguese: 3 changes by azulcosta
portuguese (brazilian): 3 changes by pasantoro
english (au): 3 changes by krysclarke
russian: 3 changes by Ln-Wolf
finnish: 3 changes by hpiirai
turkish: 4 changes by BeratSJ
french: 3 changes by ottdfevr
portuguese: 3 changes by azulcosta
portuguese (brazilian): 3 changes by pasantoro
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 | r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r18500:14a481bc4437 r19556:51f34458ed8a r10696:8dfe83e30d01 r15598:7c4c457ebe78 r15598:7c4c457ebe78 r15598:7c4c457ebe78 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r14202:008944a6e34c r10696:8dfe83e30d01 r14202:008944a6e34c r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r12138:e93d2e409e78 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r14931:fdc0797fe626 r14931:fdc0797fe626 r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r19606:13c83d3a505e r14931:fdc0797fe626 r14931:fdc0797fe626 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r18501:8e3d905ea4bc r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r18501:8e3d905ea4bc r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r15598:7c4c457ebe78 r27398:53658248e31b r16957:b73e503c5e41 r27398:53658248e31b r15598:7c4c457ebe78 r18508:f893337ab5c7 r15598:7c4c457ebe78 r18508:f893337ab5c7 r15598:7c4c457ebe78 r27354:7a607c98c943 r18441:63bc631b2d9b r27354:7a607c98c943 r15598:7c4c457ebe78 r15598:7c4c457ebe78 r15598:7c4c457ebe78 r15598:7c4c457ebe78 r15598:7c4c457ebe78 r10696:8dfe83e30d01 r19556:51f34458ed8a r19556:51f34458ed8a r19556:51f34458ed8a r19556:51f34458ed8a r19556:51f34458ed8a r19556:51f34458ed8a r15598:7c4c457ebe78 r10793:5ba2151e71e9 r18508:f893337ab5c7 r10696:8dfe83e30d01 r18508:f893337ab5c7 r18508:f893337ab5c7 r18508:f893337ab5c7 r10696:8dfe83e30d01 r10696:8dfe83e30d01 r10696:8dfe83e30d01 | /*
* 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.hpp Base functions for all AIs. */
#ifndef AI_HPP
#define AI_HPP
#include "../script/api/script_event_types.hpp"
#include "ai_scanner.hpp"
/**
* Main AI class. Contains all functions needed to start, stop, save and load AIs.
*/
class AI {
public:
/**
* Is it possible to start a new AI company?
* @return True if a new AI company can be started.
*/
static bool CanStartNew();
/**
* Start a new AI company.
* @param company At which slot the AI company should start.
* @param rerandomise_ai Whether to rerandomise the configured AI.
*/
static void StartNew(CompanyID company, bool rerandomise_ai = true);
/**
* Called every game-tick to let AIs do something.
*/
static void GameLoop();
/**
* Get the current AI tick.
*/
static uint GetTick();
/**
* Stop a company to be controlled by an AI.
* @param company The company from which the AI needs to detach.
* @pre Company::IsValidAiID(company)
*/
static void Stop(CompanyID company);
/**
* Suspend the AI and then pause execution of the script. The script
* will not be resumed from its suspended state until the script has
* been unpaused.
* @param company The company for which the AI should be paused.
* @pre Company::IsValidAiID(company)
*/
static void Pause(CompanyID company);
/**
* Resume execution of the AI. This function will not actually execute
* the script, but set a flag so that the script is executed my the usual
* mechanism that executes the script.
* @param company The company for which the AI should be unpaused.
* @pre Company::IsValidAiID(company)
*/
static void Unpause(CompanyID company);
/**
* Checks if the AI is paused.
* @param company The company for which to check if the AI is paused.
* @pre Company::IsValidAiID(company)
* @return true if the AI is paused, otherwise false.
*/
static bool IsPaused(CompanyID company);
/**
* Kill any and all AIs we manage.
*/
static void KillAll();
/**
* Initialize the AI system.
*/
static void Initialize();
/**
* Uninitialize the AI system
* @param keepConfig Should we keep AIConfigs, or can we free that memory?
*/
static void Uninitialize(bool keepConfig);
/**
* Reset all AIConfigs, and make them reload their AIInfo.
* If the AIInfo could no longer be found, an error is reported to the user.
*/
static void ResetConfig();
/**
* Queue a new event for an AI.
*/
static void NewEvent(CompanyID company, ScriptEvent *event);
/**
* Broadcast a new event to all active AIs.
*/
static void BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company = MAX_COMPANIES);
/**
* Save data from an AI to a savegame.
*/
static void Save(CompanyID company);
/** Wrapper function for AIScanner::GetAIConsoleList */
static void GetConsoleList(std::back_insert_iterator<std::string> &output_iterator, bool newest_only);
/** Wrapper function for AIScanner::GetAIConsoleLibraryList */
static void GetConsoleLibraryList(std::back_insert_iterator<std::string> &output_iterator);
/** Wrapper function for AIScanner::GetAIInfoList */
static const ScriptInfoList *GetInfoList();
/** Wrapper function for AIScanner::GetUniqueAIInfoList */
static const ScriptInfoList *GetUniqueInfoList();
/** Wrapper function for AIScanner::FindInfo */
static class AIInfo *FindInfo(const std::string &name, int version, bool force_exact_match);
/** Wrapper function for AIScanner::FindLibrary */
static class AILibrary *FindLibrary(const std::string &library, int version);
/**
* Rescans all searchpaths for available AIs. If a used AI is no longer
* found it is removed from the config.
*/
static void Rescan();
/** Gets the ScriptScanner instance that is used to find AIs */
static AIScannerInfo *GetScannerInfo();
/** Gets the ScriptScanner instance that is used to find AI Libraries */
static AIScannerLibrary *GetScannerLibrary();
/** Wrapper function for AIScanner::HasAI */
static bool HasAI(const struct ContentInfo *ci, bool md5sum);
static bool HasAILibrary(const ContentInfo *ci, bool md5sum);
private:
static uint frame_counter; ///< Tick counter for the AI code
static class AIScannerInfo *scanner_info; ///< ScriptScanner instance that is used to find AIs
static class AIScannerLibrary *scanner_library; ///< ScriptScanner instance that is used to find AI Libraries
};
#endif /* AI_HPP */
|