From 7753375bf2e4a4b58704a324462c37fde4420fd7 Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 15 Sep 2003 02:21:50 +0000 Subject: [PATCH] fixed empty texture lump handling in q1bsp loading git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3462 d7cf8633-e32d-0410-b094-e92efae38249 --- model_brush.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/model_brush.c b/model_brush.c index d63e9003..d6a220ea 100644 --- a/model_brush.c +++ b/model_brush.c @@ -737,15 +737,19 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l) loadmodel->brushq1.textures = NULL; - if (!l->filelen) - return; - - m = (dmiptexlump_t *)(mod_base + l->fileofs); - - m->nummiptex = LittleLong (m->nummiptex); - // add two slots for notexture walls and notexture liquids - loadmodel->brushq1.numtextures = m->nummiptex + 2; + if (l->filelen) + { + m = (dmiptexlump_t *)(mod_base + l->fileofs); + m->nummiptex = LittleLong (m->nummiptex); + loadmodel->brushq1.numtextures = m->nummiptex + 2; + } + else + { + m = NULL; + loadmodel->brushq1.numtextures = 2; + } + loadmodel->brushq1.textures = Mem_Alloc(loadmodel->mempool, loadmodel->brushq1.numtextures * sizeof(texture_t)); // fill out all slots with notexture @@ -766,6 +770,9 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l) tx->currentframe = tx; } + if (!m) + return; + // just to work around bounds checking when debugging with it (array index out of bounds error thing) dofs = m->dataofs; // LordHavoc: mostly rewritten map texture loader -- 2.39.2