mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-14 08:30:58 +00:00
check limits in more places when drawing walls in 2d mode.
git-svn-id: https://svn.eduke32.com/eduke32@1655 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
ff325e2205
commit
ad0284b00c
2 changed files with 105 additions and 35 deletions
|
@ -1257,7 +1257,7 @@ void overheadeditor(void)
|
||||||
int32_t tempint, tempint1, tempint2, doubvel;
|
int32_t tempint, tempint1, tempint2, doubvel;
|
||||||
int32_t startwall=0, endwall, dax, day, x1, y1, x2, y2, x3, y3, x4, y4;
|
int32_t startwall=0, endwall, dax, day, x1, y1, x2, y2, x3, y3, x4, y4;
|
||||||
int32_t highlightx1, highlighty1, highlightx2, highlighty2, xvect, yvect;
|
int32_t highlightx1, highlighty1, highlightx2, highlighty2, xvect, yvect;
|
||||||
int16_t pag, suckwall=0, sucksect, /*newnumwalls,*/ newnumsectors, split=0, bad;
|
int16_t pag, suckwall=0, sucksect, /*newnumwalls,*/ newnumsectors, split=0, bad, goodtogo;
|
||||||
int16_t splitsect=0, danumwalls, secondstartwall, joinsector[2], joinsectnum;
|
int16_t splitsect=0, danumwalls, secondstartwall, joinsector[2], joinsectnum;
|
||||||
int16_t splitstartwall=0, splitendwall, loopnum;
|
int16_t splitstartwall=0, splitendwall, loopnum;
|
||||||
int32_t mousx, mousy, bstatus;
|
int32_t mousx, mousy, bstatus;
|
||||||
|
@ -1422,6 +1422,7 @@ void overheadeditor(void)
|
||||||
|
|
||||||
if (newnumwalls >= numwalls)
|
if (newnumwalls >= numwalls)
|
||||||
{
|
{
|
||||||
|
// if we're in the process of drawing a wall, set the end point's coordinates
|
||||||
dax = mousxplc;
|
dax = mousxplc;
|
||||||
day = mousyplc;
|
day = mousyplc;
|
||||||
adjustmark(&dax,&day,newnumwalls);
|
adjustmark(&dax,&day,newnumwalls);
|
||||||
|
@ -2883,6 +2884,11 @@ SKIP:
|
||||||
{
|
{
|
||||||
printmessage16("Can't make a sector out there.");
|
printmessage16("Can't make a sector out there.");
|
||||||
}
|
}
|
||||||
|
else if (newnumwalls > MAXWALLS)
|
||||||
|
{
|
||||||
|
printmessage16("Making new sector from inner loop would exceed wall limits.");
|
||||||
|
newnumwalls = -1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i=numwalls; i<newnumwalls; i++)
|
for (i=numwalls; i<newnumwalls; i++)
|
||||||
|
@ -3054,7 +3060,7 @@ SKIP:
|
||||||
keystatus[0x2e] = 0;
|
keystatus[0x2e] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bad = (keystatus[0x39]); //Gotta do this to save lots of 3 spaces!
|
bad = keystatus[0x39]; //Gotta do this to save lots of 3 spaces!
|
||||||
|
|
||||||
if (circlewall >= 0)
|
if (circlewall >= 0)
|
||||||
{
|
{
|
||||||
|
@ -3092,6 +3098,7 @@ SKIP:
|
||||||
}
|
}
|
||||||
|
|
||||||
circlerad = ksqrt(dmulscale4(centerx-x1,centerx-x1, centery-y1,centery-y1))<<2;
|
circlerad = ksqrt(dmulscale4(centerx-x1,centerx-x1, centery-y1,centery-y1))<<2;
|
||||||
|
goodtogo = (numwalls+circlepoints <= MAXWALLS);
|
||||||
|
|
||||||
for (i=circlepoints; i>0; i--)
|
for (i=circlepoints; i>0; i--)
|
||||||
{
|
{
|
||||||
|
@ -3102,11 +3109,13 @@ SKIP:
|
||||||
bclamp(&dax, -editorgridextent, editorgridextent);
|
bclamp(&dax, -editorgridextent, editorgridextent);
|
||||||
bclamp(&day, -editorgridextent, editorgridextent);
|
bclamp(&day, -editorgridextent, editorgridextent);
|
||||||
|
|
||||||
if (bad > 0)
|
if (bad > 0 && goodtogo)
|
||||||
{
|
{
|
||||||
insertpoint(circlewall,dax,day);
|
insertpoint(circlewall,dax,day);
|
||||||
circlewall += (wall[circlewall].nextwall >= 0 && wall[circlewall].nextwall < circlewall);
|
if (wall[circlewall].nextwall >= 0 && wall[circlewall].nextwall < circlewall)
|
||||||
|
circlewall++;
|
||||||
}
|
}
|
||||||
|
|
||||||
dax = mulscale14(dax-pos.x,zoom);
|
dax = mulscale14(dax-pos.x,zoom);
|
||||||
day = mulscale14(day-pos.y,zoom);
|
day = mulscale14(day-pos.y,zoom);
|
||||||
drawline16base(halfxdim16+dax,midydim16+day, -ps,-ps, +ps,-ps, editorcolors[14]);
|
drawline16base(halfxdim16+dax,midydim16+day, -ps,-ps, +ps,-ps, editorcolors[14]);
|
||||||
|
@ -3115,14 +3124,21 @@ SKIP:
|
||||||
drawline16base(halfxdim16+dax,midydim16+day, -ps,+ps, -ps,-ps, editorcolors[14]);
|
drawline16base(halfxdim16+dax,midydim16+day, -ps,+ps, -ps,-ps, editorcolors[14]);
|
||||||
// drawcircle16(halfxdim16+dax, midydim16+day, 3, 14);
|
// drawcircle16(halfxdim16+dax, midydim16+day, 3, 14);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bad > 0)
|
if (bad > 0)
|
||||||
{
|
{
|
||||||
bad = 0;
|
bad = 0;
|
||||||
keystatus[0x39] = 0;
|
keystatus[0x39] = 0;
|
||||||
|
|
||||||
|
if (goodtogo)
|
||||||
|
{
|
||||||
asksave = 1;
|
asksave = 1;
|
||||||
printmessage16("Circle points inserted.");
|
printmessage16("Circle points inserted.");
|
||||||
circlewall = -1;
|
circlewall = -1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
printmessage16("Inserting circle points would exceed wall limit.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3130,6 +3146,7 @@ SKIP:
|
||||||
{
|
{
|
||||||
keystatus[0x39] = 0;
|
keystatus[0x39] = 0;
|
||||||
adjustmark(&mousxplc,&mousyplc,newnumwalls);
|
adjustmark(&mousxplc,&mousyplc,newnumwalls);
|
||||||
|
|
||||||
if (checkautoinsert(mousxplc,mousyplc,newnumwalls) == 1)
|
if (checkautoinsert(mousxplc,mousyplc,newnumwalls) == 1)
|
||||||
{
|
{
|
||||||
printmessage16("You must insert a point there first.");
|
printmessage16("You must insert a point there first.");
|
||||||
|
@ -3137,18 +3154,57 @@ SKIP:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bad > 0 && (max(numwalls,newnumwalls) > MAXWALLS - (newnumwalls < numwalls)))
|
goodtogo = 1; // Checking limits...
|
||||||
|
if (bad > 0)
|
||||||
{
|
{
|
||||||
if (newnumwalls < numwalls)
|
if (newnumwalls < numwalls)
|
||||||
|
{
|
||||||
|
// ---why MAXWALLS-2? wall[MAXWALLS-1] would be inserted, but would
|
||||||
|
// need to draw end of wall trail in wall[MAXWALLS]!---
|
||||||
|
|
||||||
|
// for MAXWALLS-1 we need extra space at the end of wall[]
|
||||||
|
if (numwalls >= MAXWALLS-1)
|
||||||
|
{
|
||||||
|
goodtogo = 0;
|
||||||
printmessage16("Can't start sector drawing: wall limit reached.");
|
printmessage16("Can't start sector drawing: wall limit reached.");
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
//if not back to first point
|
||||||
|
if (firstx != mousxplc || firsty != mousyplc) //nextpoint
|
||||||
|
{
|
||||||
|
if (newnumwalls>=MAXWALLS)
|
||||||
|
{
|
||||||
|
goodtogo = 0;
|
||||||
printmessage16("Inserting another point would exceed wall limit.");
|
printmessage16("Inserting another point would exceed wall limit.");
|
||||||
}
|
}
|
||||||
else if (bad > 0) //Space
|
}
|
||||||
|
|
||||||
|
//if not split and back to first point
|
||||||
|
if ((split == 0) && (firstx == mousxplc) && (firsty == mousyplc) && (newnumwalls >= numwalls+3))
|
||||||
{
|
{
|
||||||
if ((newnumwalls < numwalls) /*&& (numwalls < MAXWALLS-1)*/)
|
if (suckwall == -1) //if no connections to other sectors
|
||||||
|
{ /* No problem... */ }
|
||||||
|
else
|
||||||
{
|
{
|
||||||
firstx = mousxplc, firsty = mousyplc; //Make first point
|
if (newnumwalls>=MAXWALLS) // still too optimistic since we can have more than one new red wall
|
||||||
|
{
|
||||||
|
goodtogo = 0;
|
||||||
|
printmessage16("Closing wall drawing would exceed wall limit.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// else if (split==1) {} // handled there
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bad > 0 && goodtogo) //Space
|
||||||
|
{
|
||||||
|
if (newnumwalls < numwalls) // starting wall drawing
|
||||||
|
{
|
||||||
|
firstx = mousxplc;
|
||||||
|
firsty = mousyplc; //Make first point
|
||||||
newnumwalls = numwalls;
|
newnumwalls = numwalls;
|
||||||
suckwall = -1;
|
suckwall = -1;
|
||||||
split = 0;
|
split = 0;
|
||||||
|
@ -3161,9 +3217,11 @@ SKIP:
|
||||||
wall[newnumwalls].y = mousyplc;
|
wall[newnumwalls].y = mousyplc;
|
||||||
wall[newnumwalls].nextsector = -1;
|
wall[newnumwalls].nextsector = -1;
|
||||||
wall[newnumwalls].nextwall = -1;
|
wall[newnumwalls].nextwall = -1;
|
||||||
|
|
||||||
for (i=0; i<numwalls; i++)
|
for (i=0; i<numwalls; i++)
|
||||||
if ((wall[i].x == mousxplc) && (wall[i].y == mousyplc))
|
if (wall[i].x == mousxplc && wall[i].y == mousyplc)
|
||||||
suckwall = i;
|
suckwall = i;
|
||||||
|
|
||||||
wall[newnumwalls].point2 = newnumwalls+1;
|
wall[newnumwalls].point2 = newnumwalls+1;
|
||||||
printmessage16("Sector drawing started.");
|
printmessage16("Sector drawing started.");
|
||||||
newnumwalls++;
|
newnumwalls++;
|
||||||
|
@ -3171,13 +3229,14 @@ SKIP:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//if not back to first point
|
//if not back to first point
|
||||||
if ((firstx != mousxplc) || (firsty != mousyplc)) //nextpoint
|
if (firstx != mousxplc || firsty != mousyplc) //nextpoint
|
||||||
{
|
{
|
||||||
j = 0;
|
j = 0;
|
||||||
for (i=numwalls; i<newnumwalls; i++)
|
for (i=numwalls; i<newnumwalls; i++)
|
||||||
if ((mousxplc == wall[i].x) && (mousyplc == wall[i].y))
|
if (mousxplc == wall[i].x && mousyplc == wall[i].y)
|
||||||
j = 1;
|
j = 1;
|
||||||
if (j == 0)
|
|
||||||
|
if (j == 0) // if new point is not on a position of already drawn points
|
||||||
{
|
{
|
||||||
//check if starting to split a sector
|
//check if starting to split a sector
|
||||||
if (newnumwalls == numwalls+1)
|
if (newnumwalls == numwalls+1)
|
||||||
|
@ -3193,8 +3252,7 @@ SKIP:
|
||||||
startwall = sector[i].wallptr;
|
startwall = sector[i].wallptr;
|
||||||
endwall = startwall + sector[i].wallnum - 1;
|
endwall = startwall + sector[i].wallnum - 1;
|
||||||
for (k=startwall; k<=endwall; k++)
|
for (k=startwall; k<=endwall; k++)
|
||||||
if (wall[k].x == wall[numwalls].x)
|
if (wall[k].x==wall[numwalls].x && wall[k].y==wall[numwalls].y)
|
||||||
if (wall[k].y == wall[numwalls].y)
|
|
||||||
{
|
{
|
||||||
m = k;
|
m = k;
|
||||||
break;
|
break;
|
||||||
|
@ -3239,9 +3297,11 @@ SKIP:
|
||||||
wall[newnumwalls].y = mousyplc;
|
wall[newnumwalls].y = mousyplc;
|
||||||
wall[newnumwalls].nextsector = -1;
|
wall[newnumwalls].nextsector = -1;
|
||||||
wall[newnumwalls].nextwall = -1;
|
wall[newnumwalls].nextwall = -1;
|
||||||
|
|
||||||
for (i=0; i<numwalls; i++)
|
for (i=0; i<numwalls; i++)
|
||||||
if ((wall[i].x == mousxplc) && (wall[i].y == mousyplc))
|
if (wall[i].x == mousxplc && wall[i].y == mousyplc)
|
||||||
suckwall = i;
|
suckwall = i;
|
||||||
|
|
||||||
wall[newnumwalls].point2 = newnumwalls+1;
|
wall[newnumwalls].point2 = newnumwalls+1;
|
||||||
newnumwalls++;
|
newnumwalls++;
|
||||||
}
|
}
|
||||||
|
@ -3263,6 +3323,7 @@ SKIP:
|
||||||
for (i=0; i<numsectors; i++)
|
for (i=0; i<numsectors; i++)
|
||||||
if (inside(firstx,firsty,i) == 1)
|
if (inside(firstx,firsty,i) == 1)
|
||||||
k = i;
|
k = i;
|
||||||
|
|
||||||
if (k == -1) //if not inside another sector either
|
if (k == -1) //if not inside another sector either
|
||||||
{
|
{
|
||||||
//add island sector
|
//add island sector
|
||||||
|
@ -3277,6 +3338,7 @@ SKIP:
|
||||||
sector[numsectors].wallnum = newnumwalls-numwalls;
|
sector[numsectors].wallnum = newnumwalls-numwalls;
|
||||||
sector[numsectors].ceilingz = (-32<<8);
|
sector[numsectors].ceilingz = (-32<<8);
|
||||||
sector[numsectors].floorz = (32<<8);
|
sector[numsectors].floorz = (32<<8);
|
||||||
|
|
||||||
for (i=numwalls; i<newnumwalls; i++)
|
for (i=numwalls; i<newnumwalls; i++)
|
||||||
{
|
{
|
||||||
wall[i].cstat = 0;
|
wall[i].cstat = 0;
|
||||||
|
@ -3288,6 +3350,7 @@ SKIP:
|
||||||
wall[i].nextsector = -1;
|
wall[i].nextsector = -1;
|
||||||
wall[i].nextwall = -1;
|
wall[i].nextwall = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
headspritesect[numsectors] = -1;
|
headspritesect[numsectors] = -1;
|
||||||
numsectors++;
|
numsectors++;
|
||||||
}
|
}
|
||||||
|
@ -3357,6 +3420,7 @@ SKIP:
|
||||||
sector[numsectors].floorpicnum = sector[sucksect].floorpicnum;
|
sector[numsectors].floorpicnum = sector[sucksect].floorpicnum;
|
||||||
sector[numsectors].ceilingheinum = sector[sucksect].ceilingheinum;
|
sector[numsectors].ceilingheinum = sector[sucksect].ceilingheinum;
|
||||||
sector[numsectors].floorheinum = sector[sucksect].floorheinum;
|
sector[numsectors].floorheinum = sector[sucksect].floorheinum;
|
||||||
|
|
||||||
for (i=numwalls; i<newnumwalls; i++)
|
for (i=numwalls; i<newnumwalls; i++)
|
||||||
{
|
{
|
||||||
wall[i].cstat = wall[suckwall].cstat;
|
wall[i].cstat = wall[suckwall].cstat;
|
||||||
|
@ -3367,14 +3431,16 @@ SKIP:
|
||||||
wall[i].overpicnum = wall[suckwall].overpicnum;
|
wall[i].overpicnum = wall[suckwall].overpicnum;
|
||||||
checksectorpointer((int16_t)i,(int16_t)numsectors);
|
checksectorpointer((int16_t)i,(int16_t)numsectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
headspritesect[numsectors] = -1;
|
headspritesect[numsectors] = -1;
|
||||||
numsectors++;
|
numsectors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
numwalls = newnumwalls;
|
numwalls = newnumwalls;
|
||||||
newnumwalls = -1;
|
newnumwalls = -1;
|
||||||
asksave = 1;
|
asksave = 1;
|
||||||
}
|
}
|
||||||
if (split == 1)
|
else if (split == 1)
|
||||||
{
|
{
|
||||||
//split sector
|
//split sector
|
||||||
startwall = sector[splitsect].wallptr;
|
startwall = sector[splitsect].wallptr;
|
||||||
|
@ -4915,7 +4981,7 @@ static int32_t movewalls(int32_t start, int32_t offs)
|
||||||
|
|
||||||
int32_t checksectorpointer(int16_t i, int16_t sectnum)
|
int32_t checksectorpointer(int16_t i, int16_t sectnum)
|
||||||
{
|
{
|
||||||
int32_t j, k, startwall, endwall, x1, y1, x2, y2;
|
int32_t j, k, startwall, endwall, x1, y1, x2, y2, numnewwalls=0;
|
||||||
|
|
||||||
char buf[128];
|
char buf[128];
|
||||||
if (i<0 || i>=max(numwalls,newnumwalls))
|
if (i<0 || i>=max(numwalls,newnumwalls))
|
||||||
|
@ -4950,15 +5016,19 @@ int32_t checksectorpointer(int16_t i, int16_t sectnum)
|
||||||
if (wall[k].x == x2 && wall[k].y == y2)
|
if (wall[k].x == x2 && wall[k].y == y2)
|
||||||
if (POINT2(k).x == x1 && POINT2(k).y == y1)
|
if (POINT2(k).x == x1 && POINT2(k).y == y1)
|
||||||
if (j != sectnum)
|
if (j != sectnum)
|
||||||
|
{
|
||||||
|
if (sectnum != -2) // -2 means dry run
|
||||||
{
|
{
|
||||||
wall[i].nextsector = j;
|
wall[i].nextsector = j;
|
||||||
wall[i].nextwall = k;
|
wall[i].nextwall = k;
|
||||||
wall[k].nextsector = sectnum;
|
wall[k].nextsector = sectnum;
|
||||||
wall[k].nextwall = i;
|
wall[k].nextwall = i;
|
||||||
}
|
}
|
||||||
|
numnewwalls++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(0);
|
}
|
||||||
|
return(numnewwalls);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fixrepeats(int16_t i)
|
void fixrepeats(int16_t i)
|
||||||
|
|
|
@ -5519,7 +5519,7 @@ int32_t preinitengine(void)
|
||||||
dynarray[] =
|
dynarray[] =
|
||||||
{
|
{
|
||||||
{ (void **)§or, sizeof(sectortype) * MAXSECTORS },
|
{ (void **)§or, sizeof(sectortype) * MAXSECTORS },
|
||||||
{ (void **)&wall, sizeof(walltype) * MAXWALLS },
|
{ (void **)&wall, sizeof(walltype) * (MAXWALLS+4) }, // +4: editor quirks
|
||||||
{ (void **)&sprite, sizeof(spritetype) * MAXSPRITES },
|
{ (void **)&sprite, sizeof(spritetype) * MAXSPRITES },
|
||||||
{ (void **)&tsprite, sizeof(spritetype) * MAXSPRITESONSCREEN },
|
{ (void **)&tsprite, sizeof(spritetype) * MAXSPRITESONSCREEN },
|
||||||
{ (void **)&spriteext, sizeof(spriteext_t) * (MAXSPRITES+MAXUNIQHUDID) },
|
{ (void **)&spriteext, sizeof(spriteext_t) * (MAXSPRITES+MAXUNIQHUDID) },
|
||||||
|
|
Loading…
Reference in a new issue