Skip to content

Commit 934ba8c

Browse files
committed
Remove setControlState clientside (#4267)
1 parent 41a21fd commit 934ba8c

File tree

5 files changed

+24
-55
lines changed

5 files changed

+24
-55
lines changed

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,6 +1604,10 @@ bool CStaticFunctionDefinitions::GetPedClothes ( CClientPed & Ped, unsigned char
16041604

16051605
bool CStaticFunctionDefinitions::GetPedControlState ( CClientPed & Ped, const char * szControl, bool & bState )
16061606
{
1607+
if (&Ped == GetLocalPlayer ()) {
1608+
return GetControlState (szControl, bState);
1609+
}
1610+
16071611
if ( Ped.GetType () == CCLIENTPLAYER )
16081612
{
16091613
CControllerState cs;
@@ -1628,10 +1632,12 @@ bool CStaticFunctionDefinitions::GetPedControlState ( CClientPed & Ped, const ch
16281632
return true;
16291633
}
16301634
}
1635+
16311636
if ( Ped.m_Pad.GetControlState ( szControl, bState ) )
16321637
{
16331638
return true;
16341639
}
1640+
16351641
return false;
16361642
}
16371643

@@ -2223,6 +2229,11 @@ bool CStaticFunctionDefinitions::SetPedControlState ( CClientEntity & Entity, co
22232229
if ( IS_PED ( &Entity ) )
22242230
{
22252231
CClientPed& Ped = static_cast < CClientPed& > ( Entity );
2232+
2233+
if (&Ped == GetLocalPlayer ()) {
2234+
return SetControlState ( szControl, bState );
2235+
}
2236+
22262237
if ( Ped.m_Pad.SetControlState ( szControl, bState ) )
22272238
{
22282239
return true;

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

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -293,29 +293,6 @@ int CLuaFunctionDefs::GetKeyState ( lua_State * luaVM )
293293
return 1;
294294
}
295295

296-
297-
int CLuaFunctionDefs::GetControlState ( lua_State * luaVM )
298-
{
299-
SString strControlState = "";
300-
CScriptArgReader argStream ( luaVM );
301-
argStream.ReadString ( strControlState );
302-
303-
if ( !argStream.HasErrors ( ) )
304-
{
305-
bool bState;
306-
if ( CStaticFunctionDefinitions::GetControlState ( strControlState , bState ) )
307-
{
308-
lua_pushboolean ( luaVM, bState );
309-
return 1;
310-
}
311-
}
312-
else
313-
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
314-
315-
lua_pushboolean ( luaVM, false );
316-
return 1;
317-
}
318-
319296
int CLuaFunctionDefs::GetAnalogControlState ( lua_State * luaVM )
320297
{
321298
SString strControlState = "";
@@ -694,31 +671,6 @@ int CLuaFunctionDefs::GetKeyBoundToCommand ( lua_State* luaVM )
694671
return 1;
695672
}
696673

697-
698-
int CLuaFunctionDefs::SetControlState ( lua_State * luaVM )
699-
{
700-
SString strControl = "";
701-
bool bState = false;
702-
CScriptArgReader argStream ( luaVM );
703-
argStream.ReadString ( strControl );
704-
argStream.ReadBool ( bState );
705-
706-
if ( !argStream.HasErrors ( ) )
707-
{
708-
if ( CStaticFunctionDefinitions::SetControlState ( strControl, bState ) )
709-
{
710-
lua_pushboolean ( luaVM, true );
711-
return 1;
712-
}
713-
}
714-
else
715-
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
716-
717-
lua_pushboolean ( luaVM, false );
718-
return 1;
719-
}
720-
721-
722674
int CLuaFunctionDefs::ToggleControl ( lua_State * luaVM )
723675
{
724676
SString strControl = "";

Client/mods/deathmatch/logic/lua/CLuaManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ void CLuaManager::LoadCFunctions ( void )
214214
CLuaCFunctions::AddFunction ( "isPlayerDead", CLuaPedDefs::IsPedDead );
215215
CLuaCFunctions::AddFunction ( "guiEditSetCaratIndex", CLuaGUIDefs::GUIEditSetCaretIndex );
216216
CLuaCFunctions::AddFunction ( "guiMemoSetCaratIndex", CLuaGUIDefs::GUIMemoSetCaretIndex );
217+
CLuaCFunctions::AddFunction ( "setControlState", CLuaPedDefs::SetPedControlState);
218+
CLuaCFunctions::AddFunction ( "getControlState", CLuaPedDefs::GetPedControlState);
217219
// ** END OF BACKWARDS COMPATIBILITY FUNCS. **
218220

219221
// Event funcs
@@ -368,7 +370,6 @@ void CLuaManager::LoadCFunctions ( void )
368370
CLuaCFunctions::AddFunction ( "bindKey", CLuaFunctionDefs::BindKey );
369371
CLuaCFunctions::AddFunction ( "unbindKey", CLuaFunctionDefs::UnbindKey );
370372
CLuaCFunctions::AddFunction ( "getKeyState", CLuaFunctionDefs::GetKeyState );
371-
CLuaCFunctions::AddFunction ( "getControlState", CLuaFunctionDefs::GetControlState );
372373
CLuaCFunctions::AddFunction ( "getAnalogControlState", CLuaFunctionDefs::GetAnalogControlState );
373374
CLuaCFunctions::AddFunction ( "setAnalogControlState", CLuaFunctionDefs::SetAnalogControlState );
374375
CLuaCFunctions::AddFunction ( "isControlEnabled", CLuaFunctionDefs::IsControlEnabled );
@@ -378,7 +379,6 @@ void CLuaManager::LoadCFunctions ( void )
378379
CLuaCFunctions::AddFunction ( "getCommandsBoundToKey", CLuaFunctionDefs::GetCommandsBoundToKey );
379380
CLuaCFunctions::AddFunction ( "getKeyBoundToCommand", CLuaFunctionDefs::GetKeyBoundToCommand );
380381

381-
CLuaCFunctions::AddFunction ( "setControlState", CLuaFunctionDefs::SetControlState );
382382
CLuaCFunctions::AddFunction ( "toggleControl", CLuaFunctionDefs::ToggleControl );
383383
CLuaCFunctions::AddFunction ( "toggleAllControls", CLuaFunctionDefs::ToggleAllControls );
384384

Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,10 +1061,13 @@ int CLuaPedDefs::GetPedClothes ( lua_State* luaVM )
10611061
int CLuaPedDefs::GetPedControlState ( lua_State* luaVM )
10621062
{
10631063
// Verify the argument
1064-
CClientPed* pPed = NULL;
1064+
CClientPed* pPed = CStaticFunctionDefinitions::GetLocalPlayer();
10651065
SString strControl = "";
10661066
CScriptArgReader argStream ( luaVM );
1067-
argStream.ReadUserData ( pPed );
1067+
1068+
if (argStream.NextIsUserData ()) {
1069+
argStream.ReadUserData (pPed);
1070+
}
10681071
argStream.ReadString ( strControl );
10691072

10701073
if ( !argStream.HasErrors () )
@@ -1597,11 +1600,14 @@ int CLuaPedDefs::RemovePedClothes ( lua_State* luaVM )
15971600
int CLuaPedDefs::SetPedControlState ( lua_State* luaVM )
15981601
{
15991602
// Verify the argument
1600-
CClientEntity* pEntity = NULL;
1603+
CClientEntity* pEntity = CStaticFunctionDefinitions::GetLocalPlayer();
16011604
SString strControl = "";
16021605
bool bState = false;
16031606
CScriptArgReader argStream ( luaVM );
1604-
argStream.ReadUserData ( pEntity );
1607+
1608+
if (argStream.NextIsUserData ()) {
1609+
argStream.ReadUserData (pEntity);
1610+
}
16051611
argStream.ReadString ( strControl );
16061612
argStream.ReadBool ( bState );
16071613

Client/mods/deathmatch/logic/luadefs/CLuaPlayerDefs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,4 +629,4 @@ int CLuaPlayerDefs::GetPlayerMapBoundingBox ( lua_State* luaVM )
629629
//The map is invisible
630630
lua_pushboolean ( luaVM, false );
631631
return 1;
632-
}
632+
}

0 commit comments

Comments
 (0)