ai.hpp

Go to the documentation of this file.
00001 /* $Id: ai.hpp 24900 2013-01-08 22:46:42Z planetmaker $ */
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 "ai_scanner.hpp"
00018 #include <map>
00019 
00021 typedef std::map<const char *, class ScriptInfo *, StringCompare> ScriptInfoList;
00022 
00026 class AI {
00027 public:
00031   enum StartNext {
00032     START_NEXT_EASY   = DAYS_IN_YEAR * 2,
00033     START_NEXT_MEDIUM = DAYS_IN_YEAR,
00034     START_NEXT_HARD   = DAYS_IN_YEAR / 2,
00035     START_NEXT_MIN    = 1,
00036     START_NEXT_MAX    = 3600,
00037     START_NEXT_DEVIATION = 60,
00038   };
00039 
00044   static bool CanStartNew();
00045 
00051   static void StartNew(CompanyID company, bool rerandomise_ai = true);
00052 
00056   static void GameLoop();
00057 
00061   static uint GetTick();
00062 
00068   static void Stop(CompanyID company);
00069 
00077   static void Pause(CompanyID company);
00078 
00086   static void Unpause(CompanyID company);
00087 
00094   static bool IsPaused(CompanyID company);
00095 
00099   static void KillAll();
00100 
00104   static void Initialize();
00105 
00110   static void Uninitialize(bool keepConfig);
00111 
00116   static void ResetConfig();
00117 
00121   static void NewEvent(CompanyID company, ScriptEvent *event);
00122 
00126   static void BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company = MAX_COMPANIES);
00127 
00131   static void Save(CompanyID company);
00132 
00136   static void Load(CompanyID company, int version);
00137 
00141   static int GetStartNextTime();
00142 
00144   static char *GetConsoleList(char *p, const char *last, bool newest_only = false);
00146   static char *GetConsoleLibraryList(char *p, const char *last);
00148   static const ScriptInfoList *GetInfoList();
00150   static const ScriptInfoList *GetUniqueInfoList();
00152   static class AIInfo *FindInfo(const char *name, int version, bool force_exact_match);
00154   static class AILibrary *FindLibrary(const char *library, int version);
00155 
00160   static void Rescan();
00161 
00163   static AIScannerInfo *GetScannerInfo();
00165   static AIScannerLibrary *GetScannerLibrary();
00166 
00167 #if defined(ENABLE_NETWORK)
00168 
00169   static bool HasAI(const struct ContentInfo *ci, bool md5sum);
00170   static bool HasAILibrary(const ContentInfo *ci, bool md5sum);
00171 #endif
00172 private:
00173   static uint frame_counter;                      
00174   static class AIScannerInfo *scanner_info;       
00175   static class AIScannerLibrary *scanner_library; 
00176 };
00177 
00178 #endif /* AI_HPP */