From ae36ea88c384c0e103711a63d90c64488e889efe Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 30 Nov 2020 23:40:16 +0100 Subject: [PATCH] - wrap all checks of cl_syncinput in an inline function. --- source/blood/src/controls.cpp | 2 +- source/blood/src/player.cpp | 4 ++-- source/blood/src/view.cpp | 4 ++-- source/core/gameinput.h | 20 ++++++++++---------- source/core/inputstate.cpp | 2 +- source/core/inputstate.h | 5 +++++ source/core/mainloop.cpp | 2 +- source/exhumed/src/input.cpp | 2 +- source/exhumed/src/player.cpp | 4 ++-- source/exhumed/src/view.cpp | 4 ++-- source/games/duke/src/hudweapon_d.cpp | 2 +- source/games/duke/src/hudweapon_r.cpp | 2 +- source/games/duke/src/input.cpp | 6 +++--- source/games/duke/src/player_d.cpp | 6 +++--- source/games/duke/src/player_r.cpp | 6 +++--- source/games/duke/src/render.cpp | 6 +++--- source/sw/src/draw.cpp | 2 +- source/sw/src/input.cpp | 2 +- source/sw/src/interpso.cpp | 8 ++++---- source/sw/src/player.cpp | 20 ++++++++++---------- 20 files changed, 57 insertions(+), 52 deletions(-) diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index 72d3aad4e..194a82b8e 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -49,7 +49,7 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput) ApplyGlobalInput(gInput, hidInput); processMovement(&input, &gInput, hidInput, scaleAdjust); - if (!cl_syncinput && gamestate == GS_LEVEL) + if (!SyncInput() && gamestate == GS_LEVEL) { // Perform unsynchronised angle/horizon if not dead. if (gView->pXSprite->health != 0) diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index ffdf72df0..436537c1a 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -1433,7 +1433,7 @@ void ProcessInput(PLAYER *pPlayer) } } - if (cl_syncinput) + if (SyncInput()) { applylook(&pPlayer->angle, pInput->avel, &pInput->actions); } @@ -1560,7 +1560,7 @@ void ProcessInput(PLAYER *pPlayer) pInput->actions &= ~SB_OPEN; } - if (cl_syncinput) + if (SyncInput()) { sethorizon(&pPlayer->horizon.horiz, pInput->horz, &pInput->actions); } diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 3c3f67c8a..7b2f9af0d 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -568,7 +568,7 @@ void viewDrawScreen(bool sceneonly) v4c = finterpolate(predictOld.at1c, predict.at1c, gInterpolate); v48 = finterpolate(predictOld.at18, predict.at18, gInterpolate); - if (!cl_syncinput) + if (!SyncInput()) { cA = bamang(predict.at30.asbam() + predict.look_ang.asbam()); cH = predict.at24; @@ -596,7 +596,7 @@ void viewDrawScreen(bool sceneonly) v4c = finterpolate(pView->at1c, gView->swayWidth, gInterpolate); v48 = finterpolate(pView->at18, gView->swayHeight, gInterpolate); - if (!cl_syncinput) + if (!SyncInput()) { cA = gView->angle.sum(); cH = gView->horizon.horiz; diff --git a/source/core/gameinput.h b/source/core/gameinput.h index d99f7c1c8..ff5deecd7 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -29,7 +29,7 @@ struct PlayerHorizon void addadjustment(double value) { - if (!cl_syncinput) + if (!SyncInput()) { adjustment += value * FRACUNIT; } @@ -46,7 +46,7 @@ struct PlayerHorizon void settarget(double value, bool backup = false) { - if (!cl_syncinput && !backup) + if (!SyncInput() && !backup) { target = value * FRACUNIT; if (target == 0) target += 1; @@ -117,7 +117,7 @@ struct PlayerAngle void addadjustment(int value) { - if (!cl_syncinput) + if (!SyncInput()) { adjustment += BAngToBAM(value); } @@ -129,7 +129,7 @@ struct PlayerAngle void addadjustment(double value) { - if (!cl_syncinput) + if (!SyncInput()) { adjustment += value * BAMUNIT; } @@ -141,7 +141,7 @@ struct PlayerAngle void addadjustment(lookangle value) { - if (!cl_syncinput) + if (!SyncInput()) { adjustment += value.asbam(); } @@ -153,7 +153,7 @@ struct PlayerAngle void addadjustment(binangle value) { - if (!cl_syncinput) + if (!SyncInput()) { adjustment += value.asbam(); } @@ -170,7 +170,7 @@ struct PlayerAngle void settarget(int value, bool backup = false) { - if (!cl_syncinput && !backup) + if (!SyncInput() && !backup) { target = (ang + getincanglebam(ang, buildang(value))).asbam(); if (target == 0) target += 1; @@ -184,7 +184,7 @@ struct PlayerAngle void settarget(double value, bool backup = false) { - if (!cl_syncinput && !backup) + if (!SyncInput() && !backup) { target = (ang + getincanglebam(ang, buildfang(value))).asbam(); if (target == 0) target += 1; @@ -198,7 +198,7 @@ struct PlayerAngle void settarget(binangle value, bool backup = false) { - if (!cl_syncinput && !backup) + if (!SyncInput() && !backup) { target = (ang + getincanglebam(ang, value)).asbam(); if (target == 0) target += 1; @@ -261,7 +261,7 @@ struct PlayerAngle double look_anghalf(double const smoothratio) { - return (!cl_syncinput ? look_ang : interpolatedlookang(smoothratio)).asbam() * (0.5 / BAMUNIT); // Used within draw code for weapon and crosshair when looking left/right. + return (!SyncInput() ? look_ang : interpolatedlookang(smoothratio)).asbam() * (0.5 / BAMUNIT); // Used within draw code for weapon and crosshair when looking left/right. } }; diff --git a/source/core/inputstate.cpp b/source/core/inputstate.cpp index 71b6e469c..9593ba436 100644 --- a/source/core/inputstate.cpp +++ b/source/core/inputstate.cpp @@ -460,7 +460,7 @@ void ApplyGlobalInput(InputPacket& input, ControlInfo* hidInput, bool const crou double InputScale() { - if (!cl_syncinput) + if (!SyncInput()) { double now = I_msTimeF(); double elapsedInputTicks = lastCheck > 0 ? min(now - lastCheck, 1000.0 / GameTicRate) : 1; diff --git a/source/core/inputstate.h b/source/core/inputstate.h index e37eb447e..8bb37c1c9 100644 --- a/source/core/inputstate.h +++ b/source/core/inputstate.h @@ -105,3 +105,8 @@ void SetupGameButtons(); void ApplyGlobalInput(InputPacket& input, ControlInfo* const hidInput, bool const crouchable = true, bool const disableToggle = false); extern ESyncBits ActionsToSend; double InputScale(); + +inline bool SyncInput() +{ + return cl_syncinput; +} \ No newline at end of file diff --git a/source/core/mainloop.cpp b/source/core/mainloop.cpp index 40d31ad44..5e464322a 100644 --- a/source/core/mainloop.cpp +++ b/source/core/mainloop.cpp @@ -519,7 +519,7 @@ void TryRunTics (void) gi->Predict(myconnectindex); #endif } - if (!cl_syncinput) + if (!SyncInput()) { I_GetEvent(); auto input = CONTROL_GetInput(); diff --git a/source/exhumed/src/input.cpp b/source/exhumed/src/input.cpp index 2158f9c35..e502bd626 100644 --- a/source/exhumed/src/input.cpp +++ b/source/exhumed/src/input.cpp @@ -120,7 +120,7 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput) processMovement(&input, &localInput, hidInput, scaleAdjust); } - if (!cl_syncinput) + if (!SyncInput()) { if (!nFreeze) { diff --git a/source/exhumed/src/player.cpp b/source/exhumed/src/player.cpp index 6d5a76179..034471178 100644 --- a/source/exhumed/src/player.cpp +++ b/source/exhumed/src/player.cpp @@ -918,7 +918,7 @@ void FuncPlayer(int a, int nDamage, int nRun) } // loc_1A494: - if (cl_syncinput) + if (SyncInput()) { Player* pPlayer = &PlayerList[nPlayer]; applylook(&pPlayer->angle, sPlayerInput[nPlayer].nAngle, &sPlayerInput[nLocalPlayer].actions); @@ -2637,7 +2637,7 @@ loc_1BD2E: PlayerList[nPlayer].field_2 = 0; } - if (cl_syncinput) + if (SyncInput()) { Player* pPlayer = &PlayerList[nPlayer]; sethorizon(&pPlayer->horizon.horiz, sPlayerInput[nPlayer].pan, &sPlayerInput[nLocalPlayer].actions); diff --git a/source/exhumed/src/view.cpp b/source/exhumed/src/view.cpp index b729ccc48..1ef967610 100644 --- a/source/exhumed/src/view.cpp +++ b/source/exhumed/src/view.cpp @@ -239,7 +239,7 @@ void DrawView(double smoothRatio, bool sceneonly) nSector = nPlayerViewSect[nLocalPlayer]; updatesector(playerX, playerY, &nSector); - if (!cl_syncinput) + if (!SyncInput()) { nAngle = PlayerList[nLocalPlayer].angle.sum(); rotscrnang = PlayerList[nLocalPlayer].angle.rotscrnang; @@ -273,7 +273,7 @@ void DrawView(double smoothRatio, bool sceneonly) viewz = playerZ + nQuake[nLocalPlayer]; int floorZ = sector[sprite[nPlayerSprite].sectnum].floorz; - if (!cl_syncinput) + if (!SyncInput()) { pan = PlayerList[nLocalPlayer].horizon.sum(); } diff --git a/source/games/duke/src/hudweapon_d.cpp b/source/games/duke/src/hudweapon_d.cpp index 2475e4138..eb8ce6e76 100644 --- a/source/games/duke/src/hudweapon_d.cpp +++ b/source/games/duke/src/hudweapon_d.cpp @@ -281,7 +281,7 @@ void displayweapon_d(int snum, double smoothratio) o = 0; - horiz16th = get16thOfHoriz(snum, cl_syncinput, smoothratio); + horiz16th = get16thOfHoriz(snum, SyncInput(), smoothratio); look_anghalf = p->angle.look_anghalf(smoothratio); looking_arc = fabs(look_anghalf) / 4.5; weapon_sway = p->oweapon_sway + fmulscale16(p->weapon_sway - p->oweapon_sway, smoothratio); diff --git a/source/games/duke/src/hudweapon_r.cpp b/source/games/duke/src/hudweapon_r.cpp index f61c7dd2c..933f80289 100644 --- a/source/games/duke/src/hudweapon_r.cpp +++ b/source/games/duke/src/hudweapon_r.cpp @@ -128,7 +128,7 @@ void displayweapon_r(int snum, double smoothratio) look_anghalf = p->angle.look_anghalf(smoothratio); looking_arc = fabs(look_anghalf) / 4.5; weapon_sway = p->oweapon_sway + fmulscale16((p->weapon_sway - p->oweapon_sway), smoothratio); - TiltStatus = !cl_syncinput ? p->TiltStatus : p->oTiltStatus + fmulscale16((p->TiltStatus - p->oTiltStatus), smoothratio); + TiltStatus = !SyncInput() ? p->TiltStatus : p->oTiltStatus + fmulscale16((p->TiltStatus - p->oTiltStatus), smoothratio); if (shadedsector[p->cursectnum] == 1) shade = 16; diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index ad316377b..54bf48276 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -815,7 +815,7 @@ static void FinalizeInput(int playerNum, InputPacket& input, bool vehicle) { // input.avel already added to loc in processMovement() loc.avel = clamp(loc.avel, -MAXANGVEL, MAXANGVEL); - if (!cl_syncinput && input.avel) + if (!SyncInput() && input.avel) { p->angle.spin = bamlook(0); } @@ -863,7 +863,7 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput) processVehicleInput(p, hidInput, input, scaleAdjust); FinalizeInput(myconnectindex, input, true); - if (!cl_syncinput && p->GetActor()->s.extra > 0) + if (!SyncInput() && p->GetActor()->s.extra > 0) { p->apply_seasick(scaleAdjust); } @@ -875,7 +875,7 @@ void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput) FinalizeInput(myconnectindex, input, false); } - if (!cl_syncinput) + if (!SyncInput()) { if (p->GetActor()->s.extra > 0) { diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index fb0bfc9fe..cb0adb17d 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2760,7 +2760,7 @@ void processinput_d(int snum) pact->floorz = fz; pact->ceilingz = cz; - if (cl_syncinput) + if (SyncInput()) { p->horizon.backup(); calcviewpitch(p, 1); @@ -2883,7 +2883,7 @@ void processinput_d(int snum) p->posxv = 0; p->posyv = 0; } - else if (cl_syncinput) + else if (SyncInput()) { //p->ang += syncangvel * constant //ENGINE calculates angvel for you @@ -3121,7 +3121,7 @@ HORIZONLY: playerAimDown(snum, actions); } - if (cl_syncinput) + if (SyncInput()) { sethorizon(&p->horizon.horiz, PlayerHorizon(snum), &p->sync.actions); } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index c83a15b42..227536991 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3429,7 +3429,7 @@ void processinput_r(int snum) pact->floorz = fz; pact->ceilingz = cz; - if (cl_syncinput) + if (SyncInput()) { p->horizon.backup(); calcviewpitch(p, 1); @@ -3623,7 +3623,7 @@ void processinput_r(int snum) p->posxv = 0; p->posyv = 0; } - else if (cl_syncinput) + else if (SyncInput()) { //p->ang += syncangvel * constant //ENGINE calculates angvel for you @@ -3991,7 +3991,7 @@ HORIZONLY: p->horizon.addadjustment(-d); } - if (cl_syncinput) + if (SyncInput()) { sethorizon(&p->horizon.horiz, PlayerHorizon(snum), &p->sync.actions); } diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index 3e8077787..f5394a48a 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -538,14 +538,14 @@ void displayrooms(int snum, double smoothratio) setgamepalette(setpal(p)); // set screen rotation. - rotscrnang = !cl_syncinput ? p->angle.rotscrnang : p->angle.interpolatedrotscrn(smoothratio); + rotscrnang = !SyncInput() ? p->angle.rotscrnang : p->angle.interpolatedrotscrn(smoothratio); if ((snum == myconnectindex) && (numplayers > 1)) { cposx = omyx + xs_CRoundToInt(fmulscale16(myx - omyx, smoothratio)); cposy = omyy + xs_CRoundToInt(fmulscale16(myy - omyy, smoothratio)); cposz = omyz + xs_CRoundToInt(fmulscale16(myz - omyz, smoothratio)); - if (cl_syncinput) + if (SyncInput()) { fixed_t ohorz = (omyhoriz + omyhorizoff).asq16(); fixed_t horz = (myhoriz + myhorizoff).asq16(); @@ -564,7 +564,7 @@ void displayrooms(int snum, double smoothratio) cposx = p->oposx + xs_CRoundToInt(fmulscale16(p->posx - p->oposx, smoothratio)); cposy = p->oposy + xs_CRoundToInt(fmulscale16(p->posy - p->oposy, smoothratio)); cposz = p->oposz + xs_CRoundToInt(fmulscale16(p->posz - p->oposz, smoothratio)); - if (cl_syncinput) + if (SyncInput()) { // Original code for when the values are passed through the sync struct choriz = p->horizon.interpolatedsum(smoothratio); diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index 4f63b066c..8aef77b39 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -1652,7 +1652,7 @@ drawscreen(PLAYERp pp, double smoothratio) // Interpolate the player's angle while on a sector object, just like VoidSW. // This isn't needed for the turret as it was fixable, but moving sector objects are problematic. - if (cl_syncinput || pp != Player+myconnectindex) + if (SyncInput() || pp != Player+myconnectindex) { tang = camerapp->angle.interpolatedsum(smoothratio); thoriz = camerapp->horizon.interpolatedsum(smoothratio); diff --git a/source/sw/src/input.cpp b/source/sw/src/input.cpp index fc36f0ebe..5b8461d2e 100644 --- a/source/sw/src/input.cpp +++ b/source/sw/src/input.cpp @@ -203,7 +203,7 @@ void GameInterface::GetInput(InputPacket *packet, ControlInfo* const hidInput) processMovement(&input, &loc, hidInput, scaleAdjust, 0, !pp->sop, pp->sop_control ? 3. / 1.40625 : 1.); processWeapon(pp); - if (!cl_syncinput) + if (!SyncInput()) { if (TEST(pp->Flags2, PF2_INPUT_CAN_AIM)) { diff --git a/source/sw/src/interpso.cpp b/source/sw/src/interpso.cpp index ee862dfbc..c6a5e49d8 100644 --- a/source/sw/src/interpso.cpp +++ b/source/sw/src/interpso.cpp @@ -252,7 +252,7 @@ void so_updateinterpolations(void) // Stick at beginning of domovethings for (sop = SectorObject, interp = so_interpdata; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++) { - bool skip = !cl_syncinput && (sop->track == SO_TURRET); + bool skip = !SyncInput() && (sop->track == SO_TURRET); if (SO_EMPTY(sop) || skip) continue; if (interp->tic < interp->lasttic) @@ -291,7 +291,7 @@ void so_dointerpolations(int32_t smoothratio) // Stick at b for (sop = SectorObject, interp = so_interpdata; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++) { - bool skip = !cl_syncinput && (sop->track == SO_TURRET); + bool skip = !SyncInput() && (sop->track == SO_TURRET); if (SO_EMPTY(sop) || skip) continue; @@ -318,7 +318,7 @@ void so_dointerpolations(int32_t smoothratio) // Stick at b for (sop = SectorObject, interp = so_interpdata; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++) { - bool skip = !cl_syncinput && (sop->track == SO_TURRET); + bool skip = !SyncInput() && (sop->track == SO_TURRET); if (SO_EMPTY(sop) || skip) continue; @@ -378,7 +378,7 @@ void so_restoreinterpolations(void) // Stick at end of drawscree for (sop = SectorObject, interp = so_interpdata; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++) { - bool skip = !cl_syncinput && (sop->track == SO_TURRET); + bool skip = !SyncInput() && (sop->track == SO_TURRET); if (SO_EMPTY(sop) || skip) continue; diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 04c2514c9..549b963db 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -2142,7 +2142,7 @@ DoPlayerMove(PLAYERp pp) SlipSlope(pp); - if (!cl_syncinput) + if (!SyncInput()) { SET(pp->Flags2, PF2_INPUT_CAN_TURN_GENERAL); } @@ -2270,7 +2270,7 @@ DoPlayerMove(PLAYERp pp) DoPlayerSetWadeDepth(pp); - if (!cl_syncinput) + if (!SyncInput()) { SET(pp->Flags2, PF2_INPUT_CAN_AIM); } @@ -2433,7 +2433,7 @@ DoPlayerMoveBoat(PLAYERp pp) PlaySOsound(pp->sop->mid_sector,SO_IDLE_SOUND); } - if (!cl_syncinput) + if (!SyncInput()) { SET(pp->Flags2, PF2_INPUT_CAN_TURN_BOAT); } @@ -2488,7 +2488,7 @@ DoPlayerMoveBoat(PLAYERp pp) OperateSectorObject(pp->sop, pp->angle.ang.asbuild(), pp->posx, pp->posy); pp->cursectnum = save_sectnum; // for speed - if (!cl_syncinput) + if (!SyncInput()) { SET(pp->Flags2, PF2_INPUT_CAN_AIM); } @@ -2939,7 +2939,7 @@ DoPlayerMoveVehicle(PLAYERp pp) } else { - if (!cl_syncinput) + if (!SyncInput()) { SET(pp->Flags2, PF2_INPUT_CAN_TURN_VEHICLE); } @@ -2984,7 +2984,7 @@ DoPlayerMoveVehicle(PLAYERp pp) OperateSectorObject(pp->sop, pp->angle.ang.asbuild(), pp->posx, pp->posy); pp->cursectnum = save_sectnum; // for speed - if (!cl_syncinput) + if (!SyncInput()) { SET(pp->Flags2, PF2_INPUT_CAN_AIM); } @@ -3007,7 +3007,7 @@ DoPlayerMoveTurret(PLAYERp pp) PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND); } - if (!cl_syncinput) + if (!SyncInput()) { SET(pp->Flags2, PF2_INPUT_CAN_TURN_TURRET); } @@ -3021,7 +3021,7 @@ DoPlayerMoveTurret(PLAYERp pp) else SET(pp->Flags, PF_PLAYER_MOVED); - if (!cl_syncinput) + if (!SyncInput()) { SET(pp->Flags2, PF2_INPUT_CAN_AIM); } @@ -3600,7 +3600,7 @@ DoPlayerClimb(PLAYERp pp) sp->z = pp->posz + PLAYER_HEIGHT; changespritesect(pp->PlayerSprite, pp->cursectnum); - if (!cl_syncinput) + if (!SyncInput()) { SET(pp->Flags2, PF2_INPUT_CAN_AIM); } @@ -6169,7 +6169,7 @@ void DoPlayerDeathFollowKiller(PLAYERp pp) // allow turning if (TEST(pp->Flags, PF_DEAD_HEAD|PF_HEAD_CONTROL)) { - if (!cl_syncinput) + if (!SyncInput()) { SET(pp->Flags2, PF2_INPUT_CAN_TURN_GENERAL); }