From 3271e89128e8797d88ec86be7e283e09aa207309 Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 11 Jun 2007 16:19:07 +0000 Subject: [PATCH] merged several identical pieces of worldmodel setup code into a new function called CL_SetupWorldModel CL_VM_Init no longer resets anything, CL_ClearState now sets up the cl.csqc_vidvars defaults, this fixes the "no world model" bug git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7404 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_main.c | 5 ++++ cl_parse.c | 86 ++++++++++++++++++++++++++++-------------------------- csprogs.c | 16 ---------- 3 files changed, 50 insertions(+), 57 deletions(-) diff --git a/cl_main.c b/cl_main.c index 40d9c249..3b6061bc 100644 --- a/cl_main.c +++ b/cl_main.c @@ -110,6 +110,11 @@ void CL_ClearState(void) // reset the view zoom interpolation cl.mviewzoom[0] = cl.mviewzoom[1] = 1; + // enable rendering of the world and such + cl.csqc_vidvars.drawworld = true; + cl.csqc_vidvars.drawenginesbar = true; + cl.csqc_vidvars.drawcrosshair = true; + // set up the float version of the stats array for easier access to float stats cl.statsf = (float *)cl.stats; diff --git a/cl_parse.c b/cl_parse.c index dc75c11a..1a85027f 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -370,6 +370,47 @@ void CL_ParseEntityLump(char *entdata) } } +extern void CL_Locs_Reload_f(void); +extern void CL_VM_Init (void); +static void CL_SetupWorldModel(void) +{ + // update the world model + cl.entities[0].render.model = cl.worldmodel = cl.model_precache[1]; + CL_UpdateRenderEntity(&cl.entities[0].render); + + // set up csqc world for collision culling + if (cl.worldmodel) + { + VectorCopy(cl.worldmodel->normalmins, cl.world.areagrid_mins); + VectorCopy(cl.worldmodel->normalmaxs, cl.world.areagrid_maxs); + } + else + { + VectorSet(cl.world.areagrid_mins, -4096, -4096, -4096); + VectorSet(cl.world.areagrid_maxs, 4096, 4096, 4096); + } + World_Clear(&cl.world); + + // load or reload .loc file for team chat messages + CL_Locs_Reload_f(); + + // reset particles and other per-level things + R_Modules_NewMap(); + + // load the team chat beep if possible + cl.foundtalk2wav = FS_FileExists("sound/misc/talk2.wav"); + + // check memory integrity + Mem_CheckSentinelsGlobal(); + + // load the csqc now + if (cl.loadcsqc) + { + cl.loadcsqc = false; + CL_VM_Init(); + } +} + static qboolean QW_CL_CheckOrDownloadFile(const char *filename) { qfile_t *file; @@ -413,9 +454,7 @@ static qboolean QW_CL_CheckOrDownloadFile(const char *filename) return false; } -extern void CL_Locs_Reload_f(void); static void QW_CL_ProcessUserInfo(int slot); -extern void CL_VM_Init (void); static void QW_CL_RequestNextDownload(void) { int i; @@ -514,13 +553,7 @@ static void QW_CL_RequestNextDownload(void) // now that we have a world model, set up the world entity, renderer // modules and csqc - cl.entities[0].render.model = cl.worldmodel = cl.model_precache[1]; - CL_UpdateRenderEntity(&cl.entities[0].render); - - CL_Locs_Reload_f(); - R_Modules_NewMap(); - - cl.foundtalk2wav = FS_FileExists("sound/misc/talk2.wav"); + CL_SetupWorldModel(); // add pmodel/emodel CRCs to userinfo CL_SetInfo("pmodel", va("%i", FS_CRCFile("progs/player.mdl", NULL)), true, true, true, true); @@ -538,11 +571,6 @@ static void QW_CL_RequestNextDownload(void) // done loading cl.loadfinished = true; - if (cl.loadcsqc) - { - cl.loadcsqc = false; - CL_VM_Init(); - } break; case dl_sound: if (cls.qw_downloadnumber == 0) @@ -956,12 +984,6 @@ void CL_BeginDownloads(qboolean aborteddownload) } } - if (cl.loadcsqc) - { - cl.loadcsqc = false; - CL_VM_Init(); - } - if (cl.loadmodel_current < cl.loadmodel_total) { // loading models @@ -980,13 +1002,7 @@ void CL_BeginDownloads(qboolean aborteddownload) 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 - cl.entities[0].render.model = cl.worldmodel = cl.model_precache[1]; - CL_UpdateRenderEntity(&cl.entities[0].render); - CL_Locs_Reload_f(); - R_Modules_NewMap(); - cl.foundtalk2wav = FS_FileExists("sound/misc/talk2.wav"); - // check memory integrity - Mem_CheckSentinelsGlobal(); + CL_SetupWorldModel(); if (!cl.loadfinished && cl_joinbeforedownloadsfinish.integer) { cl.loadfinished = true; @@ -1031,13 +1047,7 @@ void CL_BeginDownloads(qboolean aborteddownload) if (cl.downloadmodel_current == 1) { // the worldmodel failed, but we need to set up anyway - cl.entities[0].render.model = cl.worldmodel = cl.model_precache[1]; - CL_UpdateRenderEntity(&cl.entities[0].render); - CL_Locs_Reload_f(); - R_Modules_NewMap(); - cl.foundtalk2wav = FS_FileExists("sound/misc/talk2.wav"); - // check memory integrity - Mem_CheckSentinelsGlobal(); + CL_SetupWorldModel(); if (!cl.loadfinished && cl_joinbeforedownloadsfinish.integer) { cl.loadfinished = true; @@ -1071,13 +1081,7 @@ void CL_BeginDownloads(qboolean aborteddownload) if (cl.downloadmodel_current == 1) { // we now have the worldmodel so we can set up the game world - cl.entities[0].render.model = cl.worldmodel = cl.model_precache[1]; - CL_UpdateRenderEntity(&cl.entities[0].render); - CL_Locs_Reload_f(); - R_Modules_NewMap(); - cl.foundtalk2wav = FS_FileExists("sound/misc/talk2.wav"); - // check memory integrity - Mem_CheckSentinelsGlobal(); + CL_SetupWorldModel(); if (!cl.loadfinished && cl_joinbeforedownloadsfinish.integer) { cl.loadfinished = true; diff --git a/csprogs.c b/csprogs.c index d19f5e5c..f2f2b6b3 100644 --- a/csprogs.c +++ b/csprogs.c @@ -513,10 +513,6 @@ void CL_VM_Init (void) Cvar_SetValueQuick(&csqc_progcrc, -1); Cvar_SetValueQuick(&csqc_progsize, -1); - cl.csqc_loaded = false; - memset(cl.csqc_model_precache, 0, sizeof(cl.csqc_model_precache)); - memset(&cl.csqc_vidvars, true, sizeof(csqc_vidvars_t)); - // if the server is not requesting a csprogs, then we're done here if (requiredcrc < 0) return; @@ -600,18 +596,6 @@ void CL_VM_Init (void) if (prog->fieldoffsets.nextthink >= 0 && prog->fieldoffsets.frame >= 0 && prog->fieldoffsets.think >= 0 && prog->globaloffsets.self >= 0) prog->flag |= PRVM_OP_STATE; - if (cl.worldmodel) - { - VectorCopy(cl.worldmodel->normalmins, cl.world.areagrid_mins); - VectorCopy(cl.worldmodel->normalmaxs, cl.world.areagrid_maxs); - } - else - { - VectorSet(cl.world.areagrid_mins, -4096, -4096, -4096); - VectorSet(cl.world.areagrid_maxs, 4096, 4096, 4096); - } - World_Clear(&cl.world); - // set time prog->globals.client->time = cl.time; -- 2.39.2