Engine: add funtion 'yax_vnextsec(wall, cf)' to C API. It's often useful when

dealing with sectors on the two sides of a bunch.  Make yax_globallev and
yax_globalbunch variables non-static.
Rewrite a TROR-related bit in the engine code using the new function.

git-svn-id: https://svn.eduke32.com/eduke32@2018 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-09-15 17:02:12 +00:00
parent 3b634f28ae
commit 7f1133a493
3 changed files with 29 additions and 16 deletions

View File

@ -99,6 +99,7 @@ void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum);
void yax_setbunches(int16_t i, int16_t cb, int16_t fb);
int16_t yax_getnextwall(int16_t wal, int16_t cf);
void yax_setnextwall(int16_t wal, int16_t cf, int16_t thenextwall);
int16_t yax_vnextsec(int16_t line, int16_t cf);
void yax_update(int32_t resetstat);
int32_t yax_getneighborsect(int32_t x, int32_t y, int32_t sectnum, int32_t cf, int16_t *ret_bunchnum);

View File

@ -261,9 +261,9 @@ void yax_updategrays(int32_t posze)
int32_t g_nodraw = 0;
int32_t scansector_retfast = 0;
static int32_t scansector_collectsprites = 1;
static int32_t yax_globalcf = -1;
static int32_t yax_globallev = YAX_MAXDRAWS;
static int32_t yax_globalbunch = -1;
static int32_t yax_globalcf = -1, yax_nomaskpass=0;
int32_t yax_globallev = YAX_MAXDRAWS;
int32_t yax_globalbunch = -1;
// duplicated tsprites
// [i]:
@ -277,11 +277,16 @@ static int16_t yax_tsprite[1 + 2*YAX_MAXDRAWS][MAXSPRITESONSCREEN];
int16_t yax_bunchnum[MAXSECTORS][2];
int16_t yax_nextwall[MAXWALLS][2];
static int32_t yax_islockededge(int16_t line, int16_t cf)
static int32_t yax_islockededge(int32_t line, int32_t cf)
{
return !!(wall[line].cstat&(YAX_NEXTWALLBIT(cf)));
}
static int32_t yax_isislandwall(int32_t line, int32_t cf)
{
return (yax_vnextsec(line, cf)>=0);
}
#define YAX_BUNCHNUM(Sect, Cf) (*(&sector[Sect].ceilingxpanning + 8*Cf))
//// bunch getters/setters
@ -374,6 +379,19 @@ void yax_setnextwall(int16_t wal, int16_t cf, int16_t thenextwall)
}
}
// make one step in the vertical direction, and if the wall we arrive at
// is red, return its nextsector.
int16_t yax_vnextsec(int16_t line, int16_t cf)
{
int16_t ynw = yax_getnextwall(line, cf);
if (ynw < 0)
return -1;
return wall[ynw].nextsector;
}
//// in-struct --> array transfer (only resetstat==0); list construction
// resetstat: 0: reset and read data from structs and construct linked lists etc.
// 1: only reset
@ -4607,11 +4625,9 @@ static void drawalls(int32_t bunch)
}
}
}
if ((nextsectnum < 0) || (wal->cstat&32)) //White/1-way wall
{
#ifdef YAX_ENABLE
int16_t ynw[2];
#endif
globalorientation = (int32_t)wal->cstat;
if (nextsectnum < 0) globalpicnum = wal->picnum;
else globalpicnum = wal->overpicnum;
@ -4643,14 +4659,11 @@ static void drawalls(int32_t bunch)
if (gotswall == 0) { gotswall = 1; prepwall(z,wal); }
wallscan(x1,x2,uplc,dplc,swall,lwall);
#ifdef YAX_ENABLE
// TODO: slopes?
ynw[0] = yax_getnextwall(wallnum, 0);
ynw[1] = yax_getnextwall(wallnum, 1);
if (globalposz > sec->floorz && ((ynw[1]>=0 && wall[ynw[1]].nextwall>=0)
// || (nextsectnum>=0 && yax_getbunch(sectnum,1)>=0)
))
if (globalposz > sec->floorz && yax_isislandwall(wallnum, YAX_FLOOR))
{
for (x=x1; x<=x2; x++)
if (dplc[x] > umost[x] && umost[x] <= dmost[x])
@ -4659,9 +4672,7 @@ static void drawalls(int32_t bunch)
if (umost[x] > dmost[x]) numhits--;
}
}
else if (globalposz < sec->ceilingz && ((ynw[0]>=0 && wall[ynw[0]].nextwall>=0)
// || (nextsectnum>=0 && yax_getbunch(sectnum,0)>=0)
))
else if (globalposz < sec->ceilingz && yax_isislandwall(wallnum, YAX_CEILING))
{
for (x=x1; x<=x2; x++)
if (uplc[x] < dmost[x] && umost[x] <= dmost[x])

View File

@ -76,8 +76,9 @@ int32_t animateoffs(int16_t tilenum, int16_t fakevar);
extern void polymost_scansector(int32_t sectnum);
#endif
int32_t engine_addtsprite(int16_t z, int16_t sectnum);
extern int32_t g_nodraw, scansector_retfast;
#ifdef YAX_ENABLE
extern int32_t g_nodraw, scansector_retfast;
extern int32_t yax_globallev, yax_globalbunch;
extern uint8_t haveymost[YAX_MAXBUNCHES>>3];
#endif