mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +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
|
||||
POLYMER = 1
|
||||
USE_OPENGL = 1
|
||||
NOASM = 0
|
||||
NOASM ?= 0
|
||||
LINKED_GTK = 0
|
||||
BUILD32_ON_64 = 0
|
||||
NEDMALLOC = 1
|
||||
|
@ -71,7 +71,7 @@ JAUDIOLIB=libjfaudiolib.a
|
|||
ENETDIR=$(SRC)/enet
|
||||
ENETLIB=libenet.a
|
||||
|
||||
CC=gcc
|
||||
CC?=gcc
|
||||
CXX=g++
|
||||
AS=nasm
|
||||
RC=windres
|
||||
|
|
|
@ -94,7 +94,7 @@ ifneq (0,$(DEBUGANYWAY))
|
|||
debug+=-ggdb
|
||||
endif
|
||||
|
||||
CC=gcc
|
||||
CC?=gcc
|
||||
CXX=gcc
|
||||
AS=nasm
|
||||
RC=windres
|
||||
|
|
|
@ -460,7 +460,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
}
|
||||
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 alphacut = 255;
|
||||
int32_t xoffset = 0, yoffset = 0;
|
||||
|
@ -1404,6 +1404,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
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;
|
||||
// FIXME?
|
||||
ii = pathsearchmode;
|
||||
pathsearchmode = 1;
|
||||
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;
|
||||
//#define WATCHME engine_watchme|=(odx!=dx||ody!=dy);
|
||||
static void attach_here() {}
|
||||
//static void attach_here() {}
|
||||
|
||||
//
|
||||
// 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;
|
||||
intptr_t p;
|
||||
|
||||
int32_t odx,ody;
|
||||
//int32_t odx,ody;
|
||||
//int32_t ox1=x1,oy1=y1, ox2=x2,oy2=y2;
|
||||
|
||||
dx = x2-x1;
|
||||
dy = y2-y1;
|
||||
|
||||
odx=dx;
|
||||
ody=dy;
|
||||
//odx=dx;
|
||||
//ody=dy;
|
||||
|
||||
if (dx >= 0)
|
||||
{
|
||||
if (x1 >= xres || x2 < 0) return 0;
|
||||
//WATCHME
|
||||
if (x1 < 0) { if (dy) y1 += scale(0-x1,dy,dx); x1 = 0; }
|
||||
//WATCHME
|
||||
if (x2 >= xres) { if (dy) y2 += scale(xres-1-x2,dy,dx); x2 = xres-1; }
|
||||
//WATCHME
|
||||
if (x1 >= xres || x2 < 0)
|
||||
return 0;
|
||||
if (x1 < 0)
|
||||
{
|
||||
if (dy) y1 += scale(0-x1,dy,dx);
|
||||
x1 = 0;
|
||||
}
|
||||
if (x2 >= xres)
|
||||
{
|
||||
if (dy) y2 += scale(xres-1-x2,dy,dx);
|
||||
x2 = xres-1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x2 >= xres || x1 < 0) return 0;
|
||||
//WATCHME
|
||||
if (x2 < 0) { if (dy) y2 += scale(0-x2,dy,dx); x2 = 0; }
|
||||
//WATCHME
|
||||
if (x1 >= xres) { if (dy) y1 += scale(xres-1-x1,dy,dx); x1 = xres-1; }
|
||||
//WATCHME
|
||||
if (x2 >= xres || x1 < 0)
|
||||
return 0;
|
||||
if (x2 < 0)
|
||||
{
|
||||
if (dy) y2 += scale(0-x2,dy,dx);
|
||||
x2 = 0;
|
||||
}
|
||||
if (x1 >= xres)
|
||||
{
|
||||
if (dy) y1 += scale(xres-1-x1,dy,dx);
|
||||
x1 = xres-1;
|
||||
}
|
||||
}
|
||||
|
||||
if (dy >= 0)
|
||||
{
|
||||
if (y1 >= ydim16 || y2 < 0) return 0;
|
||||
//WATCHME
|
||||
if (y1 < 0) { if (dx) x1 += scale(0-y1,dx,dy); y1 = 0; if (x1 < 0) x1 = 0; }
|
||||
//WATCHME
|
||||
if (y2 >= ydim16) { if (dx) x2 += scale(ydim16-1-y2,dx,dy); y2 = ydim16-1; if (x2 < 0) x2 = 0; }
|
||||
//WATCHME
|
||||
if (y1 >= ydim16 || y2 < 0)
|
||||
return 0;
|
||||
if (y1 < 0)
|
||||
{
|
||||
if (dx) x1 += scale(0-y1,dx,dy);
|
||||
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
|
||||
{
|
||||
if (y2 >= ydim16 || y1 < 0) return 0;
|
||||
//WATCHME
|
||||
if (y2 < 0) { if (dx) x2 += scale(0-y2,dx,dy); y2 = 0; if (x2 < 0) x2 = 0; }
|
||||
//WATCHME
|
||||
if (y1 >= ydim16) { if (dx) x1 += scale(ydim16-1-y1,dx,dy); y1 = ydim16-1; if (x1 < 0) x1 = 0; }
|
||||
//WATCHME
|
||||
if (y2 >= ydim16 || y1 < 0)
|
||||
return 0;
|
||||
if (y2 < 0)
|
||||
{
|
||||
if (dx) x2 += scale(0-y2,dx,dy);
|
||||
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();
|
||||
//WATCHME
|
||||
//if (odx!=dx || ody!=dy)
|
||||
// *(int*)123=234;
|
||||
//if (ox1||ox2||oy1||oy2)
|
||||
// if (x1<0||x1>=xres || y2<0||y2>=yres)
|
||||
// attach_here();
|
||||
|
||||
dx = klabs(x2-x1)+1; dy = klabs(y2-y1)+1;
|
||||
if (dx >= dy)
|
||||
|
@ -11797,7 +11823,7 @@ if (x1<0||x1>=xres || x2<0||x2>=xres) attach_here();
|
|||
for (i=dx; i>0; i--)
|
||||
{
|
||||
if (drawlinepat & pow2long[(patc++)&31])
|
||||
drawpixel_safe((char *)p, col);
|
||||
drawpixel((char *)p, col);
|
||||
d += dy;
|
||||
if (d >= dx) { d -= dx; p += pinc; }
|
||||
p++;
|
||||
|
@ -11820,7 +11846,7 @@ if (x1<0||x1>=xres || x2<0||x2>=xres) attach_here();
|
|||
for (i=dy; i>0; i--)
|
||||
{
|
||||
if (drawlinepat & pow2long[(patc++)&31])
|
||||
drawpixel_safe((char *)p, col);
|
||||
drawpixel((char *)p, col);
|
||||
d += dx;
|
||||
if (d >= dy) { d -= dy; p += pinc; }
|
||||
p += bytesperline;
|
||||
|
|
|
@ -190,13 +190,16 @@ int32_t main(int32_t argc, char *argv[])
|
|||
if (!Bstrcasecmp(argp, "TRUE"))
|
||||
{
|
||||
fp = freopen("stdout.txt", "w", stdout);
|
||||
|
||||
if (!fp)
|
||||
{
|
||||
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)
|
||||
|
|
|
@ -394,7 +394,7 @@ int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype)
|
|||
if (dasectnum == -1)
|
||||
{
|
||||
dasectnum = spr->sectnum;
|
||||
/*OSD_Printf("%s:%d wtf\n",__FILE__,__LINE__);*/
|
||||
// OSD_Printf("%s:%d wtf\n",__FILE__,__LINE__);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
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)
|
||||
{
|
||||
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)
|
||||
z -= ((tilesizy[sprite[searchwall].picnum]*sprite[searchwall].yrepeat)<<1);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CC=gcc
|
||||
CC?=gcc
|
||||
OBJ=obj
|
||||
OBJNAME?=libenet.a
|
||||
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 \
|
||||
$(F_JUMP_TABLES) $(F_NO_STACK_PROTECTOR)
|
||||
|
||||
CPPFLAGS=-I$(INC) -I$(SRC)
|
||||
CPPFLAGS=-I$(INC) -I$(SRC) -I../../$(EROOT)/include
|
||||
|
||||
OBJECTS=$(OBJ)/callbacks.o \
|
||||
$(OBJ)/host.o \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CC=gcc
|
||||
CC?=gcc
|
||||
OBJ=obj
|
||||
OBJNAME?=libjfaudiolib.a
|
||||
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 = ((sz+pagesize-1)/pagesize)*pagesize;
|
||||
# ifdef NEDMALLOC
|
||||
external_midi_argv = Bmalloc(sz);
|
||||
external_midi_argv = Bcalloc(1,sz+pagesize);
|
||||
if (!external_midi_argv)
|
||||
goto fallback;
|
||||
external_midi_argv = (char **)((intptr_t)external_midi_argv + (pagesize-(((intptr_t)external_midi_argv)&(pagesize-1))));
|
||||
# else
|
||||
if (posix_memalign((void **)&external_midi_argv, pagesize, sz))
|
||||
goto fallback;
|
||||
|
|
|
@ -843,10 +843,20 @@ REDODOOR:
|
|||
}
|
||||
else
|
||||
{
|
||||
q = sector[nextsectorneighborz(sn,sptr->floorz,1,1)].floorz;
|
||||
j = SetAnimation(sn,&sptr->floorz,q,sptr->extra);
|
||||
q = sector[nextsectorneighborz(sn,sptr->ceilingz,-1,-1)].ceilingz;
|
||||
j = SetAnimation(sn,&sptr->ceilingz,q,sptr->extra);
|
||||
int32_t fneigh=nextsectorneighborz(sn,sptr->floorz,1,1);
|
||||
int32_t cneigh=nextsectorneighborz(sn,sptr->ceilingz,-1,-1);
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue