- Duke/RR: Remove vehBraking variable from player struct.

* Back in 2020, I was trying to tidy stuff up and had no idea about network awareness, etc.
* We must continue the misuse of network bits like the original game did to make sure the RRRA vehicles are network aware.
This commit is contained in:
Mitchell Richters 2023-03-19 20:51:08 +11:00
parent 31f8de3854
commit 37e9cfed45
5 changed files with 32 additions and 31 deletions

View file

@ -83,17 +83,10 @@ void hud_input(int plnum)
p->sync.actions &= ~SB_CROUCH; p->sync.actions &= ~SB_CROUCH;
} }
if (p->OnMotorcycle || p->OnBoat) if ((isRR() && p->drink_amt > 88))
{ p->sync.actions |= SB_LOOK_LEFT;
// mask out all actions not compatible with vehicles. if ((isRR() && p->drink_amt > 99))
p->sync.actions &= ~(SB_WEAPONMASK_BITS | SB_TURNAROUND | SB_CENTERVIEW | SB_HOLSTER | SB_JUMP | SB_CROUCH | SB_RUN | p->sync.actions |= SB_LOOK_DOWN;
SB_AIM_UP | SB_AIM_DOWN | SB_AIMMODE | SB_LOOK_UP | SB_LOOK_DOWN | SB_LOOK_LEFT | SB_LOOK_RIGHT);
}
else
{
if ((isRR() && p->drink_amt > 88)) p->sync.actions |= SB_LOOK_LEFT;
if ((isRR() && p->drink_amt > 99)) p->sync.actions |= SB_LOOK_DOWN;
}
if (isRR()) if (isRR())
{ {
@ -617,11 +610,17 @@ static void processVehicleInput(player_struct *p, HIDInput* const hidInput, Inpu
{ {
float baseVel, velScale; float baseVel, velScale;
// mask out all actions not compatible with vehicles.
inputBuffer->actions &= ~(SB_WEAPONMASK_BITS | SB_TURNAROUND | SB_CENTERVIEW | SB_HOLSTER | SB_JUMP | SB_CROUCH | SB_RUN |
SB_AIM_UP | SB_AIM_DOWN | SB_AIMMODE | SB_LOOK_UP | SB_LOOK_DOWN | SB_LOOK_LEFT | SB_LOOK_RIGHT);
if (p->OnBoat || !p->moto_underwater) if (p->OnBoat || !p->moto_underwater)
{ {
p->vehForwardScale = min((buttonMap.ButtonDown(gamefunc_Move_Forward) || buttonMap.ButtonDown(gamefunc_Strafe)) + hidInput->joyaxes[JOYAXIS_Forward], 1.f); p->vehForwardScale = min((buttonMap.ButtonDown(gamefunc_Move_Forward) || buttonMap.ButtonDown(gamefunc_Strafe)) + hidInput->joyaxes[JOYAXIS_Forward], 1.f);
p->vehReverseScale = min(buttonMap.ButtonDown(gamefunc_Move_Backward) + -hidInput->joyaxes[JOYAXIS_Forward], 1.f); p->vehReverseScale = min(buttonMap.ButtonDown(gamefunc_Move_Backward) + -hidInput->joyaxes[JOYAXIS_Forward], 1.f);
p->vehBraking = buttonMap.ButtonDown(gamefunc_Run);
if (buttonMap.ButtonDown(gamefunc_Run))
inputBuffer->actions |= SB_CROUCH;
} }
if (p->OnMotorcycle) if (p->OnMotorcycle)

View file

@ -1467,6 +1467,7 @@ static void onMotorcycle(int snum, ESyncBits &actions)
auto p = &ps[snum]; auto p = &ps[snum];
auto pact = p->GetActor(); auto pact = p->GetActor();
bool braking = false;
int rng; int rng;
if (p->MotoSpeed < 0) if (p->MotoSpeed < 0)
@ -1475,11 +1476,16 @@ static void onMotorcycle(int snum, ESyncBits &actions)
bool turnLeft = p->sync.avel < 0; bool turnLeft = p->sync.avel < 0;
bool turnRight = p->sync.avel > 0; bool turnRight = p->sync.avel > 0;
if ((braking = actions & SB_CROUCH))
{
actions &= ~SB_CROUCH;
}
if (p->vehForwardScale != 0) if (p->vehForwardScale != 0)
{ {
if (p->on_ground) if (p->on_ground)
{ {
if (p->MotoSpeed == 0 && p->vehBraking) if (p->MotoSpeed == 0 && braking)
{ {
if (!S_CheckActorSoundPlaying(pact, 187)) if (!S_CheckActorSoundPlaying(pact, 187))
S_PlayActorSound(187, pact); S_PlayActorSound(187, pact);
@ -1537,7 +1543,7 @@ static void onMotorcycle(int snum, ESyncBits &actions)
if (p->on_ground == 1) if (p->on_ground == 1)
{ {
if (p->vehBraking && p->MotoSpeed > 0) if (braking && p->MotoSpeed > 0)
{ {
p->MotoSpeed -= p->moto_on_oil ? 2 : 4; p->MotoSpeed -= p->moto_on_oil ? 2 : 4;
if (p->MotoSpeed < 0) if (p->MotoSpeed < 0)
@ -1545,7 +1551,7 @@ static void onMotorcycle(int snum, ESyncBits &actions)
p->VBumpTarget = -30; p->VBumpTarget = -30;
p->moto_do_bump = 1; p->moto_do_bump = 1;
} }
else if (p->vehForwardScale != 0 && !p->vehBraking) else if (p->vehForwardScale != 0 && !braking)
{ {
if (p->MotoSpeed < 40) if (p->MotoSpeed < 40)
{ {
@ -1565,13 +1571,13 @@ static void onMotorcycle(int snum, ESyncBits &actions)
else if (p->MotoSpeed > 0) else if (p->MotoSpeed > 0)
p->MotoSpeed--; p->MotoSpeed--;
if (p->moto_do_bump && (!p->vehBraking || p->MotoSpeed == 0)) if (p->moto_do_bump && (!braking || p->MotoSpeed == 0))
{ {
p->VBumpTarget = 0; p->VBumpTarget = 0;
p->moto_do_bump = 0; p->moto_do_bump = 0;
} }
if (p->vehReverseScale != 0 && p->MotoSpeed <= 0 && !p->vehBraking) if (p->vehReverseScale != 0 && p->MotoSpeed <= 0 && !braking)
{ {
bool temp = turnRight; bool temp = turnRight;
turnRight = turnLeft; turnRight = turnLeft;
@ -1693,7 +1699,6 @@ static void onMotorcycle(int snum, ESyncBits &actions)
} }
p->moto_on_mud = p->moto_on_oil = 0; p->moto_on_mud = p->moto_on_oil = 0;
p->vehBraking = false;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -1707,7 +1712,7 @@ static void onBoat(int snum, ESyncBits &actions)
auto p = &ps[snum]; auto p = &ps[snum];
auto pact = p->GetActor(); auto pact = p->GetActor();
bool heeltoe; bool braking = false, heeltoe = false;
int rng; int rng;
bool turnLeft = p->sync.avel < 0; bool turnLeft = p->sync.avel < 0;
@ -1730,14 +1735,11 @@ static void onBoat(int snum, ESyncBits &actions)
if (p->MotoSpeed < 0) if (p->MotoSpeed < 0)
p->MotoSpeed = 0; p->MotoSpeed = 0;
if (p->vehBraking && (p->vehForwardScale != 0)) if ((actions & SB_CROUCH) && (p->vehForwardScale != 0))
{ {
heeltoe = true; heeltoe = true;
p->vehBraking = false;
p->vehForwardScale = 0; p->vehForwardScale = 0;
} }
else
heeltoe = false;
if (p->vehForwardScale != 0) if (p->vehForwardScale != 0)
{ {
@ -1770,6 +1772,11 @@ static void onBoat(int snum, ESyncBits &actions)
S_PlayActorSound(87, pact); S_PlayActorSound(87, pact);
} }
if ((braking = actions & SB_CROUCH))
{
actions &= ~SB_CROUCH;
}
if (turnLeft && !S_CheckActorSoundPlaying(pact, 91) && p->MotoSpeed > 30 && !p->NotOnWater) if (turnLeft && !S_CheckActorSoundPlaying(pact, 91) && p->MotoSpeed > 30 && !p->NotOnWater)
S_PlayActorSound(91, pact); S_PlayActorSound(91, pact);
@ -1815,7 +1822,7 @@ static void onBoat(int snum, ESyncBits &actions)
p->moto_do_bump = 1; p->moto_do_bump = 1;
} }
} }
else if (p->vehBraking && p->MotoSpeed > 0) else if (braking && p->MotoSpeed > 0)
{ {
p->MotoSpeed -= 2; p->MotoSpeed -= 2;
if (p->MotoSpeed < 0) if (p->MotoSpeed < 0)
@ -1838,13 +1845,13 @@ static void onBoat(int snum, ESyncBits &actions)
else if (p->MotoSpeed > 0) else if (p->MotoSpeed > 0)
p->MotoSpeed--; p->MotoSpeed--;
if (p->moto_do_bump && (!p->vehBraking || p->MotoSpeed == 0)) if (p->moto_do_bump && (!braking || p->MotoSpeed == 0))
{ {
p->VBumpTarget = 0; p->VBumpTarget = 0;
p->moto_do_bump = 0; p->moto_do_bump = 0;
} }
if (p->vehReverseScale != 0 && p->MotoSpeed == 0 && !p->vehBraking) if (p->vehReverseScale != 0 && p->MotoSpeed == 0 && !braking)
{ {
bool temp = turnRight; bool temp = turnRight;
turnRight = turnLeft; turnRight = turnLeft;
@ -1931,8 +1938,6 @@ static void onBoat(int snum, ESyncBits &actions)
} }
if (p->NotOnWater && p->MotoSpeed > 50) if (p->NotOnWater && p->MotoSpeed > 50)
p->MotoSpeed -= (p->MotoSpeed / 2.); p->MotoSpeed -= (p->MotoSpeed / 2.);
p->vehBraking = false;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View file

@ -309,7 +309,6 @@ struct player_struct
uint8_t OnMotorcycle, OnBoat, moto_underwater, NotOnWater, MotoOnGround; uint8_t OnMotorcycle, OnBoat, moto_underwater, NotOnWater, MotoOnGround;
uint8_t moto_do_bump, moto_bump_fast, moto_on_oil, moto_on_mud; uint8_t moto_do_bump, moto_bump_fast, moto_on_oil, moto_on_mud;
double vehForwardScale, vehReverseScale, MotoSpeed; double vehForwardScale, vehReverseScale, MotoSpeed;
bool vehBraking;
TArray<GameVarValue> uservars; TArray<GameVarValue> uservars;

View file

@ -944,7 +944,6 @@ DEFINE_FIELD_X(DukePlayer, player_struct, moto_on_mud)
DEFINE_FIELD_X(DukePlayer, player_struct, vehForwardScale) DEFINE_FIELD_X(DukePlayer, player_struct, vehForwardScale)
DEFINE_FIELD_X(DukePlayer, player_struct, vehReverseScale) DEFINE_FIELD_X(DukePlayer, player_struct, vehReverseScale)
DEFINE_FIELD_X(DukePlayer, player_struct, MotoSpeed) DEFINE_FIELD_X(DukePlayer, player_struct, MotoSpeed)
DEFINE_FIELD_X(DukePlayer, player_struct, vehBraking)
DEFINE_FIELD_X(DukePlayer, player_struct, holoduke_on) DEFINE_FIELD_X(DukePlayer, player_struct, holoduke_on)
DEFINE_FIELD_X(DukePlayer, player_struct, actorsqu) DEFINE_FIELD_X(DukePlayer, player_struct, actorsqu)
DEFINE_FIELD_X(DukePlayer, player_struct, wackedbyactor) DEFINE_FIELD_X(DukePlayer, player_struct, wackedbyactor)

View file

@ -335,7 +335,6 @@ struct DukePlayer native
native uint8 OnMotorcycle, OnBoat, moto_underwater, NotOnWater, MotoOnGround; native uint8 OnMotorcycle, OnBoat, moto_underwater, NotOnWater, MotoOnGround;
native uint8 moto_do_bump, moto_bump_fast, moto_on_oil, moto_on_mud; native uint8 moto_do_bump, moto_bump_fast, moto_on_oil, moto_on_mud;
native double vehForwardScale, vehReverseScale, MotoSpeed; native double vehForwardScale, vehReverseScale, MotoSpeed;
native bool vehBraking;
// input stuff. // input stuff.
//InputPacket sync; //InputPacket sync;