mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-17 18:40:02 +00:00
ref_soft: Fix R_NewMap, prevent crashes on changelevel/restart
This commit is contained in:
parent
e0cd5edddb
commit
cefe42fd66
@ -1173,7 +1173,7 @@ int R_CreateDecalList( decallist_t *pList )
|
|||||||
int total = 0;
|
int total = 0;
|
||||||
int i, depth;
|
int i, depth;
|
||||||
|
|
||||||
return 0; // crash on changelevel. API bug?
|
// return 0; // crash on changelevel. API bug?
|
||||||
|
|
||||||
if( WORLDMODEL )
|
if( WORLDMODEL )
|
||||||
{
|
{
|
||||||
|
69
r_main.c
69
r_main.c
@ -1822,44 +1822,51 @@ R_NewMap
|
|||||||
*/
|
*/
|
||||||
void R_NewMap (void)
|
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)
|
if (r_cnumsurfs <= MINSURFACES)
|
||||||
r_cnumsurfs = MINSURFACES;
|
r_cnumsurfs = MINSURFACES;
|
||||||
|
|
||||||
if (r_cnumsurfs > NUMSTACKSURFACES)
|
if (r_cnumsurfs > NUMSTACKSURFACES)
|
||||||
{
|
{
|
||||||
surfaces = Mem_Calloc (r_temppool, r_cnumsurfs * sizeof(surf_t));
|
surfaces = Mem_Calloc (r_temppool, r_cnumsurfs * sizeof(surf_t));
|
||||||
surface_p = surfaces;
|
surface_p = surfaces;
|
||||||
surf_max = &surfaces[r_cnumsurfs];
|
surf_max = &surfaces[r_cnumsurfs];
|
||||||
r_surfsonstack = false;
|
r_surfsonstack = false;
|
||||||
// surface 0 doesn't really exist; it's just a dummy because index 0
|
// surface 0 doesn't really exist; it's just a dummy because index 0
|
||||||
// is used to indicate no edge attached to surface
|
// is used to indicate no edge attached to surface
|
||||||
surfaces--;
|
surfaces--;
|
||||||
R_SurfacePatch ();
|
R_SurfacePatch ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
r_surfsonstack = true;
|
r_surfsonstack = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
r_numallocatededges = sw_maxedges->value;
|
r_numallocatededges = sw_maxedges->value;
|
||||||
|
|
||||||
if (r_numallocatededges < MINEDGES)
|
if (r_numallocatededges < MINEDGES)
|
||||||
r_numallocatededges = MINEDGES;
|
r_numallocatededges = MINEDGES;
|
||||||
|
|
||||||
if (r_numallocatededges <= NUMSTACKEDGES)
|
if (r_numallocatededges <= NUMSTACKEDGES)
|
||||||
{
|
{
|
||||||
auxedges = NULL;
|
auxedges = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auxedges = malloc (r_numallocatededges * sizeof(edge_t));
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user