- Blood: Make gInput static within controls.cpp.

This commit is contained in:
Mitchell Richters 2020-09-14 15:14:22 +10:00
parent d963f317d9
commit 5e484bddad
4 changed files with 17 additions and 19 deletions

View file

@ -100,7 +100,6 @@ void StartLevel(MapRecord* level)
gFrameClock = 0; gFrameClock = 0;
STAT_Update(0); STAT_Update(0);
EndLevel(); EndLevel();
gInput = {};
currentLevel = level; currentLevel = level;
if (gGameOptions.nGameType == 0) if (gGameOptions.nGameType == 0)

View file

@ -88,7 +88,7 @@ struct GameInterface : ::GameInterface
FString GetCoordString() override; FString GetCoordString() override;
ReservedSpace GetReservedScreenSpace(int viewsize) override; ReservedSpace GetReservedScreenSpace(int viewsize) override;
void UpdateSounds() override; void UpdateSounds() override;
void GetInput(InputPacket* gInput, ControlInfo* const hidInput) override; void GetInput(InputPacket* packet, ControlInfo* const hidInput) override;
void Ticker() override; void Ticker() override;
void DrawBackground() override; void DrawBackground() override;
void Startup() override; void Startup() override;

View file

@ -38,7 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS BEGIN_BLD_NS
InputPacket gInput; static InputPacket gInput;
bool bSilentAim = false; bool bSilentAim = false;
int iTurnCount = 0; int iTurnCount = 0;
@ -50,7 +50,7 @@ float gViewAngleAdjust;
float gViewLookAdjust; float gViewLookAdjust;
int gViewLookRecenter; int gViewLookRecenter;
void GetInputInternal(InputPacket &inputParm, ControlInfo* const hidInput) static void GetInputInternal(ControlInfo* const hidInput)
{ {
int prevPauseState = paused; int prevPauseState = paused;
@ -64,22 +64,22 @@ void GetInputInternal(InputPacket &inputParm, ControlInfo* const hidInput)
InputPacket input = {}; InputPacket input = {};
ApplyGlobalInput(inputParm, hidInput); ApplyGlobalInput(gInput, hidInput);
bool mouseaim = !(inputParm.actions & SB_AIMMODE); bool mouseaim = !(gInput.actions & SB_AIMMODE);
if (!mouseaim) inputParm.actions |= SB_CENTERVIEW; if (!mouseaim) gInput.actions |= SB_CENTERVIEW;
if (gPlayer[myconnectindex].nextWeapon == 0) if (gPlayer[myconnectindex].nextWeapon == 0)
{ {
} }
if (inputParm.actions & (SB_LOOK_UP|SB_LOOK_DOWN)) if (gInput.actions & (SB_LOOK_UP|SB_LOOK_DOWN))
inputParm.actions |= SB_CENTERVIEW; gInput.actions |= SB_CENTERVIEW;
int const run = !!(inputParm.actions & SB_RUN); int const run = !!(gInput.actions & SB_RUN);
int const keyMove = (1 + run) << 10; int const keyMove = (1 + run) << 10;
if (inputParm.fvel < keyMove && inputParm.fvel > -keyMove) if (gInput.fvel < keyMove && gInput.fvel > -keyMove)
{ {
if (buttonMap.ButtonDown(gamefunc_Move_Forward)) if (buttonMap.ButtonDown(gamefunc_Move_Forward))
input.fvel += keyMove; input.fvel += keyMove;
@ -88,7 +88,7 @@ void GetInputInternal(InputPacket &inputParm, ControlInfo* const hidInput)
input.fvel -= keyMove; input.fvel -= keyMove;
} }
if (inputParm.svel < keyMove && inputParm.svel > -keyMove) if (gInput.svel < keyMove && gInput.svel > -keyMove)
{ {
if (buttonMap.ButtonDown(gamefunc_Strafe_Left)) if (buttonMap.ButtonDown(gamefunc_Strafe_Left))
input.svel += keyMove; input.svel += keyMove;
@ -101,7 +101,7 @@ void GetInputInternal(InputPacket &inputParm, ControlInfo* const hidInput)
if (buttonMap.ButtonDown(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
{ {
if (inputParm.svel < keyMove && inputParm.svel > -keyMove) if (gInput.svel < keyMove && gInput.svel > -keyMove)
{ {
if (buttonMap.ButtonDown(gamefunc_Turn_Left)) if (buttonMap.ButtonDown(gamefunc_Turn_Left))
input.svel += keyMove; input.svel += keyMove;
@ -163,10 +163,10 @@ void GetInputInternal(InputPacket &inputParm, ControlInfo* const hidInput)
input.q16horz -= FloatToFixed(scaleAdjustmentToInterval(hidInput->dpitch / mlookScale)); input.q16horz -= FloatToFixed(scaleAdjustmentToInterval(hidInput->dpitch / mlookScale));
inputParm.fvel = clamp(inputParm.fvel + input.fvel, -2048, 2048); gInput.fvel = clamp(gInput.fvel + input.fvel, -2048, 2048);
inputParm.svel = clamp(inputParm.svel + input.svel, -2048, 2048); gInput.svel = clamp(gInput.svel + input.svel, -2048, 2048);
inputParm.q16avel += input.q16avel; gInput.q16avel += input.q16avel;
inputParm.q16horz = clamp(inputParm.q16horz + input.q16horz, IntToFixed(-127) >> 2, IntToFixed(127) >> 2); gInput.q16horz = clamp(gInput.q16horz + input.q16horz, IntToFixed(-127) >> 2, IntToFixed(127) >> 2);
if (gMe && gMe->pXSprite && gMe->pXSprite->health != 0 && !paused) if (gMe && gMe->pXSprite && gMe->pXSprite->health != 0 && !paused)
{ {
@ -192,7 +192,7 @@ void GetInputInternal(InputPacket &inputParm, ControlInfo* const hidInput)
void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput) void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
{ {
GetInputInternal(gInput, hidInput); GetInputInternal(hidInput);
if (packet) if (packet)
{ {
*packet = gInput; *packet = gInput;

View file

@ -26,7 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS BEGIN_BLD_NS
extern InputPacket gInput;
extern bool bSilentAim; extern bool bSilentAim;
extern fixed_t gViewLook, gViewAngle; extern fixed_t gViewLook, gViewAngle;