mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Fixes former crash in drawline16 and swaps drawpixel with the unsafe variant there; fixes potential sector[-1] access in sliding Star Trek doors; make CC overridable in Makefiles so that other toolchains or static analyzers like scan-build/clang can be used; with its help, fix some issues, some more severe than others.
git-svn-id: https://svn.eduke32.com/eduke32@1736 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
e043431060
commit
4a5e89f0dd
11 changed files with 98 additions and 57 deletions
|
@ -16,7 +16,7 @@ SUPERBUILD = 1
|
||||||
POLYMOST = 1
|
POLYMOST = 1
|
||||||
POLYMER = 1
|
POLYMER = 1
|
||||||
USE_OPENGL = 1
|
USE_OPENGL = 1
|
||||||
NOASM = 0
|
NOASM ?= 0
|
||||||
LINKED_GTK = 0
|
LINKED_GTK = 0
|
||||||
BUILD32_ON_64 = 0
|
BUILD32_ON_64 = 0
|
||||||
NEDMALLOC = 1
|
NEDMALLOC = 1
|
||||||
|
@ -71,7 +71,7 @@ JAUDIOLIB=libjfaudiolib.a
|
||||||
ENETDIR=$(SRC)/enet
|
ENETDIR=$(SRC)/enet
|
||||||
ENETLIB=libenet.a
|
ENETLIB=libenet.a
|
||||||
|
|
||||||
CC=gcc
|
CC?=gcc
|
||||||
CXX=g++
|
CXX=g++
|
||||||
AS=nasm
|
AS=nasm
|
||||||
RC=windres
|
RC=windres
|
||||||
|
|
|
@ -94,7 +94,7 @@ ifneq (0,$(DEBUGANYWAY))
|
||||||
debug+=-ggdb
|
debug+=-ggdb
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CC=gcc
|
CC?=gcc
|
||||||
CXX=gcc
|
CXX=gcc
|
||||||
AS=nasm
|
AS=nasm
|
||||||
RC=windres
|
RC=windres
|
||||||
|
|
|
@ -460,7 +460,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
}
|
}
|
||||||
case T_TILEFROMTEXTURE:
|
case T_TILEFROMTEXTURE:
|
||||||
{
|
{
|
||||||
char *texturetokptr = script->ltextptr, *textureend, *fn, *tfn = NULL, *ftd = NULL;
|
char *texturetokptr = script->ltextptr, *textureend, *fn = NULL, *tfn = NULL, *ftd = NULL;
|
||||||
int32_t tile=-1, token, i;
|
int32_t tile=-1, token, i;
|
||||||
int32_t alphacut = 255;
|
int32_t alphacut = 255;
|
||||||
int32_t xoffset = 0, yoffset = 0;
|
int32_t xoffset = 0, yoffset = 0;
|
||||||
|
@ -1404,6 +1404,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
for (i=0; i<6; i++)
|
for (i=0; i<6; i++)
|
||||||
{
|
{
|
||||||
if (!fn[i]) initprintf("Error: missing '%s filename' for skybox definition near line %s:%d\n", skyfaces[i], script->filename, scriptfile_getlinum(script,skyboxtokptr)), happy = 0;
|
if (!fn[i]) initprintf("Error: missing '%s filename' for skybox definition near line %s:%d\n", skyfaces[i], script->filename, scriptfile_getlinum(script,skyboxtokptr)), happy = 0;
|
||||||
|
// FIXME?
|
||||||
ii = pathsearchmode;
|
ii = pathsearchmode;
|
||||||
pathsearchmode = 1;
|
pathsearchmode = 1;
|
||||||
if (findfrompath(fn[i],&tfn) < 0)
|
if (findfrompath(fn[i],&tfn) < 0)
|
||||||
|
|
|
@ -11707,9 +11707,7 @@ void drawline256(int32_t x1, int32_t y1, int32_t x2, int32_t y2, char col)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//static int engine_watchme=0;
|
//static void attach_here() {}
|
||||||
//#define WATCHME engine_watchme|=(odx!=dx||ody!=dy);
|
|
||||||
static void attach_here() {}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// drawline16
|
// drawline16
|
||||||
|
@ -11724,56 +11722,84 @@ int32_t drawline16(int32_t x1, int32_t y1, int32_t x2, int32_t y2, char col)
|
||||||
uint32_t patc=0;
|
uint32_t patc=0;
|
||||||
intptr_t p;
|
intptr_t p;
|
||||||
|
|
||||||
int32_t odx,ody;
|
//int32_t odx,ody;
|
||||||
|
//int32_t ox1=x1,oy1=y1, ox2=x2,oy2=y2;
|
||||||
|
|
||||||
dx = x2-x1;
|
dx = x2-x1;
|
||||||
dy = y2-y1;
|
dy = y2-y1;
|
||||||
|
|
||||||
odx=dx;
|
//odx=dx;
|
||||||
ody=dy;
|
//ody=dy;
|
||||||
|
|
||||||
if (dx >= 0)
|
if (dx >= 0)
|
||||||
{
|
{
|
||||||
if (x1 >= xres || x2 < 0) return 0;
|
if (x1 >= xres || x2 < 0)
|
||||||
//WATCHME
|
return 0;
|
||||||
if (x1 < 0) { if (dy) y1 += scale(0-x1,dy,dx); x1 = 0; }
|
if (x1 < 0)
|
||||||
//WATCHME
|
{
|
||||||
if (x2 >= xres) { if (dy) y2 += scale(xres-1-x2,dy,dx); x2 = xres-1; }
|
if (dy) y1 += scale(0-x1,dy,dx);
|
||||||
//WATCHME
|
x1 = 0;
|
||||||
|
}
|
||||||
|
if (x2 >= xres)
|
||||||
|
{
|
||||||
|
if (dy) y2 += scale(xres-1-x2,dy,dx);
|
||||||
|
x2 = xres-1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (x2 >= xres || x1 < 0) return 0;
|
if (x2 >= xres || x1 < 0)
|
||||||
//WATCHME
|
return 0;
|
||||||
if (x2 < 0) { if (dy) y2 += scale(0-x2,dy,dx); x2 = 0; }
|
if (x2 < 0)
|
||||||
//WATCHME
|
{
|
||||||
if (x1 >= xres) { if (dy) y1 += scale(xres-1-x1,dy,dx); x1 = xres-1; }
|
if (dy) y2 += scale(0-x2,dy,dx);
|
||||||
//WATCHME
|
x2 = 0;
|
||||||
|
}
|
||||||
|
if (x1 >= xres)
|
||||||
|
{
|
||||||
|
if (dy) y1 += scale(xres-1-x1,dy,dx);
|
||||||
|
x1 = xres-1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dy >= 0)
|
if (dy >= 0)
|
||||||
{
|
{
|
||||||
if (y1 >= ydim16 || y2 < 0) return 0;
|
if (y1 >= ydim16 || y2 < 0)
|
||||||
//WATCHME
|
return 0;
|
||||||
if (y1 < 0) { if (dx) x1 += scale(0-y1,dx,dy); y1 = 0; if (x1 < 0) x1 = 0; }
|
if (y1 < 0)
|
||||||
//WATCHME
|
{
|
||||||
if (y2 >= ydim16) { if (dx) x2 += scale(ydim16-1-y2,dx,dy); y2 = ydim16-1; if (x2 < 0) x2 = 0; }
|
if (dx) x1 += scale(0-y1,dx,dy);
|
||||||
//WATCHME
|
y1 = 0;
|
||||||
|
x1 = clamp(x1, 0, xres-1);
|
||||||
|
}
|
||||||
|
if (y2 >= ydim16)
|
||||||
|
{
|
||||||
|
if (dx) x2 += scale(ydim16-1-y2,dx,dy);
|
||||||
|
y2 = ydim16-1;
|
||||||
|
x2 = clamp(x2, 0, xres-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (y2 >= ydim16 || y1 < 0) return 0;
|
if (y2 >= ydim16 || y1 < 0)
|
||||||
//WATCHME
|
return 0;
|
||||||
if (y2 < 0) { if (dx) x2 += scale(0-y2,dx,dy); y2 = 0; if (x2 < 0) x2 = 0; }
|
if (y2 < 0)
|
||||||
//WATCHME
|
{
|
||||||
if (y1 >= ydim16) { if (dx) x1 += scale(ydim16-1-y1,dx,dy); y1 = ydim16-1; if (x1 < 0) x1 = 0; }
|
if (dx) x2 += scale(0-y2,dx,dy);
|
||||||
//WATCHME
|
y2 = 0;
|
||||||
|
x2 = clamp(x2, 0, xres-1);
|
||||||
|
}
|
||||||
|
if (y1 >= ydim16)
|
||||||
|
{
|
||||||
|
if (dx) x1 += scale(ydim16-1-y1,dx,dy);
|
||||||
|
y1 = ydim16-1;
|
||||||
|
x1 = clamp(x1, 0, xres-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x1<0||x1>=xres || x2<0||x2>=xres) attach_here();
|
//if (ox1||ox2||oy1||oy2)
|
||||||
//WATCHME
|
// if (x1<0||x1>=xres || y2<0||y2>=yres)
|
||||||
//if (odx!=dx || ody!=dy)
|
// attach_here();
|
||||||
// *(int*)123=234;
|
|
||||||
|
|
||||||
dx = klabs(x2-x1)+1; dy = klabs(y2-y1)+1;
|
dx = klabs(x2-x1)+1; dy = klabs(y2-y1)+1;
|
||||||
if (dx >= dy)
|
if (dx >= dy)
|
||||||
|
@ -11797,7 +11823,7 @@ if (x1<0||x1>=xres || x2<0||x2>=xres) attach_here();
|
||||||
for (i=dx; i>0; i--)
|
for (i=dx; i>0; i--)
|
||||||
{
|
{
|
||||||
if (drawlinepat & pow2long[(patc++)&31])
|
if (drawlinepat & pow2long[(patc++)&31])
|
||||||
drawpixel_safe((char *)p, col);
|
drawpixel((char *)p, col);
|
||||||
d += dy;
|
d += dy;
|
||||||
if (d >= dx) { d -= dx; p += pinc; }
|
if (d >= dx) { d -= dx; p += pinc; }
|
||||||
p++;
|
p++;
|
||||||
|
@ -11820,7 +11846,7 @@ if (x1<0||x1>=xres || x2<0||x2>=xres) attach_here();
|
||||||
for (i=dy; i>0; i--)
|
for (i=dy; i>0; i--)
|
||||||
{
|
{
|
||||||
if (drawlinepat & pow2long[(patc++)&31])
|
if (drawlinepat & pow2long[(patc++)&31])
|
||||||
drawpixel_safe((char *)p, col);
|
drawpixel((char *)p, col);
|
||||||
d += dx;
|
d += dx;
|
||||||
if (d >= dy) { d -= dy; p += pinc; }
|
if (d >= dy) { d -= dy; p += pinc; }
|
||||||
p += bytesperline;
|
p += bytesperline;
|
||||||
|
|
|
@ -190,13 +190,16 @@ int32_t main(int32_t argc, char *argv[])
|
||||||
if (!Bstrcasecmp(argp, "TRUE"))
|
if (!Bstrcasecmp(argp, "TRUE"))
|
||||||
{
|
{
|
||||||
fp = freopen("stdout.txt", "w", stdout);
|
fp = freopen("stdout.txt", "w", stdout);
|
||||||
|
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
|
||||||
fp = fopen("stdout.txt", "w");
|
fp = fopen("stdout.txt", "w");
|
||||||
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
|
setvbuf(fp, 0, _IONBF, 0);
|
||||||
|
*stdout = *fp;
|
||||||
|
*stderr = *fp;
|
||||||
}
|
}
|
||||||
if (fp) setvbuf(fp, 0, _IONBF, 0);
|
|
||||||
*stdout = *fp;
|
|
||||||
*stderr = *fp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(USE_OPENGL) && defined(POLYMOST)
|
#if defined(USE_OPENGL) && defined(POLYMOST)
|
||||||
|
|
|
@ -394,7 +394,7 @@ int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype)
|
||||||
if (dasectnum == -1)
|
if (dasectnum == -1)
|
||||||
{
|
{
|
||||||
dasectnum = spr->sectnum;
|
dasectnum = spr->sectnum;
|
||||||
/*OSD_Printf("%s:%d wtf\n",__FILE__,__LINE__);*/
|
// OSD_Printf("%s:%d wtf\n",__FILE__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((dasectnum != spr->sectnum))
|
if ((dasectnum != spr->sectnum))
|
||||||
|
|
|
@ -3693,9 +3693,9 @@ static int32_t DrawTiles(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles, i
|
||||||
|
|
||||||
static int32_t spriteonceilingz(int32_t searchwall)
|
static int32_t spriteonceilingz(int32_t searchwall)
|
||||||
{
|
{
|
||||||
int32_t z=sprite[searchwall].z;
|
// int32_t z=sprite[searchwall].z;
|
||||||
|
|
||||||
z = getceilzofslope(searchsector,sprite[searchwall].x,sprite[searchwall].y);
|
int32_t z = getceilzofslope(searchsector,sprite[searchwall].x,sprite[searchwall].y);
|
||||||
|
|
||||||
if (sprite[searchwall].cstat&128)
|
if (sprite[searchwall].cstat&128)
|
||||||
z -= ((tilesizy[sprite[searchwall].picnum]*sprite[searchwall].yrepeat)<<1);
|
z -= ((tilesizy[sprite[searchwall].picnum]*sprite[searchwall].yrepeat)<<1);
|
||||||
|
@ -3706,9 +3706,9 @@ static int32_t spriteonceilingz(int32_t searchwall)
|
||||||
|
|
||||||
static int32_t spriteongroundz(int32_t searchwall)
|
static int32_t spriteongroundz(int32_t searchwall)
|
||||||
{
|
{
|
||||||
int32_t z=sprite[searchwall].z;
|
// int32_t z=sprite[searchwall].z;
|
||||||
|
|
||||||
z = getflorzofslope(searchsector,sprite[searchwall].x,sprite[searchwall].y);
|
int32_t z = getflorzofslope(searchsector,sprite[searchwall].x,sprite[searchwall].y);
|
||||||
|
|
||||||
if (sprite[searchwall].cstat&128)
|
if (sprite[searchwall].cstat&128)
|
||||||
z -= ((tilesizy[sprite[searchwall].picnum]*sprite[searchwall].yrepeat)<<1);
|
z -= ((tilesizy[sprite[searchwall].picnum]*sprite[searchwall].yrepeat)<<1);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
CC=gcc
|
CC?=gcc
|
||||||
OBJ=obj
|
OBJ=obj
|
||||||
OBJNAME?=libenet.a
|
OBJNAME?=libenet.a
|
||||||
PRETTY_OUTPUT?=1
|
PRETTY_OUTPUT?=1
|
||||||
|
@ -26,7 +26,7 @@ CFLAGS=$(debug) -W -Wall -Wimplicit -Werror-implicit-function-declaration \
|
||||||
-funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS -D_FORTIFY_SOURCE=2 \
|
-funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS -D_FORTIFY_SOURCE=2 \
|
||||||
$(F_JUMP_TABLES) $(F_NO_STACK_PROTECTOR)
|
$(F_JUMP_TABLES) $(F_NO_STACK_PROTECTOR)
|
||||||
|
|
||||||
CPPFLAGS=-I$(INC) -I$(SRC)
|
CPPFLAGS=-I$(INC) -I$(SRC) -I../../$(EROOT)/include
|
||||||
|
|
||||||
OBJECTS=$(OBJ)/callbacks.o \
|
OBJECTS=$(OBJ)/callbacks.o \
|
||||||
$(OBJ)/host.o \
|
$(OBJ)/host.o \
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
CC=gcc
|
CC?=gcc
|
||||||
OBJ=obj
|
OBJ=obj
|
||||||
OBJNAME?=libjfaudiolib.a
|
OBJNAME?=libjfaudiolib.a
|
||||||
PRETTY_OUTPUT?=1
|
PRETTY_OUTPUT?=1
|
||||||
|
|
|
@ -173,9 +173,10 @@ int32_t MUSIC_Init(int32_t SoundCard, int32_t Address)
|
||||||
sz = (numargs+2)*sizeof(char *) + (c-command+1);
|
sz = (numargs+2)*sizeof(char *) + (c-command+1);
|
||||||
sz = ((sz+pagesize-1)/pagesize)*pagesize;
|
sz = ((sz+pagesize-1)/pagesize)*pagesize;
|
||||||
# ifdef NEDMALLOC
|
# ifdef NEDMALLOC
|
||||||
external_midi_argv = Bmalloc(sz);
|
external_midi_argv = Bcalloc(1,sz+pagesize);
|
||||||
if (!external_midi_argv)
|
if (!external_midi_argv)
|
||||||
goto fallback;
|
goto fallback;
|
||||||
|
external_midi_argv = (char **)((intptr_t)external_midi_argv + (pagesize-(((intptr_t)external_midi_argv)&(pagesize-1))));
|
||||||
# else
|
# else
|
||||||
if (posix_memalign((void **)&external_midi_argv, pagesize, sz))
|
if (posix_memalign((void **)&external_midi_argv, pagesize, sz))
|
||||||
goto fallback;
|
goto fallback;
|
||||||
|
|
|
@ -843,10 +843,20 @@ REDODOOR:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
q = sector[nextsectorneighborz(sn,sptr->floorz,1,1)].floorz;
|
int32_t fneigh=nextsectorneighborz(sn,sptr->floorz,1,1);
|
||||||
j = SetAnimation(sn,&sptr->floorz,q,sptr->extra);
|
int32_t cneigh=nextsectorneighborz(sn,sptr->ceilingz,-1,-1);
|
||||||
q = sector[nextsectorneighborz(sn,sptr->ceilingz,-1,-1)].ceilingz;
|
|
||||||
j = SetAnimation(sn,&sptr->ceilingz,q,sptr->extra);
|
if (fneigh>=0 && cneigh>=0)
|
||||||
|
{
|
||||||
|
j = SetAnimation(sn, &sptr->floorz, sector[fneigh].floorz, sptr->extra);
|
||||||
|
j = SetAnimation(sn, &sptr->ceilingz, sector[cneigh].ceilingz, sptr->extra);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OSD_Printf("WARNING: ST22: null sector: floor neighbor=%d, ceiling neighbor=%d!\n",
|
||||||
|
fneigh, cneigh);
|
||||||
|
sptr->lotag ^= 0x8000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sptr->lotag ^= 0x8000;
|
sptr->lotag ^= 0x8000;
|
||||||
|
|
Loading…
Reference in a new issue