From c5e4d8d5a9f916af3bf0b70c917921e7a224ff19 Mon Sep 17 00:00:00 2001 From: divverent Date: Thu, 27 Nov 2008 16:30:44 +0000 Subject: [PATCH] UGLY HACK: intercept curl commands when playing back demos to immediately load all required pk3 files git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8559 d7cf8633-e32d-0410-b094-e92efae38249 --- csprogs.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/csprogs.c b/csprogs.c index b90838c3..14165f0f 100644 --- a/csprogs.c +++ b/csprogs.c @@ -350,6 +350,46 @@ void CL_VM_Parse_StuffCmd (const char *msg) csqc_progsize.flags = sizeflags; return; } + + if(cls.demoplayback) + if(!strncmp(msg, "curl --clear_autodownload\ncurl --pak --forthismap --as ", 55)) + { + // special handling for map download commands + // run these commands IMMEDIATELY, instead of waiting for a client frame + // that way, there is no black screen when playing back demos + // I know this is a really ugly hack, but I can't think of any better way + // FIXME find the actual CAUSE of this, and make demo playback WAIT + // until all maps are loaded, then remove this hack + + char buf[MAX_INPUTLINE]; + const char *p, *q; + size_t l; + + p = msg; + + for(;;) + { + q = strchr(p, '\n'); + if(q) + l = q - p; + else + l = strlen(p); + if(l > sizeof(buf) - 1) + l = sizeof(buf) - 1; + strlcpy(buf, p, l + 1); // strlcpy needs a + 1 as it includes the newline! + + Cmd_ExecuteString(buf, src_command); + + p += l; + if(*p == '\n') + ++p; // skip the newline and continue + else + break; // end of string or overflow + } + Cmd_ExecuteString("curl --clear_autodownload", src_command); // don't inhibit CSQC loading + return; + } + if(!cl.csqc_loaded) { Cbuf_AddText(msg); -- 2.39.2