diff --git a/Client/mods/deathmatch/logic/CClientPad.cpp b/Client/mods/deathmatch/logic/CClientPad.cpp index 223028a0c7..49c17c1226 100644 --- a/Client/mods/deathmatch/logic/CClientPad.cpp +++ b/Client/mods/deathmatch/logic/CClientPad.cpp @@ -17,8 +17,6 @@ #define CS_NAN -32768 -SFixedArray CClientPad::m_sScriptedStates; -SFixedArray CClientPad::m_bScriptedStatesNextFrameOverride; bool CClientPad::m_bFlyWithMouse; bool CClientPad::m_bSteerWithMouse; diff --git a/Client/mods/deathmatch/logic/CClientPad.h b/Client/mods/deathmatch/logic/CClientPad.h index 348fe5a29b..b0ac746426 100644 --- a/Client/mods/deathmatch/logic/CClientPad.h +++ b/Client/mods/deathmatch/logic/CClientPad.h @@ -35,22 +35,22 @@ class CClientPad void DoPulse(CClientPed* pPed); - static bool GetAnalogControlState(const char* szName, CControllerState& cs, bool bOnFoot, float& fState, bool bIgnoreOverrides); - static bool SetAnalogControlState(const char* szName, float fState, bool bFrameForced); - static void RemoveSetAnalogControlState(const char* szName); + bool GetAnalogControlState(const char* szName, CControllerState& cs, bool bOnFoot, float& fState, bool bIgnoreOverrides); + bool SetAnalogControlState(const char* szName, float fState, bool bFrameForced); + void RemoveSetAnalogControlState(const char* szName); - static void ProcessSetAnalogControlState(CControllerState& cs, bool bOnFoot); - static void ProcessControl(short& usControlValue, unsigned int uiIndex); + void ProcessSetAnalogControlState(CControllerState& cs, bool bOnFoot); + void ProcessControl(short& usControlValue, unsigned int uiIndex); static void ProcessAllToggledControls(CControllerState& cs, bool bOnFoot); static bool ProcessToggledControl(const char* szName, CControllerState& cs, bool bOnFoot, bool bEnabled); static bool GetControlState(const char* szName, CControllerState& State, bool bOnFoot); - static SFixedArray m_sScriptedStates; - static SFixedArray m_bScriptedStatesNextFrameOverride; - static bool m_bFlyWithMouse; - static bool m_bSteerWithMouse; + static bool m_bFlyWithMouse; + static bool m_bSteerWithMouse; protected: SFixedArray m_fStates; + SFixedArray m_sScriptedStates; + SFixedArray m_bScriptedStatesNextFrameOverride; }; diff --git a/Client/mods/deathmatch/logic/CClientPed.cpp b/Client/mods/deathmatch/logic/CClientPed.cpp index 3c8d9081e7..9a473b096f 100644 --- a/Client/mods/deathmatch/logic/CClientPed.cpp +++ b/Client/mods/deathmatch/logic/CClientPed.cpp @@ -2960,7 +2960,7 @@ void CClientPed::ApplyControllerStateFixes(CControllerState& Current) // Process our scripted control settings bool bOnFoot = pVehicle ? false : true; CClientPad::ProcessAllToggledControls(Current, bOnFoot); - CClientPad::ProcessSetAnalogControlState(Current, bOnFoot); + m_Pad.ProcessSetAnalogControlState(Current, bOnFoot); } // Is the player stealth aiming? diff --git a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index 87521a812a..0695f655eb 100644 --- a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -1725,10 +1725,12 @@ bool CStaticFunctionDefinitions::GetPedControlState(CClientPed& Ped, const char* bState = CClientPad::GetControlState(szControl, cs, bOnFoot); float fState = 0; unsigned int uiIndex; + CClientPad pad = Ped.m_Pad; + // Check it's Analog if (CClientPad::GetAnalogControlIndex(szControl, uiIndex)) { - if (CClientPad::GetAnalogControlState(szControl, cs, bOnFoot, fState, false)) + if (pad.GetAnalogControlState(szControl, cs, bOnFoot, fState, false)) { bState = fState > 0; return true; @@ -1765,7 +1767,7 @@ bool CStaticFunctionDefinitions::GetPedAnalogControlState(CClientPed& Ped, const // check it's analog or use binary. if (CClientPad::GetAnalogControlIndex(szControl, uiIndex)) - CClientPad::GetAnalogControlState(szControl, cs, bOnFoot, fState, bRawInput); + Ped.m_Pad.GetAnalogControlState(szControl, cs, bOnFoot, fState, bRawInput); else fState = CClientPad::GetControlState(szControl, cs, bOnFoot) == true ? 1.0f : 0.0f; @@ -7196,7 +7198,7 @@ bool CStaticFunctionDefinitions::GetAnalogControlState(const char* szControl, fl else pLocalPlayer->GetControllerState(cs); - if (CClientPad::GetAnalogControlState(szControl, cs, bOnFoot, fState, bRawInput)) + if (pLocalPlayer->m_Pad.GetAnalogControlState(szControl, cs, bOnFoot, fState, bRawInput)) { return true; } @@ -7223,12 +7225,13 @@ bool CStaticFunctionDefinitions::SetControlState(const char* szControl, bool bSt { assert(szControl); unsigned int uiIndex; + CClientPlayer* pLocalPlayer = m_pPlayerManager->GetLocalPlayer(); if (bState) { if (CClientPad::GetAnalogControlIndex(szControl, uiIndex)) { - if (CClientPad::SetAnalogControlState(szControl, 1.0, false)) + if (pLocalPlayer->m_Pad.SetAnalogControlState(szControl, 1.0, false)) { return true; } @@ -7248,7 +7251,7 @@ bool CStaticFunctionDefinitions::SetControlState(const char* szControl, bool bSt { if (CClientPad::GetAnalogControlIndex(szControl, uiIndex)) { - CClientPad::RemoveSetAnalogControlState(szControl); + pLocalPlayer->m_Pad.RemoveSetAnalogControlState(szControl); return true; } else diff --git a/Client/mods/deathmatch/logic/lua/CLuaFunctionDefs.Input.cpp b/Client/mods/deathmatch/logic/lua/CLuaFunctionDefs.Input.cpp index 00256a1f72..ea24aa2ad5 100644 --- a/Client/mods/deathmatch/logic/lua/CLuaFunctionDefs.Input.cpp +++ b/Client/mods/deathmatch/logic/lua/CLuaFunctionDefs.Input.cpp @@ -308,6 +308,8 @@ int CLuaFunctionDefs::SetAnalogControlState(lua_State* luaVM) CScriptArgReader argStream(luaVM); argStream.ReadString(strControlState); + CClientPlayer* localPlayer = CStaticFunctionDefinitions::GetLocalPlayer(); + if (!argStream.HasErrors()) { if (argStream.NextIsNumber()) @@ -316,7 +318,7 @@ int CLuaFunctionDefs::SetAnalogControlState(lua_State* luaVM) if (argStream.NextIsBool()) argStream.ReadBool(bForceOverrideNextFrame, false); - if (CClientPad::SetAnalogControlState(strControlState, fState, bForceOverrideNextFrame)) + if (localPlayer->m_Pad.SetAnalogControlState(strControlState, fState, bForceOverrideNextFrame)) { lua_pushboolean(luaVM, true); return 1; @@ -324,7 +326,7 @@ int CLuaFunctionDefs::SetAnalogControlState(lua_State* luaVM) } else if (argStream.NextIsNone()) { - CClientPad::RemoveSetAnalogControlState(strControlState); + localPlayer->m_Pad.RemoveSetAnalogControlState(strControlState); lua_pushboolean(luaVM, true); return 1; }