Add console command to find objects with missing specs

This commit is contained in:
Jonathan G Rennison 2024-09-21 14:33:35 +01:00
parent 63758e412c
commit c3b05c5346
2 changed files with 31 additions and 0 deletions

View File

@ -4128,6 +4128,23 @@ DEF_CONSOLE_CMD(ConFindNonRealisticBrakingSignal)
return true; return true;
} }
DEF_CONSOLE_CMD(ConFindMissingObject)
{
if (argc == 0) {
IConsolePrint(CC_HELP, "Find the next object tile where the spec is missing");
return true;
}
extern TileIndex FindMissingObjectTile();
TileIndex t = FindMissingObjectTile();
if (t != INVALID_TILE) {
ScrollMainWindowToTile(t);
SetRedErrorSquare(t);
}
return true;
}
DEF_CONSOLE_CMD(ConDumpInfo) DEF_CONSOLE_CMD(ConDumpInfo)
{ {
@ -4324,6 +4341,7 @@ void IConsoleStdLibRegister()
IConsole::CmdRegister("fps_wnd", ConFramerateWindow); IConsole::CmdRegister("fps_wnd", ConFramerateWindow);
IConsole::CmdRegister("find_non_realistic_braking_signal", ConFindNonRealisticBrakingSignal); IConsole::CmdRegister("find_non_realistic_braking_signal", ConFindNonRealisticBrakingSignal);
IConsole::CmdRegister("find_missing_object", ConFindMissingObject);
IConsole::CmdRegister("getfulldate", ConGetFullDate, nullptr, true); IConsole::CmdRegister("getfulldate", ConGetFullDate, nullptr, true);
IConsole::CmdRegister("dump_command_log", ConDumpCommandLog, nullptr, true); IConsole::CmdRegister("dump_command_log", ConDumpCommandLog, nullptr, true);

View File

@ -1294,3 +1294,16 @@ extern const TileTypeProcs _tile_type_object_procs = {
GetFoundation_Object, // get_foundation_proc GetFoundation_Object, // get_foundation_proc
TerraformTile_Object, // terraform_tile_proc TerraformTile_Object, // terraform_tile_proc
}; };
TileIndex FindMissingObjectTile()
{
for (TileIndex t = 0; t < MapSize(); t++) {
if (IsTileType(t, MP_OBJECT)) {
const Object *obj = Object::GetByTile(t);
const ObjectSpec *spec = ObjectSpec::Get(obj->type);
if (!spec->IsEnabled()) return t;
}
}
return INVALID_TILE;
}