]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
cl_main: Fix double free of meshentities texture pool when running gamedir
authorCloudwalk <cloudwalk009@gmail.com>
Thu, 22 Jul 2021 16:30:36 +0000 (12:30 -0400)
committerCloudwalk <cloudwalk009@gmail.com>
Thu, 22 Jul 2021 16:30:36 +0000 (12:30 -0400)
Implemented start and shutdown routines for its render module

cl_main.c

index e4d56733a18ba40c7f93b5ce241f1d1e35b2b46f..343aadbac0309e53066f95e8066571e9f7a12bea 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -2521,6 +2521,28 @@ static void CL_MeshEntities_Restart(void)
        }
 }
 
+static void CL_MeshEntities_Start(void)
+{
+       int i;
+       entity_t *ent;
+       for(i = 0; i < NUM_MESHENTITIES; i++)
+       {
+               ent = cl_meshentities + i;
+               Mod_Mesh_Create(ent->render.model, cl_meshentitynames[i]);
+       }
+}
+
+static void CL_MeshEntities_Shutdown(void)
+{
+       int i;
+       entity_t *ent;
+       for(i = 0; i < NUM_MESHENTITIES; i++)
+       {
+               ent = cl_meshentities + i;
+               Mod_Mesh_Destroy(ent->render.model);
+       }
+}
+
 static void CL_MeshEntities_Init(void)
 {
        int i;
@@ -2557,7 +2579,7 @@ static void CL_MeshEntities_Init(void)
                CL_UpdateRenderEntity(&ent->render);
        }
        cl_meshentities[MESH_UI].render.flags = RENDER_NOSELFSHADOW;
-       R_RegisterModule("cl_meshentities", CL_MeshEntities_Restart, CL_MeshEntities_Restart, CL_MeshEntities_Restart, CL_MeshEntities_Restart, CL_MeshEntities_Restart);
+       R_RegisterModule("cl_meshentities", CL_MeshEntities_Start, CL_MeshEntities_Shutdown, CL_MeshEntities_Restart, CL_MeshEntities_Restart, CL_MeshEntities_Restart);
 }
 
 void CL_MeshEntities_Scene_Clear(void)
@@ -2579,10 +2601,6 @@ void CL_MeshEntities_Scene_FinalizeRenderEntity(void)
        VectorCopy(ent->render.model->normalmaxs, ent->render.maxs);
 }
 
-static void CL_MeshEntities_Shutdown(void)
-{
-}
-
 extern cvar_t r_overheadsprites_pushback;
 extern cvar_t r_fullbright_directed_pitch_relative;
 extern cvar_t r_fullbright_directed_pitch;