mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Clear the world to prevent crashes
This commit is contained in:
parent
4d12bcb184
commit
86ddec3f76
4 changed files with 36 additions and 6 deletions
|
@ -2432,11 +2432,23 @@ void RE_LoadWorldMap( const char *name ) {
|
|||
UI_LoadResource("*116");
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
RE_MapVersion
|
||||
|
||||
=================
|
||||
*/
|
||||
int RE_MapVersion(void)
|
||||
{
|
||||
return map_version;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
RE_PrintBSPFileSizes
|
||||
|
||||
=================
|
||||
*/
|
||||
void RE_PrintBSPFileSizes(void)
|
||||
{
|
||||
ri.Printf(PRINT_ALL, "%s: %i\n", s_worldData.name, map_length);
|
||||
|
@ -2466,3 +2478,15 @@ void RE_PrintBSPFileSizes(void)
|
|||
ri.Printf(PRINT_ALL, "%6i static models defs %7i\n", g_nStaticModels, 164 * g_nStaticModels);
|
||||
ri.Printf(PRINT_ALL, " static model indexes %7i\n", g_nStaticModelIndices);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
R_ClearWorld
|
||||
|
||||
Set the world to NULL to prevent anyone from accessing
|
||||
freed world data
|
||||
=================
|
||||
*/
|
||||
void R_ClearWorld(void) {
|
||||
tr.world = NULL;
|
||||
}
|
||||
|
|
|
@ -1583,6 +1583,13 @@ void RE_BeginRegistration(glconfig_t* glconfigOut) {
|
|||
tr.viewCluster = -1; // force markleafs to regenerate
|
||||
R_ClearFlares();
|
||||
RE_ClearScene();
|
||||
|
||||
// Added in OPM
|
||||
// Clear the world because some components
|
||||
// like the mark system access the world object
|
||||
// to free allocated marks
|
||||
R_ClearWorld();
|
||||
|
||||
R_SetupShaders();
|
||||
R_InitLensFlare();
|
||||
R_LevelMarksInit();
|
||||
|
|
|
@ -1757,6 +1757,7 @@ void RE_SetWorldVisData( const byte *vis );
|
|||
qhandle_t RE_RegisterModel( const char *name );
|
||||
qhandle_t RE_RegisterSkin( const char *name );
|
||||
void RE_Shutdown( qboolean destroyWindow );
|
||||
void R_ClearWorld(void);
|
||||
|
||||
qboolean R_GetEntityToken( char *buffer, int size );
|
||||
|
||||
|
|
|
@ -1593,12 +1593,10 @@ void R_LevelMarksFree()
|
|||
for (i = tr.world->numDecisionNodes; i < tr.world->numnodes; i++) {
|
||||
mnode_t *pLeaf = &tr.world->nodes[i];
|
||||
|
||||
if (pLeaf->iNumMarkFragment) {
|
||||
if (pLeaf->pFirstMarkFragment) {
|
||||
ri.Free(pLeaf->pFirstMarkFragment);
|
||||
pLeaf->pFirstMarkFragment = NULL;
|
||||
pLeaf->iNumMarkFragment = 0;
|
||||
}
|
||||
if (pLeaf->iNumMarkFragment && pLeaf->pFirstMarkFragment) {
|
||||
ri.Free(pLeaf->pFirstMarkFragment);
|
||||
pLeaf->pFirstMarkFragment = NULL;
|
||||
pLeaf->iNumMarkFragment = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue