diff --git a/source/core/coreactor.h b/source/core/coreactor.h index cc436f39b..b79c91ae0 100644 --- a/source/core/coreactor.h +++ b/source/core/coreactor.h @@ -596,6 +596,19 @@ inline int pushmove(DVector3& pos, sectortype** const sect, int32_t const walldi return res; } +#if 0 +inline int pushmove(DVector3& pos, sectortype** const sect, double const walldist, double const ceildist, double const flordist, + uint32_t const cliptype, bool clear = true) +{ + auto vect = vec3_t(pos.X * worldtoint, pos.Y * worldtoint, pos.Z * zworldtoint); + int sectno = *sect ? sector.IndexOf(*sect) : -1; + int res = pushmove_(&vect, §no, walldist * worldtoint, ceildist * worldtoint, flordist * worldtoint, cliptype, clear); + pos = { vect.X * inttoworld, vect.Y * inttoworld, vect.Z * zinttoworld }; + *sect = sectno == -1 ? nullptr : §or[sectno]; + return res; +} +#endif + inline int pushmove(DCoreActor* actor, sectortype** const sect, int32_t const walldist, int32_t const ceildist, int32_t const flordist, uint32_t const cliptype, bool clear = true) { diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index ff9dfe266..d85418aa7 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -612,6 +612,14 @@ struct PLAYER { return int(hiz * zworldtoint); } + int player_int_ceiling_dist() const + { + return p_ceiling_dist * 256; + } + int player_int_floor_dist() const + { + return p_floor_dist * 256; + } DSWActor* actor; // this may not be a TObjPtr! TObjPtr lowActor, highActor; diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 65d97d7b1..7273dfd76 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1892,7 +1892,7 @@ void DoPlayerSlide(PLAYER* pp) if (labs(pp->slide_vect.X) < 12800 && labs(pp->slide_vect.Y) < 12800) pp->slide_vect.X = pp->slide_vect.Y = 0; - push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); + push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->player_int_ceiling_dist(), pp->player_int_floor_dist(), CLIPMASK_PLAYER); if (push_ret < 0) { if (!(pp->Flags & PF_DEAD)) @@ -1906,10 +1906,10 @@ void DoPlayerSlide(PLAYER* pp) return; } Collision coll; - clipmove(pp->pos, &pp->cursector, pp->slide_vect.X, pp->slide_vect.Y, ((int)actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER, coll); + clipmove(pp->pos, &pp->cursector, pp->slide_vect.X, pp->slide_vect.Y, ((int)actor->spr.clipdist<<2), pp->player_int_ceiling_dist(), pp->player_int_floor_dist(), CLIPMASK_PLAYER, coll); PlayerCheckValidMove(pp); - push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); + push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->player_int_ceiling_dist(), pp->player_int_floor_dist(), CLIPMASK_PLAYER); if (push_ret < 0) { if (!(pp->Flags & PF_DEAD)) @@ -2041,7 +2041,7 @@ void DoPlayerMove(PLAYER* pp) } else { - push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist - Z(16), CLIPMASK_PLAYER); + push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->player_int_ceiling_dist(), pp->player_int_floor_dist() - Z(16), CLIPMASK_PLAYER); if (push_ret < 0) { @@ -2064,12 +2064,12 @@ void DoPlayerMove(PLAYER* pp) actor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK); Collision coll; updatesector(pp->int_ppos().X, pp->int_ppos().Y, &pp->cursector); - clipmove(pp->pos, &pp->cursector, pp->vect.X, pp->vect.Y, ((int)actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER, coll); + clipmove(pp->pos, &pp->cursector, pp->vect.X, pp->vect.Y, ((int)actor->spr.clipdist<<2), pp->player_int_ceiling_dist(), pp->player_int_floor_dist(), CLIPMASK_PLAYER, coll); actor->spr.cstat = save_cstat; PlayerCheckValidMove(pp); - push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist - Z(16), CLIPMASK_PLAYER); + push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->player_int_ceiling_dist(), pp->player_int_floor_dist() - Z(16), CLIPMASK_PLAYER); if (push_ret < 0) { @@ -2829,9 +2829,9 @@ void DoPlayerJump(PLAYER* pp) // added this because jumping up to slopes or jumping on steep slopes // sometimes caused the view to go into the slope // if player gets to close the floor while jumping - if (PlayerFloorHit(pp, pp->int_ploz() - pp->p_floor_dist)) + if (PlayerFloorHit(pp, pp->int_ploz() - pp->player_int_floor_dist())) { - pp->set_int_ppos_Z(pp->int_ploz() - pp->p_floor_dist); + pp->pos.Z = pp->loz - pp->p_floor_dist; pp->jump_speed = 0; PlayerSectorBound(pp, Z(1)); @@ -2989,10 +2989,10 @@ void DoPlayerFall(PLAYER* pp) // need a test for head hits a sloped ceiling while falling // if player gets to close the Ceiling while Falling - if (PlayerCeilingHit(pp, pp->int_phiz() + pp->p_ceiling_dist)) + if (PlayerCeilingHit(pp, pp->int_phiz() + pp->player_int_ceiling_dist())) { // put player at the ceiling - pp->set_int_ppos_Z(pp->int_phiz() + pp->p_ceiling_dist); + pp->pos.Z = pp->hiz + pp->p_ceiling_dist; // don't return or anything - allow to fall until // hit floor } @@ -4413,9 +4413,9 @@ void DoPlayerDive(PLAYER* pp) if (sectu && (sectu->number == 0 || (sectu->flags & SECTFU_CANT_SURFACE))) { // for room over room water the hiz will be the top rooms ceiling - if (pp->int_ppos().Z < pp->int_phiz() + pp->p_ceiling_dist) + if (pp->pos.Z < pp->hiz + pp->p_ceiling_dist) { - pp->set_int_ppos_Z(pp->int_phiz() + pp->p_ceiling_dist); + pp->pos.Z = pp->hiz + pp->p_ceiling_dist; } } else @@ -4465,7 +4465,7 @@ void DoPlayerDive(PLAYER* pp) DoPlayerSpriteBob(pp, PLAYER_DIVE_HEIGHT, PLAYER_DIVE_BOB_AMT, 3); } // Reverse bobbing when getting close to the ceiling - if (pp->int_ppos().Z + pp->bob_amt < pp->int_phiz() + pp->p_ceiling_dist) + if (pp->int_ppos().Z + pp->bob_amt < pp->int_phiz() + pp->player_int_ceiling_dist()) { pp->bob_ndx = NORM_ANGLE(pp->bob_ndx + ((512) - pp->bob_ndx) * 2); DoPlayerSpriteBob(pp, PLAYER_DIVE_HEIGHT, PLAYER_DIVE_BOB_AMT, 3); @@ -4522,7 +4522,7 @@ void DoPlayerCurrent(PLAYER* pp) xvect = sectu->speed * synctics * bcos(sectu->ang) >> 4; yvect = sectu->speed * synctics * bsin(sectu->ang) >> 4; - push_ret = pushmove(pp->pos, &pp->cursector, ((int)pp->actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); + push_ret = pushmove(pp->pos, &pp->cursector, ((int)pp->actor->spr.clipdist<<2), pp->player_int_ceiling_dist(), pp->player_int_floor_dist(), CLIPMASK_PLAYER); if (push_ret < 0) { if (!(pp->Flags & PF_DEAD)) @@ -4538,10 +4538,10 @@ void DoPlayerCurrent(PLAYER* pp) return; } Collision coll; - clipmove(pp->pos, &pp->cursector, xvect, yvect, ((int)pp->actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER, coll); + clipmove(pp->pos, &pp->cursector, xvect, yvect, ((int)pp->actor->spr.clipdist<<2), pp->player_int_ceiling_dist(), pp->player_int_floor_dist(), CLIPMASK_PLAYER, coll); PlayerCheckValidMove(pp); - pushmove(pp->pos, &pp->cursector, ((int)pp->actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); + pushmove(pp->pos, &pp->cursector, ((int)pp->actor->spr.clipdist<<2), pp->player_int_ceiling_dist(), pp->player_int_floor_dist(), CLIPMASK_PLAYER); if (push_ret < 0) { if (!(pp->Flags & PF_DEAD)) diff --git a/source/games/sw/src/player.h b/source/games/sw/src/player.h index 8dfffb4db..aad369557 100644 --- a/source/games/sw/src/player.h +++ b/source/games/sw/src/player.h @@ -62,24 +62,24 @@ constexpr double PLAYER_DIVE_HEIGHTF = 26; // FLOOR_DIST variables are the difference in the Players view and the sector floor. // Must be at LEAST this distance or you cannot move onto sector. -#define PLAYER_RUN_FLOOR_DIST (PLAYER_HEIGHT - PLAYER_STEP_HEIGHT) -#define PLAYER_CRAWL_FLOOR_DIST (PLAYER_CRAWL_HEIGHT - PLAYER_CRAWL_STEP_HEIGHT) -#define PLAYER_WADE_FLOOR_DIST (PLAYER_HEIGHT - PLAYER_STEP_HEIGHT) -#define PLAYER_JUMP_FLOOR_DIST (PLAYER_HEIGHT - PLAYER_JUMP_STEP_HEIGHT) -#define PLAYER_FALL_FLOOR_DIST (PLAYER_HEIGHT - PLAYER_FALL_STEP_HEIGHT) -#define PLAYER_SWIM_FLOOR_DIST (PLAYER_SWIM_HEIGHT - PLAYER_SWIM_STEP_HEIGHT) -#define PLAYER_DIVE_FLOOR_DIST (PLAYER_DIVE_HEIGHT - PLAYER_DIVE_STEP_HEIGHT) +#define PLAYER_RUN_FLOOR_DIST PIXZ(PLAYER_HEIGHT - PLAYER_STEP_HEIGHT) +#define PLAYER_CRAWL_FLOOR_DIST PIXZ(PLAYER_CRAWL_HEIGHT - PLAYER_CRAWL_STEP_HEIGHT) +#define PLAYER_WADE_FLOOR_DIST PIXZ(PLAYER_HEIGHT - PLAYER_STEP_HEIGHT) +#define PLAYER_JUMP_FLOOR_DIST PIXZ(PLAYER_HEIGHT - PLAYER_JUMP_STEP_HEIGHT) +#define PLAYER_FALL_FLOOR_DIST PIXZ(PLAYER_HEIGHT - PLAYER_FALL_STEP_HEIGHT) +#define PLAYER_SWIM_FLOOR_DIST PIXZ(PLAYER_SWIM_HEIGHT - PLAYER_SWIM_STEP_HEIGHT) +#define PLAYER_DIVE_FLOOR_DIST PIXZ(PLAYER_DIVE_HEIGHT - PLAYER_DIVE_STEP_HEIGHT) // FLOOR_DIST variables are the difference in the Players view and the sector floor. // Must be at LEAST this distance or you cannot move onto sector. -#define PLAYER_RUN_CEILING_DIST Z(10) -#define PLAYER_SWIM_CEILING_DIST (Z(12)) -#define PLAYER_DIVE_CEILING_DIST (Z(22)) -#define PLAYER_CRAWL_CEILING_DIST (Z(12)) -#define PLAYER_JUMP_CEILING_DIST Z(4) -#define PLAYER_FALL_CEILING_DIST Z(4) -#define PLAYER_WADE_CEILING_DIST Z(4) +#define PLAYER_RUN_CEILING_DIST (10) +#define PLAYER_SWIM_CEILING_DIST ((12)) +#define PLAYER_DIVE_CEILING_DIST ((22)) +#define PLAYER_CRAWL_CEILING_DIST ((12)) +#define PLAYER_JUMP_CEILING_DIST (4) +#define PLAYER_FALL_CEILING_DIST (4) +#define PLAYER_WADE_CEILING_DIST (4) // // DIVE