A couple of small tweaks:

- fix arg checking in checkdefs.sh
 - some tilenum and quote ID validation in the CON interpreter
 - G_DrawDigiNum and friends: eliminate redundant strlen calls

git-svn-id: https://svn.eduke32.com/eduke32@2086 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-10-30 19:46:51 +00:00
parent 35a151d2cd
commit d37ef521fb
4 changed files with 48 additions and 17 deletions

View file

@ -10719,9 +10719,10 @@ int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, in
int32_t cfz1[2], cfz2[2]; // both wrt dasectnum
int16_t bn[2];
#endif
Bmemset(&pendingvec, 0, sizeof(vec3_t)); // compiler-happy
#endif
Bmemset(sectbitmap, 0, (numsectors+7)>>3);
#ifdef YAX_ENABLE
@ -15824,7 +15825,8 @@ int32_t setrendermode(int32_t renderer)
}
if (!md3postload_polymer((md3model_t *)models[i]))
OSD_Printf("INTERNAL ERROR: mdmodel %d failed postprocessing!\n", i);
OSD_Printf("INTERNAL ERROR: mdmodel %s failed postprocessing!\n",
((md3model_t *)models[i])->head.nam);
if (((md3model_t *)models[i])->head.surfs[0].geometry == NULL)
OSD_Printf("INTERNAL ERROR: wtf?\n");

View file

@ -2,6 +2,7 @@
if [ -z "$1" ]; then
echo 'Usage: checkdefs.sh <some.def> [[<some_dir>] -patch]'
exit 1
fi
deffn="$1"
@ -14,6 +15,7 @@ fi
if [ -n "$3" ]; then
if [ "$3" != "-patch" ]; then
echo 'Usage: checkdefs.sh <some.def> [[<some_dir>] -patch]'
exit 1
fi
fi

View file

