From a8b22e5292e5b0e47a7dbecf47e530f877624ecf Mon Sep 17 00:00:00 2001 From: truebrain Date: Thu, 1 Dec 2011 12:04:10 +0000 Subject: (svn r23386) -Fix: debug script related events to 'script' (removes 'ai') --- src/ai/ai_core.cpp | 4 ++-- src/ai/ai_info.cpp | 2 +- src/ai/ai_instance.cpp | 2 +- src/ai/ai_scanner.cpp | 2 +- src/debug.cpp | 4 ++-- src/debug.h | 2 +- src/saveload/ai_sl.cpp | 12 ++++++------ src/script/api/script_list.cpp | 4 ++-- src/script/api/script_log.cpp | 2 +- src/script/api/script_order.cpp | 2 +- src/script/api/script_station.cpp | 2 +- src/script/script_instance.cpp | 2 +- src/script/script_scanner.cpp | 10 +++++----- src/settings.cpp | 2 +- 14 files changed, 26 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp index 0b02170a6..ac2f00f65 100644 --- a/src/ai/ai_core.cpp +++ b/src/ai/ai_core.cpp @@ -184,7 +184,7 @@ for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) { if (_settings_game.ai_config[c] != NULL && _settings_game.ai_config[c]->HasScript()) { if (!_settings_game.ai_config[c]->ResetInfo(true)) { - DEBUG(ai, 0, "After a reload, the AI by the name '%s' was no longer found, and removed from the list.", _settings_game.ai_config[c]->GetName()); + DEBUG(script, 0, "After a reload, the AI by the name '%s' was no longer found, and removed from the list.", _settings_game.ai_config[c]->GetName()); _settings_game.ai_config[c]->Change(NULL); if (Company::IsValidAiID(c)) { /* The code belonging to an already running AI was deleted. We can only do @@ -201,7 +201,7 @@ } if (_settings_newgame.ai_config[c] != NULL && _settings_newgame.ai_config[c]->HasScript()) { if (!_settings_newgame.ai_config[c]->ResetInfo(false)) { - DEBUG(ai, 0, "After a reload, the AI by the name '%s' was no longer found, and removed from the list.", _settings_newgame.ai_config[c]->GetName()); + DEBUG(script, 0, "After a reload, the AI by the name '%s' was no longer found, and removed from the list.", _settings_newgame.ai_config[c]->GetName()); _settings_newgame.ai_config[c]->Change(NULL); } } diff --git a/src/ai/ai_info.cpp b/src/ai/ai_info.cpp index 0ce4f5297..83bae7aad 100644 --- a/src/ai/ai_info.cpp +++ b/src/ai/ai_info.cpp @@ -89,7 +89,7 @@ template <> const char *GetClassName() { return "AIInfo"; } if (info->engine->MethodExists(*info->SQ_instance, "GetAPIVersion")) { if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetAPIVersion", &info->api_version, MAX_GET_OPS)) return SQ_ERROR; if (!CheckAPIVersion(info->api_version)) { - DEBUG(ai, 1, "Loading info.nut from (%s.%d): GetAPIVersion returned invalid version", info->GetName(), info->GetVersion()); + DEBUG(script, 1, "Loading info.nut from (%s.%d): GetAPIVersion returned invalid version", info->GetName(), info->GetVersion()); return SQ_ERROR; } } else { diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp index e3375a0ba..446f06756 100644 --- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -205,7 +205,7 @@ bool AIInstance::LoadCompatibilityScripts(const char *api_version) if (this->engine->LoadScript(buf)) return true; ScriptLog::Error("Failed to load API compatibility script"); - DEBUG(ai, 0, "Error compiling / running API compatibility script: %s", buf); + DEBUG(script, 0, "Error compiling / running API compatibility script: %s", buf); return false; } diff --git a/src/ai/ai_scanner.cpp b/src/ai/ai_scanner.cpp index 25d38ccdb..f903061e4 100644 --- a/src/ai/ai_scanner.cpp +++ b/src/ai/ai_scanner.cpp @@ -67,7 +67,7 @@ AIInfo *AIScannerInfo::SelectRandomAI() const } if (num_random_ais == 0) { - DEBUG(ai, 0, "No suitable AI found, loading 'dummy' AI."); + DEBUG(script, 0, "No suitable AI found, loading 'dummy' AI."); return this->info_dummy; } diff --git a/src/debug.cpp b/src/debug.cpp index 3cdb6aaae..f7d31b89a 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -24,7 +24,6 @@ SOCKET _debug_socket = INVALID_SOCKET; #endif /* ENABLE_NETWORK */ -int _debug_ai_level; int _debug_driver_level; int _debug_grf_level; int _debug_map_level; @@ -35,6 +34,7 @@ int _debug_oldloader_level; int _debug_npf_level; int _debug_yapf_level; int _debug_freetype_level; +int _debug_script_level; int _debug_sl_level; int _debug_gamelog_level; int _debug_desync_level; @@ -49,7 +49,6 @@ struct DebugLevel { #define DEBUG_LEVEL(x) { #x, &_debug_##x##_level } static const DebugLevel debug_level[] = { - DEBUG_LEVEL(ai), DEBUG_LEVEL(driver), DEBUG_LEVEL(grf), DEBUG_LEVEL(map), @@ -60,6 +59,7 @@ struct DebugLevel { DEBUG_LEVEL(npf), DEBUG_LEVEL(yapf), DEBUG_LEVEL(freetype), + DEBUG_LEVEL(script), DEBUG_LEVEL(sl), DEBUG_LEVEL(gamelog), DEBUG_LEVEL(desync), diff --git a/src/debug.h b/src/debug.h index 76b66f341..07d4eb333 100644 --- a/src/debug.h +++ b/src/debug.h @@ -36,7 +36,6 @@ */ #define DEBUG(name, level, ...) if ((level) == 0 || _debug_ ## name ## _level >= (level)) debug(#name, __VA_ARGS__) - extern int _debug_ai_level; extern int _debug_driver_level; extern int _debug_grf_level; extern int _debug_map_level; @@ -47,6 +46,7 @@ extern int _debug_npf_level; extern int _debug_yapf_level; extern int _debug_freetype_level; + extern int _debug_script_level; extern int _debug_sl_level; extern int _debug_gamelog_level; extern int _debug_desync_level; diff --git a/src/saveload/ai_sl.cpp b/src/saveload/ai_sl.cpp index 31828be24..00ae7d72f 100644 --- a/src/saveload/ai_sl.cpp +++ b/src/saveload/ai_sl.cpp @@ -87,15 +87,15 @@ static void Load_AIPL() config->Change(_ai_saveload_name, -1, false, _ai_saveload_is_random); if (!config->HasScript()) { if (strcmp(_ai_saveload_name, "%_dummy") != 0) { - DEBUG(ai, 0, "The savegame has an AI by the name '%s', version %d which is no longer available.", _ai_saveload_name, _ai_saveload_version); - DEBUG(ai, 0, "A random other AI will be loaded in its place."); + DEBUG(script, 0, "The savegame has an AI by the name '%s', version %d which is no longer available.", _ai_saveload_name, _ai_saveload_version); + DEBUG(script, 0, "A random other AI will be loaded in its place."); } else { - DEBUG(ai, 0, "The savegame had no AIs available at the time of saving."); - DEBUG(ai, 0, "A random available AI will be loaded now."); + DEBUG(script, 0, "The savegame had no AIs available at the time of saving."); + DEBUG(script, 0, "A random available AI will be loaded now."); } } else { - DEBUG(ai, 0, "The savegame has an AI by the name '%s', version %d which is no longer available.", _ai_saveload_name, _ai_saveload_version); - DEBUG(ai, 0, "The latest version of that AI has been loaded instead, but it'll not get the savegame data as it's incompatible."); + DEBUG(script, 0, "The savegame has an AI by the name '%s', version %d which is no longer available.", _ai_saveload_name, _ai_saveload_version); + DEBUG(script, 0, "The latest version of that AI has been loaded instead, but it'll not get the savegame data as it's incompatible."); } /* Make sure the AI doesn't get the saveload data, as he was not the * writer of the saveload data in the first place */ diff --git a/src/script/api/script_list.cpp b/src/script/api/script_list.cpp index 37321fdcf..70f07a9a3 100644 --- a/src/script/api/script_list.cpp +++ b/src/script/api/script_list.cpp @@ -445,7 +445,7 @@ int32 ScriptList::Begin() int32 ScriptList::Next() { if (this->initialized == false) { - DEBUG(ai, 0, "Next() is invalid as Begin() is never called"); + DEBUG(script, 0, "Next() is invalid as Begin() is never called"); return 0; } return this->sorter->Next(); @@ -459,7 +459,7 @@ bool ScriptList::IsEmpty() bool ScriptList::IsEnd() { if (this->initialized == false) { - DEBUG(ai, 0, "IsEnd() is invalid as Begin() is never called"); + DEBUG(script, 0, "IsEnd() is invalid as Begin() is never called"); return true; } return this->sorter->IsEnd(); diff --git a/src/script/api/script_log.cpp b/src/script/api/script_log.cpp index 26eca7475..f774c5d25 100644 --- a/src/script/api/script_log.cpp +++ b/src/script/api/script_log.cpp @@ -74,7 +74,7 @@ } /* Also still print to debug window */ - DEBUG(ai, level, "[%d] [%c] %s", (uint)_current_company, logc, log->lines[log->pos]); + DEBUG(script, level, "[%d] [%c] %s", (uint)_current_company, logc, log->lines[log->pos]); InvalidateWindowData(WC_AI_DEBUG, 0, _current_company); } diff --git a/src/script/api/script_order.cpp b/src/script/api/script_order.cpp index a7ea14ce3..4a500a5ff 100644 --- a/src/script/api/script_order.cpp +++ b/src/script/api/script_order.cpp @@ -557,7 +557,7 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance) /* Make sure we don't go into an infinite loop */ int retry = ScriptObject::GetCallbackVariable(3) - 1; if (retry < 0) { - DEBUG(ai, 0, "Possible infinite loop in SetOrderFlags() detected"); + DEBUG(script, 0, "Possible infinite loop in SetOrderFlags() detected"); return false; } ScriptObject::SetCallbackVariable(3, retry); diff --git a/src/script/api/script_station.cpp b/src/script/api/script_station.cpp index d848ebe66..c4fd8274f 100644 --- a/src/script/api/script_station.cpp +++ b/src/script/api/script_station.cpp @@ -51,7 +51,7 @@ /* static */ int32 ScriptStation::GetCoverageRadius(ScriptStation::StationType station_type) { if (station_type == STATION_AIRPORT) { - DEBUG(ai, 0, "GetCoverageRadius(): coverage radius of airports needs to be requested via ScriptAirport::GetAirportCoverageRadius(), as it requires AirportType"); + DEBUG(script, 0, "GetCoverageRadius(): coverage radius of airports needs to be requested via ScriptAirport::GetAirportCoverageRadius(), as it requires AirportType"); return -1; } if (!HasExactlyOneBit(station_type)) return -1; diff --git a/src/script/script_instance.cpp b/src/script/script_instance.cpp index 97fdfd68f..8e812b82e 100644 --- a/src/script/script_instance.cpp +++ b/src/script/script_instance.cpp @@ -125,7 +125,7 @@ void ScriptInstance::Continue() void ScriptInstance::Died() { - DEBUG(ai, 0, "The script died unexpectedly."); + DEBUG(script, 0, "The script died unexpectedly."); this->is_dead = true; if (this->instance != NULL) this->engine->ReleaseObject(this->instance); diff --git a/src/script/script_scanner.cpp b/src/script/script_scanner.cpp index 57e412150..0f572a7c0 100644 --- a/src/script/script_scanner.cpp +++ b/src/script/script_scanner.cpp @@ -116,7 +116,7 @@ void ScriptScanner::RegisterScript(ScriptInfo *info) /* Check if GetShortName follows the rules */ if (strlen(info->GetShortName()) != 4) { - DEBUG(ai, 0, "The script '%s' returned a string from GetShortName() which is not four characaters. Unable to load the script.", info->GetName()); + DEBUG(script, 0, "The script '%s' returned a string from GetShortName() which is not four characaters. Unable to load the script.", info->GetName()); delete info; return; } @@ -133,10 +133,10 @@ void ScriptScanner::RegisterScript(ScriptInfo *info) return; } - DEBUG(ai, 1, "Registering two scripts with the same name and version"); - DEBUG(ai, 1, " 1: %s", this->info_list[script_name]->GetMainScript()); - DEBUG(ai, 1, " 2: %s", info->GetMainScript()); - DEBUG(ai, 1, "The first is taking precedence."); + DEBUG(script, 1, "Registering two scripts with the same name and version"); + DEBUG(script, 1, " 1: %s", this->info_list[script_name]->GetMainScript()); + DEBUG(script, 1, " 2: %s", info->GetMainScript()); + DEBUG(script, 1, "The first is taking precedence."); delete info; return; diff --git a/src/settings.cpp b/src/settings.cpp index 4082b8dbd..8a9d0548a 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1330,7 +1330,7 @@ static void AILoadConfig(IniFile *ini, const char *grpname) config->Change(item->name); if (!config->HasScript()) { if (strcmp(item->name, "none") != 0) { - DEBUG(ai, 0, "The AI by the name '%s' was no longer found, and removed from the list.", item->name); + DEBUG(script, 0, "The AI by the name '%s' was no longer found, and removed from the list.", item->name); continue; } } -- cgit v1.2.3-70-g09d2