]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_parse.c
fix the name (DOWNLOADPROGRESS -> LOADPROGRESS)
[xonotic/darkplaces.git] / cl_parse.c
index 80d11efb6650450ae95ebd4bca61da09d5f4c76c..27446104ed66a4ffea505710044903f0ac05df31 100644 (file)
@@ -290,6 +290,7 @@ void CL_KeepaliveMessage (qboolean readmessages)
 {
        float time;
        static double nextmsg = -1;
+       static double nextupdate = -1;
 #if 0
        static double lasttime = -1;
 #endif
@@ -297,6 +298,15 @@ void CL_KeepaliveMessage (qboolean readmessages)
        qboolean oldbadread;
        sizebuf_t old;
 
+       if(cls.state != ca_dedicated)
+       {
+               if((time = Sys_DoubleTime()) >= nextupdate)
+               {
+                       SCR_UpdateLoadingScreenIfShown();
+                       nextupdate = time + 2;
+               }
+       }
+
        // no need if server is local and definitely not if this is a demo
        if (!cls.netcon || cls.protocol == PROTOCOL_QUAKEWORLD || cls.signon >= SIGNONS)
                return;
@@ -977,6 +987,11 @@ static void CL_UpdateItemsAndWeapon(void)
        cl.activeweapon = cl.stats[STAT_ACTIVEWEAPON];
 }
 
