From 892dde030fcb0c156b3de153857a03b44234ed80 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 27 Mar 2023 20:43:55 +1100 Subject: [PATCH] - Tidy up nested branch in `calcChaseCamPos()`. --- source/core/gamefuncs.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/source/core/gamefuncs.cpp b/source/core/gamefuncs.cpp index 57b5709ce..e03ca151e 100644 --- a/source/core/gamefuncs.cpp +++ b/source/core/gamefuncs.cpp @@ -61,7 +61,7 @@ bool calcChaseCamPos(DVector3& ppos, DCoreActor* act, sectortype** psect, const // If something is in the way, make cameradist lower if necessary if (npos.XY().Sum() > hpos.XY().Sum()) { - double DVector3::* c = fabs(npos.X) > fabs(npos.Y) ? &DVector3::X : &DVector3::Y; + const auto c = fabs(npos.X) > fabs(npos.Y) ? &DVector3::X : &DVector3::Y; if (hitinfo.hitWall != nullptr) { @@ -75,25 +75,22 @@ bool calcChaseCamPos(DVector3& ppos, DCoreActor* act, sectortype** psect, const *psect = hitinfo.hitSector; hpos.*c -= npos.*c * (1. / 32.); } - else + else if (!(hitinfo.hitActor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL)) { // If you hit a sprite that's not a wall sprite - try again. - if (!(hitinfo.hitActor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL)) - { - bakcstat = hitinfo.hitActor->spr.cstat; - hitinfo.hitActor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); - calcChaseCamPos(ppos, act, psect, angles, interpfrac, backamp); - hitinfo.hitActor->spr.cstat = bakcstat; - return false; - } - else - { - // same as wall calculation. - hpos.*c -= npos.*c * npos.XY().dot((act->spr.Angles.Yaw - DAngle90).ToVector().Rotated90CW()) * (1. / 1024.); - } + bakcstat = hitinfo.hitActor->spr.cstat; + hitinfo.hitActor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); + calcChaseCamPos(ppos, act, psect, angles, interpfrac, backamp); + hitinfo.hitActor->spr.cstat = bakcstat; + return false; + } + else + { + // same as wall calculation. + hpos.*c -= npos.*c * npos.XY().dot((act->spr.Angles.Yaw - DAngle90).ToVector().Rotated90CW()) * (1. / 1024.); } - double newdist = hpos.*c / npos.*c; + const double newdist = hpos.*c / npos.*c; if (newdist < cameradist) cameradist = newdist; }