1
0
Fork 0
forked from fte/fteqw

Add a couple of extra options for jumping around demos.

This commit is contained in:
Shpoike 2024-12-28 14:18:46 +00:00
parent 59c0c8857a
commit 0c5e912397
4 changed files with 55 additions and 11 deletions

View file

@ -76,7 +76,7 @@ void CL_StopPlayback (void)
cls.demoinfile = NULL; cls.demoinfile = NULL;
cls.state = ca_disconnected; cls.state = ca_disconnected;
cls.demoplayback = DPB_NONE; cls.demoplayback = DPB_NONE;
cls.demoseeking = false; //just in case cls.demoseeking = DEMOSEEK_NOT; //just in case
cls.demotrack = -1; cls.demotrack = -1;
cls.demoeztv_ext = 0; cls.demoeztv_ext = 0;
@ -393,7 +393,7 @@ void CL_ProgressDemoTime(void)
void CL_DemoJump_f(void) void CL_DemoJump_f(void)
{ {
float newtime; 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, ':'); char *colon = strchr(s, ':');
if (!cls.demoplayback) if (!cls.demoplayback)
@ -414,6 +414,17 @@ void CL_DemoJump_f(void)
return; //can't seek live streams... 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 (*s == '+' || *s == '-')
{ {
if (colon) if (colon)
@ -457,7 +468,7 @@ void CL_DemoJump_f(void)
//now fastparse it. //now fastparse it.
cls.demoseektime = newtime; cls.demoseektime = newtime;
} }
cls.demoseeking = true; cls.demoseeking = DEMOSEEK_TIME;
} }
void CL_DemoNudge_f(void) void CL_DemoNudge_f(void)
@ -610,11 +621,11 @@ qboolean CL_GetDemoMessage (void)
return 0; return 0;
}*/ }*/
cls.netchan.last_received = realtime; cls.netchan.last_received = realtime;
if (cls.demoseeking) if (cls.demoseeking == DEMOSEEK_TIME)
{ {
if (cl.gametime > cls.demoseektime) if (cl.gametime > cls.demoseektime)
{ {
cls.demoseeking = false; cls.demoseeking = DEMOSEEK_NOT;
return 0; return 0;
} }
} }
@ -731,11 +742,11 @@ readnext:
// decide if it is time to grab the next message // decide if it is time to grab the next message
if (cls.demoseeking) if (cls.demoseeking != DEMOSEEK_NOT)
{ {
demtime = demotime; //warp demtime = demotime; //warp
if (demtime >= cls.demoseektime) if (cls.demoseeking == DEMOSEEK_TIME && demtime >= cls.demoseektime)
cls.demoseeking = false; cls.demoseeking = DEMOSEEK_NOT;
} }
else if (cls.timedemo) else if (cls.timedemo)
{ {

View file

@ -2632,6 +2632,14 @@ void CL_Disconnect_f (void)
(void)CSQC_UnconnectedInit(); (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 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 if (cls.download && cls.download->method <= DL_QWPENDING) // don't change when downloading
return; return;
cls.demoseeking = false; //don't seek over it cls.demoseeking = DEMOSEEK_NOT; //don't seek over it
if (*mapname) if (*mapname)
SCR_ImageName(mapname); SCR_ImageName(mapname);
@ -5959,7 +5967,9 @@ void CL_Init (void)
Cmd_AddCommand ("qtvplay", CL_QTVPlay_f); Cmd_AddCommand ("qtvplay", CL_QTVPlay_f);
Cmd_AddCommand ("qtvlist", CL_QTVList_f); Cmd_AddCommand ("qtvlist", CL_QTVList_f);
Cmd_AddCommand ("qtvdemos", CL_QTVDemos_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_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); Cmd_AddCommandAD ("timedemo", CL_TimeDemo_f, CL_DemoList_c, NULL);
#ifdef _DEBUG #ifdef _DEBUG

View file

@ -7312,6 +7312,11 @@ static void CL_ParseStuffCmd(char *msg, int destsplit) //this protects stuffcmds
Plug_Command_f(); Plug_Command_f();
} }
#endif #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 else
{ {
if (!strncmp(stufftext, "cmd ", 4)) if (!strncmp(stufftext, "cmd ", 4))
@ -8067,6 +8072,12 @@ void CLQW_ParseServerMessage (void)
cl.playerview[destsplit].simorg[i] = MSG_ReadCoord (); cl.playerview[destsplit].simorg[i] = MSG_ReadCoord ();
for (i=0 ; i<3 ; i++) for (i=0 ; i<3 ; i++)
cl.playerview[destsplit].intermissionangles[i] = MSG_ReadAngle (); cl.playerview[destsplit].intermissionangles[i] = MSG_ReadAngle ();
if (cls.demoseeking == DEMOSEEK_INTERMISSION)
{
cls.demoseeking = DEMOSEEK_NOT; //reached it.
//FIXME: pause it.
}
break; break;
case svc_finale: case svc_finale:
@ -9869,6 +9880,12 @@ void CLNQ_ParseServerMessage (void)
cl.completed_time = cl.gametime; cl.completed_time = cl.gametime;
} }
cl.intermissionmode = IM_NQSCORES; cl.intermissionmode = IM_NQSCORES;
if (cls.demoseeking == DEMOSEEK_INTERMISSION)
{
cls.demoseeking = DEMOSEEK_NOT; //reached it.
//FIXME: pause it.
}
break; break;
case svc_finale: case svc_finale:

View file

@ -533,7 +533,13 @@ typedef struct
#define EZTV_SETINFO (1u<<1) //proxy wants setinfo + ptrack commands #define EZTV_SETINFO (1u<<1) //proxy wants setinfo + ptrack commands
#define EZTV_QTVUSERLIST (1u<<2) //'//qul cmd id [name]' commands from proxy. #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 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; float demoseektime;
int demotrack; int demotrack;
qboolean timedemo; qboolean timedemo;