diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 21bf0f7f7..01afa096e 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -6383,6 +6383,8 @@ double Host_Frame (double time) cl.playerview[i].audio.reverbtype = 0; VectorClear(cl.playerview[i].audio.velocity); } + if (cls.state && r_worldentity.model && r_worldentity.model->loadstate == MLS_NOTLOADED) + Mod_LoadModel(cl.worldmodel, MLV_WARNSYNC); if (SCR_UpdateScreen && !vid.isminimized) { diff --git a/engine/client/image.c b/engine/client/image.c index 6db0547b8..6a5cbd6cd 100644 --- a/engine/client/image.c +++ b/engine/client/image.c @@ -37,14 +37,8 @@ cvar_t r_dodgytgafiles = CVARD("r_dodgytgafiles", "0", "Many old glquake engines cvar_t r_dodgypcxfiles = CVARD("r_dodgypcxfiles", "0", "When enabled, this will ignore the palette stored within pcx files, for compatibility with quake2."); #endif cvar_t r_dodgymiptex = CVARD("r_dodgymiptex", "1", "When enabled, this will force regeneration of mipmaps, discarding mips1-4 like glquake did. This may eg solve fullbright issues with some maps, but may reduce distant detail levels."); -static void QDECL R_Image_BuggyCvar (struct cvar_s *var, char *oldvalue) -{ //force these cvars to value 1 if they're empty. - //cvars using this should be changed to 0 by default, once our engine bugs are debugged/fixed. - if (!*var->string) - var->ival = var->value = true; -} -cvar_t r_keepimages = CVARCD("r_keepimages", "", R_Image_BuggyCvar, "Retain unused images in memory for slightly faster map loading. FIXME: a setting of 0 may be crashy! (empty is treated as 1 for now).\n0: Redundant images will be purged after each map change.\n1: Images will be retained until vid_reload (potentially consuming a lot of ram)."); -cvar_t r_ignoremapprefixes = CVARCD("r_ignoremapprefixes", "", R_Image_BuggyCvar, "Ignores when textures were loaded from map-specific paths. FIXME: empty is currently interpretted as 1 because the alternative is too memory hungary with r_keepimages 1."); +cvar_t r_keepimages = CVARD("r_keepimages", "0", "Retain unused images in memory for slightly faster map loading.\n0: Redundant images will be purged after each map change.\n1: Images will be retained until vid_reload (potentially consuming a lot of ram)."); +cvar_t r_ignoremapprefixes = CVARD("r_ignoremapprefixes", "0", "Ignores when textures were loaded from map-specific paths.\n0: textures/foo/tex.tga will not be confused with textures/foo/tex.tga.\n1: The same texture might be loaded multiple times over."); char *r_defaultimageextensions = #ifdef IMAGEFMT_DDS diff --git a/engine/gl/gl_model.c b/engine/gl/gl_model.c index dfde7b772..e4671d323 100644 --- a/engine/gl/gl_model.c +++ b/engine/gl/gl_model.c @@ -505,15 +505,18 @@ qboolean Mod_PurgeModel(model_t *mod, enum mod_purge_e ptype) #ifdef TERRAIN //we can safely flush all terrain sections at any time - if (mod->terrain && ptype != MP_MAPCHANGED) + if (mod->terrain) + { + if (ptype == MP_MAPCHANGED) + return false; //don't destroy any data there that the user might want to save. FIXME: handle better. Terr_PurgeTerrainModel(mod, false, true); + } #endif //purge any vbos if (mod->type == mod_brush) { - //brush models cannot be safely flushed. - if (ptype != MP_RESET) + if (ptype == MP_FLUSH) return false; #ifndef SERVERONLY Surf_Clear(mod); @@ -522,12 +525,7 @@ qboolean Mod_PurgeModel(model_t *mod, enum mod_purge_e ptype) #ifdef TERRAIN if (mod->type == mod_brush || mod->type == mod_heightmap) - { - //heightmap/terrain models cannot be safely flushed (brush models might have terrain embedded). - if (ptype != MP_RESET) - return false; Terr_FreeModel(mod); - } #endif if (mod->type == mod_alias) { @@ -1004,6 +1002,8 @@ void Mod_ModelLoaded(void *ctx, void *data, size_t a, size_t b) if (mod->type == mod_brush) { Surf_BuildModelLightmaps(mod); + r_oldviewcluster = -1; //just in case. + r_oldviewcluster2 = -2; } if (mod->type == mod_sprite) { diff --git a/engine/gl/gl_rlight.c b/engine/gl/gl_rlight.c index 437fcf9dc..819e248e5 100644 --- a/engine/gl/gl_rlight.c +++ b/engine/gl/gl_rlight.c @@ -737,13 +737,16 @@ void R_PushDlights (void) return; #endif - if (r_dynamic.ival <= 0|| !cl.worldmodel) + if (r_dynamic.ival <= 0|| !r_worldentity.model) return; - if (!cl.worldmodel->nodes) + if (r_worldentity.model->loadstate != MLS_LOADED) return; - currentmodel = cl.worldmodel; + if (!r_worldentity.model->nodes) + return; + + currentmodel = r_worldentity.model; if (!currentmodel->funcs.MarkLights) return; diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index c06ee2f2d..75954757f 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -5309,6 +5309,10 @@ float SV_Frame (void) if (sv.state < ss_active) //whoops... return delay; + //make sure the worldmodel is actually valid... + if (sv.world.worldmodel && sv.world.worldmodel->loadstate != MLS_LOADED) + Mod_LoadModel(sv.world.worldmodel, MLV_ERROR); + SV_CheckVars (); // send messages back to the clients that had packets read this frame