From 9b57e0ea51107228b069eabdeccb62a4248c7ee7 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Thu, 15 Nov 2012 06:42:57 +0000 Subject: [PATCH] Address crash when model skins have invalid file names. Affected surfaces will not be drawn, but FPS will plummet as mdloadskin() is called repeatedly. A more optimal solution would either flag the surface as invalid (so the renderers skip it) or reject the entire model when defs are loaded. http://forums.duke4.net/topic/6031-eduke32-crashes-if-hrp-model-skin-not-available/ git-svn-id: https://svn.eduke32.com/eduke32@3164 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/mdsprite.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/polymer/eduke32/build/src/mdsprite.c b/polymer/eduke32/build/src/mdsprite.c index 24ae4c027..4ecce3b09 100644 --- a/polymer/eduke32/build/src/mdsprite.c +++ b/polymer/eduke32/build/src/mdsprite.c @@ -797,10 +797,14 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf) //OSD_Printf("Using def skin 0,0 as fallback, pal=%d\n", pal); } else + return 0; +#if 0 { + // fall back to the model-defined texture if ((unsigned)number >= (unsigned)m->numskins) number = 0; + // m->skinfn is undefined when md3model_t is cast to md2model_t --> crash skinfile = m->skinfn + number*64; texidx = &m->texid[number*(HICEFFECTMASK+1) + hicfxmask(pal)]; Bstrncpyz(fn, m->basepath, BMAX_PATH); @@ -808,6 +812,7 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf) Bstrcat(fn,skinfile); //OSD_Printf("Using MD2/MD3 skin (%d) %s, pal=%d\n",number,skinfile,pal); } +#endif } if (!skinfile[0])