When loading a map in-game, clear TROR wall members corresponding to up/down links.

I find this cleaner for two reasons.  First, lotags won't get in the way of
neartag(), so that doors and switches near constrained TROR walls can be
pushed.  Second, this removes the information leak so that CON coders aren't
tempted to read that values directly before a proper API for that comes along.
When writing out a map in-game (e.g. with dndebug), restore the respective
members so that it can be loaded in the editor again.

git-svn-id: https://svn.eduke32.com/eduke32@2349 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-02-16 19:25:18 +00:00
parent 0538c70242
commit 30e16fe7bb
2 changed files with 44 additions and 6 deletions

View file

@ -82,7 +82,8 @@ void yax_updategrays(int32_t posze);
#ifdef YAX_ENABLE
// more user tag hijacking: lotag/extra :/
# define YAX_NEXTWALL(Wall, Cf) (*(&wall[Wall].lotag + 2*Cf))
# define YAX_PTRNEXTWALL(Ptr, Wall, Cf) (*(&Ptr[Wall].lotag + 2*Cf))
# define YAX_NEXTWALL(Wall, Cf) YAX_PTRNEXTWALL(wall, Wall, Cf)
# define YAX_ITER_WALLS(Wal, Itervar, Cfvar) Cfvar=0, Itervar=(Wal); Itervar!=-1; \
Itervar=yax_getnextwall(Itervar, Cfvar), (void)(Itervar==-1 && Cfvar==0 && (Cfvar=1) && (Itervar=yax_getnextwall((Wal), Cfvar)))

View file

@ -306,7 +306,8 @@ static int32_t yax_islockededge(int32_t line, int32_t cf)
return !!(wall[line].cstat&(YAX_NEXTWALLBIT(cf)));
}
#define YAX_BUNCHNUM(Sect, Cf) (*(&sector[Sect].ceilingxpanning + 8*Cf))
#define YAX_PTRBUNCHNUM(Ptr, Sect, Cf) (*(&Ptr[Sect].ceilingxpanning + 8*Cf))
#define YAX_BUNCHNUM(Sect, Cf) YAX_PTRBUNCHNUM(sector, Sect, Cf)
//// bunch getters/setters
int16_t yax_getbunch(int16_t i, int16_t cf)
@ -446,7 +447,10 @@ void yax_update(int32_t resetstat)
return;
// constuct singly linked list of sectors-of-bunch
editstatus = (resetstat==0); // read bunchnums directly from the sector struct!
// read bunchnums directly from the sector struct in yax_[gs]etbunch{es}!
editstatus = (resetstat==0);
// use oeditstatus to check for in-gamedness from here on!
if (resetstat==0)
{
@ -503,7 +507,11 @@ void yax_update(int32_t resetstat)
for (j=sector[i].wallptr; j<sector[i].wallptr+sector[i].wallnum; j++)
{
if (yax_islockededge(j,YAX_CEILING))
{
yax_nextwall[j][0] = YAX_NEXTWALL(j,0);
if (oeditstatus==0)
YAX_NEXTWALL(j,0) = 0; // reset lotag!
}
}
if (headsectbunch[0][cb] == -1)
@ -528,7 +536,11 @@ void yax_update(int32_t resetstat)
for (j=sector[i].wallptr; j<sector[i].wallptr+sector[i].wallnum; j++)
{
if (yax_islockededge(j,YAX_FLOOR))
{
yax_nextwall[j][1] = YAX_NEXTWALL(j,1);
if (oeditstatus==0)
YAX_NEXTWALL(j,1) = -1; // reset extra!
}
}
if (headsectbunch[1][fb] == -1)
@ -541,6 +553,7 @@ void yax_update(int32_t resetstat)
}
}
}
editstatus = oeditstatus;
}
@ -683,6 +696,9 @@ static int yax_cmpbunches(const int16_t *b1, const int16_t *b2)
static void yax_tweakpicnums(int32_t bunchnum, int32_t cf, int32_t restore)
{
// for polymer, this is called before polymer_drawrooms() with restore==0
// and after polymer_drawmasks() with restore==1
static int16_t opicnum[2][MAXSECTORS];
int32_t i, dastat;
@ -690,6 +706,7 @@ static void yax_tweakpicnums(int32_t bunchnum, int32_t cf, int32_t restore)
{
dastat = (SECTORFLD(i,stat, cf)&(128+256));
// only consider non-masked ceilings/floors
if (dastat==0 || (restore==1 && opicnum[cf][i]&0x8000))
{
if (!restore)
@ -1089,8 +1106,6 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn
#endif
}
#undef YAX_BUNCHNUM
#endif
//
@ -4579,7 +4594,7 @@ static void drawalls(int32_t bunch)
// x------------------x
// 0 ---> 1
//
// 4 (our pos)
// 4 (our pos, z wrt the nextsector!)
getzsofslope((int16_t)sectnum,wal->x,wal->y,&cz[0],&fz[0]);
getzsofslope((int16_t)sectnum,wall[wal->point2].x,wall[wal->point2].y,&cz[1],&fz[1]);
@ -9974,6 +9989,17 @@ int32_t saveboard(const char *filename, int32_t *daposx, int32_t *daposy, int32_
sec->lotag = B_LITTLE16(sec->lotag);
sec->hitag = B_LITTLE16(sec->hitag);
sec->extra = B_LITTLE16(sec->extra);
#ifdef YAX_ENABLE
if (editstatus == 0)
{
// if in-game, pack game-time bunchnum data back into structs
int32_t cf, bn;
for (cf=0; cf<2; cf++)
if ((bn=yax_getbunch(i, cf)) >= 0)
YAX_PTRBUNCHNUM(tsect, i, cf) = bn;
}
#endif
}
Bwrite(fil,&tsect[0],sizeof(sectortype) * numsectors);
@ -10000,6 +10026,17 @@ int32_t saveboard(const char *filename, int32_t *daposx, int32_t *daposy, int32_
wal->cstat = B_LITTLE16(wal->cstat);
wal->picnum = B_LITTLE16(wal->picnum);
wal->overpicnum = B_LITTLE16(wal->overpicnum);
#ifdef YAX_ENABLE
if (editstatus == 0)
{
// if in-game, pack game-time yax-nextwall data back into structs
int16_t ynw;
if ((ynw=yax_getnextwall(i, YAX_CEILING))>=0)
YAX_PTRNEXTWALL(twall,i,YAX_CEILING) = ynw;
if ((ynw=yax_getnextwall(i, YAX_FLOOR))>=0)
YAX_PTRNEXTWALL(twall,i,YAX_FLOOR) = ynw;
}
#endif
wal->lotag = B_LITTLE16(wal->lotag);
wal->hitag = B_LITTLE16(wal->hitag);
wal->extra = B_LITTLE16(wal->extra);