Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef AI_HPP
00013 #define AI_HPP
00014
00015 #ifdef ENABLE_AI
00016 #include "api/ai_event_types.hpp"
00017 #include "../date_type.h"
00018 #include "../core/string_compare_type.hpp"
00019 #include <map>
00020
00022 typedef std::map<const char *, class AIInfo *, StringCompare> AIInfoList;
00023
00027 class AI {
00028 public:
00032 enum StartNext {
00033 START_NEXT_EASY = DAYS_IN_YEAR * 2,
00034 START_NEXT_MEDIUM = DAYS_IN_YEAR,
00035 START_NEXT_HARD = DAYS_IN_YEAR / 2,
00036 START_NEXT_MIN = 1,
00037 START_NEXT_MAX = 3600,
00038 START_NEXT_DEVIATION = 60,
00039 };
00040
00045 static bool CanStartNew();
00046
00052 static void StartNew(CompanyID company, bool rerandomise_ai = true);
00053
00057 static void GameLoop();
00058
00062 static uint GetTick();
00063
00069 static void Stop(CompanyID company);
00070
00078 static void Suspend(CompanyID company);
00079
00083 static void KillAll();
00084
00088 static void Initialize();
00089
00094 static void Uninitialize(bool keepConfig);
00095
00100 static void ResetConfig();
00101
00105 static void NewEvent(CompanyID company, AIEvent *event);
00106
00110 static void BroadcastNewEvent(AIEvent *event, CompanyID skip_company = MAX_COMPANIES);
00111
00115 static void Save(CompanyID company);
00116
00120 static void Load(CompanyID company, int version);
00121
00125 static int GetStartNextTime();
00126
00128 static char *GetConsoleList(char *p, const char *last, bool newest_only = false);
00130 static char *GetConsoleLibraryList(char *p, const char *last);
00132 static const AIInfoList *GetInfoList();
00134 static const AIInfoList *GetUniqueInfoList();
00136 static AIInfo *FindInfo(const char *name, int version, bool force_exact_match);
00138 static bool ImportLibrary(const char *library, const char *class_name, int version, HSQUIRRELVM vm);
00139
00144 static void Rescan();
00145 #if defined(ENABLE_NETWORK)
00146
00147 static bool HasAI(const struct ContentInfo *ci, bool md5sum);
00148 #endif
00149 private:
00150 static uint frame_counter;
00151 static class AIScanner *ai_scanner;
00152 };
00153
00154 #else
00155
00156 #include "../company_type.h"
00157
00158 #define NewEvent(cid, event) nop()
00159 #define BroadcastNewEvent(...) nop()
00160
00161 class AI {
00162 public:
00163 static void StartNew(CompanyID company, bool rerandomise_ai = true) {}
00164 static void Stop(CompanyID company) {}
00165 static void Initialize() {}
00166 static void Uninitialize(bool keepConfig) {}
00167 static void KillAll() {}
00168 static void GameLoop() {}
00169 static bool HasAI(const struct ContentInfo *ci, bool md5sum) { return false; }
00170 static void Rescan() {}
00171 static char *GetConsoleList(char *p, const char *last, bool newest_only = false) { return p; }
00172 static void nop() { }
00173 };
00174
00175 #endif
00176 #endif