changeset 18542:50f097910f96 draft

(svn r23386) -Fix: debug script related events to 'script' (removes 'ai')
author truebrain <truebrain@openttd.org>
date Thu, 01 Dec 2011 12:04:10 +0000
parents 6b1c16f6f815
children 1ba866a592fd
files bin/ai/regression/run.sh src/ai/ai_core.cpp src/ai/ai_info.cpp src/ai/ai_instance.cpp src/ai/ai_scanner.cpp src/debug.cpp src/debug.h src/saveload/ai_sl.cpp src/script/api/script_list.cpp src/script/api/script_log.cpp src/script/api/script_order.cpp src/script/api/script_station.cpp src/script/script_instance.cpp src/script/script_scanner.cpp src/settings.cpp
diffstat 15 files changed, 27 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/bin/ai/regression/run.sh
+++ b/bin/ai/regression/run.sh
@@ -25,7 +25,7 @@
 if [ -n "$gdb" ]; then
 	$gdb ./openttd -x -c ai/regression/regression.cfg $params -g ai/regression/regression.sav
 else
-	./openttd -x -c ai/regression/regression.cfg $params -g ai/regression/regression.sav -d ai=2 2>&1 | awk '{ gsub("0x(\\(nil\\)|0+)(x0)?", "0x00000000", $0); gsub("^dbg: \\[ai\\]", "", $0); gsub("^ ", "ERROR: ", $0); gsub("ERROR: \\[1\\] ", "", $0); gsub("\\[P\\] ", "", $0); print $0; }' > tmp.regression
+	./openttd -x -c ai/regression/regression.cfg $params -g ai/regression/regression.sav -d script=2 2>&1 | awk '{ gsub("0x(\\(nil\\)|0+)(x0)?", "0x00000000", $0); gsub("^dbg: \\[script\\]", "", $0); gsub("^ ", "ERROR: ", $0); gsub("ERROR: \\[1\\] ", "", $0); gsub("\\[P\\] ", "", $0); print $0; }' > tmp.regression
 fi
 
 ret=0
--- 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);
 			}
 		}
--- a/src/ai/ai_info.cpp
+++ b/src/ai/ai_info.cpp
@@ -89,7 +89,7 @@
 	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 {
--- a/src/ai/ai_instance.cpp
+++ b/src/ai/ai_instance.cpp
@@ -205,7 +205,7 @@
 		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;
 	}
 
--- a/src/ai/ai_scanner.cpp
+++ b/src/ai/ai_scanner.cpp
@@ -67,7 +67,7 @@
 	}
 
 	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;
 	}
 
--- 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_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 @@
 
 #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 @@
 	DEBUG_LEVEL(npf),
 	DEBUG_LEVEL(yapf),
 	DEBUG_LEVEL(freetype),
+	DEBUG_LEVEL(script),
 	DEBUG_LEVEL(sl),
 	DEBUG_LEVEL(gamelog),
 	DEBUG_LEVEL(desync),
--- 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;
--- a/src/saveload/ai_sl.cpp
+++ b/src/saveload/ai_sl.cpp
@@ -87,15 +87,15 @@
 				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 */
--- a/src/script/api/script_list.cpp
+++ b/src/script/api/script_list.cpp
@@ -445,7 +445,7 @@
 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::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();
--- 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);
 }
 
--- a/src/script/api/script_order.cpp
+++ b/src/script/api/script_order.cpp
@@ -557,7 +557,7 @@
 	/* 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);
--- 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;
--- a/src/script/script_instance.cpp
+++ b/src/script/script_instance.cpp
@@ -125,7 +125,7 @@
 
 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);
--- a/src/script/script_scanner.cpp
+++ b/src/script/script_scanner.cpp
@@ -116,7 +116,7 @@
 
 	/* 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 @@
 			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;
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1330,7 +1330,7 @@
 		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;
 			}
 		}