diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 561658957..8158c28b8 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -12194,17 +12194,27 @@ void updatesectorexclude(int32_t x, int32_t y, int16_t *sectnum, const uint8_t * *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) { walltype *wal; 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 getzsofslope(*sectnum, x, y, &cz, &fz); - if ((z >= cz) && (z <= fz)) - if (inside(x,y,*sectnum) != 0) return; + #ifdef YAX_ENABLE if (z < cz) { @@ -12219,6 +12229,8 @@ void updatesectorz(int32_t x, int32_t y, int32_t z, int16_t *sectnum) { *sectnum = i; return; } } #endif + if (nofirstzcheck || ((z >= cz) && (z <= fz))) + if (inside(x,y,*sectnum) != 0) return; wal = &wall[sector[*sectnum].wallptr]; j = sector[*sectnum].wallnum; diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index 1d17814bf..f1524a4ba 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -4529,7 +4529,6 @@ void P_ProcessInput(int32_t snum) int32_t fz, cz, hz, lz, truefdist, x, y, psectlotag; uint8_t *kb = &p->kickback_pic; int16_t tempsect; - int32_t jetpackdz = 0; if (g_player[snum].playerquitflag == 0) return; @@ -4929,7 +4928,6 @@ void P_ProcessInput(int32_t snum) if (p->jetpack_on < 11) { p->jetpack_on++; - jetpackdz -= (p->jetpack_on<<7); p->pos.z -= (p->jetpack_on<<7); //Goin up } 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); if (aGameVars[g_iReturnVarID].val.lValue == 0) { - jetpackdz -= j; p->pos.z -= j; p->crack_time = 777; } @@ -4958,7 +4955,6 @@ void P_ProcessInput(int32_t snum) VM_OnEvent(EVENT_SOARDOWN,p->i,snum, -1); if (aGameVars[g_iReturnVarID].val.lValue == 0) { - jetpackdz += j; p->pos.z += j; p->crack_time = 777; } @@ -5373,33 +5369,20 @@ HORIZONLY: else { #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, // so make it a bit conditional... OTOH, this way we have an ugly z jump when // changing from above water to underwater - if (p->cursectnum >= 0 && !(sector[p->cursectnum].lotag==1 && - p->on_ground && yax_getbunch(p->cursectnum, YAX_FLOOR)>=0)) + if (sect >= 0 && !(sector[sect].lotag==1 && p->on_ground && fb>=0)) { - int32_t tmpdz = 0; - - // 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) + if ((fb>=0 && !(sector[sect].floorstat&512)) || (cb>=0 && !(sector[sect].ceilingstat&512))) { + p->cursectnum += MAXSECTORS; // skip initial z check, restored by updatesectorz updatesectorz(p->pos.x,p->pos.y,p->pos.z,&p->cursectnum); } }