Skip to content

Commit 648c325

Browse files
committed
Fix issue #9487 (getBonePosition OOP is broken)
1 parent a517c51 commit 648c325

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
139139
lua_classfunction(luaVM, "getTargetEnd", "getPedTargetEnd");
140140
lua_classfunction(luaVM, "getTargetStart", "getPedTargetStart");
141141
lua_classfunction(luaVM, "getWeaponMuzzlePosition", "getPedWeaponMuzzlePosition");
142-
lua_classfunction(luaVM, "getBonePosition", "getPedBonePosition");
142+
lua_classfunction(luaVM, "getBonePosition", OOP_GetPedBonePosition);
143143
lua_classfunction(luaVM, "getCameraRotation", "getPedCameraRotation");
144144
lua_classfunction(luaVM, "getWeaponSlot", "getPedWeaponSlot");
145145
lua_classfunction(luaVM, "getWalkingStyle", "getPedWalkingStyle");
@@ -946,6 +946,35 @@ int CLuaPedDefs::GetPedBonePosition(lua_State* luaVM)
946946
return 1;
947947
}
948948

949+
int CLuaPedDefs::OOP_GetPedBonePosition(lua_State* luaVM)
950+
{
951+
// Verify the argument
952+
CClientPed* pPed = NULL;
953+
unsigned char ucBone = 0;
954+
CScriptArgReader argStream(luaVM);
955+
argStream.ReadUserData(pPed);
956+
argStream.ReadNumber(ucBone);
957+
958+
if (!argStream.HasErrors())
959+
{
960+
if (ucBone <= BONE_RIGHTFOOT)
961+
{
962+
eBone bone = (eBone)ucBone;
963+
CVector vecPosition;
964+
if (CStaticFunctionDefinitions::GetPedBonePosition(*pPed, bone, vecPosition))
965+
{
966+
lua_pushvector(luaVM, vecPosition);
967+
return 1;
968+
}
969+
}
970+
}
971+
else
972+
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
973+
974+
lua_pushboolean(luaVM, false);
975+
return 1;
976+
}
977+
949978
int CLuaPedDefs::SetPedWeaponSlot(lua_State* luaVM)
950979
{
951980
// Verify the argument

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class CLuaPedDefs : public CLuaDefs
4848
LUA_DECLARE(GetPedContactElement);
4949
LUA_DECLARE(GetPedRotation);
5050
LUA_DECLARE(CanPedBeKnockedOffBike);
51-
LUA_DECLARE(GetPedBonePosition);
51+
LUA_DECLARE_OOP(GetPedBonePosition);
5252
LUA_DECLARE(GetPedClothes);
5353
LUA_DECLARE(GetPedControlState);
5454
LUA_DECLARE(GetPedAnalogControlState);

0 commit comments

Comments
 (0)