# ai.hpp

Go to the documentation of this file.

    00001 /* $Id: ai.hpp 18781 2010-01-11 18:46:09Z rubidium $ */
    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 "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 class AI {
    00024 public:
    00028   enum StartNext {
    00029     START_NEXT_EASY   = DAYS_IN_YEAR * 2,
    00030     START_NEXT_MEDIUM = DAYS_IN_YEAR,
    00031     START_NEXT_HARD   = DAYS_IN_YEAR / 2,
    00032     START_NEXT_MIN    = 1,
    00033     START_NEXT_MAX    = 3600,
    00034     START_NEXT_DEVIATION = 60,
    00035   };
    00036
    00041   static bool CanStartNew();
    00042
    00048   static void StartNew(CompanyID company, bool rerandomise_ai = true);
    00049
    00053   static void GameLoop();
    00054
    00058   static uint GetTick();
    00059
    00065   static void Stop(CompanyID company);
    00066
    00070   static void KillAll();
    00071
    00075   static void Initialize();
    00076
    00081   static void Uninitialize(bool keepConfig);
    00082
    00087   static void ResetConfig();
    00088
    00092   static void NewEvent(CompanyID company, AIEvent *event);
    00093
    00097   static void BroadcastNewEvent(AIEvent *event, CompanyID skip_company = MAX_COMPANIES);
    00098
    00102   static void Save(CompanyID company);
    00103
    00107   static void Load(CompanyID company, int version);
    00108
    00112   static int GetStartNextTime();
    00113
    00114   static char *GetConsoleList(char *p, const char *last);
    00115   static const AIInfoList *GetInfoList();
    00116   static const AIInfoList *GetUniqueInfoList();
    00117   static AIInfo *FindInfo(const char *name, int version);
    00118   static bool ImportLibrary(const char *library, const char *class_name, int version, HSQUIRRELVM vm);
    00119   static void Rescan();
    00120 #if defined(ENABLE_NETWORK)
    00121   static bool HasAI(const struct ContentInfo *ci, bool md5sum);
    00122 #endif
    00123 private:
    00124   static uint frame_counter;
    00125   static class AIScanner *ai_scanner;
    00126 };
    00127
    00128 #endif /* AI_HPP */