Introduce "twalltype" for temporary uses of walltype where using wall_tracker_hook() would be invalid. This is similar to "tspritetype" and fixes a bunch of problems in the editor that cropped up when changing the tracker sanity checks to an assert that only exists in debug builds (branching upon any write to a sprite, sector or wall had an unacceptable impact on performance).

git-svn-id: https://svn.eduke32.com/eduke32@4903 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2015-01-11 04:56:38 +00:00
parent 364cf15c4f
commit 107bb7a3fa
5 changed files with 43 additions and 34 deletions

View file

@ -364,6 +364,17 @@ typedef struct
Tracker(Wall, int16_t) extra; Tracker(Wall, int16_t) extra;
} walltypev7; } walltypev7;
typedef struct
{
int32_t x, y;
int16_t point2, nextwall, nextsector;
uint16_t cstat;
int16_t picnum, overpicnum;
int8_t shade;
uint8_t pal, xrepeat, yrepeat, xpanning, ypanning;
uint16_t lotag, hitag;
int16_t extra;
} twalltype;
enum { enum {
SPR_XFLIP = 4, SPR_XFLIP = 4,
@ -1268,7 +1279,7 @@ int32_t sectorofwall_noquick(int16_t theline);
int32_t loopnumofsector(int16_t sectnum, int16_t wallnum); int32_t loopnumofsector(int16_t sectnum, int16_t wallnum);
void setslope(int32_t sectnum, int32_t cf, int16_t slope); void setslope(int32_t sectnum, int32_t cf, int16_t slope);
int32_t lineintersect(int32_t x1, int32_t y1, int32_t z1, int32_t x2, int32_t y2, int32_t z2, int32_t x3, int32_t lintersect(int32_t x1, int32_t y1, int32_t z1, int32_t x2, int32_t y2, int32_t z2, int32_t x3,
int32_t y3, int32_t x4, int32_t y4, int32_t *intx, int32_t *inty, int32_t *intz); int32_t y3, int32_t x4, int32_t y4, int32_t *intx, int32_t *inty, int32_t *intz);
int32_t rayintersect(int32_t x1, int32_t y1, int32_t z1, int32_t vx, int32_t vy, int32_t vz, int32_t x3, int32_t rayintersect(int32_t x1, int32_t y1, int32_t z1, int32_t vx, int32_t vy, int32_t vz, int32_t x3,

View file

@ -192,8 +192,8 @@ typedef struct
int16_t *ynextwall; // [numwalls][2] int16_t *ynextwall; // [numwalls][2]
#endif #endif
sectortype *sector; sectortype *sector;
walltype *wall; twalltype *wall;
spritetype *sprite; tspritetype *sprite;
} mapinfofull_t; } mapinfofull_t;
int32_t g_doScreenShot; int32_t g_doScreenShot;
@ -1605,7 +1605,7 @@ static int32_t backup_highlighted_map(mapinfofull_t *mapinfo)
// allocate temp storage // allocate temp storage
mapinfo->sector = (sectortype *)Xmalloc(highlightsectorcnt * sizeof(sectortype)); mapinfo->sector = (sectortype *)Xmalloc(highlightsectorcnt * sizeof(sectortype));
mapinfo->wall = (walltype *)Xmalloc(tmpnumwalls * sizeof(walltype)); mapinfo->wall = (twalltype *)Xmalloc(tmpnumwalls * sizeof(walltype));
#ifdef YAX_ENABLE #ifdef YAX_ENABLE
if (mapinfo->numyaxbunches > 0) if (mapinfo->numyaxbunches > 0)
@ -1621,7 +1621,7 @@ static int32_t backup_highlighted_map(mapinfofull_t *mapinfo)
if (tmpnumsprites>0) if (tmpnumsprites>0)
{ {
mapinfo->sprite = (spritetype *)Xmalloc(tmpnumsprites * sizeof(spritetype)); mapinfo->sprite = (tspritetype *)Xmalloc(tmpnumsprites * sizeof(spritetype));
} }
else else
{ {
@ -1838,7 +1838,7 @@ static int32_t restore_highlighted_map(mapinfofull_t *mapinfo, int32_t forreal)
// insert sprites // insert sprites
for (i=0; i<mapinfo->numsprites; i++) for (i=0; i<mapinfo->numsprites; i++)
{ {
const spritetype *srcspr = &mapinfo->sprite[i]; const tspritetype *srcspr = &mapinfo->sprite[i];
int32_t sect = onumsectors + srcspr->sectnum; int32_t sect = onumsectors + srcspr->sectnum;
j = insertsprite(sect, srcspr->statnum); j = insertsprite(sect, srcspr->statnum);
@ -2245,9 +2245,9 @@ void fade_editor_screen(int32_t keepcol)
static void copy_some_wall_members(int16_t dst, int16_t src, int32_t reset_some) static void copy_some_wall_members(int16_t dst, int16_t src, int32_t reset_some)
{ {
static walltype nullwall; static twalltype nullwall;
walltype *dstwal=&wall[dst]; walltype * const dstwal = &wall[dst];
const walltype *srcwal = src >= 0 ? &wall[src] : &nullwall; const twalltype *srcwal = src >= 0 ? (twalltype *)&wall[src] : &nullwall;
memset(&nullwall, 0, sizeof(nullwall)); memset(&nullwall, 0, sizeof(nullwall));
nullwall.yrepeat = 8; nullwall.yrepeat = 8;
@ -2472,7 +2472,7 @@ static int32_t trace_loop(int32_t j, uint8_t *visitedwall, int16_t *ignore_ret,
// Context that needs special treatment: suckwall, splitsect, splitstartwall // Context that needs special treatment: suckwall, splitsect, splitstartwall
static int32_t backup_drawn_walls(int32_t restore) static int32_t backup_drawn_walls(int32_t restore)
{ {
static walltype *tmpwall; static twalltype *tmpwall;
// back up // back up
if (restore==0) if (restore==0)
@ -2485,7 +2485,7 @@ static int32_t backup_drawn_walls(int32_t restore)
return 2; return 2;
Bfree(tmpwall); Bfree(tmpwall);
tmpwall = (walltype *)Xmalloc((newnumwalls-numwalls) * sizeof(walltype)); tmpwall = (twalltype *)Xmalloc((newnumwalls-numwalls) * sizeof(walltype));
ovh.bak_wallsdrawn = newnumwalls-numwalls; ovh.bak_wallsdrawn = newnumwalls-numwalls;
@ -2636,8 +2636,8 @@ static int32_t sectors_components(int16_t hlsectcnt, const int16_t *hlsector, in
static int cmpgeomwal1(const void *w1, const void *w2) static int cmpgeomwal1(const void *w1, const void *w2)
{ {
const walltype *wal1 = &wall[*(int16_t *)w1]; twalltype const * const wal1 = (twalltype *)&wall[*(int16_t *)w1];
const walltype *wal2 = &wall[*(int16_t *)w2]; twalltype const * const wal2 = (twalltype *)&wall[*(int16_t *)w2];
if (wal1->x == wal2->x) if (wal1->x == wal2->x)
return wal1->y - wal2->y; return wal1->y - wal2->y;
@ -2944,7 +2944,7 @@ static int32_t lineintersect2v(const vec2_t *p1, const vec2_t *p2, // line segm
vec2_t *pint) vec2_t *pint)
{ {
int32_t intz; int32_t intz;
return lineintersect(p1->x, p1->y, 0, p2->x, p2->y, 0, return lintersect(p1->x, p1->y, 0, p2->x, p2->y, 0,
q1->x, q1->y, q2->x, q2->y, q1->x, q1->y, q2->x, q2->y,
&pint->x, &pint->y, &intz); &pint->x, &pint->y, &intz);
} }
@ -3431,7 +3431,7 @@ void overheadeditor(void)
i = newnumwalls-1; i = newnumwalls-1;
for (; i>=0; i--) for (; i>=0; i--)
{ {
const walltype *wal = &wall[i]; walltype const * const wal = &wall[i];
if (j>=0 && sector[j].wallptr > i) if (j>=0 && sector[j].wallptr > i)
j--; j--;
@ -3605,7 +3605,7 @@ void overheadeditor(void)
if ((highlight[i]&16384)==0) if ((highlight[i]&16384)==0)
{ {
const walltype *wal = &wall[highlight[i]]; walltype const * const wal = &wall[highlight[i]];
const int32_t p2=wal->point2, hlp=(show2dwall[p2>>3]&(1<<(p2&7))); const int32_t p2=wal->point2, hlp=(show2dwall[p2>>3]&(1<<(p2&7)));
vec3_t v1 = { x, y, 0 }, v2 = { wall[p2].x, wall[p2].y, 0 }; vec3_t v1 = { x, y, 0 }, v2 = { wall[p2].x, wall[p2].y, 0 };
@ -3799,7 +3799,7 @@ void overheadeditor(void)
int32_t startofloop, endofloop; int32_t startofloop, endofloop;
int32_t numtoswap = -1; int32_t numtoswap = -1;
int32_t w=0; int32_t w=0;
walltype tempwall; twalltype tempwall;
startofloop = startwall = sector[highlightsector[i]].wallptr; startofloop = startwall = sector[highlightsector[i]].wallptr;
endofloop = endwall = startwall+sector[highlightsector[i]].wallnum-1; endofloop = endwall = startwall+sector[highlightsector[i]].wallnum-1;
@ -5067,7 +5067,7 @@ end_yax: ;
sector[refsect].wallnum += n; sector[refsect].wallnum += n;
if (refsect != numsectors-1) if (refsect != numsectors-1)
{ {
walltype *tmpwall = (walltype *)Xmalloc(n * sizeof(walltype)); twalltype *tmpwall = (twalltype *)Xmalloc(n * sizeof(walltype));
int16_t *tmponw = (int16_t *)Xmalloc(n * sizeof(int16_t)); int16_t *tmponw = (int16_t *)Xmalloc(n * sizeof(int16_t));
for (m=0; m<numwalls; m++) for (m=0; m<numwalls; m++)
@ -5824,7 +5824,7 @@ end_point_dragging:
int32_t numouterwalls[2] = {0,0}, numowals; int32_t numouterwalls[2] = {0,0}, numowals;
static int16_t outerwall[2][MAXWALLS]; static int16_t outerwall[2][MAXWALLS];
const walltype *wal0, *wal1, *wal0p2, *wal1p2; const twalltype *wal0, *wal1, *wal0p2, *wal1p2;
// join sector ceilings/floors to a new bunch // join sector ceilings/floors to a new bunch
if (numyaxbunches==YAX_MAXBUNCHES) if (numyaxbunches==YAX_MAXBUNCHES)
@ -5918,11 +5918,11 @@ end_point_dragging:
for (k=0; k<numowals; k++) for (k=0; k<numowals; k++)
{ {
wal0 = &wall[outerwall[0][k]]; wal0 = (twalltype *)&wall[outerwall[0][k]];
wal1 = &wall[outerwall[1][k]]; wal1 = (twalltype *)&wall[outerwall[1][k]];
wal0p2 = &wall[wal0->point2]; wal0p2 = (twalltype *)&wall[wal0->point2];
wal1p2 = &wall[wal1->point2]; wal1p2 = (twalltype *)&wall[wal1->point2];
if (k==0) if (k==0)
{ {
@ -5935,14 +5935,14 @@ end_point_dragging:
{ {
pos.x = wal0->x + (wal0p2->x - wal0->x)/4; pos.x = wal0->x + (wal0p2->x - wal0->x)/4;
pos.y = wal0->y + (wal0p2->y - wal0->y)/4; pos.y = wal0->y + (wal0p2->y - wal0->y)/4;
pos.z = getflorzofslope(sectorofwall(wal0-wall), pos.x, pos.y); pos.z = getflorzofslope(sectorofwall(wal0-(twalltype *)wall), pos.x, pos.y);
if (!delayerr) if (!delayerr)
message("Outer wall coordinates must coincide for both components"); message("Outer wall coordinates must coincide for both components");
OSD_Printf("wal0:%d (%d,%d)--(%d,%d)\n",(int)(wal0-wall), OSD_Printf("wal0:%d (%d,%d)--(%d,%d)\n",(int)(wal0-(twalltype *)wall),
TrackerCast(wal0->x),TrackerCast(wal0->y), TrackerCast(wal0p2->x),TrackerCast(wal0p2->y)); wal0->x,wal0->y, wal0p2->x,wal0p2->y);
OSD_Printf("wal1:%d (%d,%d)--(%d,%d)\n",(int)(wal1-wall), OSD_Printf("wal1:%d (%d,%d)--(%d,%d)\n",(int)(wal1-(twalltype *)wall),
TrackerCast(wal1->x),TrackerCast(wal1->y), TrackerCast(wal1p2->x),TrackerCast(wal1p2->y)); wal1->x,wal1->y, wal1p2->x,wal1p2->y);
goto end_join_sectors; goto end_join_sectors;
} }
@ -10250,14 +10250,12 @@ void showsectordata(int16_t sectnum, int16_t small)
void showwalldata(int16_t wallnum, int16_t small) void showwalldata(int16_t wallnum, int16_t small)
{ {
walltype *wal; walltype const * const wal = &wall[wallnum];
int32_t sec; int32_t sec;
char snotbuf[80]; char snotbuf[80];
int32_t col=0; //, row = 0; int32_t col=0; //, row = 0;
int32_t color = small ? whitecol : editorcolors[11]; int32_t color = small ? whitecol : editorcolors[11];
wal = &wall[wallnum];
if (small) if (small)
{ {
_printmessage16("^10Wall %d %s ^O(F8 to edit)", wallnum, _printmessage16("^10Wall %d %s ^O(F8 to edit)", wallnum,

View file

@ -9853,7 +9853,7 @@ int32_t ExtPostStartupWindow(void)
} }
if (ReadPaletteTable()) if (ReadPaletteTable())
return -1; return 0;
InitCustomColors(); InitCustomColors();

View file

@ -2986,7 +2986,7 @@ nullquote:
int32_t intx, inty, intz, ret; int32_t intx, inty, intz, ret;
if (tw==CON_LINEINTERSECT) if (tw==CON_LINEINTERSECT)
ret = lineintersect(x1, y1, z1, x2, y2, z2, x3, y3, x4, y4, &intx, &inty, &intz); ret = lintersect(x1, y1, z1, x2, y2, z2, x3, y3, x4, y4, &intx, &inty, &intz);
else else
ret = rayintersect(x1, y1, z1, x2, y2, z2, x3, y3, x4, y4, &intx, &inty, &intz); ret = rayintersect(x1, y1, z1, x2, y2, z2, x3, y3, x4, y4, &intx, &inty, &intz);

View file

@ -1820,7 +1820,7 @@ badindex:
int32_t intx, inty, intz, ret; int32_t intx, inty, intz, ret;
if (tw==CON_LINEINTERSECT) if (tw==CON_LINEINTERSECT)
ret = lineintersect(x1, y1, z1, x2, y2, z2, x3, y3, x4, y4, &intx, &inty, &intz); ret = lintersect(x1, y1, z1, x2, y2, z2, x3, y3, x4, y4, &intx, &inty, &intz);
else else
ret = rayintersect(x1, y1, z1, x2, y2, z2, x3, y3, x4, y4, &intx, &inty, &intz); ret = rayintersect(x1, y1, z1, x2, y2, z2, x3, y3, x4, y4, &intx, &inty, &intz);