From 5bfa1829d63b8756d54456a66fb3f251cafb0661 Mon Sep 17 00:00:00 2001 From: Spoike Date: Sat, 15 Dec 2007 18:45:40 +0000 Subject: [PATCH] a qtvplay bug fixed. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2815 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_demo.c | 50 ++++++++++++++++++++++++++++++++--------- engine/client/cl_main.c | 4 ++-- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/engine/client/cl_demo.c b/engine/client/cl_demo.c index 4809b9c89..d745c42ea 100644 --- a/engine/client/cl_demo.c +++ b/engine/client/cl_demo.c @@ -30,7 +30,12 @@ int cls_lasttype; void CL_PlayDemo(char *demoname); char lastdemoname[256]; -extern cvar_t qtv_workaroundeztv; +extern cvar_t qtvcl_forceversion1; + +unsigned char demobuffer[1024*16]; +int demobuffersize; +int demopreparsedbytes; +qboolean disablepreparse; #define BUFFERTIME 0.1 /* @@ -179,7 +184,11 @@ int demo_preparsedemo(unsigned char *buffer, int bytes) break; length = (buffer[ofs+0]<<0) + (buffer[ofs+1]<<8) + (buffer[ofs+2]<<16) + (buffer[ofs+3]<<24); if (length > MAX_OVERALLMSGLEN) + { + disablepreparse = true; + Con_Printf("Error looking ahead at demo\n"); return parsed; + } ofs+=4; } else @@ -207,9 +216,6 @@ int demo_preparsedemo(unsigned char *buffer, int bytes) return parsed; } -unsigned char demobuffer[1024*16]; -int demobuffersize; -int demopreparsedbytes; int readdemobytes(int *readpos, void *data, int len) { int i; @@ -232,7 +238,10 @@ int readdemobytes(int *readpos, void *data, int len) if (i > 0) { demobuffersize += i; - demopreparsedbytes += demo_preparsedemo(demobuffer+demopreparsedbytes, demobuffersize-demopreparsedbytes); + if (disablepreparse) + demopreparsedbytes = demobuffersize; + else + demopreparsedbytes += demo_preparsedemo(demobuffer+demopreparsedbytes, demobuffersize-demopreparsedbytes); } else if (i < 0) { //0 means no data available yet @@ -1473,6 +1482,7 @@ vfsfile_t *qtvrequest; void CL_QTVPoll (void) { char *s, *e, *colon; + char *tail = NULL; int len; qboolean streamavailable = false; qboolean saidheader = false; @@ -1505,15 +1515,35 @@ void CL_QTVPoll (void) for (s = qtvrequestbuffer; *s; s++) { if (s[0] == '\n' && s[1] == '\n') + { + tail = s+2; break; + } + if (s[0] == '\r' && s[1] == '\n' && s[2] == '\r' && s[3] == '\n') + { + tail = s+4; + break; + } + if (s[0] == '\r' && s[1] == '\n' && s[2] == '\n') + { + tail = s+3; + break; + } + if (s[0] == '\n' && s[1] == '\r' && s[2] == '\n') + { + tail = s+3; + break; + } } - if (!*s) + if (!tail) return; s[1] = '\0'; //make sure its null terminated before the data payload s = qtvrequestbuffer; for (e = s; *e; ) { - if (*e == '\n') + if (*e == '\r') + *e = '\0'; + else if (*e == '\n') { *e = '\0'; colon = strchr(s, ':'); @@ -1610,7 +1640,7 @@ void CL_QTVPoll (void) { CL_QTVPlay(qtvrequest); qtvrequest = NULL; - demo_resetcache(qtvrequestsize - (e-qtvrequestbuffer), e); + demo_resetcache(qtvrequestsize - (tail-qtvrequestbuffer), tail); return; } @@ -1725,7 +1755,7 @@ void CL_QTVPlay_f (void) else host = NULL; - if (qtv_workaroundeztv.value) + if (qtvcl_forceversion1.value) { connrequest = "QTV\n" "VERSION: 1.0\n"; @@ -1784,7 +1814,7 @@ void CL_QTVList_f (void) return; } - if (qtv_workaroundeztv.value) + if (qtvcl_forceversion1.value) { connrequest = "QTV\n" "VERSION: 1.0\n"; diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index ee17443a9..d16712fe1 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -73,7 +73,7 @@ cvar_t cl_predict_players2 = SCVAR("cl_predict_players2", "1"); cvar_t cl_solid_players = SCVAR("cl_solid_players", "1"); cvar_t cl_noblink = SCVAR("cl_noblink", "0"); cvar_t cl_servername = SCVAR("cl_servername", "none"); -cvar_t qtv_workaroundeztv = SCVAR("qtv_workaroundeztv", "0"); +cvar_t qtvcl_forceversion1 = SCVAR("qtvcl_forceversion1", "0"); cvar_t cl_demospeed = FCVAR("cl_demospeed", "demo_setspeed", "1", 0); @@ -2904,7 +2904,7 @@ void CL_Init (void) Cvar_Register (&ruleset_allow_overlongsounds, cl_controlgroup); Cvar_Register (&ruleset_allow_larger_models, cl_controlgroup); - Cvar_Register (&qtv_workaroundeztv, cl_controlgroup); + Cvar_Register (&qtvcl_forceversion1, cl_controlgroup); #ifdef WEBCLIENT Cmd_AddCommand ("ftp", CL_FTP_f); #endif