Add a "misc_debug" console command

Add a flag to open veh window when TrainBrakesOverheatedBreakdown called
This commit is contained in:
Jonathan G Rennison
2021-04-12 00:18:13 +01:00
parent d7b23733b3
commit 8e92a6844f
4 changed files with 31 additions and 0 deletions

View File

@@ -52,6 +52,7 @@
#include "string_func_extra.h" #include "string_func_extra.h"
#include "linkgraph/linkgraphjob.h" #include "linkgraph/linkgraphjob.h"
#include "base_media_base.h" #include "base_media_base.h"
#include "debug_settings.h"
#include <time.h> #include <time.h>
#include "safeguards.h" #include "safeguards.h"
@@ -2847,6 +2848,23 @@ DEF_CONSOLE_CMD(ConRecalculateRoadCachedOneWayStates)
return true; return true;
} }
DEF_CONSOLE_CMD(ConMiscDebug)
{
if (argc < 1 || argc > 2) {
IConsoleHelp("Debug: misc flags. Usage: 'misc_debug [<flags>]'");
IConsoleHelp(" 1: MDF_OVERHEAT_BREAKDOWN_OPEN_WIN");
return true;
}
if (argc == 1) {
IConsolePrintF(CC_DEFAULT, "Misc debug flags: %X", _misc_debug_flags);
} else {
_misc_debug_flags = strtoul(argv[1], nullptr, 16);
}
return true;
}
DEF_CONSOLE_CMD(ConDoDisaster) DEF_CONSOLE_CMD(ConDoDisaster)
{ {
if (argc == 0) { if (argc == 0) {
@@ -3437,6 +3455,7 @@ void IConsoleStdLibRegister()
IConsoleCmdRegister("gfx_debug", ConGfxDebug, nullptr, true); IConsoleCmdRegister("gfx_debug", ConGfxDebug, nullptr, true);
IConsoleCmdRegister("csleep", ConCSleep, nullptr, true); IConsoleCmdRegister("csleep", ConCSleep, nullptr, true);
IConsoleCmdRegister("recalculate_road_cached_one_way_states", ConRecalculateRoadCachedOneWayStates, ConHookNoNetwork, true); IConsoleCmdRegister("recalculate_road_cached_one_way_states", ConRecalculateRoadCachedOneWayStates, ConHookNoNetwork, true);
IConsoleCmdRegister("misc_debug", ConMiscDebug, nullptr, true);
/* NewGRF development stuff */ /* NewGRF development stuff */
IConsoleCmdRegister("reload_newgrfs", ConNewGRFReload, ConHookNewGRFDeveloperTool); IConsoleCmdRegister("reload_newgrfs", ConNewGRFReload, ConHookNewGRFDeveloperTool);

View File

@@ -60,6 +60,8 @@ std::string _loadgame_DBGL_data;
bool _save_DBGC_data = false; bool _save_DBGC_data = false;
std::string _loadgame_DBGC_data; std::string _loadgame_DBGC_data;
uint32 _misc_debug_flags;
struct DebugLevel { struct DebugLevel {
const char *name; const char *name;
int *level; int *level;

View File

@@ -23,4 +23,9 @@ inline bool HasChickenBit(ChickenBitFlags flag)
return HasBit(_settings_game.debug.chicken_bits, flag); return HasBit(_settings_game.debug.chicken_bits, flag);
} }
enum MiscDebugFlags {
MDF_OVERHEAT_BREAKDOWN_OPEN_WIN,
};
extern uint32 _misc_debug_flags;
#endif /* DEBUG_SETTINGS_H */ #endif /* DEBUG_SETTINGS_H */

View File

@@ -43,6 +43,7 @@
#include "scope_info.h" #include "scope_info.h"
#include "scope.h" #include "scope.h"
#include "core/checksum_func.hpp" #include "core/checksum_func.hpp"
#include "debug_settings.h"
#include "table/strings.h" #include "table/strings.h"
#include "table/train_cmd.h" #include "table/train_cmd.h"
@@ -6800,6 +6801,10 @@ void TrainBrakesOverheatedBreakdown(Vehicle *v)
Train *t = Train::From(v)->First(); Train *t = Train::From(v)->First();
if (t->breakdown_ctr != 0 || (t->vehstatus & VS_CRASHED)) return; if (t->breakdown_ctr != 0 || (t->vehstatus & VS_CRASHED)) return;
if (unlikely(HasBit(_misc_debug_flags, MDF_OVERHEAT_BREAKDOWN_OPEN_WIN)) && !_network_dedicated) {
ShowVehicleViewWindow(t);
}
t->crash_anim_pos = std::min<uint>(1500, t->crash_anim_pos + 200); t->crash_anim_pos = std::min<uint>(1500, t->crash_anim_pos + 200);
if (t->crash_anim_pos < 1500) return; if (t->crash_anim_pos < 1500) return;