diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index 17a4fcaa5..e948e1fac 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -378,51 +378,54 @@ void applylook(PlayerAngle* angle, float const avel, ESyncBits* actions, double void calcviewpitch(vec2_t const pos, fixedhoriz* horizoff, binangle const ang, bool const aimmode, bool const canslopetilt, int const cursectnum, double const scaleAdjust, bool const climbing) { - if (aimmode && canslopetilt) // If the floor is sloped + if (cl_slopetilting) { - // Get a point, 512 units ahead of player's position - int x = pos.x + ang.bcos(-5); - int y = pos.y + ang.bsin(-5); - int16_t tempsect = cursectnum; - updatesector(x, y, &tempsect); - - if (tempsect >= 0) // If the new point is inside a valid sector... + if (aimmode && canslopetilt) // If the floor is sloped { - // Get the floorz as if the new (x,y) point was still in - // your sector - int j = getflorzofslope(cursectnum, pos.x, pos.y); - int k = getflorzofslope(cursectnum, x, y); + // Get a point, 512 units ahead of player's position + int x = pos.x + ang.bcos(-5); + int y = pos.y + ang.bsin(-5); + int16_t tempsect = cursectnum; + updatesector(x, y, &tempsect); - // If extended point is in same sector as you or the slopes - // of the sector of the extended point and your sector match - // closely (to avoid accidently looking straight out when - // you're at the edge of a sector line) then adjust horizon - // accordingly - if (cursectnum == tempsect || abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8)) + if (tempsect >= 0) // If the new point is inside a valid sector... { - *horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((j - k) * 160))); + // Get the floorz as if the new (x,y) point was still in + // your sector + int j = getflorzofslope(cursectnum, pos.x, pos.y); + int k = getflorzofslope(cursectnum, x, y); + + // If extended point is in same sector as you or the slopes + // of the sector of the extended point and your sector match + // closely (to avoid accidently looking straight out when + // you're at the edge of a sector line) then adjust horizon + // accordingly + if (cursectnum == tempsect || abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8)) + { + *horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((j - k) * 160))); + } } } - } - if (climbing) - { - // tilt when climbing but you can't even really tell it. - if (horizoff->asq16() < IntToFixed(100)) - *horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * (((IntToFixed(100) - horizoff->asq16()) >> 3) + FRACUNIT))); - } - else - { - // Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope. - if (horizoff->asq16() > 0) + if (climbing) { - *horizoff += q16horiz(xs_CRoundToInt(-scaleAdjust * ((horizoff->asq16() >> 3) + FRACUNIT))); - if (horizoff->asq16() < 0) *horizoff = q16horiz(0); + // tilt when climbing but you can't even really tell it. + if (horizoff->asq16() < IntToFixed(100)) + *horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * (((IntToFixed(100) - horizoff->asq16()) >> 3) + FRACUNIT))); } - if (horizoff->asq16() < 0) + else { - *horizoff += q16horiz(xs_CRoundToInt(-scaleAdjust * ((horizoff->asq16() >> 3) + FRACUNIT))); - if (horizoff->asq16() > 0) *horizoff = q16horiz(0); + // Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope. + if (horizoff->asq16() > 0) + { + *horizoff += q16horiz(xs_CRoundToInt(-scaleAdjust * ((horizoff->asq16() >> 3) + FRACUNIT))); + if (horizoff->asq16() < 0) *horizoff = q16horiz(0); + } + if (horizoff->asq16() < 0) + { + *horizoff += q16horiz(xs_CRoundToInt(-scaleAdjust * ((horizoff->asq16() >> 3) + FRACUNIT))); + if (horizoff->asq16() > 0) *horizoff = q16horiz(0); + } } } } diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index f39368bf9..1cc44ebdf 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -195,11 +195,8 @@ inline double get16thOfHoriz(int const snum, bool const interpolate, double cons inline void doslopetilting(player_struct* p, double const scaleAdjust) { - if (cl_slopetilting) - { - bool const canslopetilt = p->on_ground && sector[p->cursectnum].lotag != ST_2_UNDERWATER && (sector[p->cursectnum].floorstat & 2); - calcviewpitch(p->pos.vec2, &p->horizon.horizoff, p->angle.ang, p->aim_mode == 0, canslopetilt, p->cursectnum, scaleAdjust); - } + bool const canslopetilt = p->on_ground && sector[p->cursectnum].lotag != ST_2_UNDERWATER && (sector[p->cursectnum].floorstat & 2); + calcviewpitch(p->pos.vec2, &p->horizon.horizoff, p->angle.ang, p->aim_mode == 0, canslopetilt, p->cursectnum, scaleAdjust); } diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index da36fec18..b119ab20f 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -1667,12 +1667,8 @@ void SlipSlope(PLAYERp pp) void DoPlayerHorizon(PLAYERp pp, float const horz, double const scaleAdjust) { - if (cl_slopetilting) - { - bool const canslopetilt = !TEST(pp->Flags, PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING) && TEST(sector[pp->cursectnum].floorstat, FLOOR_STAT_SLOPE); - calcviewpitch(pp->pos.vec2, &pp->horizon.horizoff, pp->angle.ang, pp->input.actions & SB_AIMMODE, canslopetilt, pp->cursectnum, scaleAdjust, TEST(pp->Flags, PF_CLIMBING)); - } - + bool const canslopetilt = !TEST(pp->Flags, PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING) && TEST(sector[pp->cursectnum].floorstat, FLOOR_STAT_SLOPE); + calcviewpitch(pp->pos.vec2, &pp->horizon.horizoff, pp->angle.ang, pp->input.actions & SB_AIMMODE, canslopetilt, pp->cursectnum, scaleAdjust, TEST(pp->Flags, PF_CLIMBING)); sethorizon(&pp->horizon.horiz, horz, &pp->input.actions, scaleAdjust); }