mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
A couple of inside()-related cleanups.
- make inside_editor() static in build.c - replace comparisons of inside()'s return values with 0 by ones with 1 (since a returned 0 can mean -1 or 1, i.e. oob sector or is really inside) - prevent a theoretically possible oob access in correct_ornamented_sprite() git-svn-id: https://svn.eduke32.com/eduke32@3038 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
d4ff4c4595
commit
2ab247b68a
3 changed files with 21 additions and 19 deletions
|
@ -245,8 +245,6 @@ void reset_highlight(void);
|
||||||
void ovh_whiteoutgrab(int32_t restoreredwalls);
|
void ovh_whiteoutgrab(int32_t restoreredwalls);
|
||||||
|
|
||||||
int32_t inside_editor_curpos(int16_t sectnum);
|
int32_t inside_editor_curpos(int16_t sectnum);
|
||||||
int32_t inside_editor(const vec3_t *pos, int32_t searchx, int32_t searchy, int32_t zoom,
|
|
||||||
int32_t x, int32_t y, int16_t sectnum);
|
|
||||||
void correct_sprite_yoffset(int32_t i);
|
void correct_sprite_yoffset(int32_t i);
|
||||||
|
|
||||||
void inflineintersect(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
void inflineintersect(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||||
|
|
|
@ -1413,14 +1413,9 @@ static struct overheadstate
|
||||||
int16_t splitstartwall;
|
int16_t splitstartwall;
|
||||||
} ovh;
|
} ovh;
|
||||||
|
|
||||||
int32_t inside_editor_curpos(int16_t sectnum)
|
|
||||||
{
|
|
||||||
// TODO: take care: mous[xy]plc global vs overheadeditor auto
|
|
||||||
return inside_editor(&pos, searchx,searchy, zoom, mousxplc,mousyplc, sectnum);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t inside_editor(const vec3_t *pos, int32_t searchx, int32_t searchy, int32_t zoom,
|
static int32_t inside_editor(const vec3_t *pos, int32_t searchx, int32_t searchy, int32_t zoom,
|
||||||
int32_t x, int32_t y, int16_t sectnum)
|
int32_t x, int32_t y, int16_t sectnum)
|
||||||
{
|
{
|
||||||
if (!m32_sideview)
|
if (!m32_sideview)
|
||||||
return inside(x, y, sectnum);
|
return inside(x, y, sectnum);
|
||||||
|
@ -1456,6 +1451,13 @@ int32_t inside_editor(const vec3_t *pos, int32_t searchx, int32_t searchy, int32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t inside_editor_curpos(int16_t sectnum)
|
||||||
|
{
|
||||||
|
// TODO: take care: mous[xy]plc global vs overheadeditor auto
|
||||||
|
return inside_editor(&pos, searchx,searchy, zoom, mousxplc,mousyplc, sectnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void drawline16base(int32_t bx, int32_t by, int32_t x1, int32_t y1, int32_t x2, int32_t y2, char col)
|
static inline void drawline16base(int32_t bx, int32_t by, int32_t x1, int32_t y1, int32_t x2, int32_t y2, char col)
|
||||||
{
|
{
|
||||||
drawline16(bx+x1, by+y1, bx+x2, by+y2, col);
|
drawline16(bx+x1, by+y1, bx+x2, by+y2, col);
|
||||||
|
@ -2015,15 +2017,17 @@ static void correct_ornamented_sprite(int32_t i, int32_t hitw)
|
||||||
int32_t j;
|
int32_t j;
|
||||||
|
|
||||||
if (hitw >= 0)
|
if (hitw >= 0)
|
||||||
|
{
|
||||||
sprite[i].ang = (getangle(POINT2(hitw).x-wall[hitw].x,
|
sprite[i].ang = (getangle(POINT2(hitw).x-wall[hitw].x,
|
||||||
POINT2(hitw).y-wall[hitw].y)+512)&2047;
|
POINT2(hitw).y-wall[hitw].y)+512)&2047;
|
||||||
|
|
||||||
//Make sure sprite's in right sector
|
//Make sure sprite's in right sector
|
||||||
if (inside(sprite[i].x, sprite[i].y, sprite[i].sectnum) == 0)
|
if (inside(sprite[i].x, sprite[i].y, sprite[i].sectnum) != 1)
|
||||||
{
|
{
|
||||||
j = wall[hitw].point2;
|
j = wall[hitw].point2;
|
||||||
sprite[i].x -= ksgn(wall[j].y-wall[hitw].y);
|
sprite[i].x -= ksgn(wall[j].y-wall[hitw].y);
|
||||||
sprite[i].y += ksgn(wall[j].x-wall[hitw].x);
|
sprite[i].y += ksgn(wall[j].x-wall[hitw].x);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6514,7 +6518,7 @@ end_join_sectors:
|
||||||
// will add an inner loop
|
// will add an inner loop
|
||||||
for (j=numwalls+1; j<newnumwalls; j++)
|
for (j=numwalls+1; j<newnumwalls; j++)
|
||||||
{
|
{
|
||||||
if (inside(wall[j].x, wall[j].y, i) == 0)
|
if (inside(wall[j].x, wall[j].y, i) != 1)
|
||||||
goto check_next_sector;
|
goto check_next_sector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11393,7 +11393,7 @@ static int32_t hitscan_trysector(const vec3_t *sv, const sectortype *sec, hitdat
|
||||||
{
|
{
|
||||||
if (tmp==NULL)
|
if (tmp==NULL)
|
||||||
{
|
{
|
||||||
if (inside(x1,y1,sec-sector) != 0)
|
if (inside(x1,y1,sec-sector) == 1)
|
||||||
{
|
{
|
||||||
hit->sect = sec-sector; hit->wall = -1; hit->sprite = -1;
|
hit->sect = sec-sector; hit->wall = -1; hit->sprite = -1;
|
||||||
hit->pos.x = x1; hit->pos.y = y1; hit->pos.z = z1;
|
hit->pos.x = x1; hit->pos.y = y1; hit->pos.z = z1;
|
||||||
|
@ -11408,7 +11408,7 @@ static int32_t hitscan_trysector(const vec3_t *sv, const sectortype *sec, hitdat
|
||||||
|
|
||||||
if (!thislastsec)
|
if (!thislastsec)
|
||||||
{
|
{
|
||||||
if (inside(x1,y1,sec-sector) != 0)
|
if (inside(x1,y1,sec-sector) == 1)
|
||||||
{
|
{
|
||||||
hit->sect = curspr->sectnum; hit->wall = -1; hit->sprite = curspr-sprite;
|
hit->sect = curspr->sectnum; hit->wall = -1; hit->sprite = curspr-sprite;
|
||||||
hit->pos.x = x1; hit->pos.y = y1; hit->pos.z = z1;
|
hit->pos.x = x1; hit->pos.y = y1; hit->pos.z = z1;
|
||||||
|
@ -11419,7 +11419,7 @@ static int32_t hitscan_trysector(const vec3_t *sv, const sectortype *sec, hitdat
|
||||||
{
|
{
|
||||||
for (i=clipinfo[curidx].qbeg; i<clipinfo[curidx].qend; i++)
|
for (i=clipinfo[curidx].qbeg; i<clipinfo[curidx].qend; i++)
|
||||||
{
|
{
|
||||||
if (inside(x1,y1,sectq[i]) != 0)
|
if (inside(x1,y1,sectq[i]) == 1)
|
||||||
{
|
{
|
||||||
hit->sect = curspr->sectnum; hit->wall = -1; hit->sprite = curspr-sprite;
|
hit->sect = curspr->sectnum; hit->wall = -1; hit->sprite = curspr-sprite;
|
||||||
hit->pos.x = x1; hit->pos.y = y1; hit->pos.z = z1;
|
hit->pos.x = x1; hit->pos.y = y1; hit->pos.z = z1;
|
||||||
|
|
Loading…
Reference in a new issue