From: havoc Date: Mon, 15 Sep 2003 02:21:50 +0000 (+0000) Subject: fixed empty texture lump handling in q1bsp loading X-Git-Tag: xonotic-v0.1.0preview~6381 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7753375bf2e4a4b58704a324462c37fde4420fd7;p=xonotic%2Fdarkplaces.git fixed empty texture lump handling in q1bsp loading git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3462 d7cf8633-e32d-0410-b094-e92efae38249 --- 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