Skip to content

Commit

Permalink
Amendments
Browse files Browse the repository at this point in the history
  • Loading branch information
FileEX committed May 2, 2024
1 parent f55aca8 commit 30c251a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
12 changes: 6 additions & 6 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5602,14 +5602,14 @@ void CClientGame::ResetMapInfo()
ReinitMarkers();
}

void CClientGame::SendObjectBreakPacket(CClientObject* Object, ElementID attackerID)
void CClientGame::SendObjectBreakPacket(CClientObject* pObject, ElementID attackerID)
{
if (Object && Object->GetHealth() == 0.0f)
if (pObject != nullptr && pObject->GetHealth() == 0.0f)
{
NetBitStreamInterface* pBitStream = g_pNet->AllocateNetBitStream();
if (pBitStream)
{
pBitStream->Write(Object->GetID());
pBitStream->Write(pObject->GetID());
pBitStream->Write(attackerID);

g_pNet->SendPacket(PACKET_ID_OBJECT_BREAK, pBitStream, PACKET_PRIORITY_MEDIUM, PACKET_RELIABILITY_RELIABLE_ORDERED);
Expand All @@ -5618,14 +5618,14 @@ void CClientGame::SendObjectBreakPacket(CClientObject* Object, ElementID attacke
}
}

void CClientGame::SendObjectDamagePacket(CClientObject* Object, float fLoss, ElementID attackerID)
void CClientGame::SendObjectDamagePacket(CClientObject* pObject, float fLoss, ElementID attackerID)
{
if (Object)
if (pObject != nullptr)
{
NetBitStreamInterface* pBitStream = g_pNet->AllocateNetBitStream();
if (pBitStream)
{
pBitStream->Write(Object->GetID());
pBitStream->Write(pObject->GetID());
pBitStream->Write(fLoss);
pBitStream->Write(attackerID);

Expand Down
4 changes: 2 additions & 2 deletions Client/mods/deathmatch/logic/CClientGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ class CClientGame
void SendPedWastedPacket(CClientPed* Ped, ElementID damagerID = INVALID_ELEMENT_ID, unsigned char ucWeapon = 0xFF, unsigned char ucBodyPiece = 0xFF,
AssocGroupId animGroup = 0, AnimationId animID = 15);

void SendObjectBreakPacket(CClientObject* Object, ElementID attackerID);
void SendObjectDamagePacket(CClientObject* Object, float fHealthLoss, ElementID attackerID);
void SendObjectBreakPacket(CClientObject* pObject, ElementID attackerID);
void SendObjectDamagePacket(CClientObject* pObject, float fHealthLoss, ElementID attackerID);

CClientGUIElement* GetClickedGUIElement() { return m_pClickedGUIElement; }
void SetClickedGUIElement(CClientGUIElement* pElement) { m_pClickedGUIElement = NULL; }
Expand Down
12 changes: 6 additions & 6 deletions Server/mods/deathmatch/logic/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2345,11 +2345,11 @@ void CGame::Packet_ObjectBreak(CObjectBreakPacket& Packet)
if (!pPlayer || !pPlayer->IsJoined())
return;

CObject* pObject = static_cast<CObject*>(CElementIDs::GetElement(Packet.m_ObjectID));
CElement* pObject = CElementIDs::GetElement(Packet.m_ObjectID);

if (pObject != nullptr)
if (pObject != nullptr && IS_OBJECT(pObject))
{
CElement* pAttacker = (Packet.m_Attacker != INVALID_ELEMENT_ID) ? CElementIDs::GetElement(Packet.m_Attacker) : NULL;
CElement* pAttacker = (Packet.m_Attacker != INVALID_ELEMENT_ID) ? CElementIDs::GetElement(Packet.m_Attacker) : nullptr;

CLuaArguments Arguments;
if (pAttacker)
Expand All @@ -2367,11 +2367,11 @@ void CGame::Packet_ObjectDamage(CObjectDamagePacket& Packet)
if (!pPlayer || !pPlayer->IsJoined())
return;

CObject* pObject = static_cast<CObject*>(CElementIDs::GetElement(Packet.m_ObjectID));
CElement* pObject = CElementIDs::GetElement(Packet.m_ObjectID);

if (pObject != nullptr)
if (pObject != nullptr && IS_OBJECT(pObject))
{
CElement* pAttacker = (Packet.m_Attacker != INVALID_ELEMENT_ID) ? CElementIDs::GetElement(Packet.m_Attacker) : NULL;
CElement* pAttacker = (Packet.m_Attacker != INVALID_ELEMENT_ID) ? CElementIDs::GetElement(Packet.m_Attacker) : nullptr;

CLuaArguments Arguments;
Arguments.PushNumber(Packet.m_fLoss);
Expand Down
4 changes: 1 addition & 3 deletions Server/mods/deathmatch/logic/packets/CObjectBreakPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
#include <CObject.h>
#include <net/SyncStructures.h>

CObjectBreakPacket::CObjectBreakPacket()
CObjectBreakPacket::CObjectBreakPacket() : m_ObjectID(INVALID_ELEMENT_ID), m_Attacker(INVALID_ELEMENT_ID)
{
m_ObjectID = INVALID_ELEMENT_ID;
m_Attacker = INVALID_ELEMENT_ID;
}

CObjectBreakPacket::CObjectBreakPacket(CObject* pObject, CElement* pAttacker)
Expand Down
5 changes: 1 addition & 4 deletions Server/mods/deathmatch/logic/packets/CObjectDamagePacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
#include <CObject.h>
#include <net/SyncStructures.h>

CObjectDamagePacket::CObjectDamagePacket()
CObjectDamagePacket::CObjectDamagePacket() : m_ObjectID(INVALID_ELEMENT_ID), m_Attacker(INVALID_ELEMENT_ID), m_fLoss(0)
{
m_ObjectID = INVALID_ELEMENT_ID;
m_Attacker = INVALID_ELEMENT_ID;
m_fLoss = 0;
}

CObjectDamagePacket::CObjectDamagePacket(CObject* pObject, float fLoss, CElement* pAttacker)
Expand Down

0 comments on commit 30c251a

Please sign in to comment.