From eeb3245ce326e88255063cab25421f1d128cec20 Mon Sep 17 00:00:00 2001 From: divverent Date: Sun, 5 Oct 2008 20:08:16 +0000 Subject: [PATCH] fix engine crash when a polygon was left over and had a texture reference when switching maps git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8523 d7cf8633-e32d-0410-b094-e92efae38249 --- clvm_cmds.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/clvm_cmds.c b/clvm_cmds.c index d3da4299..656fbc4e 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -2373,6 +2373,7 @@ typedef struct vmpolygons_s { mempool_t *pool; qboolean initialized; + double progstarttime; int max_vertices; int num_vertices; @@ -2412,6 +2413,7 @@ void VM_CL_R_RenderScene (void) R_RenderView(); polys->num_vertices = polys->num_triangles = 0; + polys->progstarttime = prog->starttime; } static void VM_ResizePolygons(vmpolygons_t *polys) @@ -2463,6 +2465,8 @@ static void VM_DrawPolygonCallback (const entity_render_t *ent, const rtlight_t { int surfacelistindex; vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr(); + if(polys->progstarttime != prog->starttime) // from other progs? won't draw these (this can cause crashes!) + return; R_Mesh_ResetTextureState(); R_Mesh_Matrix(&identitymatrix); GL_CullFace(GL_NONE); @@ -2586,6 +2590,12 @@ void VM_CL_R_PolygonBegin (void) if (!polys->initialized) VM_InitPolygons(polys); + if(polys->progstarttime != prog->starttime) + { + // from another progs? then reset the polys first (fixes crashes on map change, because that can make skinframe textures invalid) + polys->num_vertices = polys->num_triangles = 0; + polys->progstarttime = prog->starttime; + } if (polys->begin_active) { VM_Warning("VM_CL_R_PolygonBegin: called twice without VM_CL_R_PolygonBegin after first\n"); -- 2.39.2