- Blood: Cut q16horiz/q16slopehoriz over to PlayerHorizon struct.

This commit is contained in:
Mitchell Richters 2020-10-07 17:16:58 +11:00
parent f39939d114
commit c03131f8d1
8 changed files with 56 additions and 51 deletions

View file

@ -56,10 +56,15 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
if (gView->pXSprite->health != 0)
{
applylook(&pPlayer->q16ang, &pPlayer->q16look_ang, &pPlayer->q16rotscrnang, &pPlayer->spin, input.q16avel, &pPlayer->input.actions, scaleAdjust, pPlayer->posture != 0);
sethorizon2(&pPlayer->q16horiz, input.q16horz, &pPlayer->input.actions, scaleAdjust);
sethorizon(&pPlayer->horizon.horiz, input.q16horz, &pPlayer->input.actions, scaleAdjust);
}
playerProcessHelpers(&pPlayer->q16ang, &pPlayer->angAdjust, &pPlayer->angTarget, &pPlayer->q16horiz, &pPlayer->horizAdjust, &pPlayer->horizTarget, scaleAdjust);
// temporary vals to pass through to playerProcessHelpers().
fixed_t horiz = 0;
fixed_t target = 0;
double adjust = 0;
playerProcessHelpers(&pPlayer->q16ang, &pPlayer->angAdjust, &pPlayer->angTarget, &horiz, &adjust, &target, scaleAdjust);
pPlayer->horizon.processhelpers(scaleAdjust);
UpdatePlayerSpriteAngle(pPlayer);
}

View file

@ -1488,15 +1488,15 @@ void trPlayerCtrlSetLookAngle(XSPRITE* pXSource, PLAYER* pPlayer)
if (abs(look) > 0)
{
if (pPlayer->q16horiz != 0)
if (pPlayer->horizon.horiz.asq16() != 0)
{
// move q16horiz back to 0
pPlayer->q16horiz += xs_CRoundToInt(-pPlayer->q16horiz * (1. / 3.));
// move horiz back to 0
pPlayer->horizon.horiz += q16horiz(xs_CRoundToInt(-pPlayer->horizon.horiz.asq16() * (1. / 3.)));
}
}
else
{
pPlayer->q16horiz = 0;
pPlayer->horizon.horiz = q16horiz(0);
}
}

View file

@ -56,7 +56,7 @@ static int osdcmd_warptocoords(CCmdFuncPtr parm)
if (parm->numparms == 5)
{
pPlayer->q16horiz = gView->q16horiz = IntToFixed(atoi(parm->parms[4]));
pPlayer->horizon.horiz = gView->horizon.horiz = buildhoriz(atoi(parm->parms[4]));
}
viewBackupView(pPlayer->nPlayer);

View file

