X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=cl_parse.c;h=bee2cb533c4d08efcbca02f4ce858b439c79dcb7;hp=d3df3867bec9f935b94fda6e0a5c20f24602b34e;hb=145be4b7f63608b1b43cdae981761cc74c34efa0;hpb=d9c86e8e4cd0f66c6033d49d07c3f008cdfcd48a diff --git a/cl_parse.c b/cl_parse.c index d3df3867..bee2cb53 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -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; @@ -566,7 +576,9 @@ static void QW_CL_RequestNextDownload(void) cl.model_bolt2 = Mod_ForName("progs/bolt2.mdl", false, false, NULL); cl.model_bolt3 = Mod_ForName("progs/bolt3.mdl", false, false, NULL); cl.model_beam = Mod_ForName("progs/beam.mdl", false, false, NULL); - Mod_PurgeUnused(); + + // we purge the models and sounds later in CL_SignonReply + //Mod_PurgeUnused(); // now we try to load everything that is new @@ -620,9 +632,8 @@ static void QW_CL_RequestNextDownload(void) cls.qw_downloadtype = dl_none; - // load new sounds and unload old ones - // FIXME: S_ServerSounds does not know about cl.sfx_ sounds - S_ServerSounds(cl.sound_name, cls.qw_downloadnumber); + // clear sound usage flags for purging of unused sounds + S_ClearUsed(); // precache any sounds used by the client cl.sfx_wizhit = S_PrecacheSound(cl_sound_wizardhit.string, false, true); @@ -633,12 +644,12 @@ static void QW_CL_RequestNextDownload(void) cl.sfx_ric3 = S_PrecacheSound(cl_sound_ric3.string, false, true); cl.sfx_r_exp3 = S_PrecacheSound(cl_sound_r_exp3.string, false, true); - // sounds + // sounds used by the game for (i = 1;i < MAX_SOUNDS && cl.sound_name[i][0];i++) - { - // Don't lock the sfx here, S_ServerSounds already did that - cl.sound_precache[i] = S_PrecacheSound(cl.sound_name[i], true, false); - } + cl.sound_precache[i] = S_PrecacheSound(cl.sound_name[i], true, true); + + // we purge the models and sounds later in CL_SignonReply + //S_PurgeUnused(); // check memory integrity Mem_CheckSentinelsGlobal(); @@ -977,6 +988,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 +1008,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 +1044,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(false, 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 +1080,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,18 +1120,26 @@ 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); + SCR_PushLoadingScreen(false, cl.sound_name[cl.loadsound_current], 1.0 / cl.loadsound_total); if (cl.sound_precache[cl.loadsound_current] && S_IsSoundPrecached(cl.sound_precache[cl.loadsound_current])) { SCR_PopLoadingScreen(false); continue; } CL_KeepaliveMessage(true); - // Don't lock the sfx here, S_ServerSounds already did that - cl.sound_precache[cl.loadsound_current] = S_PrecacheSound(cl.sound_name[cl.loadsound_current], false, false); + cl.sound_precache[cl.loadsound_current] = S_PrecacheSound(cl.sound_name[cl.loadsound_current], false, true); SCR_PopLoadingScreen(false); } SCR_PopLoadingScreen(false); @@ -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) { @@ -1185,8 +1254,7 @@ void CL_BeginDownloads(qboolean aborteddownload) return; } } - // Don't lock the sfx here, S_ServerSounds already did that - cl.sound_precache[cl.downloadsound_current] = S_PrecacheSound(cl.sound_name[cl.downloadsound_current], false, false); + cl.sound_precache[cl.downloadsound_current] = S_PrecacheSound(cl.sound_name[cl.downloadsound_current], false, true); } // finished loading sounds @@ -1214,10 +1282,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) @@ -1475,7 +1540,10 @@ static void CL_SignonReply (void) case 4: // after the level has been loaded, we shouldn't need the shaders, and // if they are needed again they will be automatically loaded... + // we also don't need the unused models or sounds from the last level Mod_FreeQ3Shaders(); + Mod_PurgeUnused(); + S_PurgeUnused(); Con_ClearNotify(); if (COM_CheckParm("-profilegameonly")) @@ -1671,11 +1739,13 @@ void CL_ParseServerInfo (void) cl.model_bolt2 = Mod_ForName("progs/bolt2.mdl", false, false, NULL); cl.model_bolt3 = Mod_ForName("progs/bolt3.mdl", false, false, NULL); cl.model_beam = Mod_ForName("progs/beam.mdl", false, false, NULL); - Mod_PurgeUnused(); - // do the same for sounds - // FIXME: S_ServerSounds does not know about cl.sfx_ sounds - S_ServerSounds (cl.sound_name, numsounds); + // we purge the models and sounds later in CL_SignonReply + //Mod_PurgeUnused(); + //S_PurgeUnused(); + + // clear sound usage flags for purging of unused sounds + S_ClearUsed(); // precache any sounds used by the client cl.sfx_wizhit = S_PrecacheSound(cl_sound_wizardhit.string, false, true); @@ -1686,6 +1756,10 @@ void CL_ParseServerInfo (void) cl.sfx_ric3 = S_PrecacheSound(cl_sound_ric3.string, false, true); cl.sfx_r_exp3 = S_PrecacheSound(cl_sound_r_exp3.string, false, true); + // sounds used by the game + for (i = 1;i < MAX_SOUNDS && cl.sound_name[i][0];i++) + cl.sound_precache[i] = S_PrecacheSound(cl.sound_name[i], true, true); + // now we try to load everything that is new cl.loadmodel_current = 1; cl.downloadmodel_current = 1; @@ -1797,10 +1871,11 @@ void CL_MoveLerpEntityStates(entity_t *ent) VectorCopy(ent->state_current.angles, ent->persistent.newangles); ent->persistent.trail_allowed = false; - if(ent->state_current.frame != ent->state_previous.frame) + // if(ent->state_current.frame != ent->state_previous.frame) + // do this even if we did change the frame + // teleport bit is only used if an animation restart, or a jump, is necessary + // so it should be always harmless to do this { - // if we ALSO changed animation frame in the process (but ONLY then!) - // then let's reset the animation interpolation too ent->render.framegroupblend[0].frame = ent->render.framegroupblend[1].frame = ent->state_current.frame; ent->render.framegroupblend[0].start = ent->render.framegroupblend[1].start = cl.time; ent->render.framegroupblend[0].lerp = 1;ent->render.framegroupblend[1].lerp = 0; @@ -3706,7 +3781,7 @@ void CL_ParseServerMessage(void) i -= 32768; if (i >= 1 && i < MAX_SOUNDS) { - sfx_t *sfx = S_PrecacheSound (s, true, false); + sfx_t *sfx = S_PrecacheSound (s, true, true); if (!sfx && snd_initialized.integer) Con_DPrintf("svc_precache: S_PrecacheSound(\"%s\") failed\n", s); cl.sound_precache[i] = sfx;