From 3ac4e7ed2d4a1cf70e372c4742e7f9b4a50f0e5f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 31 Aug 2022 00:39:32 +0200 Subject: [PATCH] - eliminated player_int_ceiling_dist, player_int_floor_dist wrappers --- source/core/coreactor.h | 30 ++++++++++++++++++++++++ source/games/sw/src/game.h | 10 +------- source/games/sw/src/player.cpp | 18 +++++++------- wadsrc/static/zscript/games/sw/swgame.zs | 2 +- 4 files changed, 41 insertions(+), 19 deletions(-) diff --git a/source/core/coreactor.h b/source/core/coreactor.h index 750a75f21..27505d6f5 100644 --- a/source/core/coreactor.h +++ b/source/core/coreactor.h @@ -500,6 +500,25 @@ inline int clipmove(DVector3& pos, sectortype** const sect, int xvect, int yvect return res; } +inline int clipmove(DVector3& pos, sectortype** const sect, int xvect, int yvect, + int const walldist, double const ceildist, double const flordist, unsigned const cliptype, CollisionBase& result, int clipmoveboxtracenum = 3) +{ + auto vect = vec3_t(pos.X * worldtoint, pos.Y * worldtoint, pos.Z * zworldtoint); + int res = clipmove(vect, sect, xvect, yvect, walldist, int(ceildist * zworldtoint), int(flordist * zworldtoint), cliptype, result, clipmoveboxtracenum); + pos = { vect.X * inttoworld, vect.Y * inttoworld, vect.Z * zinttoworld }; + return res; +} + +// this one should be the final version everything needs to migrate to +inline int clipmove(DVector3& pos, sectortype** const sect, const DVector2& mvec, + double const walldist, double const ceildist, double const flordist, unsigned const cliptype, CollisionBase& result, int clipmoveboxtracenum = 3) +{ + auto vect = vec3_t(pos.X * worldtoint, pos.Y * worldtoint, pos.Z * zworldtoint); + int res = clipmove(vect, sect, int(mvec.X * worldtoint), int(mvec.Y * worldtoint), int(walldist * worldtoint), int(ceildist * zworldtoint), int(flordist * zworldtoint), cliptype, result, clipmoveboxtracenum); + pos = { vect.X * inttoworld, vect.Y * inttoworld, vect.Z * zinttoworld }; + return res; +} + inline int pushmove(vec3_t* const vect, sectortype** const sect, int32_t const walldist, int32_t const ceildist, int32_t const flordist, uint32_t const cliptype, bool clear = true) @@ -521,6 +540,17 @@ inline int pushmove(DVector3& pos, sectortype** const sect, int32_t const walldi return res; } +inline int pushmove(DVector3& pos, sectortype** const sect, int32_t 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, int(ceildist * zworldtoint), int(flordist * zworldtoint), cliptype, clear); + pos = { vect.X * inttoworld, vect.Y * inttoworld, vect.Z * zinttoworld }; + *sect = sectno == -1 ? nullptr : §or[sectno]; + 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) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 49649cf53..72992e74d 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -607,14 +607,6 @@ struct PLAYER { pos.XY() += { z.X * inttoworld, z.Y * inttoworld }; } - int player_int_ceiling_dist() const - { - return p_ceiling_dist * 256; - } - int player_int_floor_dist() const - { - return p_floor_dist * 256; - } int int_bob_amt() const { return bob_amt * zworldtoint; @@ -642,7 +634,7 @@ struct PLAYER int16_t down_speed, up_speed; // diving int z_speed; // used for diving and flying instead of down_speed, up_speed int climb_ndx; - int p_ceiling_dist,p_floor_dist; + double p_ceiling_dist,p_floor_dist; sectortype* hi_sectp, *lo_sectp; int circle_camera_dist; diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index ceeedd3ac..371b14cd6 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1875,7 +1875,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->player_int_ceiling_dist(), pp->player_int_floor_dist(), CLIPMASK_PLAYER); + push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); if (push_ret < 0) { if (!(pp->Flags & PF_DEAD)) @@ -1889,10 +1889,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->player_int_ceiling_dist(), pp->player_int_floor_dist(), CLIPMASK_PLAYER, 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); PlayerCheckValidMove(pp); - push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->player_int_ceiling_dist(), pp->player_int_floor_dist(), CLIPMASK_PLAYER); + push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); if (push_ret < 0) { if (!(pp->Flags & PF_DEAD)) @@ -2024,7 +2024,7 @@ void DoPlayerMove(PLAYER* pp) } else { - 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); + push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist - Z(16), CLIPMASK_PLAYER); if (push_ret < 0) { @@ -2047,12 +2047,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->player_int_ceiling_dist(), pp->player_int_floor_dist(), CLIPMASK_PLAYER, coll); + 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); actor->spr.cstat = save_cstat; PlayerCheckValidMove(pp); - 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); + push_ret = pushmove(pp->pos, &pp->cursector, ((int)actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist - Z(16), CLIPMASK_PLAYER); if (push_ret < 0) { @@ -4495,7 +4495,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->player_int_ceiling_dist(), pp->player_int_floor_dist(), CLIPMASK_PLAYER); + push_ret = pushmove(pp->pos, &pp->cursector, ((int)pp->actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); if (push_ret < 0) { if (!(pp->Flags & PF_DEAD)) @@ -4511,10 +4511,10 @@ void DoPlayerCurrent(PLAYER* pp) return; } Collision 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); + clipmove(pp->pos, &pp->cursector, xvect, yvect, ((int)pp->actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER, coll); PlayerCheckValidMove(pp); - pushmove(pp->pos, &pp->cursector, ((int)pp->actor->spr.clipdist<<2), pp->player_int_ceiling_dist(), pp->player_int_floor_dist(), CLIPMASK_PLAYER); + pushmove(pp->pos, &pp->cursector, ((int)pp->actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); if (push_ret < 0) { if (!(pp->Flags & PF_DEAD)) diff --git a/wadsrc/static/zscript/games/sw/swgame.zs b/wadsrc/static/zscript/games/sw/swgame.zs index e0315c3f3..009e9a0be 100644 --- a/wadsrc/static/zscript/games/sw/swgame.zs +++ b/wadsrc/static/zscript/games/sw/swgame.zs @@ -192,7 +192,7 @@ struct SWPlayer native native int z_speed; // used for diving and flying instead of down_speed, up_speed native int climb_ndx; native double hiz,loz; - native int p_ceiling_dist,p_floor_dist; + native double p_ceiling_dist,p_floor_dist; native int circle_camera_dist; native double siang;