@ -721,8 +721,7 @@ void playerStart(int nPlayer, int bNewLevel)
pPlayer->pXSprite->health = pDudeInfo->startHealth<<4;
pPlayer->pSprite->cstat &= (unsigned short)~32768;
pPlayer->bloodlust = 0;
pPlayer->q16horiz = 0;
pPlayer->q16slopehoriz = 0;
pPlayer->horizon.horiz = pPlayer->horizon.horizoff = q16horiz(0);
pPlayer->slope = 0;
pPlayer->fraggerId = -1;
pPlayer->underwaterTime = 1200;
@ -1325,7 +1324,7 @@ void UpdatePlayerSpriteAngle(PLAYER *pPlayer)
static void resetinputhelpers(PLAYER* pPlayer)
{
pPlayer->horizAdjust = 0;
pPlayer->horizon.resetadjustment();
pPlayer->angAdjust = 0;
}
@ -1364,7 +1363,7 @@ void ProcessInput(PLAYER *pPlayer)
}
pPlayer->deathTime += 4;
if (!bSeqStat)
playerAddHoriz2(&pPlayer->q16horiz, &pPlayer->horizAdjust, FixedToFloat(mulscale16(0x8000-(Cos(ClipHigh(pPlayer->deathTime<<3, 1024))>>15), gi->playerHorizMax()) - pPlayer->q16horiz));
pPlayer->horizon.addadjustment(FixedToFloat(mulscale16(0x8000-(Cos(ClipHigh(pPlayer->deathTime<<3, 1024))>>15), gi->playerHorizMax()) - pPlayer->horizon.horiz.asq16()));
if (pPlayer->curWeapon)
pInput->setNewWeapon(pPlayer->curWeapon);
if (pInput->actions & SB_OPEN)
@ -1558,7 +1557,7 @@ void ProcessInput(PLAYER *pPlayer)
if (cl_syncinput)
{
sethorizon2(&pPlayer->q16horiz, pInput->q16horz, &pInput->actions, 1);
sethorizon(&pPlayer->horizon.horiz, pInput->q16horz, &pInput->actions, 1);
}
int nSector = pSprite->sectnum;
@ -1578,16 +1577,16 @@ void ProcessInput(PLAYER *pPlayer)
if (nSector2 == nSector)
{
int z2 = getflorzofslope(nSector2, x2, y2);
pPlayer->q16slopehoriz = interpolate(pPlayer->q16slopehoriz, IntToFixed(z1-z2)>>3, 0x4000);
pPlayer->horizon.horizoff = q16horiz(interpolate(pPlayer->horizon.horizoff.asq16(), IntToFixed(z1-z2)>>3, 0x4000));
}
}
else
{
pPlayer->q16slopehoriz = interpolate(pPlayer->q16slopehoriz, 0, 0x4000);
if (klabs(pPlayer->q16slopehoriz) < 4)
pPlayer->q16slopehoriz = 0;
pPlayer->horizon.horizoff = q16horiz(interpolate(pPlayer->horizon.horizoff.asq16(), 0, 0x4000));
if (klabs(pPlayer->horizon.horizoff.asq16()) < 4)
pPlayer->horizon.horizoff = q16horiz(0);
}
pPlayer->slope = -pPlayer->q16horiz >> 9;
pPlayer->slope = -pPlayer->horizon.horiz.asq16() >> 9;
if (pInput->actions & SB_INVPREV)
{
pInput->actions&= ~SB_INVPREV;

View file

@ -84,7 +84,8 @@ struct PLAYER
spritetype* pSprite;
XSPRITE* pXSprite;
DUDEINFO* pDudeInfo;
InputPacket input;
InputPacket input;
PlayerHorizon horizon;
uint8_t newWeapon;
int used1; // something related to game checksum
int weaponQav;
@ -108,8 +109,6 @@ struct PLAYER
int zViewVel;
int zWeapon;
int zWeaponVel;
fixed_t q16horiz; // horiz
fixed_t q16slopehoriz; // horizoff
int slope;
bool isUnderwater;
bool hasKey[8];
@ -188,8 +187,8 @@ struct PLAYER
fixed_t q16rotscrnang;
// Input helper variables.
double horizAdjust, angAdjust;
fixed_t horizTarget, angTarget;
double angAdjust;
fixed_t angTarget;
};
struct PROFILE

View file

