From 27e68e85e5a964c0f2ff8737a2dc6178d2dc23cb Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sat, 10 Mar 2012 09:44:54 +0000 Subject: [PATCH] Add file existence check for model skins. git-svn-id: https://svn.eduke32.com/eduke32@2436 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/defs.c | 44 +++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/polymer/eduke32/build/src/defs.c b/polymer/eduke32/build/src/defs.c index 58951b395..409a92422 100644 --- a/polymer/eduke32/build/src/defs.c +++ b/polymer/eduke32/build/src/defs.c @@ -830,8 +830,8 @@ static int32_t defsparser(scriptfile *script) break; case T_DEFINEMODELSKIN: { - int32_t palnum; - char *skinfn; + int32_t palnum, i; + char *skinfn, *tfn = NULL; if (scriptfile_getsymbol(script,&palnum)) break; if (scriptfile_getstring(script,&skinfn)) break; //skin filename @@ -851,6 +851,24 @@ static int32_t defsparser(scriptfile *script) if (seenframe) { modelskin = ++lastmodelskin; } seenframe = 0; + i = pathsearchmode; + pathsearchmode = 1; + if (findfrompath(skinfn,&tfn) < 0) + { + char buf[BMAX_PATH]; + + Bstrcpy(buf,skinfn); + kzfindfilestart(buf); + if (!kzfindfile(buf)) + { + initprintf("Error: file '%s' does not exist\n",skinfn); + pathsearchmode = i; + break; + } + } + else Bfree(tfn); + pathsearchmode = i; + #ifdef USE_OPENGL switch (md_defineskin(lastmodelid, skinfn, palnum, max(0,modelskin), 0, 0.0f, 1.0f, 1.0f)) { @@ -1151,8 +1169,8 @@ static int32_t defsparser(scriptfile *script) case T_SKIN: case T_DETAIL: case T_GLOW: case T_SPECULAR: case T_NORMAL: { char *skintokptr = script->ltextptr; - char *skinend, *skinfn = 0; - int32_t palnum = 0, surfnum = 0; + char *skinend, *skinfn = 0, *tfn = NULL; + int32_t palnum = 0, surfnum = 0, i; double param = 1.0, specpower = 1.0, specfactor = 1.0; static const tokenlist modelskintokens[] = @@ -1215,6 +1233,24 @@ static int32_t defsparser(scriptfile *script) break; } + i = pathsearchmode; + pathsearchmode = 1; + if (findfrompath(skinfn,&tfn) < 0) + { + char buf[BMAX_PATH]; + + Bstrcpy(buf,skinfn); + kzfindfilestart(buf); + if (!kzfindfile(buf)) + { + initprintf("Error: file '%s' does not exist\n",skinfn); + pathsearchmode = i; + break; + } + } + else Bfree(tfn); + pathsearchmode = i; + #ifdef USE_OPENGL switch (md_defineskin(lastmodelid, skinfn, palnum, max(0,modelskin), surfnum, param, specpower, specfactor)) {