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 #include "api/ai_event_types.hpp"
00016 #include "../date_type.h"
00017 #include "../core/string_compare_type.hpp"
00018 #include <map>
00019
00020 typedef std::map<const char *, class AIInfo *, StringCompare> AIInfoList;
00021
00022
00023 void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2);
00024
00025 class AI {
00026 public:
00030 enum StartNext {
00031 START_NEXT_EASY = DAYS_IN_YEAR * 2,
00032 START_NEXT_MEDIUM = DAYS_IN_YEAR,
00033 START_NEXT_HARD = DAYS_IN_YEAR / 2,
00034 START_NEXT_MIN = 1,
00035 START_NEXT_MAX = 3600,
00036 START_NEXT_DEVIATION = 60,
00037 };
00038
00043 static bool CanStartNew();
00044
00049 static void StartNew(CompanyID company);
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);
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 #endif