OpenTTD
ai.hpp
Go to the documentation of this file.
1 /* $Id: ai.hpp 24900 2013-01-08 22:46:42Z planetmaker $ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * 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.
6  * 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.
7  * 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/>.
8  */
9 
12 #ifndef AI_HPP
13 #define AI_HPP
14 
15 #include "../script/api/script_event_types.hpp"
16 #include "../core/string_compare_type.hpp"
17 #include "ai_scanner.hpp"
18 #include <map>
19 
21 typedef std::map<const char *, class ScriptInfo *, StringCompare> ScriptInfoList;
22 
26 class AI {
27 public:
31  enum StartNext {
32  START_NEXT_EASY = DAYS_IN_YEAR * 2,
33  START_NEXT_MEDIUM = DAYS_IN_YEAR,
34  START_NEXT_HARD = DAYS_IN_YEAR / 2,
35  START_NEXT_MIN = 1,
36  START_NEXT_MAX = 3600,
37  START_NEXT_DEVIATION = 60,
38  };
39 
44  static bool CanStartNew();
45 
51  static void StartNew(CompanyID company, bool rerandomise_ai = true);
52 
56  static void GameLoop();
57 
61  static uint GetTick();
62 
68  static void Stop(CompanyID company);
69 
77  static void Pause(CompanyID company);
78 
86  static void Unpause(CompanyID company);
87 
94  static bool IsPaused(CompanyID company);
95 
99  static void KillAll();
100 
104  static void Initialize();
105 
110  static void Uninitialize(bool keepConfig);
111 
116  static void ResetConfig();
117 
121  static void NewEvent(CompanyID company, ScriptEvent *event);
122 
126  static void BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company = MAX_COMPANIES);
127 
131  static void Save(CompanyID company);
132 
136  static void Load(CompanyID company, int version);
137 
141  static int GetStartNextTime();
142 
144  static char *GetConsoleList(char *p, const char *last, bool newest_only = false);
146  static char *GetConsoleLibraryList(char *p, const char *last);
148  static const ScriptInfoList *GetInfoList();
150  static const ScriptInfoList *GetUniqueInfoList();
152  static class AIInfo *FindInfo(const char *name, int version, bool force_exact_match);
154  static class AILibrary *FindLibrary(const char *library, int version);
155 
160  static void Rescan();
161 
163  static AIScannerInfo *GetScannerInfo();
166 
167 #if defined(ENABLE_NETWORK)
168 
169  static bool HasAI(const struct ContentInfo *ci, bool md5sum);
170  static bool HasAILibrary(const ContentInfo *ci, bool md5sum);
171 #endif
172 private:
173  static uint frame_counter;
174  static class AIScannerInfo *scanner_info;
176 };
177 
178 #endif /* AI_HPP */