- Duke/RR: Partially revert c9d875327850e839e3ad1f367ede15497d44fda3 by truncating p->MotoSpeed to integer when calculating xvel/yvel to preserve original vehicle feel.

This commit is contained in:
Mitchell Richters 2020-11-06 15:59:24 +11:00
parent 567738f3ad
commit 6f5f66ad35

View file

@ -1749,26 +1749,25 @@ static void onMotorcycle(int snum, ESyncBits &actions)
p->horizon.addadjustment(horiz - FixedToFloat(p->horizon.horiz.asq16())); p->horizon.addadjustment(horiz - FixedToFloat(p->horizon.horiz.asq16()));
} }
double currSpeed = p->MotoSpeed; int currSpeed = p->MotoSpeed;
short currAngle = p->angle.ang.asbuild(), velAdjustment; short currAngle = p->angle.ang.asbuild(), velAdjustment;
if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight)) if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight))
{ {
velAdjustment = p->vehTurnLeft ? -10 : 10; velAdjustment = p->vehTurnLeft ? -10 : 10;
short angAdjustAmt = 350; short angAdjustment = velAdjustment < 0 ? 350 : -350;
short angAdjustment = velAdjustment < 0 ? angAdjustAmt : -angAdjustAmt;
if (p->moto_on_mud || p->moto_on_oil || !p->NotOnWater) if (p->moto_on_mud || p->moto_on_oil || !p->NotOnWater)
{ {
currSpeed *= p->moto_on_oil ? 8 : 4; currSpeed <<= p->moto_on_oil ? 3 : 2;
if (p->moto_do_bump) if (p->moto_do_bump)
{ {
currSpeed /= 32.; currSpeed >>= 5;
angAdjustment >>= 2; angAdjustment >>= 2;
} }
else else
{ {
currSpeed /= 128.; currSpeed >>= 7;
angAdjustment >>= 6; angAdjustment >>= 6;
} }
@ -1779,29 +1778,29 @@ static void onMotorcycle(int snum, ESyncBits &actions)
{ {
if (p->moto_do_bump) if (p->moto_do_bump)
{ {
currSpeed /= 32.; currSpeed >>= 5;
angAdjustment >>= 4; angAdjustment >>= 4;
if (!S_CheckActorSoundPlaying(pact, 220)) if (!S_CheckActorSoundPlaying(pact, 220))
S_PlayActorSound(220, pact); S_PlayActorSound(220, pact);
} }
else else
{ {
currSpeed /= 128.; currSpeed >>= 7;
angAdjustment >>= 7; angAdjustment >>= 7;
} }
} }
p->posxv += xs_CRoundToInt(currSpeed * (sintable[(velAdjustment * -51 + currAngle + 512) & 2047] << 4)); p->posxv += currSpeed * (sintable[(velAdjustment * -51 + currAngle + 512) & 2047] << 4);
p->posyv += xs_CRoundToInt(currSpeed * (sintable[(velAdjustment * -51 + currAngle) & 2047] << 4)); p->posyv += currSpeed * (sintable[(velAdjustment * -51 + currAngle) & 2047] << 4);
p->angle.addadjustment(FixedToFloat(getincangleq16(p->angle.ang.asq16(), IntToFixed(currAngle - angAdjustment)))); p->angle.addadjustment(FixedToFloat(getincangleq16(p->angle.ang.asq16(), IntToFixed(currAngle - angAdjustment))));
} }
else if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->moto_on_mud || p->moto_on_oil)) else if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->moto_on_mud || p->moto_on_oil))
{ {
rng = krand() & 1; rng = krand() & 1;
velAdjustment = rng == 0 ? -10 : 10; velAdjustment = rng == 0 ? -10 : 10;
currSpeed = fmulscale7(currSpeed, p->moto_on_oil ? 10 : 5); currSpeed = mulscale7(currSpeed, p->moto_on_oil ? 10 : 5);
p->posxv += xs_CRoundToInt(currSpeed * (sintable[(velAdjustment * -51 + currAngle + 512) & 2047] << 4)); p->posxv += currSpeed * (sintable[(velAdjustment * -51 + currAngle + 512) & 2047] << 4);
p->posyv += xs_CRoundToInt(currSpeed * (sintable[(velAdjustment * -51 + currAngle) & 2047] << 4)); p->posyv += currSpeed * (sintable[(velAdjustment * -51 + currAngle) & 2047] << 4);
} }
p->moto_on_mud = 0; p->moto_on_mud = 0;
@ -2031,25 +2030,24 @@ static void onBoat(int snum, ESyncBits &actions)
if (p->MotoSpeed > 0 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight)) if (p->MotoSpeed > 0 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight))
{ {
short angAdjustAmt = 350; int currSpeed = p->MotoSpeed * 4.;
double currSpeed = p->MotoSpeed * 4.;
short currAngle = p->angle.ang.asbuild(); short currAngle = p->angle.ang.asbuild();
short velAdjustment = p->vehTurnLeft ? -10 : 10; short velAdjustment = p->vehTurnLeft ? -10 : 10;
short angAdjustment = velAdjustment < 0 ? angAdjustAmt : -angAdjustAmt; short angAdjustment = velAdjustment < 0 ? 350 : -350;
if (p->moto_do_bump) if (p->moto_do_bump)
{ {
currSpeed /= 64.; currSpeed >>= 6;
angAdjustment >>= 5; angAdjustment >>= 5;
} }
else else
{ {
currSpeed /= 128.; currSpeed >>= 7;
angAdjustment >>= 6; angAdjustment >>= 6;
} }
p->posxv += xs_CRoundToInt(currSpeed * (sintable[(velAdjustment * -51 + currAngle + 512) & 2047] << 4)); p->posxv += currSpeed * (sintable[(velAdjustment * -51 + currAngle + 512) & 2047] << 4);
p->posyv += xs_CRoundToInt(currSpeed * (sintable[(velAdjustment * -51 + currAngle) & 2047] << 4)); p->posyv += currSpeed * (sintable[(velAdjustment * -51 + currAngle) & 2047] << 4);
p->angle.addadjustment(FixedToFloat(getincangleq16(p->angle.ang.asq16(), IntToFixed(currAngle - angAdjustment)))); p->angle.addadjustment(FixedToFloat(getincangleq16(p->angle.ang.asq16(), IntToFixed(currAngle - angAdjustment))));
} }
if (p->NotOnWater && p->MotoSpeed > 50) if (p->NotOnWater && p->MotoSpeed > 50)