Skip to content

Commit e658778

Browse files
committed
Clean up client Ped luadefs
Includes d691b66 (Fix getPedTotalAmmo crashing game if incorrect slot ID was passed) and other small OOP changes not already backported (cherry picked from commit 282e2c3)
1 parent 7e6df07 commit e658778

File tree

12 files changed

+738
-748
lines changed

12 files changed

+738
-748
lines changed

MTA10/mods/deathmatch/StdInc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
#include <CScriptArgReader.h>
107107
#include <luadefs/CLuaDefs.h>
108108
#include <luadefs/CLuaClassDefs.h>
109+
#include <luadefs/CLuaPedDefs.h>
109110
#include <luadefs/CLuaVector2Defs.h>
110111
#include <luadefs/CLuaVector3Defs.h>
111112
#include <luadefs/CLuaVector4Defs.h>

MTA10/mods/deathmatch/_Deathmatch 2008.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@
365365
<ClCompile Include="..\shared_logic\CClientSearchLight.cpp" />
366366
<ClCompile Include="..\shared_logic\CClientPointLights.cpp" />
367367
<ClCompile Include="..\shared_logic\CClientPointLightsManager.cpp" />
368+
<ClCompile Include="..\shared_logic\luadefs\CLuaPedDefs.cpp" />
368369
<ClCompile Include="..\shared_logic\luadefs\CLuaSearchLightDefs.cpp" />
369370
<ClCompile Include="..\shared_logic\luadefs\CLuaVector2Defs.cpp" />
370371
<ClCompile Include="..\shared_logic\luadefs\CLuaVector3Defs.cpp" />
@@ -575,7 +576,6 @@
575576
<ClCompile Include="..\shared_logic\lua\CLuaFunctionDefs.Marker.cpp" />
576577
<ClCompile Include="..\shared_logic\lua\CLuaFunctionDefs.Object.cpp" />
577578
<ClCompile Include="..\shared_logic\lua\CLuaFunctionDefs.Output.cpp" />
578-
<ClCompile Include="..\shared_logic\lua\CLuaFunctionDefs.Ped.cpp" />
579579
<ClCompile Include="..\shared_logic\lua\CLuaFunctionDefs.Pickup.cpp" />
580580
<ClCompile Include="..\shared_logic\lua\CLuaFunctionDefs.Player.cpp" />
581581
<ClCompile Include="..\shared_logic\lua\CLuaFunctionDefs.Projectile.cpp" />
@@ -599,7 +599,6 @@
599599
<ClCompile Include="..\shared_logic\lua\LuaCommon.cpp" />
600600
<ClCompile Include="..\shared_logic\lua\oopdefs\CLuaOOPFunctionDefs.Camera.cpp" />
601601
<ClCompile Include="..\shared_logic\lua\oopdefs\CLuaOOPFunctionDefs.Element.cpp" />
602-
<ClCompile Include="..\shared_logic\lua\oopdefs\CLuaOOPFunctionDefs.Ped.cpp" />
603602
<ClCompile Include="..\shared_logic\lua\oopdefs\CLuaOOPFunctionDefs.Vehicle.cpp" />
604603
<ClCompile Include="..\..\..\vendor\bochs\bochs_internal\crc32.cpp" />
605604
<ClCompile Include="..\shared_logic\luadefs\CLuaClassDefs.cpp" />
@@ -762,6 +761,7 @@
762761
<ClInclude Include="..\shared_logic\CClientSearchLight.h" />
763762
<ClInclude Include="..\shared_logic\CClientPointLights.h" />
764763
<ClInclude Include="..\shared_logic\CClientPointLightsManager.h" />
764+
<ClInclude Include="..\shared_logic\luadefs\CLuaPedDefs.h" />
765765
<ClInclude Include="..\shared_logic\luadefs\CLuaSearchLightDefs.h" />
766766
<ClInclude Include="..\shared_logic\luadefs\CLuaVector2Defs.h" />
767767
<ClInclude Include="..\shared_logic\luadefs\CLuaVector3Defs.h" />