@ -922,10 +922,9 @@ static void G_DrawWeapAmounts(DukePlayer_t *p,int32_t x,int32_t y,int32_t u)
static void G_DrawDigiNum(int32_t x,int32_t y,int32_t n,char s,int32_t cs)
{
int32_t i, j = 0, k, p, c;
char b[10];
char b[12];
Bsnprintf(b,10,"%d",n);
i = Bstrlen(b);
i = Bsprintf(b,"%d",n);
for (k=i-1; k>=0; k--)
{
@ -947,16 +946,15 @@ void G_DrawTXDigiNumZ(int32_t starttile, int32_t x,int32_t y,int32_t n,int32_t s
int32_t cs,int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t z)
{
int32_t i, j = 0, k, p, c;
char b[10];
char b[12];
int32_t shift = (cs&ROTATESPRITE_MAX)?0:16;
//ltoa(n,b,10);
Bsnprintf(b,10,"%d",n);
i = Bstrlen(b);
i = Bsprintf(b,"%d",n);
for (k=i-1; k>=0; k--)
{
p = starttile+*(b+k)-'0';
p = starttile + b[k]-'0';
j += ((1+tilesizx[p])*z)>>16;
}
if (cs&ROTATESPRITE_MAX) j<<=16;
@ -965,7 +963,7 @@ void G_DrawTXDigiNumZ(int32_t starttile, int32_t x,int32_t y,int32_t n,int32_t s
j = 0;
for (k=0; k<i; k++)
{
p = starttile+*(b+k)-'0';
p = starttile + b[k]-'0';
rotatesprite((c+j)<<shift,y<<shift,z,0,p,s,pal,2|cs,x1,y1,x2,y2);
j += (((1+tilesizx[p])*z)>>((cs&ROTATESPRITE_MAX)?0:16));
}
@ -974,15 +972,14 @@ void G_DrawTXDigiNumZ(int32_t starttile, int32_t x,int32_t y,int32_t n,int32_t s
static void G_DrawAltDigiNum(int32_t x,int32_t y,int32_t n,char s,int32_t cs)
{
int32_t i, j = 0, k, p, c;
char b[10];
char b[12];
int32_t rev = (x < 0);
int32_t shd = (y < 0);
if (rev) x = -x;
if (shd) y = -y;
Bsnprintf(b,10,"%d",n);
i = Bstrlen(b);
i = Bsprintf(b,"%d",n);
for (k=i-1; k>=0; k--)
{

View file

@ -2288,7 +2288,7 @@ nullquote:
int32_t y2=scale(Gv_GetVarX(*insptr++),ydim,200);
int32_t smoothratio = min(max((totalclock - ototalclock) * (65536 / 4),0),65536);
#ifdef USE_OPENGL
int32_t j;
int32_t oprojhacks;
#endif
if (g_screenCapture) continue;
@ -2308,7 +2308,7 @@ nullquote:
}
#ifdef USE_OPENGL
j = glprojectionhacks;
oprojhacks = glprojectionhacks;
glprojectionhacks = 0;
#endif
setview(x1,y1,x2,y2);
@ -2373,7 +2373,7 @@ nullquote:
G_RestoreInterpolations();
G_UpdateScreenArea();
#ifdef USE_OPENGL
glprojectionhacks = j;
glprojectionhacks = oprojhacks;
#endif
continue;
}
@ -2394,7 +2394,13 @@ nullquote:
y<<=16;
}
if (x < (-320)<<16 || x >= (640<<16) || y < (-200)<<16 || y >= (400<<16))
if ((unsigned)tilenum >= MAXTILES)
{
OSD_Printf(CON_ERROR "invalid tilenum %d\n", g_errorLineNum, keyw[g_tw], tilenum);
continue;
}
if (x < -(320<<16) || x >= (640<<16) || y < -(200<<16) || y >= (400<<16))
{
OSD_Printf(CON_ERROR "invalid coordinates: %d, %d\n",g_errorLineNum, keyw[g_tw], x, y);
continue;
@ -2416,6 +2422,18 @@ nullquote:
int32_t x2=Gv_GetVarX(*insptr++), y2=Gv_GetVarX(*insptr++);
int32_t z = (tw == CON_GAMETEXTZ) ? Gv_GetVarX(*insptr++) : 65536;
if (tilenum < 0 || tilenum+255 >= MAXTILES)
{
OSD_Printf(CON_ERROR "invalid base tilenum %d\n", g_errorLineNum, keyw[g_tw], tilenum);
continue;
}
if ((unsigned)q >= MAXQUOTES)
{
OSD_Printf(CON_ERROR "invalid quote ID %d\n", g_errorLineNum, keyw[g_tw], q);
continue;
}
if ((ScriptQuotes[q] == NULL))
{
OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],q);
@ -2440,6 +2458,12 @@ nullquote:
int32_t x2=Gv_GetVarX(*insptr++), y2=Gv_GetVarX(*insptr++);
int32_t z = (tw == CON_DIGITALNUMBERZ) ? Gv_GetVarX(*insptr++) : 65536;
if (tilenum < 0 || tilenum+'9' >= MAXTILES)
{
OSD_Printf(CON_ERROR "invalid base tilenum %d\n", g_errorLineNum, keyw[g_tw], tilenum);
continue;
}
G_DrawTXDigiNumZ(tilenum,x,y,q,shade,pal,orientation,x1,y1,x2,y2,z);
continue;
}
@ -2450,6 +2474,12 @@ nullquote:
int32_t x=Gv_GetVarX(*insptr++), y=Gv_GetVarX(*insptr++), q=Gv_GetVarX(*insptr++);
int32_t shade=Gv_GetVarX(*insptr++), pal=Gv_GetVarX(*insptr++);
if ((unsigned)q >= MAXQUOTES)
{
OSD_Printf(CON_ERROR "invalid quote ID %d\n", g_errorLineNum, keyw[g_tw], q);
continue;
}
if ((ScriptQuotes[q] == NULL))
{
OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],q);