ai.hpp

Go to the documentation of this file.
00001 /* $Id: ai.hpp 23384 2011-12-01 12:03:34Z truebrain $ */
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 "../date_type.h"
00017 #include "../core/string_compare_type.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 Suspend(CompanyID company);
00078 
00082   static void KillAll();
00083 
00087   static void Initialize();
00088 
00093   static void Uninitialize(bool keepConfig);
00094 
00099   static void ResetConfig();
00100 
00104   static void NewEvent(CompanyID company, ScriptEvent *event);
00105 
00109   static void BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company = MAX_COMPANIES);
00110 
00114   static void Save(CompanyID company);
00115 
00119   static void Load(CompanyID company, int version);
00120 
00124   static int GetStartNextTime();
00125 
00127   static char *GetConsoleList(char *p, const char *last, bool newest_only = false);
00129   static char *GetConsoleLibraryList(char *p, const char *last);
00131   static const ScriptInfoList *GetInfoList();
00133   static const ScriptInfoList *GetUniqueInfoList();
00135   static class AIInfo *FindInfo(const char *name, int version, bool force_exact_match);
00137   static class AILibrary *FindLibrary(const char *library, int version);
00138 
00143   static void Rescan();
00144 #if defined(ENABLE_NETWORK)
00145 
00146   static bool HasAI(const struct ContentInfo *ci, bool md5sum);
00147   static bool HasAILibrary(const ContentInfo *ci, bool md5sum);
00148 #endif
00149 private:
00150   static uint frame_counter;                      
00151   static class AIScannerInfo *scanner_info;       
00152   static class AIScannerLibrary *scanner_library; 
00153 };
00154 
00155 #endif /* AI_HPP */