[nq,qw] Add a debug_debug cvar

Setting the cvar to > 0 causes demo playback to stop (via demo_speed 0)
when the read packet count reaches the specified value. Very useful for
debugging rendering glitches that are easily reproduced in a demo.
This commit is contained in:
Bill Currie 2023-07-28 19:19:13 +09:00
parent fc946a604d
commit ad1b2d00d4
2 changed files with 44 additions and 0 deletions

View file

@ -48,6 +48,8 @@
#include "QF/scene/scene.h" #include "QF/scene/scene.h"
#include "QF/plugin/vid_render.h"
#include "compat.h" #include "compat.h"
#include "client/world.h" #include "client/world.h"
@ -96,6 +98,16 @@ static cvar_t demo_speed_cvar = {
.flags = CVAR_NONE, .flags = CVAR_NONE,
.value = { .type = &cexpr_float, .value = &demo_speed }, .value = { .type = &cexpr_float, .value = &demo_speed },
}; };
int demo_debug;
static cvar_t demo_debug_cvar = {
.name = "demo_debug",
.description =
"set demo_speed to 0 when the packet count reaches this value (0 to "
"disable)",
.default_value = "0",
.flags = CVAR_NONE,
.value = { .type = &cexpr_int, .value = &demo_debug },
};
int demo_quit; int demo_quit;
static cvar_t demo_quit_cvar = { static cvar_t demo_quit_cvar = {
.name = "demo_quit", .name = "demo_quit",
@ -279,6 +291,16 @@ CL_GetMessage (void)
{ {
if (cls.demoplayback) { if (cls.demoplayback) {
int ret = CL_GetDemoMessage (); int ret = CL_GetDemoMessage ();
if (demo_debug) {
static int packet_count = 0;
if (ret) {
packet_count++;
if (packet_count == demo_debug) {
demo_speed = 0;
}
}
r_funcs->Draw_String (32, 64, va (0, "%4d", packet_count));
}
if (!ret && demo_timeframes_isactive && cls.td_starttime) { if (!ret && demo_timeframes_isactive && cls.td_starttime) {
CL_TimeFrames_AddTimestamp (); CL_TimeFrames_AddTimestamp ();
@ -687,6 +709,7 @@ CL_Demo_Init (void)
Cvar_Register (&demo_gzip_cvar, 0, 0); Cvar_Register (&demo_gzip_cvar, 0, 0);
Cvar_Register (&demo_speed_cvar, 0, 0); Cvar_Register (&demo_speed_cvar, 0, 0);
Cvar_Register (&demo_debug_cvar, 0, 0);
Cvar_Register (&demo_quit_cvar, 0, 0); Cvar_Register (&demo_quit_cvar, 0, 0);
Cvar_Register (&demo_timeframes_cvar, 0, 0); Cvar_Register (&demo_timeframes_cvar, 0, 0);
Cmd_AddCommand ("record", CL_Record_f, "Record a demo, if no filename " Cmd_AddCommand ("record", CL_Record_f, "Record a demo, if no filename "

View file

@ -113,6 +113,16 @@ static cvar_t demo_speed_cvar = {
.flags = CVAR_NONE, .flags = CVAR_NONE,
.value = { .type = &cexpr_float, .value = &demo_speed }, .value = { .type = &cexpr_float, .value = &demo_speed },
}; };
int demo_debug;
static cvar_t demo_debug_cvar = {
.name = "demo_debug",
.description =
"set demo_speed to 0 when the packet count reaches this value (0 to "
"disable)",
.default_value = "0",
.flags = CVAR_NONE,
.value = { .type = &cexpr_int, .value = &demo_debug },
};
int demo_quit; int demo_quit;
static cvar_t demo_quit_cvar = { static cvar_t demo_quit_cvar = {
.name = "demo_quit", .name = "demo_quit",
@ -449,6 +459,16 @@ CL_GetMessage (void)
{ {
if (cls.demoplayback) { if (cls.demoplayback) {
int ret = CL_GetDemoMessage (); int ret = CL_GetDemoMessage ();
if (demo_debug) {
static int packet_count = 0;
if (ret) {
packet_count++;
if (packet_count == demo_debug) {
demo_speed = 0;
}
}
r_funcs->Draw_String (32, 64, va (0, "%4d", packet_count));
}
if (!ret && demo_timeframes_isactive && cls.td_starttime) { if (!ret && demo_timeframes_isactive && cls.td_starttime) {
CL_TimeFrames_AddTimestamp (); CL_TimeFrames_AddTimestamp ();
@ -1235,6 +1255,7 @@ CL_Demo_Init (void)
Cvar_Register (&demo_gzip_cvar, 0, 0); Cvar_Register (&demo_gzip_cvar, 0, 0);
Cvar_Register (&demo_speed_cvar, 0, 0); Cvar_Register (&demo_speed_cvar, 0, 0);
Cvar_Register (&demo_debug_cvar, 0, 0);
Cvar_Register (&demo_quit_cvar, 0, 0); Cvar_Register (&demo_quit_cvar, 0, 0);
Cvar_Register (&demo_timeframes_cvar, 0, 0); Cvar_Register (&demo_timeframes_cvar, 0, 0);
Cmd_AddCommand ("record", CL_Record_f, "Record a demo, if no filename " Cmd_AddCommand ("record", CL_Record_f, "Record a demo, if no filename "