@ -58,8 +58,8 @@ static VIEW predictFifo[256];
void viewInitializePrediction(void)
{
predict.at30 = gMe->q16ang;
predict.at24 = gMe->q16horiz;
predict.at28 = gMe->q16slopehoriz;
predict.at24 = gMe->horizon.horiz;
predict.at28 = gMe->horizon.horizoff;
predict.at2c = gMe->slope;
predict.at6f = gMe->cantJump;
predict.at70 = gMe->isRunning;
@ -212,6 +212,7 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
break;
}
#if 0
if (predict.at6e && !(pInput->actions & (SB_LOOK_UP | SB_LOOK_DOWN)))
{
if (predict.at20 < 0)
@ -236,6 +237,7 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
predict.at24 = FloatToFixed(fmulscale30(180., Sinf(FixedToFloat(predict.at20) * 8.)));
else
predict.at24 = 0;
#endif
int nSector = predict.at68;
int florhit = predict.at75.florhit & 0xc000;
@ -254,16 +256,16 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
if (nSector2 == nSector)
{
int z2 = getflorzofslope(nSector2, x2, y2);
predict.at28 = interpolate(predict.at28, IntToFixed(z1-z2)>>3, 0x4000);
predict.at28 = q16horiz(interpolate(predict.at28.asq16(), IntToFixed(z1 - z2) >> 3, 0x4000));
}
}
else
{
predict.at28 = interpolate(predict.at28, 0, 0x4000);
if (klabs(predict.at28) < 4)
predict.at28 = 0;
predict.at28 = q16horiz(interpolate(predict.at28.asq16(), 0, 0x4000));
if (klabs(predict.at28.asq16()) < 4)
predict.at28 = q16horiz(0);
}
predict.at2c = -predict.at24 >> 9;
predict.at2c = -predict.at24.asq16() >> 9;
}
void fakePlayerProcess(PLAYER *pPlayer, InputPacket *pInput)
@ -654,7 +656,7 @@ void viewCorrectPrediction(void)
#if 0
spritetype *pSprite = gMe->pSprite;
VIEW *pView = &predictFifo[(gNetFifoTail-1)&255];
if (gMe->q16ang != pView->at30 || pView->at24 != gMe->q16horiz || pView->at50 != pSprite->x || pView->at54 != pSprite->y || pView->at58 != pSprite->z)
if (gMe->q16ang != pView->at30 || pView->at24 != gMe->horizon.horiz || pView->at50 != pSprite->x || pView->at54 != pSprite->y || pView->at58 != pSprite->z)
{
viewInitializePrediction();
predictOld = gPrevView[myconnectindex];

View file

@ -109,8 +109,8 @@ void viewBackupView(int nPlayer)
pView->at54 = pPlayer->pSprite->y;
pView->at38 = pPlayer->zView;
pView->at34 = pPlayer->zWeapon-pPlayer->zView-0xc00;
pView->at24 = pPlayer->q16horiz;
pView->at28 = pPlayer->q16slopehoriz;
pView->at24 = pPlayer->horizon.horiz;
pView->at28 = pPlayer->horizon.horizoff;
pView->at2c = pPlayer->slope;
pView->at8 = pPlayer->bobHeight;
pView->atc = pPlayer->bobWidth;
@ -633,7 +633,8 @@ void viewDrawScreen(bool sceneonly)
renderSetAspect(v1, yxaspect);
int cX, cY, cZ, v74, v8c;
fixed_t cA, q16horiz, q16slopehoriz, q16rotscrnang;
fixed_t cA, q16rotscrnang;
fixedhoriz q16horizon, q16horizoff;
double zDelta, v4c, v48;
int nSectnum = gView->pSprite->sectnum;
if (numplayers > 1 && gView == gMe && gPrediction && gMe->pXSprite->health > 0)
@ -643,7 +644,7 @@ 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);
q16slopehoriz = interpolate(predictOld.at28, predict.at28, gInterpolate);
q16horizoff = 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);
@ -652,13 +653,13 @@ void viewDrawScreen(bool sceneonly)
if (!cl_syncinput)
{
cA = predict.at30 + predict.q16look_ang;
q16horiz = predict.at24;
q16horizon = predict.at24;
q16rotscrnang = predict.q16rotscrnang;
}
else
{
cA = interpolateangfix16(predictOld.at30 + predictOld.q16look_ang, predict.at30 + predict.q16look_ang, gInterpolate);
q16horiz = interpolate(predictOld.at24, predict.at24, gInterpolate);
q16horizon = q16horiz(interpolate(predictOld.at24.asq16(), predict.at24.asq16(), gInterpolate));
q16rotscrnang = interpolateangfix16(predictOld.q16rotscrnang, predict.q16rotscrnang, gInterpolate);
}
}
@ -669,7 +670,7 @@ 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);
q16slopehoriz = interpolate(pView->at28, gView->q16slopehoriz, gInterpolate);
q16horizoff = 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);
@ -678,26 +679,26 @@ void viewDrawScreen(bool sceneonly)
if (!cl_syncinput)
{
cA = gView->q16ang + gView->q16look_ang;
q16horiz = gView->q16horiz;
q16horizon = gView->horizon.horiz;
q16rotscrnang = gView->q16rotscrnang;
}
else
{
cA = interpolateangfix16(pView->at30 + pView->q16look_ang, gView->q16ang + gView->q16look_ang, gInterpolate);
q16horiz = interpolate(pView->at24, gView->q16horiz, gInterpolate);
q16horizon = q16horiz(interpolate(pView->at24.asq16(), gView->horizon.horiz.asq16(), gInterpolate));
q16rotscrnang = interpolateangfix16(pView->q16rotscrnang, gView->q16rotscrnang, gInterpolate);
}
}
viewUpdateShake();
q16horiz += IntToFixed(shakeHoriz);
q16horizon += buildhoriz(shakeHoriz);
cA += IntToFixed(shakeAngle);
cX += shakeX;
cY += shakeY;
cZ += shakeZ;
v4c += shakeBobX;
v48 += shakeBobY;
q16horiz += IntToFixed(mulscale30(0x40000000 - Cos(gView->tiltEffect << 2), 30));
q16horizon += buildhoriz(mulscale30(0x40000000 - Cos(gView->tiltEffect << 2), 30));
if (gViewPos == 0)
{
if (cl_viewbob)
@ -714,15 +715,15 @@ void viewDrawScreen(bool sceneonly)
}
if (cl_slopetilting)
{
q16horiz += q16slopehoriz;
q16horizon += q16horizoff;
}
cZ += xs_CRoundToInt(q16horiz / 6553.6);
cZ += xs_CRoundToInt(q16horizon.asq16() / 6553.6);
cameradist = -1;
cameraclock = gFrameClock +mulscale16(4, (int)gInterpolate);
}
else
{
CalcPosition(gView->pSprite, (int*)&cX, (int*)&cY, (int*)&cZ, &nSectnum, FixedToInt(cA), q16horiz, (int)gInterpolate);
CalcPosition(gView->pSprite, (int*)&cX, (int*)&cY, (int*)&cZ, &nSectnum, FixedToInt(cA), q16horizon.asq16(), (int)gInterpolate);
}
CheckLink((int*)&cX, (int*)&cY, (int*)&cZ, &nSectnum);
int v78 = interpolateang(gScreenTiltO, gScreenTilt, gInterpolate);
@ -879,13 +880,13 @@ void viewDrawScreen(bool sceneonly)
{
cZ = vfc + (gLowerLink[nSectnum] >= 0 ? 0 : (8 << 8));
}
q16horiz = ClipRange(q16horiz, gi->playerHorizMin(), gi->playerHorizMax());
q16horizon = q16horiz(ClipRange(q16horizon.asq16(), gi->playerHorizMin(), gi->playerHorizMax()));
RORHACK:
int ror_status[16];
for (int i = 0; i < 16; i++)
ror_status[i] = TestBitString(gotpic, 4080 + i);
fixed_t deliriumPitchI = interpolate(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate);
DrawMirrors(cX, cY, cZ, cA, q16horiz + deliriumPitchI, gInterpolate, gViewIndex);
DrawMirrors(cX, cY, cZ, cA, q16horizon.asq16() + deliriumPitchI, gInterpolate, gViewIndex);
int bakCstat = gView->pSprite->cstat;
if (gViewPos == 0)
{
@ -896,7 +897,7 @@ void viewDrawScreen(bool sceneonly)
gView->pSprite->cstat |= 514;
}
renderDrawRoomsQ16(cX, cY, cZ, cA, q16horiz + deliriumPitchI, nSectnum);
renderDrawRoomsQ16(cX, cY, cZ, cA, q16horizon.asq16() + deliriumPitchI, nSectnum);
viewProcessSprites(cX, cY, cZ, FixedToInt(cA), gInterpolate);
bool do_ror_hack = false;
for (int i = 0; i < 16; i++)
@ -954,7 +955,7 @@ void viewDrawScreen(bool sceneonly)
int v8 = byte_1CE5C2 > 0 && (sector[tmpSect].ceilingstat & 1);
if (gWeather.at12d8 > 0 || v8)
{
gWeather.Draw(cX, cY, cZ, cA, q16horiz + deliriumPitch, gWeather.at12d8);
gWeather.Draw(cX, cY, cZ, cA, q16horizon.asq16() + deliriumPitch, gWeather.at12d8);
if (v8)
{
gWeather.at12d8 = ClipRange(delta * 8 + gWeather.at12d8, 0, 4095);

View file

@ -39,9 +39,8 @@ struct VIEW {
int at14;
int at18; // bob sway y
int at1c; // bob sway x
fixed_t at20;
fixed_t at24; // horiz
int at28; // horizoff
fixedhoriz at24; // horiz
fixedhoriz at28; // horizoff
int at2c;
fixed_t at30; // angle
int at34; // weapon z