From cc12942d70fa2a672c59e848c196c6647f8f1129 Mon Sep 17 00:00:00 2001 From: truebrain Date: Thu, 1 Dec 2011 12:03:34 +0000 Subject: (svn r23384) -Remove: no longer allow a binary to be without AI support; the parts some compilers failed at, are integrated in other parts of the code now too --- src/ai/ai.hpp | 24 ----------- src/ai/ai_gui.hpp | 13 ------ src/ai/ai_info.hpp | 3 -- src/company_cmd.cpp | 4 -- src/console_cmds.cpp | 4 -- src/crashlog.cpp | 2 - src/lang/english.txt | 3 -- src/network/network_command.cpp | 4 -- src/network/network_content.cpp | 2 - src/openttd.cpp | 4 -- src/saveload/ai_sl.cpp | 88 +++-------------------------------------- src/screenshot.cpp | 2 - src/settings.cpp | 6 --- src/settings_gui.cpp | 2 - 14 files changed, 5 insertions(+), 156 deletions(-) (limited to 'src') diff --git a/src/ai/ai.hpp b/src/ai/ai.hpp index d8647be0c..f0a5eb67b 100644 --- a/src/ai/ai.hpp +++ b/src/ai/ai.hpp @@ -12,7 +12,6 @@ #ifndef AI_HPP #define AI_HPP -#ifdef ENABLE_AI #include "../script/api/script_event_types.hpp" #include "../date_type.h" #include "../core/string_compare_type.hpp" @@ -153,27 +152,4 @@ private: static class AIScannerLibrary *scanner_library; ///< ScriptScanner instance that is used to find AI Libraries }; -#else /* ENABLE_AI */ - -#include "../company_type.h" - -#define NewEvent(cid, event) nop() -#define BroadcastNewEvent(...) nop() - -class AI { -public: - static void StartNew(CompanyID company, bool rerandomise_ai = true) {} - static void Stop(CompanyID company) {} - static void Initialize() {} - static void Uninitialize(bool keepConfig) {} - static void KillAll() {} - static void GameLoop() {} - static bool HasAI(const struct ContentInfo *ci, bool md5sum) { return false; } - static bool HasAILibrary(const struct ContentInfo *ci, bool md5sum) { return false; } - static void Rescan() {} - static char *GetConsoleList(char *p, const char *last, bool newest_only = false) { return p; } - static void nop() { } -}; - -#endif /* ENABLE_AI */ #endif /* AI_HPP */ diff --git a/src/ai/ai_gui.hpp b/src/ai/ai_gui.hpp index 3fe822879..ac8cb4a01 100644 --- a/src/ai/ai_gui.hpp +++ b/src/ai/ai_gui.hpp @@ -14,22 +14,9 @@ #include "../company_type.h" -#ifdef ENABLE_AI void ShowAIDebugWindow(CompanyID show_company = INVALID_COMPANY); void ShowAIConfigWindow(); void ShowAIDebugWindowIfAIError(); void InitializeAIGui(); -#else -#include "../gui.h" -#include "table/strings.h" - -static inline void ShowAIConfigWindow() -{ - ShowErrorMessage(STR_ERROR_NO_AI, STR_ERROR_NO_AI_SUB, WL_INFO); -} -static inline void ShowAIDebugWindow(CompanyID show_company = INVALID_COMPANY) {ShowAIConfigWindow();} -static inline void ShowAIDebugWindowIfAIError() {} -static inline void InitializeAIGui() {} -#endif /* ENABLE_AI */ #endif /* AI_GUI_HPP */ diff --git a/src/ai/ai_info.hpp b/src/ai/ai_info.hpp index 924ddd2e0..c582e70c2 100644 --- a/src/ai/ai_info.hpp +++ b/src/ai/ai_info.hpp @@ -12,8 +12,6 @@ #ifndef AI_INFO_HPP #define AI_INFO_HPP -#ifdef ENABLE_AI - #include "../script/script_info.hpp" #include "../script/script_config.hpp" @@ -84,5 +82,4 @@ private: const char *category; ///< The category this library is in. }; -#endif /* ENABLE_AI */ #endif /* AI_INFO_HPP */ diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 2ebd99d66..692431e6e 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -572,7 +572,6 @@ void StartupCompanies() _next_competitor_start = 0; } -#ifdef ENABLE_AI /** Start a new competitor company if possible. */ static void MaybeStartNewCompany() { @@ -594,7 +593,6 @@ static void MaybeStartNewCompany() DoCommandP(0, 1 | INVALID_COMPANY << 16, 0, CMD_COMPANY_CTRL); } } -#endif /* ENABLE_AI */ /** Initialize the pool of companies. */ void InitializeCompanies() @@ -693,7 +691,6 @@ void OnTick_Companies() if (c->bankrupt_asked != 0) HandleBankruptcyTakeover(c); } -#ifdef ENABLE_AI if (_next_competitor_start == 0) { _next_competitor_start = AI::GetStartNextTime() * DAY_TICKS; } @@ -701,7 +698,6 @@ void OnTick_Companies() if (AI::CanStartNew() && _game_mode != GM_MENU && --_next_competitor_start == 0) { MaybeStartNewCompany(); } -#endif /* ENABLE_AI */ _cur_company_tick_index = (_cur_company_tick_index + 1) % MAX_COMPANIES; } diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 4c6a51ba8..6a6404cbc 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -1069,7 +1069,6 @@ DEF_CONSOLE_CMD(ConRestart) return true; } -#ifdef ENABLE_AI /** * Print a text buffer line by line to the console. Lines are seperated by '\n'. * @param buf The buffer to print. @@ -1255,7 +1254,6 @@ DEF_CONSOLE_CMD(ConRescanAI) return true; } -#endif /* ENABLE_AI */ DEF_CONSOLE_CMD(ConRescanNewGRF) { @@ -1892,14 +1890,12 @@ void IConsoleStdLibRegister() IConsoleAliasRegister("list_patches", "list_settings %+"); IConsoleAliasRegister("developer", "setting developer %+"); -#ifdef ENABLE_AI IConsoleCmdRegister("list_ai_libs", ConListAILibs); IConsoleCmdRegister("list_ai", ConListAI); IConsoleCmdRegister("reload_ai", ConReloadAI); IConsoleCmdRegister("rescan_ai", ConRescanAI); IConsoleCmdRegister("start_ai", ConStartAI); IConsoleCmdRegister("stop_ai", ConStopAI); -#endif /* ENABLE_AI */ /* networking functions */ #ifdef ENABLE_NETWORK diff --git a/src/crashlog.cpp b/src/crashlog.cpp index bda4d674f..c5719ad47 100644 --- a/src/crashlog.cpp +++ b/src/crashlog.cpp @@ -151,9 +151,7 @@ char *CrashLog::LogConfiguration(char *buffer, const char *last) const if (c->ai_info == NULL) { buffer += seprintf(buffer, last, " %2i: Human\n", (int)c->index); } else { -#ifdef ENABLE_AI buffer += seprintf(buffer, last, " %2i: %s (v%d)\n", (int)c->index, c->ai_info->GetName(), c->ai_info->GetVersion()); -#endif /* ENABLE_AI */ } } buffer += seprintf(buffer, last, "\n"); diff --git a/src/lang/english.txt b/src/lang/english.txt index 3e33db7ee..28699feeb 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -3412,9 +3412,6 @@ STR_AI_DEBUG_CONTINUE :{BLACK}Continue STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Unpause and continue the AI STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}View debug output of this AI -STR_ERROR_NO_AI :{WHITE}OpenTTD is built without AI support... -STR_ERROR_NO_AI_SUB :{WHITE}... no AIs are available! - STR_ERROR_AI_NO_AI_FOUND :No suitable AI found to load.{}This AI is a dummy AI and won't do anything.{}You can download several AIs via the 'Online Content' system STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}One of the running AIs crashed. Please report this to the AI author with a screenshot of the AI Debug Window STR_ERROR_AI_DEBUG_SERVER_ONLY :{YELLOW}AI Debug window is only available for the server diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp index 0e37eeff4..070e810d8 100644 --- a/src/network/network_command.cpp +++ b/src/network/network_command.cpp @@ -39,11 +39,7 @@ static CommandCallback * const _callback_table[] = { /* 0x0F */ CcPlaySound1E, /* 0x10 */ CcStation, /* 0x11 */ CcTerraform, -#ifdef ENABLE_AI /* 0x12 */ CcAI, -#else - /* 0x12 */ NULL, -#endif /* ENABLE_AI */ /* 0x13 */ CcCloneVehicle, /* 0x14 */ CcGiveMoney, /* 0x15 */ CcCreateGroup, diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index de7087c1e..98c9f171b 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -180,10 +180,8 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentType type) this->RequestContentList(CONTENT_TYPE_BASE_SOUNDS); this->RequestContentList(CONTENT_TYPE_SCENARIO); this->RequestContentList(CONTENT_TYPE_HEIGHTMAP); -#ifdef ENABLE_AI this->RequestContentList(CONTENT_TYPE_AI); this->RequestContentList(CONTENT_TYPE_AI_LIBRARY); -#endif /* ENABLE_AI */ this->RequestContentList(CONTENT_TYPE_NEWGRF); return; } diff --git a/src/openttd.cpp b/src/openttd.cpp index a0c16f910..d20a2c33a 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -342,27 +342,23 @@ static void LoadIntroGame(bool load_newgrfs = true) void MakeNewgameSettingsLive() { -#ifdef ENABLE_AI for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) { if (_settings_game.ai_config[c] != NULL) { delete _settings_game.ai_config[c]; } } -#endif /* ENABLE_AI */ /* Copy newgame settings to active settings. * Also initialise old settings needed for savegame conversion. */ _settings_game = _settings_newgame; _old_vds = _settings_client.company.vehicle; -#ifdef ENABLE_AI for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) { _settings_game.ai_config[c] = NULL; if (_settings_newgame.ai_config[c] != NULL) { _settings_game.ai_config[c] = new AIConfig(_settings_newgame.ai_config[c]); } } -#endif /* ENABLE_AI */ } /** Callback structure of statements to be executed after the NewGRF scan. */ diff --git a/src/saveload/ai_sl.cpp b/src/saveload/ai_sl.cpp index cfb90c34c..31828be24 100644 --- a/src/saveload/ai_sl.cpp +++ b/src/saveload/ai_sl.cpp @@ -15,6 +15,11 @@ #include "saveload.h" #include "../string_func.h" +#include "../ai/ai.hpp" +#include "../ai/ai_config.hpp" +#include "../network/network.h" +#include "../ai/ai_instance.hpp" + static char _ai_saveload_name[64]; static int _ai_saveload_version; static char _ai_saveload_settings[1024]; @@ -28,12 +33,6 @@ static const SaveLoad _ai_company[] = { SLE_END() }; -#ifdef ENABLE_AI -#include "../ai/ai.hpp" -#include "../ai/ai_config.hpp" -#include "../network/network.h" -#include "../ai/ai_instance.hpp" - static void SaveReal_AIPL(int *index_ptr) { CompanyID index = (CompanyID)*index_ptr; @@ -125,80 +124,3 @@ static void Save_AIPL() extern const ChunkHandler _ai_chunk_handlers[] = { { 'AIPL', Save_AIPL, Load_AIPL, NULL, NULL, CH_ARRAY | CH_LAST}, }; -#else - -/** The type of the data that follows in the savegame. */ -enum SQSaveLoadType { - SQSL_INT = 0x00, ///< The following data is an integer. - SQSL_STRING = 0x01, ///< The following data is an string. - SQSL_ARRAY = 0x02, ///< The following data is an array. - SQSL_TABLE = 0x03, ///< The following data is an table. - SQSL_BOOL = 0x04, ///< The following data is a boolean. - SQSL_NULL = 0x05, ///< A null variable. - SQSL_ARRAY_TABLE_END = 0xFF, ///< Marks the end of an array or table, no data follows. -}; - -static byte _ai_sl_byte; - -static const SaveLoad _ai_byte[] = { - SLEG_VAR(_ai_sl_byte, SLE_UINT8), - SLE_END() -}; - -static bool LoadObjects() -{ - SlObject(NULL, _ai_byte); - switch (_ai_sl_byte) { - case SQSL_INT: { - int value; - SlArray(&value, 1, SLE_INT32); - return true; - } - - case SQSL_STRING: { - SlObject(NULL, _ai_byte); - static char buf[256]; - SlArray(buf, _ai_sl_byte, SLE_CHAR); - return true; - } - - case SQSL_ARRAY: - while (LoadObjects()) { } - return true; - - case SQSL_TABLE: - while (LoadObjects()) { LoadObjects(); } - return true; - - case SQSL_BOOL: - SlObject(NULL, _ai_byte); - return true; - - case SQSL_NULL: - return true; - - case SQSL_ARRAY_TABLE_END: - return false; - - default: SlErrorCorrupt("Invalid AI data type"); - } -} - -static void Load_AIPL() -{ - CompanyID index; - while ((index = (CompanyID)SlIterateArray()) != (CompanyID)-1) { - SlObject(NULL, _ai_company); - - if (!Company::IsValidAiID(index)) continue; - SlObject(NULL, _ai_byte); - /* Check if there was anything saved at all. */ - if (_ai_sl_byte == 0) continue; - LoadObjects(); - } -} - -extern const ChunkHandler _ai_chunk_handlers[] = { - { 'AIPL', NULL, Load_AIPL, NULL, NULL, CH_ARRAY | CH_LAST}, -}; -#endif /* ENABLE_AI */ diff --git a/src/screenshot.cpp b/src/screenshot.cpp index 474c321ee..d5d63d113 100644 --- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -327,9 +327,7 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user if (c->ai_info == NULL) { p += seprintf(p, lastof(buf), "%2i: Human\n", (int)c->index); } else { -#ifdef ENABLE_AI p += seprintf(p, lastof(buf), "%2i: %s (v%d)\n", (int)c->index, c->ai_info->GetName(), c->ai_info->GetVersion()); -#endif /* ENABLE_AI */ } } text[1].key = const_cast("Description"); diff --git a/src/settings.cpp b/src/settings.cpp index ddbf7f583..4082b8dbd 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1044,9 +1044,7 @@ static bool DifficultyNoiseChange(int32 i) static bool MaxNoAIsChange(int32 i) { if (GetGameSettings().difficulty.max_no_competitors != 0 && -#ifdef ENABLE_AI AI::GetInfoList()->size() == 0 && -#endif /* ENABLE_AI */ (!_networking || _network_server)) { ShowErrorMessage(STR_WARNING_NO_SUITABLE_AI, INVALID_STRING_ID, WL_CRITICAL); } @@ -1314,7 +1312,6 @@ static void NewsDisplayLoadConfig(IniFile *ini, const char *grpname) static void AILoadConfig(IniFile *ini, const char *grpname) { -#ifdef ENABLE_AI IniGroup *group = ini->GetGroup(grpname); IniItem *item; @@ -1339,7 +1336,6 @@ static void AILoadConfig(IniFile *ini, const char *grpname) } if (item->value != NULL) config->StringToSettings(item->value); } -#endif /* ENABLE_AI */ } /** @@ -1436,7 +1432,6 @@ static void NewsDisplaySaveConfig(IniFile *ini, const char *grpname) static void AISaveConfig(IniFile *ini, const char *grpname) { -#ifdef ENABLE_AI IniGroup *group = ini->GetGroup(grpname); if (group == NULL) return; @@ -1457,7 +1452,6 @@ static void AISaveConfig(IniFile *ini, const char *grpname) IniItem *item = new IniItem(group, name, strlen(name)); item->SetValue(value); } -#endif /* ENABLE_AI */ } /** diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 019fd3490..47225e2a2 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -738,9 +738,7 @@ public: this->InvalidateData(); if (widget / 3 == 0 && -#ifdef ENABLE_AI AI::GetInfoList()->size() == 0 && -#endif /* ENABLE_AI */ this->opt_mod_temp.difficulty.max_no_competitors != 0) { ShowErrorMessage(STR_WARNING_NO_SUITABLE_AI, INVALID_STRING_ID, WL_CRITICAL); } -- cgit v1.2.3-54-g00ecf