ai.hpp
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);
00130 static const AIInfoList *GetInfoList();
00132 static const AIInfoList *GetUniqueInfoList();
00134 static AIInfo *FindInfo(const char *name, int version, bool force_exact_match);
00136 static bool ImportLibrary(const char *library, const char *class_name, int version, HSQUIRRELVM vm);
00137
00142 static void Rescan();
00143 #if defined(ENABLE_NETWORK)
00144
00145 static bool HasAI(const struct ContentInfo *ci, bool md5sum);
00146 #endif
00147 private:
00148 static uint frame_counter;
00149 static class AIScanner *ai_scanner;
00150 };
00151
00152 #else
00153
00154 #include "../company_type.h"
00155
00156 #define NewEvent(cid, event) nop()
00157 #define BroadcastNewEvent(...) nop()
00158
00159 class AI {
00160 public:
00161 static void StartNew(CompanyID company, bool rerandomise_ai = true) {}
00162 static void Stop(CompanyID company) {}
00163 static void Initialize() {}
00164 static void Uninitialize(bool keepConfig) {}
00165 static void KillAll() {}
00166 static void GameLoop() {}
00167 static bool HasAI(const struct ContentInfo *ci, bool md5sum) { return false; }
00168 static void Rescan() {}
00169 static char *GetConsoleList(char *p, const char *last) { return p; }
00170 static void nop() { }
00171 };
00172
00173 #endif
00174 #endif