# ai.hpp

Go to the documentation of this file.

    00001 /* $Id$ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * 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.
    00006  * 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.
    00007  * 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/>.
    00008  */
    00009
    00012 #ifndef AI_HPP
    00013 #define AI_HPP
    00014
    00015 #include "../script/api/script_event_types.hpp"
    00016 #include "../core/string_compare_type.hpp"
    00017 #include <map>
    00018
    00020 typedef std::map<const char *, class ScriptInfo *, StringCompare> ScriptInfoList;
    00021
    00025 class AI {
    00026 public:
    00030   enum StartNext {
    00031     START_NEXT_EASY   = DAYS_IN_YEAR * 2,
    00032     START_NEXT_MEDIUM = DAYS_IN_YEAR,
    00033     START_NEXT_HARD   = DAYS_IN_YEAR / 2,
    00034     START_NEXT_MIN    = 1,
    00035     START_NEXT_MAX    = 3600,
    00036     START_NEXT_DEVIATION = 60,
    00037   };
    00038
    00043   static bool CanStartNew();
    00044
    00050   static void StartNew(CompanyID company, bool rerandomise_ai = true);
    00051
    00055   static void GameLoop();
    00056
    00060   static uint GetTick();
    00061
    00067   static void Stop(CompanyID company);
    00068
    00076   static void Suspend(CompanyID company);
    00077
    00081   static void KillAll();
    00082
    00086   static void Initialize();
    00087
    00092   static void Uninitialize(bool keepConfig);
    00093
    00098   static void ResetConfig();
    00099
    00103   static void NewEvent(CompanyID company, ScriptEvent *event);
    00104
    00108   static void BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company = MAX_COMPANIES);
    00109
    00113   static void Save(CompanyID company);
    00114
    00118   static void Load(CompanyID company, int version);
    00119
    00123   static int GetStartNextTime();
    00124
    00126   static char *GetConsoleList(char *p, const char *last, bool newest_only = false);
    00128   static char *GetConsoleLibraryList(char *p, const char *last);
    00130   static const ScriptInfoList *GetInfoList();
    00132   static const ScriptInfoList *GetUniqueInfoList();
    00134   static class AIInfo *FindInfo(const char *name, int version, bool force_exact_match);
    00136   static class AILibrary *FindLibrary(const char *library, int version);
    00137
    00142   static void Rescan();
    00143 #if defined(ENABLE_NETWORK)
    00144
    00145   static bool HasAI(const struct ContentInfo *ci, bool md5sum);
    00146   static bool HasAILibrary(const ContentInfo *ci, bool md5sum);
    00147 #endif
    00148 private:
    00149   static uint frame_counter;
    00150   static class AIScannerInfo *scanner_info;
    00151   static class AIScannerLibrary *scanner_library;
    00152 };
    00153
    00154 #endif /* AI_HPP */