]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
demos: support curl/dlcache (down)loading at start of playback
authorbones_was_here <bones_was_here@xonotic.au>
Fri, 29 Dec 2023 22:14:28 +0000 (08:14 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Sat, 30 Dec 2023 21:21:33 +0000 (07:21 +1000)
Fixes https://gitlab.com/xonotic/darkplaces/-/issues/386

Not sure why the hacky way broke but we can do it without hacks or
netcode special cases.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
cl_demo.c
cl_parse.c
csprogs.c

index 502a7fac4581fe0aa5ed7d9b51ecd3d1b5810651..268e66dd87ed7cdf3bc34fff6e6c1468c71e8233 100644 (file)
--- a/cl_demo.c
+++ b/cl_demo.c
@@ -244,6 +244,13 @@ void CL_ReadDemoMessage(void)
                        }
                }
 
+               /* At signon 1 the cl_begindownloads command starts the world and, if applicable,
+                * boots up CSQC which may be required to parse the next message.
+                * That will be delayed if curl must first (down)load the map.
+                */
+               if (cls.signon == 1 && cl.loadcsqc) // waiting for CL_VM_Init() to be called
+                       return;
+
                // get the next message
                FS_Read(cls.demofile, &cl_message.cursize, 4);
                cl_message.cursize = LittleLong(cl_message.cursize);
index ae96302b42cceb6cac3335f0ac661e8af06b5f95..d9c8fb1775cae277a503b2e3cd6fe394411db29d 100644 (file)
@@ -1624,16 +1624,13 @@ static void CL_SignonReply(int signon_stage)
                        // (so that the server can see the player name while downloading)
                        CL_SendPlayerInfo();
 
-                       // execute cl_begindownloads next frame
-                       // (after any commands added by svc_stufftext have been executed)
-                       // when done with downloads the "prespawn" will be sent
-                       Cbuf_AddText(cmd_local, "\ncl_begindownloads\n");
-
                        //MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
                        //MSG_WriteString (&cls.netcon->message, "prespawn");
                }
-               else // playing a demo...  make sure loading occurs as soon as possible
-                       CL_BeginDownloads(false);
+               // execute cl_begindownloads next frame
+               // (after any commands added by svc_stufftext have been executed)
+               // when done with downloads the "prespawn" will be sent
+               Cbuf_AddText(cmd_local, "\ncl_begindownloads\n");
                break;
 
        case 2:
index 20c318a848fa3ae76d51b9ddac22a2368b47845d..7bc6cee08e51bb8231b2511ed8e2688aea6064f4 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -580,45 +580,6 @@ void CL_VM_Parse_StuffCmd (const char *msg)
                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(cmd_local, buf, src_local, true);
-
-                       p += l;
-                       if(*p == '\n')
-                               ++p; // skip the newline and continue
-                       else
-                               break; // end of string or overflow
-               }
-               Cmd_ExecuteString(cmd_local, "curl --clear_autodownload", src_local, true); // don't inhibit CSQC loading
-               return;
-       }
-
        if(!cl.csqc_loaded)
        {
                Cbuf_AddText(cmd_local, msg);