Skip to content

Commit f762077

Browse files
committed
Fix bug
1 parent e831f62 commit f762077

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

Client/mods/deathmatch/logic/CClientPad.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
#define CS_NAN -32768
1919

20-
SFixedArray<short, MAX_GTA_CONTROLS> CClientPad::m_sScriptedStates;
21-
SFixedArray<bool, MAX_GTA_ANALOG_CONTROLS> CClientPad::m_bScriptedStatesNextFrameOverride;
2220
bool CClientPad::m_bFlyWithMouse;
2321
bool CClientPad::m_bSteerWithMouse;
2422

Client/mods/deathmatch/logic/CClientPad.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@ class CClientPad
3434

3535
void DoPulse(CClientPed* pPed);
3636

37-
static bool GetAnalogControlState(const char* szName, CControllerState& cs, bool bOnFoot, float& fState, bool bIgnoreOverrides);
38-
static bool SetAnalogControlState(const char* szName, float fState, bool bFrameForced);
39-
static void RemoveSetAnalogControlState(const char* szName);
37+
bool GetAnalogControlState(const char* szName, CControllerState& cs, bool bOnFoot, float& fState, bool bIgnoreOverrides);
38+
bool SetAnalogControlState(const char* szName, float fState, bool bFrameForced);
39+
void RemoveSetAnalogControlState(const char* szName);
4040

41-
static void ProcessSetAnalogControlState(CControllerState& cs, bool bOnFoot);
42-
static void ProcessControl(short& usControlValue, unsigned int uiIndex);
41+
void ProcessSetAnalogControlState(CControllerState& cs, bool bOnFoot);
42+
void ProcessControl(short& usControlValue, unsigned int uiIndex);
4343

4444
static void ProcessAllToggledControls(CControllerState& cs, bool bOnFoot);
4545
static bool ProcessToggledControl(const char* szName, CControllerState& cs, bool bOnFoot, bool bEnabled);
4646
static bool GetControlState(const char* szName, CControllerState& State, bool bOnFoot);
4747

48-
static SFixedArray<short, MAX_GTA_CONTROLS> m_sScriptedStates;
49-
static SFixedArray<bool, MAX_GTA_ANALOG_CONTROLS> m_bScriptedStatesNextFrameOverride;
50-
static bool m_bFlyWithMouse;
51-
static bool m_bSteerWithMouse;
48+
static bool m_bFlyWithMouse;
49+
static bool m_bSteerWithMouse;
5250

5351
protected:
5452
SFixedArray<float, MAX_GTA_CONTROLS> m_fStates;
53+
SFixedArray<short, MAX_GTA_CONTROLS> m_sScriptedStates;
54+
SFixedArray<bool, MAX_GTA_ANALOG_CONTROLS> m_bScriptedStatesNextFrameOverride;
5555
};

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2957,7 +2957,7 @@ void CClientPed::ApplyControllerStateFixes(CControllerState& Current)
29572957
// Process our scripted control settings
29582958
bool bOnFoot = pVehicle ? false : true;
29592959
CClientPad::ProcessAllToggledControls(Current, bOnFoot);
2960-
CClientPad::ProcessSetAnalogControlState(Current, bOnFoot);
2960+
m_Pad.ProcessSetAnalogControlState(Current, bOnFoot);
29612961
}
29622962

