diff --git a/r_decals.c b/r_decals.c index 8aba9c42..15c6748d 100644 --- a/r_decals.c +++ b/r_decals.c @@ -1173,7 +1173,7 @@ int R_CreateDecalList( decallist_t *pList ) int total = 0; int i, depth; - return 0; // crash on changelevel. API bug? +// return 0; // crash on changelevel. API bug? if( WORLDMODEL ) { diff --git a/r_main.c b/r_main.c index e1cf762a..07fbd91c 100644 --- a/r_main.c +++ b/r_main.c @@ -1822,44 +1822,51 @@ R_NewMap */ void R_NewMap (void) { - r_viewcluster = -1; + int i; + r_viewcluster = -1; + R_ClearDecals(); // clear all level decals + R_StudioResetPlayerModels(); - D_FlushCaches( true ); + D_FlushCaches( true ); - r_cnumsurfs = sw_maxsurfs->value; + r_cnumsurfs = sw_maxsurfs->value; - if (r_cnumsurfs <= MINSURFACES) - r_cnumsurfs = MINSURFACES; + if (r_cnumsurfs <= MINSURFACES) + r_cnumsurfs = MINSURFACES; - if (r_cnumsurfs > NUMSTACKSURFACES) - { - surfaces = Mem_Calloc (r_temppool, r_cnumsurfs * sizeof(surf_t)); - surface_p = surfaces; - surf_max = &surfaces[r_cnumsurfs]; - r_surfsonstack = false; - // surface 0 doesn't really exist; it's just a dummy because index 0 - // is used to indicate no edge attached to surface - surfaces--; - R_SurfacePatch (); - } - else - { - r_surfsonstack = true; - } + if (r_cnumsurfs > NUMSTACKSURFACES) + { + surfaces = Mem_Calloc (r_temppool, r_cnumsurfs * sizeof(surf_t)); + surface_p = surfaces; + surf_max = &surfaces[r_cnumsurfs]; + r_surfsonstack = false; + // surface 0 doesn't really exist; it's just a dummy because index 0 + // is used to indicate no edge attached to surface + surfaces--; + R_SurfacePatch (); + } + else + { + r_surfsonstack = true; + } - r_numallocatededges = sw_maxedges->value; + r_numallocatededges = sw_maxedges->value; - if (r_numallocatededges < MINEDGES) - r_numallocatededges = MINEDGES; + if (r_numallocatededges < MINEDGES) + r_numallocatededges = MINEDGES; - if (r_numallocatededges <= NUMSTACKEDGES) - { - auxedges = NULL; - } - else - { - auxedges = malloc (r_numallocatededges * sizeof(edge_t)); - } + if (r_numallocatededges <= NUMSTACKEDGES) + { + auxedges = NULL; + } + else + { + auxedges = malloc (r_numallocatededges * sizeof(edge_t)); + } + + // clear out efrags in case the level hasn't been reloaded + for( i = 0; i < WORLDMODEL->numleafs; i++ ) + WORLDMODEL->leafs[i+1].efrags = NULL; } /*