From 0ef9da6a0c1f99119dfde22a710b6bfa0668cd35 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 6 Sep 2020 20:12:39 +1000 Subject: [PATCH] - SW: Make game's local input buffer static within input.cpp. --- source/sw/src/draw.cpp | 3 +-- source/sw/src/game.h | 2 -- source/sw/src/input.cpp | 34 +++++++++++++++++----------------- source/sw/src/save.cpp | 5 ++--- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index bdb5aac28..6b2180825 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -1650,8 +1650,7 @@ drawscreen(PLAYERp pp, double smoothratio) tz = camerapp->oposz + xs_CRoundToInt(fmulscale16(camerapp->posz - camerapp->oposz, smoothratio)); // TODO: It'd be better to check pp->input.q16angvel instead, problem is that // it's been repurposed for the q16ang diff while tying input to framerate - if (cl_syncinput || (pp != Player+myconnectindex) || - (TEST(pp->Flags, PF_DEAD) && (loc.q16avel == 0))) + if (cl_syncinput || (pp != Player+myconnectindex) || TEST(pp->Flags, PF_DEAD)) { tq16ang = camerapp->oq16ang + xs_CRoundToInt(fmulscale16(NORM_Q16ANGLE(camerapp->q16ang + IntToFixed(1024) - camerapp->oq16ang) - IntToFixed(1024), smoothratio)); tq16horiz = camerapp->oq16horiz + xs_CRoundToInt(fmulscale16(camerapp->q16horiz - camerapp->oq16horiz, smoothratio)); diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 7a4f731cb..54282ee04 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -805,8 +805,6 @@ enum }; -extern InputPacket loc; - #define PACK 1 extern SWBOOL CameraTestMode; diff --git a/source/sw/src/input.cpp b/source/sw/src/input.cpp index 9370b468e..233a5b292 100644 --- a/source/sw/src/input.cpp +++ b/source/sw/src/input.cpp @@ -40,7 +40,7 @@ double scaleAdjustmentToInterval(double x) { return x * (120 / synctics) / (1000 void DoPlayerTurn(PLAYERp pp, fixed_t *pq16ang, fixed_t q16angvel); void DoPlayerHorizon(PLAYERp pp, fixed_t *pq16horiz, fixed_t q16horz); -InputPacket loc; +static InputPacket loc; void InitNetVars(void) @@ -67,7 +67,7 @@ void GameInterface::ResetFollowPos(bool) Follow_posy = pp->posy; } -static void getinput(InputPacket *loc, ControlInfo* const hidInput) +static void getinput(ControlInfo* const hidInput) { int i; PLAYERp pp = Player + myconnectindex; @@ -126,9 +126,9 @@ static void getinput(InputPacket *loc, ControlInfo* const hidInput) // for dividing controller input to match speed input speed of other games. float const ticrateScale = 0.75f; - ApplyGlobalInput(*loc, hidInput); + ApplyGlobalInput(loc, hidInput); - bool mouseaim = !(loc->actions & SB_AIMMODE); + bool mouseaim = !(loc.actions & SB_AIMMODE); if (!CommEnabled) { @@ -149,10 +149,10 @@ static void getinput(InputPacket *loc, ControlInfo* const hidInput) if (buttonMap.ButtonDown(gamefunc_Toggle_Crouch)) // this shares a bit with another function so cannot be in the common code. - loc->actions |= SB_CROUCH_LOCK; + loc.actions |= SB_CROUCH_LOCK; - if (loc->actions & SB_RUN) + if (loc.actions & SB_RUN) { if (pp->sop_control) turnamount = RUNTURN * 3; @@ -272,14 +272,14 @@ static void getinput(InputPacket *loc, ControlInfo* const hidInput) pp->oq16horiz += pp->camq16horiz - prevcamq16horiz; } - loc->fvel = clamp(loc->fvel + vel, -MAXVEL, MAXVEL); - loc->svel = clamp(loc->svel + svel, -MAXSVEL, MAXSVEL); + loc.fvel = clamp(loc.fvel + vel, -MAXVEL, MAXVEL); + loc.svel = clamp(loc.svel + svel, -MAXSVEL, MAXSVEL); - loc->q16avel += q16angvel; - loc->q16horz += q16horz; + loc.q16avel += q16angvel; + loc.q16horz += q16horz; - if (loc->getNewWeapon() == WeaponSel_Next) + if (loc.getNewWeapon() == WeaponSel_Next) { USERp u = User[pp->PlayerSprite]; short next_weapon = u->WeaponNum + 1; @@ -313,9 +313,9 @@ static void getinput(InputPacket *loc, ControlInfo* const hidInput) } } - loc->setNewWeapon(next_weapon + 1); + loc.setNewWeapon(next_weapon + 1); } - else if (loc->getNewWeapon() == WeaponSel_Prev) + else if (loc.getNewWeapon() == WeaponSel_Prev) { USERp u = User[pp->PlayerSprite]; short prev_weapon = u->WeaponNum - 1; @@ -346,19 +346,19 @@ static void getinput(InputPacket *loc, ControlInfo* const hidInput) } } } - loc->setNewWeapon(prev_weapon + 1); + loc.setNewWeapon(prev_weapon + 1); } - else if (loc->getNewWeapon() == WeaponSel_Alt) + else if (loc.getNewWeapon() == WeaponSel_Alt) { USERp u = User[pp->PlayerSprite]; short const which_weapon = u->WeaponNum + 1; - loc->setNewWeapon(which_weapon); + loc.setNewWeapon(which_weapon); } } void GameInterface::GetInput(InputPacket *packet, ControlInfo* const hidInput) { - getinput(&loc, hidInput); + getinput(hidInput); if (packet) { PLAYERp pp = &Player[myconnectindex]; diff --git a/source/sw/src/save.cpp b/source/sw/src/save.cpp index 3dd664349..46f4e5757 100644 --- a/source/sw/src/save.cpp +++ b/source/sw/src/save.cpp @@ -85,7 +85,6 @@ extern short BossSpriteNum[3]; #define PANEL_SAVE 1 #define ANIM_SAVE 1 -extern InputPacket loc; extern STATE s_NotRestored[]; OrgTileListP otlist[] = {&orgwalllist, &orgwalloverlist, &orgsectorceilinglist, &orgsectorfloorlist}; @@ -469,7 +468,7 @@ bool GameInterface::SaveGame(FSaveGameNode *sv) MWRITE(Track[i].TrackPoint, Track[i].NumPoints * sizeof(TRACK_POINT),1,fil); } - MWRITE(&loc,sizeof(loc),1,fil); + // MWRITE(&loc,sizeof(loc),1,fil); MWRITE(&screenpeek,sizeof(screenpeek),1,fil); MWRITE(&randomseed, sizeof(randomseed), 1, fil); @@ -860,7 +859,7 @@ bool GameInterface::LoadGame(FSaveGameNode* sv) } } - MREAD(&loc,sizeof(loc),1,fil); + // MREAD(&loc,sizeof(loc),1,fil); MREAD(&screenpeek,sizeof(screenpeek),1,fil); MREAD(&randomseed, sizeof(randomseed), 1, fil);