-
-
Notifications
You must be signed in to change notification settings - Fork 446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add serverside isPedReloadingWeapon #3295
Changes from all commits
e3478d6
2307df1
f43f6a5
17d45cb
925a40e
e99fa60
1e5419e
d8c26f0
5f9ae30
c1df200
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -269,6 +269,9 @@ class CPed : public CElement | |
bool GetCollisionEnabled() { return m_bCollisionsEnabled; } | ||
void SetCollisionEnabled(bool bCollisionEnabled) { m_bCollisionsEnabled = bCollisionEnabled; } | ||
|
||
bool IsReloadingWeapon() const { return m_bReloadingWeapon; } | ||
void SetReloadingWeapon(bool bState) { m_bReloadingWeapon = bState; } | ||
Comment on lines
+272
to
+273
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
long long GetLastFarSyncTick() { return m_llLastFarSyncTick; } | ||
void SetLastFarSyncTick(long long llLastSyncTick) { m_llLastFarSyncTick = llLastSyncTick; } | ||
|
||
|
@@ -316,6 +319,7 @@ class CPed : public CElement | |
bool m_bFrozen; | ||
bool m_bStealthAiming; | ||
CVehicle* m_pJackingVehicle; | ||
bool m_bReloadingWeapon; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you could, please don't use hungarian notation: |
||
|
||
CVehicle* m_pVehicle; | ||
unsigned int m_uiVehicleSeat; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,7 @@ void CLuaPedDefs::LoadFunctions() | |
{"takeAllWeapons", TakeAllWeapons}, | ||
{"giveWeaponAmmo", GiveWeapon}, | ||
{"takeWeaponAmmo", TakeWeapon}, | ||
{"isPedReloadingWeapon", ArgumentParser<IsPedReloadingWeapon>}, | ||
}; | ||
|
||
// Add functions | ||
|
@@ -117,6 +118,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM) | |
lua_classfunction(luaVM, "isFrozen", "isPedFrozen"); | ||
lua_classfunction(luaVM, "isHeadless", "isPedHeadless"); | ||
lua_classfunction(luaVM, "isWearingJetpack", "isPedWearingJetpack"); // introduced in 1.5.5-9.13846 | ||
lua_classfunction(luaVM, "isReloadingWeapon", "isPedReloadingWeapon"); | ||
|
||
lua_classfunction(luaVM, "getArmor", "getPedArmor"); | ||
lua_classfunction(luaVM, "getFightingStyle", "getPedFightingStyle"); | ||
|
@@ -168,6 +170,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM) | |
lua_classvariable(luaVM, "vehicle", "warpPedIntoVehicle", "getPedOccupiedVehicle", OOP_WarpPedIntoVehicle, GetPedOccupiedVehicle); | ||
lua_classvariable(luaVM, "walkingStyle", "setPedWalkingStyle", "getPedWalkingStyle"); | ||
lua_classvariable(luaVM, "jetpack", "setPedWearingJetpack", "isPedWearingJetpack"); // introduced in 1.5.5-9.13846 | ||
lua_classvariable(luaVM, "reloadingWeapon", nullptr, "isPedReloadingWeapon"); | ||
|
||
// TODO(qaisjp): setting this to any value will kill the ped. add OOP_KillPed that only allows `true`. | ||
lua_classvariable(luaVM, "dead", "killPed", "isPedDead"); | ||
|
@@ -1617,3 +1620,8 @@ int CLuaPedDefs::TakeAllWeapons(lua_State* luaVM) | |
lua_pushboolean(luaVM, false); | ||
return 1; | ||
} | ||
|
||
bool CLuaPedDefs::IsPedReloadingWeapon(CPed* const ped) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
return ped->IsReloadingWeapon(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,4 +79,6 @@ class CLuaPedDefs : public CLuaDefs | |
LUA_DECLARE(SetPedHeadless); | ||
LUA_DECLARE(SetPedFrozen); | ||
LUA_DECLARE(reloadPedWeapon); | ||
|
||
static bool IsPedReloadingWeapon(CPed* const ped); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -547,8 +547,29 @@ struct SPlayerPuresyncFlags : public ISyncStructure | |
BITCOUNT = 12 | ||
}; | ||
|
||
bool Read(NetBitStreamInterface& bitStream) { return bitStream.ReadBits((char*)&data, BITCOUNT); } | ||
void Write(NetBitStreamInterface& bitStream) const { bitStream.WriteBits((const char*)&data, BITCOUNT); } | ||
enum | ||
{ | ||
BITCOUNT2 = 1 | ||
}; | ||
|
||
bool Read(NetBitStreamInterface& bitStream) | ||
{ | ||
bool bOk = bitStream.ReadBits((char*)&data, BITCOUNT); | ||
|
||
if (bitStream.Can(eBitStreamVersion::CPed_isReloadingWeapon)) | ||
bOk &= bitStream.ReadBits((char*)&data2, BITCOUNT2); | ||
else | ||
data2.bIsReloadingWeapon = 0; | ||
|
||
return bOk; | ||
} | ||
void Write(NetBitStreamInterface& bitStream) const | ||
{ | ||
bitStream.WriteBits((const char*)&data, BITCOUNT); | ||
|
||
if (bitStream.Can(eBitStreamVersion::CPed_isReloadingWeapon)) | ||
bitStream.WriteBits((const char*)&data2, BITCOUNT2); | ||
} | ||
|
||
struct | ||
{ | ||
|
@@ -565,6 +586,12 @@ struct SPlayerPuresyncFlags : public ISyncStructure | |
bool bSyncingVelocity : 1; | ||
bool bStealthAiming : 1; | ||
} data; | ||
|
||
// Add new ones in separate structs | ||
struct | ||
{ | ||
bool bIsReloadingWeapon : 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just put it into the existing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to maintain compatibility with older BitStream version on the server/client. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this it's enough to permute BITCOUNT depending on a bitstream version. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Earlier, I tried to apply it like this, but there were issues with comparing the bitstream versions with different client <-> server versions. |
||
} data2; | ||
}; | ||
|
||
struct SPedRotationSync : public ISyncStructure | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to move it into the member initializer list.