Add console command to dump vehicle info

This commit is contained in:
Jonathan G Rennison
2021-10-04 01:02:39 +01:00
parent 6b250c203c
commit 1451aa76ff

View File

@@ -54,6 +54,7 @@
#include "base_media_base.h" #include "base_media_base.h"
#include "debug_settings.h" #include "debug_settings.h"
#include "debug_desync.h" #include "debug_desync.h"
#include "scope_info.h"
#include <time.h> #include <time.h>
#include "safeguards.h" #include "safeguards.h"
@@ -2623,6 +2624,23 @@ DEF_CONSOLE_CMD(ConDumpCargoTypes)
return true; return true;
} }
DEF_CONSOLE_CMD(ConDumpVehicle)
{
if (argc != 2) {
IConsoleHelp("Debug: Show vehicle information. Usage: 'dump_vehicle <vehicle-id>'");
return true;
}
const Vehicle *v = Vehicle::GetIfValid(atoi(argv[1]));
if (v != nullptr) {
IConsolePrint(CC_DEFAULT, scope_dumper().VehicleInfo(v));
} else {
IConsolePrint(CC_DEFAULT, "No such vehicle");
}
return true;
}
/** /**
* Dump the state of a tile on the map. * Dump the state of a tile on the map.
* param x tile number or tile x coordinate. * param x tile number or tile x coordinate.
@@ -3465,6 +3483,7 @@ void IConsoleStdLibRegister()
IConsole::CmdRegister("dump_rail_types", ConDumpRailTypes, nullptr, true); IConsole::CmdRegister("dump_rail_types", ConDumpRailTypes, nullptr, true);
IConsole::CmdRegister("dump_bridge_types", ConDumpBridgeTypes, nullptr, true); IConsole::CmdRegister("dump_bridge_types", ConDumpBridgeTypes, nullptr, true);
IConsole::CmdRegister("dump_cargo_types", ConDumpCargoTypes, nullptr, true); IConsole::CmdRegister("dump_cargo_types", ConDumpCargoTypes, nullptr, true);
IConsole::CmdRegister("dump_vehicle", ConDumpVehicle, nullptr, true);
IConsole::CmdRegister("dump_tile", ConDumpTile, nullptr, true); IConsole::CmdRegister("dump_tile", ConDumpTile, nullptr, true);
IConsole::CmdRegister("check_caches", ConCheckCaches, nullptr, true); IConsole::CmdRegister("check_caches", ConCheckCaches, nullptr, true);
IConsole::CmdRegister("show_town_window", ConShowTownWindow, nullptr, true); IConsole::CmdRegister("show_town_window", ConShowTownWindow, nullptr, true);