From 0c5e9123979c8715810f54d4f2749b2583565be6 Mon Sep 17 00:00:00 2001 From: Shpoike Date: Sat, 28 Dec 2024 14:18:46 +0000 Subject: [PATCH] Add a couple of extra options for jumping around demos. --- engine/client/cl_demo.c | 27 +++++++++++++++++++-------- engine/client/cl_main.c | 14 ++++++++++++-- engine/client/cl_parse.c | 17 +++++++++++++++++ engine/client/client.h | 8 +++++++- 4 files changed, 55 insertions(+), 11 deletions(-) diff --git a/engine/client/cl_demo.c b/engine/client/cl_demo.c index 2c0c78cf7..bf301af34 100644 --- a/engine/client/cl_demo.c +++ b/engine/client/cl_demo.c @@ -76,7 +76,7 @@ void CL_StopPlayback (void) cls.demoinfile = NULL; cls.state = ca_disconnected; cls.demoplayback = DPB_NONE; - cls.demoseeking = false; //just in case + cls.demoseeking = DEMOSEEK_NOT; //just in case cls.demotrack = -1; cls.demoeztv_ext = 0; @@ -393,7 +393,7 @@ void CL_ProgressDemoTime(void) void CL_DemoJump_f(void) { float newtime; - char *s = Cmd_Argv(1); + char *s = (!strncmp(Cmd_Argv(0), "demo_jump_", 10))?Cmd_Argv(0)+10:Cmd_Argv(1); char *colon = strchr(s, ':'); if (!cls.demoplayback) @@ -414,6 +414,17 @@ void CL_DemoJump_f(void) return; //can't seek live streams... } + if (!strcmp(s, "intermission") || !strcmp(s, "end")) + { //seeks until we see an svc_intermission + cls.demoseeking = DEMOSEEK_INTERMISSION; + return; + } + if (!strcmp(s, "mark")) + { //seeks until we see an svc_stufftext `//demomark` + cls.demoseeking = DEMOSEEK_MARK; + return; + } + if (*s == '+' || *s == '-') { if (colon) @@ -457,7 +468,7 @@ void CL_DemoJump_f(void) //now fastparse it. cls.demoseektime = newtime; } - cls.demoseeking = true; + cls.demoseeking = DEMOSEEK_TIME; } void CL_DemoNudge_f(void) @@ -610,11 +621,11 @@ qboolean CL_GetDemoMessage (void) return 0; }*/ cls.netchan.last_received = realtime; - if (cls.demoseeking) + if (cls.demoseeking == DEMOSEEK_TIME) { if (cl.gametime > cls.demoseektime) { - cls.demoseeking = false; + cls.demoseeking = DEMOSEEK_NOT; return 0; } } @@ -731,11 +742,11 @@ readnext: // decide if it is time to grab the next message - if (cls.demoseeking) + if (cls.demoseeking != DEMOSEEK_NOT) { demtime = demotime; //warp - if (demtime >= cls.demoseektime) - cls.demoseeking = false; + if (cls.demoseeking == DEMOSEEK_TIME && demtime >= cls.demoseektime) + cls.demoseeking = DEMOSEEK_NOT; } else if (cls.timedemo) { diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 995565fb0..5c63b06c8 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -2632,6 +2632,14 @@ void CL_Disconnect_f (void) (void)CSQC_UnconnectedInit(); } +void CL_Disconnect2_f (void) +{ + char *reason = Cmd_Argv(1); + if (*reason) + Cvar_Set(&cl_disconnectreason, reason); + CL_Disconnect_f(); +} + /* ==================== CL_User_f @@ -3786,7 +3794,7 @@ void CL_Changing_f (void) if (cls.download && cls.download->method <= DL_QWPENDING) // don't change when downloading return; - cls.demoseeking = false; //don't seek over it + cls.demoseeking = DEMOSEEK_NOT; //don't seek over it if (*mapname) SCR_ImageName(mapname); @@ -5959,7 +5967,9 @@ void CL_Init (void) Cmd_AddCommand ("qtvplay", CL_QTVPlay_f); Cmd_AddCommand ("qtvlist", CL_QTVList_f); Cmd_AddCommand ("qtvdemos", CL_QTVDemos_f); - Cmd_AddCommandD ("demo_jump", CL_DemoJump_f, "Jump to a specified time in a demo. Prefix with a + or - for a relative offset. Seeking backwards will restart the demo and the fast forward, which can take some time in long demos."); + Cmd_AddCommandD ("demo_jump", CL_DemoJump_f, "Jump to a specified time in a demo. Prefix with a + or - for a relative offset. Seeking backwards will restart the demo and the fast forward, which can take some time in long demos."); + Cmd_AddCommandD ("demo_jump_mark", CL_DemoJump_f, "Jump to the next '//demomark' marker."); + Cmd_AddCommandD ("demo_jump_end", CL_DemoJump_f, "Jump to the next intermission message."); Cmd_AddCommandD ("demo_nudge", CL_DemoNudge_f, "Nudge the demo by one frame. Argument should be +1 or -1. Nudging backwards is limited."); Cmd_AddCommandAD ("timedemo", CL_TimeDemo_f, CL_DemoList_c, NULL); #ifdef _DEBUG diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index 746becedd..0448e922b 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -7312,6 +7312,11 @@ static void CL_ParseStuffCmd(char *msg, int destsplit) //this protects stuffcmds Plug_Command_f(); } #endif + else if (!strncmp(stufftext, "//demomark", 10) && (stufftext[10]==0||stufftext[10]==' ') && cls.demoseeking == DEMOSEEK_MARK) + { //found the next marker. we're done seeking. + cls.demoseeking = DEMOSEEK_NOT; + //FIXME: pause it. + } else { if (!strncmp(stufftext, "cmd ", 4)) @@ -8067,6 +8072,12 @@ void CLQW_ParseServerMessage (void) cl.playerview[destsplit].simorg[i] = MSG_ReadCoord (); for (i=0 ; i<3 ; i++) cl.playerview[destsplit].intermissionangles[i] = MSG_ReadAngle (); + + if (cls.demoseeking == DEMOSEEK_INTERMISSION) + { + cls.demoseeking = DEMOSEEK_NOT; //reached it. + //FIXME: pause it. + } break; case svc_finale: @@ -9869,6 +9880,12 @@ void CLNQ_ParseServerMessage (void) cl.completed_time = cl.gametime; } cl.intermissionmode = IM_NQSCORES; + + if (cls.demoseeking == DEMOSEEK_INTERMISSION) + { + cls.demoseeking = DEMOSEEK_NOT; //reached it. + //FIXME: pause it. + } break; case svc_finale: diff --git a/engine/client/client.h b/engine/client/client.h index a9031c364..c29c406ec 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -533,7 +533,13 @@ typedef struct #define EZTV_SETINFO (1u<<1) //proxy wants setinfo + ptrack commands #define EZTV_QTVUSERLIST (1u<<2) //'//qul cmd id [name]' commands from proxy. qboolean demohadkeyframe; //q2 needs to wait for a packet with a key frame, supposedly. - qboolean demoseeking; + enum + { + DEMOSEEK_NOT, + DEMOSEEK_TIME, //stops one we reach demoseektime + DEMOSEEK_MARK, //stops once we reach a '//demomark' + DEMOSEEK_INTERMISSION, //stops once we reach an svc_intermission + } demoseeking; float demoseektime; int demotrack; qboolean timedemo;