MTA10/mods/deathmatch/_Deathmatch 2008.vcxproj.filters

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,6 @@
614614
<ClCompile Include="..\shared_logic\lua\CLuaFunctionDefs.Output.cpp">
615615
<Filter>Source Files\shared_logic\lua</Filter>
616616
</ClCompile>
617-
<ClCompile Include="..\shared_logic\lua\CLuaFunctionDefs.Ped.cpp">
618-
<Filter>Source Files\shared_logic\lua</Filter>
619-
</ClCompile>
620617
<ClCompile Include="..\shared_logic\lua\CLuaFunctionDefs.Pickup.cpp">
621618
<Filter>Source Files\shared_logic\lua</Filter>
622619
</ClCompile>
@@ -686,9 +683,6 @@
686683
<ClCompile Include="..\shared_logic\lua\oopdefs\CLuaOOPFunctionDefs.Element.cpp">
687684
<Filter>Source Files\shared_logic\lua\oopdefs</Filter>
688685
</ClCompile>
689-
<ClCompile Include="..\shared_logic\lua\oopdefs\CLuaOOPFunctionDefs.Ped.cpp">
690-
<Filter>Source Files\shared_logic\lua\oopdefs</Filter>
691-
</ClCompile>
692686
<ClCompile Include="..\shared_logic\lua\oopdefs\CLuaOOPFunctionDefs.Vehicle.cpp">
693687
<Filter>Source Files\shared_logic\lua\oopdefs</Filter>
694688
</ClCompile>
@@ -944,6 +938,9 @@
944938
<ClCompile Include="..\shared_logic\luadefs\CLuaSearchLightDefs.cpp">
945939
<Filter>Source Files\shared_logic\luadefs</Filter>
946940
</ClCompile>
941+
<ClCompile Include="..\shared_logic\luadefs\CLuaPedDefs.cpp">
942+
<Filter>Source Files\shared_logic\luadefs</Filter>
943+
</ClCompile>
947944
</ItemGroup>
948945
<ItemGroup>
949946
<ClInclude Include="CClient.h">
@@ -1669,5 +1666,8 @@
16691666
<ClInclude Include="..\shared_logic\luadefs\CLuaSearchLightDefs.h">
16701667
<Filter>Header Files\shared_logic\luadefs</Filter>
16711668
</ClInclude>
1669+
<ClInclude Include="..\shared_logic\luadefs\CLuaPedDefs.h">
1670+
<Filter>Header Files\shared_logic\luadefs</Filter>
1671+
</ClInclude>
16721672
</ItemGroup>
16731673
</Project>

MTA10/mods/shared_logic/lua/CLuaFunctionDefs.h

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -217,81 +217,6 @@ class CLuaFunctionDefs
217217
LUA_DECLARE ( SetPlayerNametagColor );
218218
LUA_DECLARE ( SetPlayerNametagShowing );
219219

