mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 06:15:04 +00:00
(svn r23386) -Fix: debug script related events to 'script' (removes 'ai')
This commit is contained in:
parent
fedeba5f00
commit
a8b22e5292
@ -25,7 +25,7 @@ fi
|
||||
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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ template <> const char *GetClassName<AIInfo, ST_AI>() { 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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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),
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user