From c3b05c53464b84a4826df8430fba99b0ad2ca7e4 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 21 Sep 2024 14:33:35 +0100 Subject: [PATCH] Add console command to find objects with missing specs --- src/console_cmds.cpp | 18 ++++++++++++++++++ src/object_cmd.cpp | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 1beb01cbb6..92ccf03461 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -4128,6 +4128,23 @@ DEF_CONSOLE_CMD(ConFindNonRealisticBrakingSignal) 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) { @@ -4324,6 +4341,7 @@ void IConsoleStdLibRegister() IConsole::CmdRegister("fps_wnd", ConFramerateWindow); IConsole::CmdRegister("find_non_realistic_braking_signal", ConFindNonRealisticBrakingSignal); + IConsole::CmdRegister("find_missing_object", ConFindMissingObject); IConsole::CmdRegister("getfulldate", ConGetFullDate, nullptr, true); IConsole::CmdRegister("dump_command_log", ConDumpCommandLog, nullptr, true); diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp index a1808b4e9b..5a56e73ac2 100644 --- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -1294,3 +1294,16 @@ extern const TileTypeProcs _tile_type_object_procs = { GetFoundation_Object, // get_foundation_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; +}