29632963
// Is the player stealth aiming?

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,10 +1725,12 @@ bool CStaticFunctionDefinitions::GetPedControlState(CClientPed& Ped, const char*
17251725
bState = CClientPad::GetControlState(szControl, cs, bOnFoot);
17261726
float fState = 0;
17271727
unsigned int uiIndex;
1728+
CClientPad pad = Ped.m_Pad;
1729+
17281730
// Check it's Analog
17291731
if (CClientPad::GetAnalogControlIndex(szControl, uiIndex))
17301732
{
1731-
if (CClientPad::GetAnalogControlState(szControl, cs, bOnFoot, fState, false))
1733+
if (pad.GetAnalogControlState(szControl, cs, bOnFoot, fState, false))
17321734
{
17331735
bState = fState > 0;
17341736
return true;
@@ -1765,7 +1767,7 @@ bool CStaticFunctionDefinitions::GetPedAnalogControlState(CClientPed& Ped, const
17651767

17661768
// check it's analog or use binary.
17671769
if (CClientPad::GetAnalogControlIndex(szControl, uiIndex))
1768-
CClientPad::GetAnalogControlState(szControl, cs, bOnFoot, fState, bRawInput);
1770+
Ped.m_Pad.GetAnalogControlState(szControl, cs, bOnFoot, fState, bRawInput);
17691771
else
17701772
fState = CClientPad::GetControlState(szControl, cs, bOnFoot) == true ? 1.0f : 0.0f;
17711773

@@ -7196,7 +7198,7 @@ bool CStaticFunctionDefinitions::GetAnalogControlState(const char* szControl, fl
71967198
else
71977199
pLocalPlayer->GetControllerState(cs);
71987200

7199-
if (CClientPad::GetAnalogControlState(szControl, cs, bOnFoot, fState, bRawInput))
7201+
if (pLocalPlayer->m_Pad.GetAnalogControlState(szControl, cs, bOnFoot, fState, bRawInput))
72007202
{
72017203
return true;
72027204
}
@@ -7223,12 +7225,13 @@ bool CStaticFunctionDefinitions::SetControlState(const char* szControl, bool bSt
72237225
{
72247226
assert(szControl);
72257227
unsigned int uiIndex;
7228+
CClientPlayer* pLocalPlayer = m_pPlayerManager->GetLocalPlayer();
72267229

72277230
if (bState)
72287231
{
72297232
if (CClientPad::GetAnalogControlIndex(szControl, uiIndex))
72307233
{
7231-
if (CClientPad::SetAnalogControlState(szControl, 1.0, false))
7234+
if (pLocalPlayer->m_Pad.SetAnalogControlState(szControl, 1.0, false))
72327235
{
72337236
return true;
72347237
}
@@ -7248,7 +7251,7 @@ bool CStaticFunctionDefinitions::SetControlState(const char* szControl, bool bSt
72487251
{
72497252
if (CClientPad::GetAnalogControlIndex(szControl, uiIndex))
72507253
{
7251-
CClientPad::RemoveSetAnalogControlState(szControl);
7254+
pLocalPlayer->m_Pad.RemoveSetAnalogControlState(szControl);
72527255
return true;
72537256
}
72547257
else

Client/mods/deathmatch/logic/lua/CLuaFunctionDefs.Input.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ int CLuaFunctionDefs::SetAnalogControlState(lua_State* luaVM)
308308
CScriptArgReader argStream(luaVM);
309309
argStream.ReadString(strControlState);
310310

311+
CClientPlayer* localPlayer = CStaticFunctionDefinitions::GetLocalPlayer();
312+
311313
if (!argStream.HasErrors())
312314
{
313315
if (argStream.NextIsNumber())
@@ -316,15 +318,15 @@ int CLuaFunctionDefs::SetAnalogControlState(lua_State* luaVM)
316318
if (argStream.NextIsBool())
317319
argStream.ReadBool(bForceOverrideNextFrame, false);
318320

319-
if (CClientPad::SetAnalogControlState(strControlState, fState, bForceOverrideNextFrame))
321+
if (localPlayer->m_Pad.SetAnalogControlState(strControlState, fState, bForceOverrideNextFrame))
320322
{
321323
lua_pushboolean(luaVM, true);
322324
return 1;
323325
}
324326
}
325327
else if (argStream.NextIsNone())
326328
{
327-
CClientPad::RemoveSetAnalogControlState(strControlState);
329+
localPlayer->m_Pad.RemoveSetAnalogControlState(strControlState);
328330
lua_pushboolean(luaVM, true);
329331
return 1;
330332
}

0 commit comments

Comments
 (0)