diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index 23f4c76cc..4b7de23eb 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -36,6 +36,7 @@ BEGIN_BLD_NS static InputPacket gInput; void UpdatePlayerSpriteAngle(PLAYER* pPlayer); +void doslopetilting(PLAYER* pPlayer, double const scaleAdjust); void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput) { @@ -59,6 +60,7 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput) { applylook(&pPlayer->angle, input.avel, &pPlayer->input.actions, scaleAdjust); sethorizon(&pPlayer->horizon.horiz, input.horz, &pPlayer->input.actions, scaleAdjust); + doslopetilting(pPlayer, scaleAdjust); } pPlayer->angle.processhelpers(scaleAdjust); diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index 972004d40..53bb37584 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -1292,6 +1292,21 @@ void UpdatePlayerSpriteAngle(PLAYER *pPlayer) pSprite->ang = pPlayer->angle.ang.asbuild(); } +//--------------------------------------------------------------------------- +// +// Player's slope tilting wrapper function function, called in ProcessInput() or from gi->GetInput() as required. +// +//--------------------------------------------------------------------------- + +void doslopetilting(PLAYER* pPlayer, double const scaleAdjust = 1) +{ + auto* const pSprite = pPlayer->pSprite; + auto* const pXSprite = pPlayer->pXSprite; + int const florhit = gSpriteHit[pSprite->extra].florhit & 0xc000; + char const va = pXSprite->height < 16 && (florhit == 0x4000 || florhit == 0) ? 1 : 0; + calcviewpitch(pSprite->pos.vec2, &pPlayer->horizon.horizoff, buildang(pSprite->ang), va, sector[pSprite->sectnum].floorstat & 2, pSprite->sectnum, scaleAdjust); +} + void ProcessInput(PLAYER *pPlayer) { enum @@ -1545,32 +1560,11 @@ void ProcessInput(PLAYER *pPlayer) // disable synchronised input if set by game. resetForcedSyncInput(); - int nSector = pSprite->sectnum; - int florhit = gSpriteHit[pSprite->extra].florhit & 0xc000; - char va; - if (pXSprite->height < 16 && (florhit == 0x4000 || florhit == 0)) - va = 1; - else - va = 0; - if (va && (sector[nSector].floorstat&2)) + if (SyncInput()) { - int z1 = getflorzofslope(nSector, pSprite->x, pSprite->y); - int x2 = pSprite->x+mulscale30(64, Cos(pSprite->ang)); - int y2 = pSprite->y+mulscale30(64, Sin(pSprite->ang)); - short nSector2 = nSector; - updatesector(x2, y2, &nSector2); - if (nSector2 == nSector) - { - int z2 = getflorzofslope(nSector2, x2, y2); - pPlayer->horizon.horizoff = q16horiz(interpolate(pPlayer->horizon.horizoff.asq16(), IntToFixed(z1-z2)>>3, 0x4000)); - } - } - else - { - pPlayer->horizon.horizoff = q16horiz(interpolate(pPlayer->horizon.horizoff.asq16(), 0, 0x4000)); - if (klabs(pPlayer->horizon.horizoff.asq16()) < 4) - pPlayer->horizon.horizoff = q16horiz(0); + doslopetilting(pPlayer); } + pPlayer->slope = -pPlayer->horizon.horiz.asq16() >> 9; if (pInput->actions & SB_INVPREV) { diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 894fc01b5..15b7ba6ca 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -548,7 +548,7 @@ void viewDrawScreen(bool sceneonly) int cX, cY, cZ, v74, v8c; lookangle rotscrnang; binangle cA; - fixedhoriz cH, cOff; + fixedhoriz cH; double zDelta, v4c, v48; int nSectnum = gView->pSprite->sectnum; if (numplayers > 1 && gView == gMe && gPrediction && gMe->pXSprite->health > 0) @@ -558,7 +558,6 @@ void viewDrawScreen(bool sceneonly) cY = interpolate(predictOld.at54, predict.at54, gInterpolate); cZ = interpolate(predictOld.at38, predict.at38, gInterpolate); zDelta = finterpolate(predictOld.at34, predict.at34, gInterpolate); - cOff = q16horiz(interpolate(predictOld.at28.asq16(), predict.at28.asq16(), gInterpolate)); v74 = interpolate(predictOld.atc, predict.atc, gInterpolate); v8c = interpolate(predictOld.at8, predict.at8, gInterpolate); v4c = finterpolate(predictOld.at1c, predict.at1c, gInterpolate); @@ -567,7 +566,7 @@ void viewDrawScreen(bool sceneonly) if (!SyncInput()) { cA = bamang(predict.at30.asbam() + predict.look_ang.asbam()); - cH = predict.at24; + cH = predict.at24 + predict.at28; rotscrnang = predict.rotscrnang; } else @@ -575,7 +574,11 @@ void viewDrawScreen(bool sceneonly) uint32_t oang = predictOld.at30.asbam() + predictOld.look_ang.asbam(); uint32_t ang = predict.at30.asbam() + predict.look_ang.asbam(); cA = interpolateangbin(oang, ang, gInterpolate); - cH = q16horiz(interpolate(predictOld.at24.asq16(), predict.at24.asq16(), gInterpolate)); + + fixed_t ohoriz = (predictOld.at24 + predictOld.at28).asq16(); + fixed_t horiz = (predict.at24 + predict.at28).asq16(); + cH = q16horiz(interpolate(ohoriz, horiz, gInterpolate)); + rotscrnang = interpolateanglook(predictOld.rotscrnang.asbam(), predict.rotscrnang.asbam(), gInterpolate); } } @@ -586,7 +589,6 @@ void viewDrawScreen(bool sceneonly) cY = interpolate(pView->at54, gView->pSprite->y, gInterpolate); cZ = interpolate(pView->at38, gView->zView, gInterpolate); zDelta = finterpolate(pView->at34, gView->zWeapon - gView->zView - (12 << 8), gInterpolate); - cOff = q16horiz(interpolate(pView->at28.asq16(), gView->horizon.horizoff.asq16(), gInterpolate)); v74 = interpolate(pView->atc, gView->bobWidth, gInterpolate); v8c = interpolate(pView->at8, gView->bobHeight, gInterpolate); v4c = finterpolate(pView->at1c, gView->swayWidth, gInterpolate); @@ -595,13 +597,13 @@ void viewDrawScreen(bool sceneonly) if (!SyncInput()) { cA = gView->angle.sum(); - cH = gView->horizon.horiz; + cH = gView->horizon.sum(); rotscrnang = gView->angle.rotscrnang; } else { cA = gView->angle.interpolatedsum(gInterpolate); - cH = q16horiz(interpolate(pView->at24.asq16(), gView->horizon.horiz.asq16(), gInterpolate)); + cH = gView->horizon.interpolatedsum(gInterpolate); rotscrnang = gView->angle.interpolatedrotscrn(gInterpolate); } } @@ -626,10 +628,6 @@ void viewDrawScreen(bool sceneonly) { cZ += v8c; } - if (cl_slopetilting) - { - cH += cOff; - } cZ += xs_CRoundToInt(cH.asq16() / 6553.6); cameradist = -1; cameraclock = gFrameClock +mulscale16(4, (int)gInterpolate); diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index ac6c4f6d5..a7717a0df 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -403,9 +403,11 @@ void calcviewpitch(vec2_t const pos, fixedhoriz* horizoff, binangle const ang, b { if (aimmode && canslopetilt) // If the floor is sloped { - // Get a point, 512 units ahead of player's position - int x = pos.x + ang.bcos(-5); - int y = pos.y + ang.bsin(-5); + // Get a point, 512 (64 for Blood) units ahead of player's position + bool const isBlood = g_gameType & GAMEFLAG_BLOOD; + int const shift = -(isBlood ? 8 : 5); + int const x = pos.x + ang.bcos(shift); + int const y = pos.y + ang.bsin(shift); int16_t tempsect = cursectnum; updatesector(x, y, &tempsect); @@ -413,17 +415,17 @@ void calcviewpitch(vec2_t const pos, fixedhoriz* horizoff, binangle const ang, b { // 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); + int const j = getflorzofslope(cursectnum, pos.x, pos.y); + int const k = getflorzofslope(tempsect, 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)) + if (cursectnum == tempsect || (!isBlood && abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))) { - *horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((j - k) * 160))); + *horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((j - k) * (!isBlood ? 160 : 1408)))); } } }