+#define LOADPROGRESSWEIGHT_SOUND            1.0
+#define LOADPROGRESSWEIGHT_MODEL            4.0
+#define LOADPROGRESSWEIGHT_WORLDMODEL      30.0
+#define LOADPROGRESSWEIGHT_WORLDMODEL_INIT  2.0
+
 void CL_BeginDownloads(qboolean aborteddownload)
 {
        // quakeworld works differently
@@ -992,6 +1007,8 @@ void CL_BeginDownloads(qboolean aborteddownload)
 
        // if we got here...
        // curl is done, so let's start with the business
+       if(!cl.loadbegun)
+               SCR_PushLoadingScreen(false, "Loading precaches", 1);
        cl.loadbegun = true;
 
        // if already downloading something from the previous level, don't stop it
@@ -1026,12 +1043,31 @@ void CL_BeginDownloads(qboolean aborteddownload)
                if(cl.loadmodel_current == 1)
                {
                        // worldmodel counts as 16 models (15 + world model setup), for better progress bar
-                       SCR_PushLoadingScreen(false, "Loading precached models", (cl.loadmodel_total + 15) / (float) (cl.loadmodel_total + cl.loadsound_total + 15));
+                       SCR_PushLoadingScreen(false, "Loading precached models",
+                               (
+                                       (cl.loadmodel_total - 1) * LOADPROGRESSWEIGHT_MODEL
+                               +       LOADPROGRESSWEIGHT_WORLDMODEL
+                               +       LOADPROGRESSWEIGHT_WORLDMODEL_INIT
+                               ) / (
+                                       (cl.loadmodel_total - 1) * LOADPROGRESSWEIGHT_MODEL
+                               +       LOADPROGRESSWEIGHT_WORLDMODEL
+                               +       LOADPROGRESSWEIGHT_WORLDMODEL_INIT
+                               +       cl.loadsound_total * LOADPROGRESSWEIGHT_SOUND
+                               )
+                       );
                        SCR_BeginLoadingPlaque();
                }
                for (;cl.loadmodel_current < cl.loadmodel_total;cl.loadmodel_current++)
                {
-                       SCR_PushLoadingScreen(true, cl.model_name[cl.loadmodel_current], (cl.loadmodel_current == 1 ? 15.0 : 1.0) / cl.loadmodel_total);
+                       SCR_PushLoadingScreen(true, cl.model_name[cl.loadmodel_current],
+                               (
+                                       (cl.loadmodel_current == 1) ? LOADPROGRESSWEIGHT_WORLDMODEL : LOADPROGRESSWEIGHT_MODEL
+                               ) / (
+                                       (cl.loadmodel_total - 1) * LOADPROGRESSWEIGHT_MODEL
+                               +       LOADPROGRESSWEIGHT_WORLDMODEL
+                               +       LOADPROGRESSWEIGHT_WORLDMODEL_INIT
+                               )
+                       );
                        if (cl.model_precache[cl.loadmodel_current] && cl.model_precache[cl.loadmodel_current]->Draw)
                        {
                                SCR_PopLoadingScreen(false);
@@ -1043,12 +1079,27 @@ void CL_BeginDownloads(qboolean aborteddownload)
                                continue;
                        }
                        CL_KeepaliveMessage(true);
+
+                       if(cl.loadmodel_current == 1)
+                       {
+                               // they'll be soon loaded, but make sure we apply freshly downloaded shaders from a curled pk3
+                               Mod_FreeQ3Shaders();
+                       }
+
                        cl.model_precache[cl.loadmodel_current] = Mod_ForName(cl.model_name[cl.loadmodel_current], false, false, cl.model_name[cl.loadmodel_current][0] == '*' ? cl.model_name[1] : NULL);
                        SCR_PopLoadingScreen(false);
                        if (cl.model_precache[cl.loadmodel_current] && cl.model_precache[cl.loadmodel_current]->Draw && cl.loadmodel_current == 1)
                        {
                                // we now have the worldmodel so we can set up the game world
-                               SCR_PushLoadingScreen(true, "world model setup", 1.0 / cl.loadmodel_total);
+                               SCR_PushLoadingScreen(true, "world model setup",
+                                       (
+                                               LOADPROGRESSWEIGHT_WORLDMODEL_INIT
+                                       ) / (
+                                               (cl.loadmodel_total - 1) * LOADPROGRESSWEIGHT_MODEL
+                                       +       LOADPROGRESSWEIGHT_WORLDMODEL
+                                       +       LOADPROGRESSWEIGHT_WORLDMODEL_INIT
+                                       )
+                               );
                                CL_SetupWorldModel();
                                SCR_PopLoadingScreen(true);
                                if (!cl.loadfinished && cl_joinbeforedownloadsfinish.integer)
@@ -1068,7 +1119,16 @@ void CL_BeginDownloads(qboolean aborteddownload)
        {
                // loading sounds
                if(cl.loadsound_current == 1)
-                       SCR_PushLoadingScreen(false, "Loading precached sounds", cl.loadsound_total / (float) (cl.loadmodel_total + cl.loadsound_total + 15));
+                       SCR_PushLoadingScreen(false, "Loading precached sounds",
+                               (
+                                       cl.loadsound_total * LOADPROGRESSWEIGHT_SOUND
+                               ) / (
+                                       (cl.loadmodel_total - 1) * LOADPROGRESSWEIGHT_MODEL
+                               +       LOADPROGRESSWEIGHT_WORLDMODEL
+                               +       LOADPROGRESSWEIGHT_WORLDMODEL_INIT
+                               +       cl.loadsound_total * LOADPROGRESSWEIGHT_SOUND
+                               )
+                       );
                for (;cl.loadsound_current < cl.loadsound_total;cl.loadsound_current++)
                {
                        SCR_PushLoadingScreen(true, cl.sound_name[cl.loadsound_current], 1.0 / cl.loadsound_total);
@@ -1107,9 +1167,11 @@ void CL_BeginDownloads(qboolean aborteddownload)
                {
                        if (aborteddownload)
                        {
+
                                if (cl.downloadmodel_current == 1)
                                {
                                        // the worldmodel failed, but we need to set up anyway
+                                       Mod_FreeQ3Shaders();
                                        CL_SetupWorldModel();
                                        if (!cl.loadfinished && cl_joinbeforedownloadsfinish.integer)
                                        {
@@ -1139,6 +1201,13 @@ void CL_BeginDownloads(qboolean aborteddownload)
                                        return;
                                }
                        }
+
+                       if(cl.downloadmodel_current == 1)
+                       {
+                               // they'll be soon loaded, but make sure we apply freshly downloaded shaders from a curled pk3
+                               Mod_FreeQ3Shaders();
+                       }
+
                        cl.model_precache[cl.downloadmodel_current] = Mod_ForName(cl.model_name[cl.downloadmodel_current], false, false, cl.model_name[cl.downloadmodel_current][0] == '*' ? cl.model_name[1] : NULL);
                        if (cl.downloadmodel_current == 1)
                        {
@@ -1214,10 +1283,7 @@ void CL_BeginDownloads_f(void)
        if(cl.loadbegun)
                Con_Printf("cl_begindownloads is only valid once per match\n");
        else
-       {
-               SCR_PushLoadingScreen(false, "Loading precaches", 1);
                CL_BeginDownloads(false);
-       }
 }
 
 void CL_StopDownload(int size, int crc)
@@ -1448,10 +1514,7 @@ static void CL_SignonReply (void)
                        //MSG_WriteString (&cls.netcon->message, "prespawn");
                }
                else // playing a demo...  make sure loading occurs as soon as possible
-               {
-                       SCR_PushLoadingScreen(false, "Loading precaches", 1);
                        CL_BeginDownloads(false);
-               }
                break;
 
        case 2: