Much more elegant solution to updating the player's sectnum when passing through

TROR portals that works with a little help from updatesectorz() (change not visible
from CON code). Relies only on the presence of an extension whose portal isn't
blocked and also plays nicely with corner cases like being shrunk and enabling
the jetpack. This should fix the upward moving platforms in WGR2.

git-svn-id: https://svn.eduke32.com/eduke32@1996 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-09-01 18:38:13 +00:00
parent b72d351f20
commit 99ce725b60
2 changed files with 24 additions and 29 deletions

View file

@ -12194,17 +12194,27 @@ void updatesectorexclude(int32_t x, int32_t y, int16_t *sectnum, const uint8_t *
*sectnum = -1; *sectnum = -1;
} }
// new: if *sectnum >= MAXSECTORS, *sectnum-=MAXSECTORS is considered instead
// as starting sector and the 'initial' z check is skipped
// (not initial anymore because it follows the sector updating due to TROR)
void updatesectorz(int32_t x, int32_t y, int32_t z, int16_t *sectnum) void updatesectorz(int32_t x, int32_t y, int32_t z, int16_t *sectnum)
{ {
walltype *wal; walltype *wal;
int32_t i, j, cz, fz; int32_t i, j, cz, fz;
if ((*sectnum >= 0) && (*sectnum < numsectors)) if ((uint32_t)(*sectnum) < 2*MAXSECTORS)
{ {
int32_t nofirstzcheck = 0;
if (*sectnum >= MAXSECTORS)
{
*sectnum -= MAXSECTORS;
nofirstzcheck = 1;
}
// this block used to be outside the "if" and caused crashes in Polymost Mapster32 // this block used to be outside the "if" and caused crashes in Polymost Mapster32
getzsofslope(*sectnum, x, y, &cz, &fz); getzsofslope(*sectnum, x, y, &cz, &fz);
if ((z >= cz) && (z <= fz))
if (inside(x,y,*sectnum) != 0) return;
#ifdef YAX_ENABLE #ifdef YAX_ENABLE
if (z < cz) if (z < cz)
{ {
@ -12219,6 +12229,8 @@ void updatesectorz(int32_t x, int32_t y, int32_t z, int16_t *sectnum)
{ *sectnum = i; return; } { *sectnum = i; return; }
} }
#endif #endif
if (nofirstzcheck || ((z >= cz) && (z <= fz)))
if (inside(x,y,*sectnum) != 0) return;
wal = &wall[sector[*sectnum].wallptr]; wal = &wall[sector[*sectnum].wallptr];
j = sector[*sectnum].wallnum; j = sector[*sectnum].wallnum;

View file

@ -4529,7 +4529,6 @@ void P_ProcessInput(int32_t snum)
int32_t fz, cz, hz, lz, truefdist, x, y, psectlotag; int32_t fz, cz, hz, lz, truefdist, x, y, psectlotag;
uint8_t *kb = &p->kickback_pic; uint8_t *kb = &p->kickback_pic;
int16_t tempsect; int16_t tempsect;
int32_t jetpackdz = 0;
if (g_player[snum].playerquitflag == 0) if (g_player[snum].playerquitflag == 0)
return; return;
@ -4929,7 +4928,6 @@ void P_ProcessInput(int32_t snum)
if (p->jetpack_on < 11) if (p->jetpack_on < 11)
{ {
p->jetpack_on++; p->jetpack_on++;
jetpackdz -= (p->jetpack_on<<7);
p->pos.z -= (p->jetpack_on<<7); //Goin up p->pos.z -= (p->jetpack_on<<7); //Goin up
} }
else if (p->jetpack_on == 11 && !A_CheckSoundPlaying(p->i,DUKE_JETPACK_IDLE)) else if (p->jetpack_on == 11 && !A_CheckSoundPlaying(p->i,DUKE_JETPACK_IDLE))
@ -4945,7 +4943,6 @@ void P_ProcessInput(int32_t snum)
VM_OnEvent(EVENT_SOARUP,p->i,snum, -1); VM_OnEvent(EVENT_SOARUP,p->i,snum, -1);
if (aGameVars[g_iReturnVarID].val.lValue == 0) if (aGameVars[g_iReturnVarID].val.lValue == 0)
{ {
jetpackdz -= j;
p->pos.z -= j; p->pos.z -= j;
p->crack_time = 777; p->crack_time = 777;
} }
@ -4958,7 +4955,6 @@ void P_ProcessInput(int32_t snum)
VM_OnEvent(EVENT_SOARDOWN,p->i,snum, -1); VM_OnEvent(EVENT_SOARDOWN,p->i,snum, -1);
if (aGameVars[g_iReturnVarID].val.lValue == 0) if (aGameVars[g_iReturnVarID].val.lValue == 0)
{ {
jetpackdz += j;
p->pos.z += j; p->pos.z += j;
p->crack_time = 777; p->crack_time = 777;
} }
@ -5373,33 +5369,20 @@ HORIZONLY:
else else
{ {
#ifdef YAX_ENABLE #ifdef YAX_ENABLE
int32_t sect = p->cursectnum;
int16_t cb, fb;
if (sect >= 0)
yax_getbunches(sect, &cb, &fb);
// this updatesectorz conflicts with Duke3d's way of teleporting through water, // this updatesectorz conflicts with Duke3d's way of teleporting through water,
// so make it a bit conditional... OTOH, this way we have an ugly z jump when // so make it a bit conditional... OTOH, this way we have an ugly z jump when
// changing from above water to underwater // changing from above water to underwater
if (p->cursectnum >= 0 && !(sector[p->cursectnum].lotag==1 && if (sect >= 0 && !(sector[sect].lotag==1 && p->on_ground && fb>=0))
p->on_ground && yax_getbunch(p->cursectnum, YAX_FLOOR)>=0))
{ {
int32_t tmpdz = 0; if ((fb>=0 && !(sector[sect].floorstat&512)) || (cb>=0 && !(sector[sect].ceilingstat&512)))
// Do updatesectorz only if ceiling/floor bunchnum is >= 0. Otherwise, unwanted
// side-effects like dying when jumping into a lotag==1 sector or on other
// occasions can occur.
// The 'if' is divided in two disjunct cases (jetpack off or on), because we can't
// trust p->vel.z when we're flying. In this case, jetpackdz gives the z delta for
// this tic.
// The (!shrunk || ...) part is so that we don't 'squish' when taking off shrunk.
if (p->jetpack_on)
{
if (!shrunk || p->jetpack_on==11)
tmpdz = jetpackdz;
}
else if (!p->jetpack_on && p->vel.z)
{
tmpdz = p->vel.z;
}
if (tmpdz && yax_getbunch(p->cursectnum, (tmpdz>0))>=0)
{ {
p->cursectnum += MAXSECTORS; // skip initial z check, restored by updatesectorz
updatesectorz(p->pos.x,p->pos.y,p->pos.z,&p->cursectnum); updatesectorz(p->pos.x,p->pos.y,p->pos.z,&p->cursectnum);
} }
} }