220-
// Ped funcs
221-
LUA_DECLARE ( CreatePed );
222-
223-
LUA_DECLARE ( DetonateSatchels );
224-
225-
LUA_DECLARE ( GetPedVoice );
226-
LUA_DECLARE ( SetPedVoice );
227-
LUA_DECLARE ( GetPedTarget );
228-
LUA_DECLARE ( GetPedTargetStart );
229-
LUA_DECLARE ( GetPedTargetEnd );
230-
LUA_DECLARE ( GetPedTargetRange );
231-
LUA_DECLARE ( GetPedTargetCollision );
232-
LUA_DECLARE ( GetPedWeaponSlot );
233-
LUA_DECLARE ( GetPedWeapon );
234-
LUA_DECLARE ( GetPedAmmoInClip );
235-
LUA_DECLARE ( GetPedTotalAmmo );
236-
LUA_DECLARE ( GetPedWeaponMuzzlePosition );
237-
LUA_DECLARE ( GetPedStat );
238-
LUA_DECLARE ( GetPedOccupiedVehicle );
239-
LUA_DECLARE ( GetPedOccupiedVehicleSeat );
240-
LUA_DECLARE ( GetPedArmor );
241-
LUA_DECLARE ( IsPedChoking );
242-
LUA_DECLARE ( IsPedDucked );
243-
LUA_DECLARE ( IsPedInVehicle );
244-
LUA_DECLARE ( DoesPedHaveJetPack );
245-
LUA_DECLARE ( IsPedOnGround );
246-
LUA_DECLARE ( GetPedTask );
247-
LUA_DECLARE ( GetPedSimplestTask );
248-
LUA_DECLARE ( IsPedDoingTask );
249-
LUA_DECLARE ( GetPedContactElement );
250-
LUA_DECLARE ( GetPedRotation );
251-
LUA_DECLARE ( CanPedBeKnockedOffBike );
252-
LUA_DECLARE ( GetPedBonePosition );
253-
LUA_DECLARE ( GetPedClothes );
254-
LUA_DECLARE ( GetPedControlState );
255-
LUA_DECLARE ( GetPedAnalogControlState );
256-
LUA_DECLARE ( IsPedSunbathing );
257-
LUA_DECLARE ( IsPedDoingGangDriveby );
258-
LUA_DECLARE ( GetPedAnimation );
259-
LUA_DECLARE ( GetPedMoveState );
260-
LUA_DECLARE ( GetPedMoveAnim );
261-
LUA_DECLARE ( IsPedHeadless );
262-
LUA_DECLARE ( IsPedFrozen );
263-
LUA_DECLARE ( IsPedFootBloodEnabled );
264-
LUA_DECLARE ( GetPedCameraRotation );
265-
LUA_DECLARE ( IsPedOnFire );
266-
LUA_DECLARE ( GetWeaponProperty );
267-
LUA_DECLARE ( GetOriginalWeaponProperty );
268-
LUA_DECLARE ( GetPedOxygenLevel );
269-
LUA_DECLARE ( IsPedDead );
270-
271-
LUA_DECLARE ( SetPedRotation );
272-
LUA_DECLARE ( SetPedCanBeKnockedOffBike );
273-
LUA_DECLARE ( SetPedAnimation );
274-
LUA_DECLARE ( SetPedAnimationProgress );
275-
LUA_DECLARE ( SetPedMoveAnim );
276-
LUA_DECLARE ( SetPedWeaponSlot );
277-
LUA_DECLARE ( GivePedWeapon );
278-
LUA_DECLARE ( AddPedClothes );
279-
LUA_DECLARE ( RemovePedClothes );
280-
LUA_DECLARE ( SetPedControlState );
281-
LUA_DECLARE ( SetPedAnalogControlState );
282-
LUA_DECLARE ( SetPedSunbathing );
283-
LUA_DECLARE ( SetPedDoingGangDriveby );
284-
LUA_DECLARE ( SetPedLookAt );
285-
LUA_DECLARE ( SetPedHeadless );
286-
LUA_DECLARE ( SetPedFrozen );
287-
LUA_DECLARE ( SetPedFootBloodEnabled );
288-
LUA_DECLARE ( SetPedCameraRotation );
289-
LUA_DECLARE ( SetPedAimTarget );
290-
LUA_DECLARE ( SetPedOnFire );
291-
LUA_DECLARE ( WarpPedIntoVehicle );
292-
LUA_DECLARE ( RemovePedFromVehicle );
293-
LUA_DECLARE ( SetPedOxygenLevel );
294-
295220
// Clothes and body functions
296221
LUA_DECLARE ( GetBodyPartName );
297222
LUA_DECLARE ( GetClothesByTypeIndex );

MTA10/mods/shared_logic/lua/CLuaMain.cpp

Lines changed: 2 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -419,124 +419,7 @@ void CLuaMain::AddVehicleClass ( lua_State* luaVM )
419419
lua_registerclass ( luaVM, "Vehicle", "Element" );
420420
}
421421

