mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 19:20:46 +00:00
When defining a model with the 'model' token and there were errors, don't
let it hang around causing trouble later on; delete it right now and inform the user. Add a couple of 'static's to some functions and file scope data in mdsprite.c git-svn-id: https://svn.eduke32.com/eduke32@2237 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
b926e2a496
commit
114d8e4a36
2 changed files with 33 additions and 4 deletions
|
@ -934,6 +934,8 @@ static int32_t defsparser(scriptfile *script)
|
||||||
int32_t shadeoffs=0, pal=0, flags=0;
|
int32_t shadeoffs=0, pal=0, flags=0;
|
||||||
uint8_t usedframebitmap[1024>>3];
|
uint8_t usedframebitmap[1024>>3];
|
||||||
|
|
||||||
|
int32_t model_ok = 1;
|
||||||
|
|
||||||
static const tokenlist modeltokens[] =
|
static const tokenlist modeltokens[] =
|
||||||
{
|
{
|
||||||
{ "scale", T_SCALE },
|
{ "scale", T_SCALE },
|
||||||
|
@ -1020,6 +1022,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
|
|
||||||
if (ftilenume < 0) initprintf("Error: missing 'first tile number' for frame definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,frametokptr)), happy = 0;
|
if (ftilenume < 0) initprintf("Error: missing 'first tile number' for frame definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,frametokptr)), happy = 0;
|
||||||
if (ltilenume < 0) initprintf("Error: missing 'last tile number' for frame definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,frametokptr)), happy = 0;
|
if (ltilenume < 0) initprintf("Error: missing 'last tile number' for frame definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,frametokptr)), happy = 0;
|
||||||
|
model_ok &= happy;
|
||||||
if (!happy) break;
|
if (!happy) break;
|
||||||
|
|
||||||
if (ltilenume < ftilenume)
|
if (ltilenume < ftilenume)
|
||||||
|
@ -1057,6 +1060,8 @@ static int32_t defsparser(scriptfile *script)
|
||||||
if (framei >= 0 && framei<1024)
|
if (framei >= 0 && framei<1024)
|
||||||
usedframebitmap[framei>>3] |= (1<<(framei&7));
|
usedframebitmap[framei>>3] |= (1<<(framei&7));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model_ok &= happy;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
seenframe = 1;
|
seenframe = 1;
|
||||||
|
@ -1095,6 +1100,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
|
|
||||||
if (!startframe) initprintf("Error: missing 'start frame' for anim definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,animtokptr)), happy = 0;
|
if (!startframe) initprintf("Error: missing 'start frame' for anim definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,animtokptr)), happy = 0;
|
||||||
if (!endframe) initprintf("Error: missing 'end frame' for anim definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,animtokptr)), happy = 0;
|
if (!endframe) initprintf("Error: missing 'end frame' for anim definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,animtokptr)), happy = 0;
|
||||||
|
model_ok &= happy;
|
||||||
if (!happy) break;
|
if (!happy) break;
|
||||||
|
|
||||||
if (lastmodelid < 0)
|
if (lastmodelid < 0)
|
||||||
|
@ -1112,14 +1118,17 @@ static int32_t defsparser(scriptfile *script)
|
||||||
case -2:
|
case -2:
|
||||||
initprintf("Invalid starting frame name on line %s:%d\n",
|
initprintf("Invalid starting frame name on line %s:%d\n",
|
||||||
script->filename, scriptfile_getlinum(script,animtokptr));
|
script->filename, scriptfile_getlinum(script,animtokptr));
|
||||||
|
model_ok = 0;
|
||||||
break;
|
break;
|
||||||
case -3:
|
case -3:
|
||||||
initprintf("Invalid ending frame name on line %s:%d\n",
|
initprintf("Invalid ending frame name on line %s:%d\n",
|
||||||
script->filename, scriptfile_getlinum(script,animtokptr));
|
script->filename, scriptfile_getlinum(script,animtokptr));
|
||||||
|
model_ok = 0;
|
||||||
break;
|
break;
|
||||||
case -4:
|
case -4:
|
||||||
initprintf("Out of memory on line %s:%d\n",
|
initprintf("Out of memory on line %s:%d\n",
|
||||||
script->filename, scriptfile_getlinum(script,animtokptr));
|
script->filename, scriptfile_getlinum(script,animtokptr));
|
||||||
|
model_ok = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1168,6 +1177,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
if (!skinfn)
|
if (!skinfn)
|
||||||
{
|
{
|
||||||
initprintf("Error: missing 'skin filename' for skin definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,skintokptr));
|
initprintf("Error: missing 'skin filename' for skin definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,skintokptr));
|
||||||
|
model_ok = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1201,14 +1211,17 @@ static int32_t defsparser(scriptfile *script)
|
||||||
case -2:
|
case -2:
|
||||||
initprintf("Invalid skin filename on line %s:%d\n",
|
initprintf("Invalid skin filename on line %s:%d\n",
|
||||||
script->filename, scriptfile_getlinum(script,skintokptr));
|
script->filename, scriptfile_getlinum(script,skintokptr));
|
||||||
|
model_ok = 0;
|
||||||
break;
|
break;
|
||||||
case -3:
|
case -3:
|
||||||
initprintf("Invalid palette number on line %s:%d\n",
|
initprintf("Invalid palette number on line %s:%d\n",
|
||||||
script->filename, scriptfile_getlinum(script,skintokptr));
|
script->filename, scriptfile_getlinum(script,skintokptr));
|
||||||
|
model_ok = 0;
|
||||||
break;
|
break;
|
||||||
case -4:
|
case -4:
|
||||||
initprintf("Out of memory on line %s:%d\n",
|
initprintf("Out of memory on line %s:%d\n",
|
||||||
script->filename, scriptfile_getlinum(script,skintokptr));
|
script->filename, scriptfile_getlinum(script,skintokptr));
|
||||||
|
model_ok = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1271,6 +1284,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
|
|
||||||
if (ftilenume < 0) initprintf("Error: missing 'first tile number' for hud definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,hudtokptr)), happy = 0;
|
if (ftilenume < 0) initprintf("Error: missing 'first tile number' for hud definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,hudtokptr)), happy = 0;
|
||||||
if (ltilenume < 0) initprintf("Error: missing 'last tile number' for hud definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,hudtokptr)), happy = 0;
|
if (ltilenume < 0) initprintf("Error: missing 'last tile number' for hud definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,hudtokptr)), happy = 0;
|
||||||
|
model_ok &= happy;
|
||||||
if (!happy) break;
|
if (!happy) break;
|
||||||
|
|
||||||
if (ltilenume < ftilenume)
|
if (ltilenume < ftilenume)
|
||||||
|
@ -1306,6 +1320,8 @@ static int32_t defsparser(scriptfile *script)
|
||||||
happy = 0;
|
happy = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model_ok &= happy;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1313,6 +1329,17 @@ static int32_t defsparser(scriptfile *script)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!model_ok)
|
||||||
|
{
|
||||||
|
if (lastmodelid >= 0)
|
||||||
|
{
|
||||||
|
initprintf("Removing model %d due to errors.\n", lastmodelid);
|
||||||
|
md_undefinemodel(lastmodelid);
|
||||||
|
nextmodelid--;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
md_setmisc(lastmodelid,(float)scale,shadeoffs,(float)mzadd,flags);
|
md_setmisc(lastmodelid,(float)scale,shadeoffs,(float)mzadd,flags);
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ static void QuitOnFatalError(const char *msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t addtileP(int32_t model,int32_t tile,int32_t pallet)
|
static int32_t addtileP(int32_t model,int32_t tile,int32_t pallet)
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(model);
|
UNREFERENCED_PARAMETER(model);
|
||||||
if (curextra==MAXTILES+EXTRATILES-2)return curextra;
|
if (curextra==MAXTILES+EXTRATILES-2)return curextra;
|
||||||
|
@ -75,7 +75,7 @@ static GLuint *indexvbos = NULL;
|
||||||
|
|
||||||
mdmodel_t *mdload(const char *);
|
mdmodel_t *mdload(const char *);
|
||||||
int32_t mddraw(spritetype *);
|
int32_t mddraw(spritetype *);
|
||||||
void mdfree(mdmodel_t *);
|
static void mdfree(mdmodel_t *);
|
||||||
int32_t globalnoeffect=0;
|
int32_t globalnoeffect=0;
|
||||||
|
|
||||||
extern int32_t timerticspersec;
|
extern int32_t timerticspersec;
|
||||||
|
@ -501,6 +501,8 @@ int32_t md_undefinetile(int32_t tile)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* this function is problematic, it leaves NULL holes in model[]
|
||||||
|
* (which runs from 0 to nextmodelid-1) */
|
||||||
int32_t md_undefinemodel(int32_t modelid)
|
int32_t md_undefinemodel(int32_t modelid)
|
||||||
{
|
{
|
||||||
int32_t i;
|
int32_t i;
|
||||||
|
@ -520,8 +522,8 @@ int32_t md_undefinemodel(int32_t modelid)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
md2model_t *modelhead;
|
static md2model_t *modelhead;
|
||||||
mdskinmap_t *skhead;
|
static mdskinmap_t *skhead;
|
||||||
|
|
||||||
static int32_t daskinloader(int32_t filh, intptr_t *fptr, int32_t *bpl, int32_t *sizx, int32_t *sizy, int32_t *osizx, int32_t *osizy, char *hasalpha, int32_t pal, char effect)
|
static int32_t daskinloader(int32_t filh, intptr_t *fptr, int32_t *bpl, int32_t *sizx, int32_t *sizy, int32_t *osizx, int32_t *osizy, char *hasalpha, int32_t pal, char effect)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue