diff options
author | rubidium <rubidium@openttd.org> | 2010-02-10 16:24:05 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-02-10 16:24:05 +0000 |
commit | 21bd2722cd89995370523385c213da32c8d47100 (patch) | |
tree | e7f3bb43657b1f8a59f89899dfc582d480bedad0 | |
parent | 78ce2858fc2704a5aafbc0b76cdb636338122f63 (diff) | |
download | openttd-21bd2722cd89995370523385c213da32c8d47100.tar.xz |
(svn r19081) -Codechange: make it possible to disable compilation of the AI+Squirrel
-rw-r--r-- | Doxyfile | 2 | ||||
-rw-r--r-- | Makefile.src.in | 5 | ||||
-rw-r--r-- | config.lib | 26 | ||||
-rwxr-xr-x | configure | 1 | ||||
-rwxr-xr-x | projects/generate | 2 | ||||
-rw-r--r-- | source.list | 2 | ||||
-rw-r--r-- | src/ai/ai.hpp | 23 | ||||
-rw-r--r-- | src/ai/ai_config.hpp | 2 | ||||
-rw-r--r-- | src/ai/ai_gui.hpp | 10 | ||||
-rw-r--r-- | src/ai/ai_info.hpp | 3 | ||||
-rw-r--r-- | src/aircraft_cmd.cpp | 5 | ||||
-rw-r--r-- | src/company_cmd.cpp | 4 | ||||
-rw-r--r-- | src/console_cmds.cpp | 15 | ||||
-rw-r--r-- | src/crashlog.cpp | 2 | ||||
-rw-r--r-- | src/lang/english.txt | 3 | ||||
-rw-r--r-- | src/network/network_command.cpp | 4 | ||||
-rw-r--r-- | src/network/network_content.cpp | 4 | ||||
-rw-r--r-- | src/openttd.cpp | 4 | ||||
-rw-r--r-- | src/saveload/ai_sl.cpp | 87 | ||||
-rw-r--r-- | src/settings.cpp | 9 | ||||
-rw-r--r-- | src/settings_gui.cpp | 7 |
21 files changed, 190 insertions, 30 deletions
@@ -196,7 +196,7 @@ EXPAND_ONLY_PREDEF = YES SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = -PREDEFINED = +PREDEFINED = ENABLE_NETWORK ENABLE_AI EXPAND_AS_DEFINED = DEF_COMMAND SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- diff --git a/Makefile.src.in b/Makefile.src.in index 21317ebce..6c5702e49 100644 --- a/Makefile.src.in +++ b/Makefile.src.in @@ -58,7 +58,10 @@ RES := $(shell mkdir -p $(BIN_DIR) $(sort $(dir $(OBJS)))) # Make sure endian_target.h is reasable as if it was in the src/ dir CFLAGS += -I $(SRC_OBJS_DIR) -I $(LANG_OBJS_DIR) -CFLAGS_MAKEDEP += -I $(SRC_OBJS_DIR) -I $(LANG_OBJS_DIR) -I $(SCRIPT_SRC_DIR) +CFLAGS_MAKEDEP += -I $(SRC_OBJS_DIR) -I $(LANG_OBJS_DIR) +ifdef SCRIPT_SRC_DIR + CFLAGS_MAKEDEP += -I $(SCRIPT_SRC_DIR) +endif ENDIAN_TARGETS := endian_target.h $(ENDIAN_CHECK) diff --git a/config.lib b/config.lib index 348d4bae9..86ac07d97 100644 --- a/config.lib +++ b/config.lib @@ -51,6 +51,7 @@ set_default() { enable_lto="0" enable_dedicated="0" enable_network="1" + enable_ai="1" enable_static="1" enable_translator="0" enable_unicode="1" @@ -122,6 +123,7 @@ set_default() { enable_lto enable_dedicated enable_network + enable_ai enable_static enable_translator enable_unicode @@ -277,6 +279,9 @@ detect_params() { --enable-network) enable_network="2";; --enable-network=*) enable_network="$optarg";; --disable-network) enable_network="0";; + --enable-ai) enable_ai="2";; + --enable-ai=*) enable_ai="$optarg";; + --disable-ai) enable_ai="0";; --disable-static) enable_static="0";; --enable-static) enable_static="2";; --enable-static=*) enable_static="$optarg";; @@ -713,6 +718,14 @@ check_params() { log 1 "checking network... disabled" fi + if [ "$enable_ai" != "0" ]; then + log 1 "checking ai... found" + SCRIPT_SRC_DIR="$ROOT_DIR/src/3rdparty/squirrel/include" + else + log 1 "checking ai... disabled" + SCRIPT_SRC_DIR="" + fi + if [ "$enable_translator" != "0" ]; then log 1 "checking translator... debug" # -t shows TODO items, normally they are muted @@ -728,15 +741,6 @@ check_params() { log 1 "checking assert... disabled" fi - SCRIPT_SRC_DIR="$ROOT_DIR/src/3rdparty/squirrel/include" - if [ ! -d "$SCRIPT_SRC_DIR" ]; then - log 1 "checking 3rdparty... NOT FOUND" - log 1 "ERROR: please make sure you have src/3rdparty/squirrel" - log 1 "ERROR: you can find the source at svn://svn.openttd.org/3rdparty/squirrel" - exit 1 - fi - log 1 "checking 3rdparty... found" - pre_detect_with_zlib=$with_zlib detect_zlib @@ -1429,7 +1433,9 @@ make_cflags_and_ldflags() { if [ "$cpu_type" = "64" ] && [ "$enable_universal" = "0" ]; then CFLAGS="$CFLAGS -D_SQ64" fi - CFLAGS="$CFLAGS -I$SCRIPT_SRC_DIR" + if [ "$enable_ai" != "0" ]; then + CFLAGS="$CFLAGS -I$SCRIPT_SRC_DIR -DENABLE_AI" + fi if [ -n "$png_config" ]; then CFLAGS="$CFLAGS -DWITH_PNG" @@ -113,6 +113,7 @@ AWKCOMMAND=' if ($0 == "OS2" && "'$os'" != "OS2") { next; } if ($0 == "PSP" && "'$os'" != "PSP") { next; } if ($0 == "DEDICATED" && "'$enable_dedicated'" != "1") { next; } + if ($0 == "AI" && "'$enable_ai'" == "0") { next; } if ($0 == "COCOA" && "'$with_cocoa'" == "0") { next; } if ($0 == "DOS" && "'$os'" != "DOS") { next; } if ($0 == "BEOS" && "'$os'" != "BEOS" && diff --git a/projects/generate b/projects/generate index 9ef2e0a32..0a3055863 100755 --- a/projects/generate +++ b/projects/generate @@ -40,6 +40,7 @@ sdl_config="1" png_config="1" os="MSVC" enable_dedicated="0" +enable_ai="1" with_cocoa="0" enable_directmusic="1" with_threads="1" @@ -94,6 +95,7 @@ load_main_data() { if ($0 == "PSP" && "'$os'" != "PSP") { next; } if ($0 == "DOS" && "'$os'" != "DOS") { next; } if ($0 == "DEDICATED" && "'$enable_dedicated'" != "1") { next; } + if ($0 == "AI" && "'$enable_ai'" == "0") { next; } if ($0 == "COCOA" && "'$with_cocoa'" == "0") { next; } if ($0 == "BEOS" && "'$os'" != "BEOS") { next; } if ($0 == "WIN32" && "'$os'" != "MINGW" && diff --git a/source.list b/source.list index 3b44baf28..23c61bd3d 100644 --- a/source.list +++ b/source.list @@ -517,6 +517,7 @@ table/water_land.h 3rdparty/md5/md5.cpp 3rdparty/md5/md5.h +#if AI # Script script/script_info.cpp script/script_info.hpp @@ -697,6 +698,7 @@ ai/api/ai_vehicle.cpp ai/api/ai_vehiclelist.cpp ai/api/ai_waypoint.cpp ai/api/ai_waypointlist.cpp +#end # Blitters #if DEDICATED diff --git a/src/ai/ai.hpp b/src/ai/ai.hpp index 65ad7705f..495a030a1 100644 --- a/src/ai/ai.hpp +++ b/src/ai/ai.hpp @@ -12,6 +12,7 @@ #ifndef AI_HPP #define AI_HPP +#ifdef ENABLE_AI #include "api/ai_event_types.hpp" #include "../date_type.h" #include "../core/string_compare_type.hpp" @@ -125,4 +126,26 @@ private: static class AIScanner *ai_scanner; }; +#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 void Rescan() {} + static char *GetConsoleList(char *p, const char *last) { return p; } + static void nop() { } +}; + +#endif /* ENABLE_AI */ #endif /* AI_HPP */ diff --git a/src/ai/ai_config.hpp b/src/ai/ai_config.hpp index 3eb9d78d2..05afda9d6 100644 --- a/src/ai/ai_config.hpp +++ b/src/ai/ai_config.hpp @@ -11,6 +11,7 @@ #ifndef AI_CONFIG_HPP #define AI_CONFIG_HPP +#ifdef ENABLE_AI #include <map> #include "ai_info.hpp" @@ -130,4 +131,5 @@ private: bool is_random_ai; }; +#endif /* ENABLE_AI */ #endif /* AI_CONFIG_HPP */ diff --git a/src/ai/ai_gui.hpp b/src/ai/ai_gui.hpp index 56d775a16..254e2955c 100644 --- a/src/ai/ai_gui.hpp +++ b/src/ai/ai_gui.hpp @@ -14,7 +14,17 @@ #include "../company_type.h" +#ifdef ENABLE_AI void ShowAIDebugWindow(CompanyID show_company = INVALID_COMPANY); void ShowAIConfigWindow(); +#else +#include "table/strings.h" + +static inline void ShowAIConfigWindow() +{ + ShowErrorMessage(STR_ERROR_NO_AI, STR_ERROR_NO_AI_SUB, 0, 0); +} +static inline void ShowAIDebugWindow(CompanyID show_company = INVALID_COMPANY) {ShowAIConfigWindow();} +#endif /* ENABLE_AI */ #endif /* AI_GUI_HPP */ diff --git a/src/ai/ai_info.hpp b/src/ai/ai_info.hpp index e3b116b3e..9ef6e3df1 100644 --- a/src/ai/ai_info.hpp +++ b/src/ai/ai_info.hpp @@ -12,6 +12,8 @@ #ifndef AI_INFO #define AI_INFO +#ifdef ENABLE_AI + #include <list> #include "../core/smallmap_type.hpp" #include "../script/script_info.hpp" @@ -141,4 +143,5 @@ private: const char *category; }; +#endif /* ENABLE_AI */ #endif /* AI_INFO */ diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 64bfb04d6..bea8f1f72 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -1269,17 +1269,14 @@ static void CrashAirplane(Aircraft *v) v->Next()->cargo.Truncate(0); const Station *st = GetTargetAirportIfValid(v); StringID newsitem; - AIEventVehicleCrashed::CrashReason crash_reason; if (st == NULL) { newsitem = STR_NEWS_PLANE_CRASH_OUT_OF_FUEL; - crash_reason = AIEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT; } else { SetDParam(1, st->index); newsitem = STR_NEWS_AIRCRAFT_CRASH; - crash_reason = AIEventVehicleCrashed::CRASH_PLANE_LANDING; } - AI::NewEvent(v->owner, new AIEventVehicleCrashed(v->index, v->tile, crash_reason)); + AI::NewEvent(v->owner, new AIEventVehicleCrashed(v->index, v->tile, st == NULL ? AIEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : AIEventVehicleCrashed::CRASH_PLANE_LANDING)); AddVehicleNewsItem(newsitem, NS_ACCIDENT, diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 06baa2aef..5e7d4ed41 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -507,6 +507,7 @@ void StartupCompanies() _next_competitor_start = 0; } +#ifdef ENABLE_AI static void MaybeStartNewCompany() { #ifdef ENABLE_NETWORK @@ -527,6 +528,7 @@ static void MaybeStartNewCompany() DoCommandP(0, 1, INVALID_COMPANY, CMD_COMPANY_CTRL); } } +#endif /* ENABLE_AI */ void InitializeCompanies() { @@ -608,6 +610,7 @@ 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; } @@ -615,6 +618,7 @@ 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 37400899b..1b4eac61d 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -991,6 +991,7 @@ DEF_CONSOLE_CMD(ConRestart) return true; } +#ifdef ENABLE_AI DEF_CONSOLE_CMD(ConListAI) { char buf[4096]; @@ -1157,6 +1158,7 @@ DEF_CONSOLE_CMD(ConRescanAI) return true; } +#endif /* ENABLE_AI */ DEF_CONSOLE_CMD(ConGetSeed) { @@ -1793,7 +1795,6 @@ void IConsoleStdLibRegister() IConsoleCmdRegister("help", ConHelp); IConsoleCmdRegister("info_cmd", ConInfoCmd); IConsoleCmdRegister("info_var", ConInfoVar); - IConsoleCmdRegister("list_ai", ConListAI); IConsoleCmdRegister("list_cmds", ConListCommands); IConsoleCmdRegister("list_vars", ConListVariables); IConsoleCmdRegister("list_aliases", ConListAliases); @@ -1802,8 +1803,6 @@ void IConsoleStdLibRegister() IConsoleCmdRegister("getseed", ConGetSeed); IConsoleCmdRegister("getdate", ConGetDate); IConsoleCmdRegister("quit", ConExit); - IConsoleCmdRegister("reload_ai", ConReloadAI); - IConsoleCmdRegister("rescan_ai", ConRescanAI); IConsoleCmdRegister("resetengines", ConResetEngines); IConsoleCmdRegister("return", ConReturn); IConsoleCmdRegister("screenshot", ConScreenShot); @@ -1814,8 +1813,6 @@ void IConsoleStdLibRegister() IConsoleCmdRegister("rm", ConRemove); IConsoleCmdRegister("save", ConSave); IConsoleCmdRegister("saveconfig", ConSaveConfig); - IConsoleCmdRegister("start_ai", ConStartAI); - IConsoleCmdRegister("stop_ai", ConStopAI); IConsoleCmdRegister("ls", ConListFiles); IConsoleCmdRegister("cd", ConChangeDirectory); IConsoleCmdRegister("pwd", ConPrintWorkingDirectory); @@ -1835,7 +1832,13 @@ void IConsoleStdLibRegister() IConsoleAliasRegister("set_newgame", "setting_newgame %+"); IConsoleAliasRegister("list_patches", "list_settings %+"); - +#ifdef ENABLE_AI + IConsoleCmdRegister("list_ai", ConListAI); + IConsoleCmdRegister("reload_ai", ConReloadAI); + IConsoleCmdRegister("rescan_ai", ConRescanAI); + IConsoleCmdRegister("start_ai", ConStartAI); + IConsoleCmdRegister("stop_ai", ConStopAI); +#endif /* ENABLE_AI */ IConsoleVarRegister("developer", &_stdlib_developer, ICONSOLE_VAR_BYTE, "Redirect debugging output from the console/command line to the ingame console (value 2). Default value: 1"); diff --git a/src/crashlog.cpp b/src/crashlog.cpp index c3284120e..0cce6d087 100644 --- a/src/crashlog.cpp +++ b/src/crashlog.cpp @@ -134,7 +134,9 @@ 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 80b3f5d12..073a2b514 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -3218,6 +3218,9 @@ STR_AI_DEBUG_SETTINGS_TOOLTIP :{BLACK}Change t STR_AI_DEBUG_RELOAD :{BLACK}Reload AI STR_AI_DEBUG_RELOAD_TOOLTIP :{BLACK}Kill the AI, reload the script, and restart the AI +STR_ERROR_NO_AI :{WHITE}OpenTTD is build 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 7e849cf9a..15a67b957 100644 --- a/src/network/network_command.cpp +++ b/src/network/network_command.cpp @@ -38,7 +38,11 @@ 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 f18381f05..b5177d6ad 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -167,9 +167,11 @@ 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_NEWGRF); 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 255e76767..47f3e804a 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -385,20 +385,24 @@ static void LoadIntroGame() 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 */ _settings_game = _settings_newgame; +#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 */ } byte _savegame_sort_order; diff --git a/src/saveload/ai_sl.cpp b/src/saveload/ai_sl.cpp index 2a0e5d4ad..a9ae30020 100644 --- a/src/saveload/ai_sl.cpp +++ b/src/saveload/ai_sl.cpp @@ -14,10 +14,6 @@ #include "../debug.h" #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; @@ -32,6 +28,12 @@ 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; @@ -121,3 +123,80 @@ static void Save_AIPL() extern const ChunkHandler _ai_chunk_handlers[] = { { 'AIPL', Save_AIPL, Load_AIPL, 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: NOT_REACHED(); + } +} + +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, CH_ARRAY | CH_LAST}, +}; +#endif /* ENABLE_AI */ diff --git a/src/settings.cpp b/src/settings.cpp index 63d13470d..42776fc0f 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -866,7 +866,10 @@ static bool DifficultyChange(int32) } if (((_game_mode == GM_MENU) ? _settings_newgame.difficulty : _settings_game.difficulty).max_no_competitors != 0 && - AI::GetInfoList()->size() == 0 && (!_networking || _network_server)) { +#ifdef ENABLE_AI + AI::GetInfoList()->size() == 0 && +#endif /* ENABLE_AI */ + (!_networking || _network_server)) { ShowErrorMessage(STR_WARNING_NO_SUITABLE_AI, INVALID_STRING_ID, 0, 0, true); } @@ -1145,6 +1148,7 @@ 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; @@ -1169,6 +1173,7 @@ static void AILoadConfig(IniFile *ini, const char *grpname) } if (item->value != NULL) config->StringToSettings(item->value); } +#endif /* ENABLE_AI */ } /* Load a GRF configuration from the given group name */ @@ -1254,6 +1259,7 @@ 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; @@ -1274,6 +1280,7 @@ 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 b652ea5d2..0173bfb6d 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -655,8 +655,11 @@ public: this->LowerWidget(GDW_LVL_CUSTOM); this->InvalidateData(); - if (widget / 3 == 0 && this->opt_mod_temp.difficulty.max_no_competitors != 0 && - AI::GetInfoList()->size() == 0) { + 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, 0, 0, true); } return; |