422-
423-
// TODO: special tables
424-
void CLuaMain::AddPedClass ( lua_State* luaVM )
425-
{
426-
lua_newclass ( luaVM );
427-
428-
lua_classfunction ( luaVM, "create", "createPed" );
429-
430-
lua_classfunction ( luaVM, "getBodyPartName", "getBodyPartName" );
431-
lua_classfunction ( luaVM, "getClothesTypeName", "getClothesTypeName" );
432-
lua_classfunction ( luaVM, "getValidModels", "getValidPedModels" );
433-
lua_classfunction ( luaVM, "getTypeIndexFromClothes", "getTypeIndexFromClothes" );
434-
lua_classfunction ( luaVM, "getClothesByTypeIndex", "getClothesByTypeIndex" );
435-
lua_classvariable ( luaVM, "validModels", NULL, "getValidPedModels" );
436-
//lua_classvariable ( luaVM, "clothesTypeName", NULL, "getClothesTypeName" ); table
437-
//lua_classvariable ( luaVM, "bodyPartName", NULL, "getBodyPartName" ); table
438-
439-
lua_classfunction ( luaVM, "canBeKnockedOffBike", "canPedBeKnockedOffBike" );
440-
lua_classfunction ( luaVM, "doesHaveJetPack", "doesPedHaveJetPack" );
441-
lua_classfunction ( luaVM, "getAmmoInClip", "getPedAmmoInClip" );
442-
lua_classfunction ( luaVM, "getAnalogControlState", "getPedAnalogControlState");
443-
lua_classfunction ( luaVM, "getAnimation", "getPedAnimation" );
444-
lua_classfunction ( luaVM, "getAnimationData", "getPedAnimationData" );
445-
lua_classfunction ( luaVM, "getArmor", "getPedArmor" );
446-
lua_classfunction ( luaVM, "getClothes", "getPedClothes" );
447-
lua_classfunction ( luaVM, "addClothes", "addPedClothes" );
448-
lua_classfunction ( luaVM, "removeClothes", "removePedClothes" );
449-
lua_classfunction ( luaVM, "getContactElement", "getPedContactElement" );
450-
lua_classfunction ( luaVM, "getControlState", "getPedControlState" );
451-
lua_classfunction ( luaVM, "getMoveState", "getPedMoveState" );
452-
lua_classfunction ( luaVM, "getOccupiedVehicle", "getPedOccupiedVehicle" );
453-
lua_classfunction ( luaVM, "getOccupiedVehicleSeat", "getPedOccupiedVehicleSeat" );
454-
lua_classfunction ( luaVM, "getOxygenLevel", "getPedOxygenLevel" );
455-
lua_classfunction ( luaVM, "getStat", "getPedStat" );
456-
lua_classfunction ( luaVM, "getTarget", "getPedTarget" );
457-
lua_classfunction ( luaVM, "getTargetCollision", "getPedTargetCollision" );
458-
lua_classfunction ( luaVM, "getSimplestTask", "getPedSimplestTask" );
459-
lua_classfunction ( luaVM, "getTask", "getPedTask" );
460-
lua_classfunction ( luaVM, "getTotalAmmo", "getPedTotalAmmo" );
461-
lua_classfunction ( luaVM, "getVoice", "getPedVoice" );
462-
lua_classfunction ( luaVM, "getWeapon", "getPedWeapon" );
463-
lua_classfunction ( luaVM, "isChocking", "isPedChoking" );
464-
lua_classfunction ( luaVM, "isDoingGangDriveby", "isPedDoingGangDriveby" );
465-
lua_classfunction ( luaVM, "isDoingTask", "isPedDoingTask" );
466-
lua_classfunction ( luaVM, "isDucked", "isPedDucked" );
467-
lua_classfunction ( luaVM, "isHeadless", "isPedHeadless" );
468-
lua_classfunction ( luaVM, "isInVehicle", "isPedInVehicle" );
469-
lua_classfunction ( luaVM, "isOnFire", "isPedOnFire" );
470-
lua_classfunction ( luaVM, "isOnGround", "isPedOnGround" );
471-
lua_classfunction ( luaVM, "isTargetingMarkerEnabled", "isPedTargetingMarkerEnabled" );
472-
lua_classfunction ( luaVM, "isDead", "isPedDead" );
473-
lua_classfunction ( luaVM, "setFootBloodEnabled", "setPedFootBloodEnabled" );
474-
lua_classfunction ( luaVM, "getTargetEnd", "getPedTargetEnd" );
475-
lua_classfunction ( luaVM, "getTargetStart", "getPedTargetStart" );
476-
lua_classfunction ( luaVM, "getWeaponMuzzlePosition", "getPedWeaponMuzzlePosition" );
477-
lua_classfunction ( luaVM, "getBonePosition", "getPedBonePosition" );
478-
lua_classfunction ( luaVM, "getCameraRotation", "getPedCameraRotation" );
479-
lua_classfunction ( luaVM, "getWeaponSlot", "getPedWeaponSlot" );
480-
lua_classfunction ( luaVM, "getWalkingStyle", "getPedWalkingStyle" );
481-
482-
lua_classfunction ( luaVM, "setCanBeKnockedOffBike", "setPedCanBeKnockedOffBike" );
483-
lua_classfunction ( luaVM, "setAnalogControlState", "setPedAnalogControlState" );
484-
lua_classfunction ( luaVM, "setAnimation", "setPedAnimation" );
485-
lua_classfunction ( luaVM, "setAnimationProgress", "setPedAnimationProgress" );
486-
lua_classfunction ( luaVM, "setCameraRotation", "setPedCameraRotation" );
487-
lua_classfunction ( luaVM, "setControlState", "setPedControlState" );
488-
lua_classfunction ( luaVM, "warpIntoVehicle", "warpPedIntoVehicle" );
489-
lua_classfunction ( luaVM, "setOxygenLevel", "setPedOxygenLevel" );
490-
lua_classfunction ( luaVM, "setWeaponSlot", "setPedWeaponSlot" );
491-
lua_classfunction ( luaVM, "setDoingGangDriveby", "setPedDoingGangDriveby" );
492-
lua_classfunction ( luaVM, "setHeadless", "setPedHeadless" );
493-
lua_classfunction ( luaVM, "setOnFire", "setPedOnFire" );
494-
lua_classfunction ( luaVM, "setTargetingMarkerEnabled", "setPedTargetingMarkerEnabled" );
495-
lua_classfunction ( luaVM, "setVoice", "setPedVoice" );
496-
lua_classfunction ( luaVM, "removeFromVehicle", "removePedFromVehicle" );
497-
lua_classfunction ( luaVM, "setAimTarget", "setPedAimTarget" );
498-
lua_classfunction ( luaVM, "setLookAt", "setPedLookAt" );
499-
lua_classfunction ( luaVM, "setWalkingStyle", "setPedWalkingStyle" );
500-
lua_classfunction ( luaVM, "giveWeapon", "givePedWeapon" );
501-
502-
lua_classvariable ( luaVM, "vehicle", CLuaOOPDefs::SetPedOccupiedVehicle, CLuaFunctionDefs::GetPedOccupiedVehicle );
503-
lua_classvariable ( luaVM, "vehicleSeat", NULL, "getPedOccupiedVehicleSeat" );
504-
lua_classvariable ( luaVM, "canBeKnockedOffBike", "setPedCanBeKnockedOffBike", "canPedBeKnockedOffBike" );
505-
lua_classvariable ( luaVM, "hasJetPack", NULL, "doesPedHaveJetPack" );
506-
lua_classvariable ( luaVM, "armor", NULL, "getPedArmor" );
507-
lua_classvariable ( luaVM, "cameraRotation", "setPedCameraRotation", "getPedCameraRotation" );
508-
lua_classvariable ( luaVM, "contactElement", NULL, "getPedContactElement" );
509-
lua_classvariable ( luaVM, "moveState", NULL, "getPedMoveState" );
510-
lua_classvariable ( luaVM, "oxygenLevel", "setPedOxygenLevel", "getPedOxygenLevel" );
511-
lua_classvariable ( luaVM, "target", NULL, "getPedTarget" );
512-
lua_classvariable ( luaVM, "simplestTask", NULL, "getPedSimplestTask" );
513-
lua_classvariable ( luaVM, "choking", NULL, "isPedChoking" );
514-
lua_classvariable ( luaVM, "doingGangDriveby", "setPedDoingGangDriveby", "isPedDoingGangDriveby" );
515-
lua_classvariable ( luaVM, "ducked", NULL, "isPedDucked" );
516-
lua_classvariable ( luaVM, "headless", "setPedHeadless", "isPedHeadless" );
517-
lua_classvariable ( luaVM, "inVehicle", NULL, "isPedInVehicle" );
518-
lua_classvariable ( luaVM, "onFire", "setPedOnFire", "isPedOnFire" );
519-
lua_classvariable ( luaVM, "onGround", NULL, "isPedOnGround" );
520-
lua_classvariable ( luaVM, "dead", NULL, "isPedDead" );
521-
lua_classvariable ( luaVM, "targetingMarker", "setPedTargetingMarkerEnabled", "isPedTargetingMarkerEnabled" );
522-
lua_classvariable ( luaVM, "footBlood", "setPedFootBloodEnabled", NULL );
523-
lua_classvariable ( luaVM, "targetCollision", NULL, "getPedTargetCollision" );
524-
lua_classvariable ( luaVM, "targetEnd", NULL, "getPedTargetEnd" );
525-
lua_classvariable ( luaVM, "targetStart", NULL, "getPedTargetStart" );
526-
lua_classvariable ( luaVM, "muzzlePosition", NULL, "getPedMuzzlePosition" );
527-
lua_classvariable ( luaVM, "weaponSlot", "setPedWeaponSlot", "getPedWeaponSlot" );
528-
lua_classvariable ( luaVM, "walkingStyle", "setPedWalkingStyle", "getPedWalkingStyle" );
529-
530-
//lua_classvariable ( luaVM, "ammoInClip", NULL, CLuaOOPDefs::GetPedAmmoInClip ); // .ammoInClip["slot"] (readonly)
531-
//lua_classvariable ( luaVM, "analogControlState", CLuaOOPDefs::SetPedAnalogControlState, CLuaOOPDefs::GetPedAnalogControlState ); //TODO: .analogControlState["control"] = value
532-
//lua_classvariable ( luaVM, "controlState", CLuaOOPDefs::SetPedControlState, CLuaOOPDefs::GetPedControlState ); // TODO: .controlState["control"] = value
533-
//lua_classvariable ( luaVM, "stats", NULL, CLuaOOPDefs::GetPedStat ); // table (readonly)
534-
//lua_classvariable ( luaVM, "doingTask", NULL, CLuaOOPDefs::IsPedDoingTask ); // table (readonly)
535-
//lua_classvariable ( luaVM, "totalAmmo", NULL, CLuaDefs::GetPedTotalAmmo ); // table readonly
536-
lua_registerclass ( luaVM, "Ped", "Element" );
537-
}
538-
539-
422+
540423
// TODO: integrate colour class
541424
void CLuaMain::AddPlayerClass ( lua_State* luaVM )
542425
{
@@ -1672,7 +1555,7 @@ void CLuaMain::InitClasses ( lua_State* luaVM )
16721555

16731556
AddElementClass ( luaVM );
16741557
AddVehicleClass ( luaVM );
1675-
AddPedClass ( luaVM );
1558+
CLuaPedDefs::AddClass ( luaVM );
16761559
AddPlayerClass ( luaVM );
16771560
AddObjectClass ( luaVM );
16781561
AddMarkerClass ( luaVM );

MTA10/mods/shared_logic/lua/CLuaMain.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515

1616
class CLuaMain;
1717

18-
#ifndef __CLUAMAIN_H
19-
#define __CLUAMAIN_H
18+
#pragma once
2019

2120
#include "CLuaTimerManager.h"
2221
#include "CLuaVector2.h"
@@ -79,7 +78,6 @@ class CLuaMain //: public CClient
7978

8079
void AddElementClass ( lua_State* luaVM );
8180
void AddVehicleClass ( lua_State* luaVM );
82-
void AddPedClass ( lua_State* luaVM );
8381
void AddPlayerClass ( lua_State* luaVM );
8482
void AddObjectClass ( lua_State* luaVM );
8583
void AddMarkerClass ( lua_State* luaVM );
@@ -163,6 +161,4 @@ class CLuaMain //: public CClient
163161
public:
164162
CFastHashMap < const void*, CRefInfo > m_CallbackTable;
165163
std::map < int, SString > m_FunctionTagMap;
166-
};
167-
168-
#endif
164+
};

0 commit comments

Comments
 (0)