]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
merged several identical pieces of worldmodel setup code into
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 11 Jun 2007 16:19:07 +0000 (16:19 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 11 Jun 2007 16:19:07 +0000 (16:19 +0000)
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
cl_parse.c
csprogs.c

index 40d9c249a09f15821968ff040f1bcf6f1c445d3d..3b6061bc2e39974c74da672efce5584c1a14e8cb 100644 (file)
--- 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;
 
index dc75c11ac56134ee34eb8e577e27fcc067c5decb..1a85027fd76f292ef16804f73e43654e10b0a02e 100644 (file)
@@ -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;
index d19f5e5cea55c84858478400d074165c6ada75c4..f2f2b6b3ba2c974ff6524a21a6a0d70702a82237 100644 (file)
--- 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;