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
00021 typedef std::map<const char *, class AIInfo *, StringCompare> AIInfoList;
00022
00023
00024 class AI {
00025 public:
00029 enum StartNext {
00030 START_NEXT_EASY = DAYS_IN_YEAR * 2,
00031 START_NEXT_MEDIUM = DAYS_IN_YEAR,
00032 START_NEXT_HARD = DAYS_IN_YEAR / 2,
00033 START_NEXT_MIN = 1,
00034 START_NEXT_MAX = 3600,
00035 START_NEXT_DEVIATION = 60,
00036 };
00037
00042 static bool CanStartNew();
00043
00049 static void StartNew(CompanyID company, bool rerandomise_ai = true);
00050
00054 static void GameLoop();
00055
00059 static uint GetTick();
00060
00066 static void Stop(CompanyID company);
00067
00071 static void KillAll();
00072
00076 static void Initialize();
00077
00082 static void Uninitialize(bool keepConfig);
00083
00088 static void ResetConfig();
00089
00093 static void NewEvent(CompanyID company, AIEvent *event);
00094
00098 static void BroadcastNewEvent(AIEvent *event, CompanyID skip_company = MAX_COMPANIES);
00099
00103 static void Save(CompanyID company);
00104
00108 static void Load(CompanyID company, int version);
00109
00113 static int GetStartNextTime();
00114
00115 static char *GetConsoleList(char *p, const char *last);
00116 static const AIInfoList *GetInfoList();
00117 static const AIInfoList *GetUniqueInfoList();
00118 static AIInfo *FindInfo(const char *name, int version, bool force_exact_match);
00119 static bool ImportLibrary(const char *library, const char *class_name, int version, HSQUIRRELVM vm);
00120 static void Rescan();
00121 #if defined(ENABLE_NETWORK)
00122 static bool HasAI(const struct ContentInfo *ci, bool md5sum);
00123 #endif
00124 private:
00125 static uint frame_counter;
00126 static class AIScanner *ai_scanner;
00127 };
00128
00129 #else
00130
00131 #include "../company_type.h"
00132
00133 #define NewEvent(cid, event) nop()
00134 #define BroadcastNewEvent(...) nop()
00135
00136 class AI {
00137 public:
00138 static void StartNew(CompanyID company, bool rerandomise_ai = true) {}
00139 static void Stop(CompanyID company) {}
00140 static void Initialize() {}
00141 static void Uninitialize(bool keepConfig) {}
00142 static void KillAll() {}
00143 static void GameLoop() {}
00144 static bool HasAI(const struct ContentInfo *ci, bool md5sum) { return false; }
00145 static void Rescan() {}
00146 static char *GetConsoleList(char *p, const char *last) { return p; }
00147 static void nop() { }
00148 };
00149
00150 #endif
00151 #endif