diff --git a/engine/client/client.h b/engine/client/client.h index a73af3be3..6c90e2b45 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -1452,7 +1452,7 @@ qboolean CL_MayLerp(void); // #ifdef CSQC_DAT qboolean CSQC_Inited(void); -void CSQC_RendererRestarted(void); +void CSQC_RendererRestarted(qboolean initing); qboolean CSQC_UnconnectedOkay(qboolean inprinciple); qboolean CSQC_UnconnectedInit(void); qboolean CSQC_CheckDownload(const char *name, unsigned int checksum, size_t checksize); //reports whether we already have a usable csprogs.dat diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index c749d8ea9..70a079cc4 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -793,7 +793,7 @@ static model_t *CSQC_GetModelForIndex(int index) else if (index < 0 && index > -MAX_CSMODELS) { if (!cl.model_csqcprecache[-index]) - cl.model_csqcprecache[-index] = Mod_ForName(Mod_FixName(cl.model_csqcname[-index], csqc_world.worldmodel->publicname), MLV_WARN); + cl.model_csqcprecache[-index] = Mod_ForName(Mod_FixName(cl.model_csqcname[-index], csqc_world.worldmodel?csqc_world.worldmodel->publicname:NULL), MLV_WARN); return cl.model_csqcprecache[-index]; } else @@ -2770,7 +2770,8 @@ static void QCBUILTIN PF_R_RenderScene(pubprogfuncs_t *prinst, struct globalvars { csqc_worldchanged = false; cl.worldmodel = r_worldentity.model = csqc_world.worldmodel; - FS_LoadMapPackFile(cl.worldmodel->name, cl.worldmodel->archive); + if (cl.worldmodel) + FS_LoadMapPackFile(cl.worldmodel->name, cl.worldmodel->archive); Surf_NewMap(csqc_world.worldmodel); CL_UpdateWindowTitle(); @@ -8552,7 +8553,7 @@ qboolean CSQC_Init (qboolean anycsqc, const char *csprogsname, unsigned int chec csqc_world.physicstime = 0.1; - CSQC_RendererRestarted(); + CSQC_RendererRestarted(true); if (cls.state == ca_disconnected) CSQC_WorldLoaded(); @@ -8561,17 +8562,36 @@ qboolean CSQC_Init (qboolean anycsqc, const char *csprogsname, unsigned int chec return true; //success! } -void CSQC_RendererRestarted(void) +void CSQC_RendererRestarted(qboolean initing) { int i; if (!csqcprogs) return; - csqc_world.worldmodel = cl.worldmodel; - - for (i = 0; i < MAX_CSMODELS; i++) + if (initing) { - cl.model_csqcprecache[i] = NULL; + //called at startup + if (csqc_worldchanged) + { + csqc_worldchanged = false; + cl.worldmodel = r_worldentity.model = csqc_world.worldmodel; + if (cl.worldmodel) + FS_LoadMapPackFile(cl.worldmodel->name, cl.worldmodel->archive); + Surf_NewMap(csqc_world.worldmodel); + CL_UpdateWindowTitle(); + + World_RBE_Shutdown(&csqc_world); + World_RBE_Start(&csqc_world); + } + } + else + { //FIXME: this might be awkward in the purecsqc case. + csqc_world.worldmodel = cl.worldmodel; + + for (i = 0; i < MAX_CSMODELS; i++) + { + cl.model_csqcprecache[i] = NULL; + } } //FIXME: registered shaders diff --git a/engine/client/renderer.c b/engine/client/renderer.c index aa3a4df1b..46d9bf389 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -1895,7 +1895,7 @@ TRACE(("dbg: R_ApplyRenderer: efrags\n")); #endif #ifdef CSQC_DAT Shader_DoReload(); - CSQC_RendererRestarted(); + CSQC_RendererRestarted(false); #endif #ifdef MENU_DAT MP_RendererRestarted();