diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index e00654c5c7..1f33e3913d 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -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); @@ -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); diff --git a/Client/mods/deathmatch/logic/CClientGame.h b/Client/mods/deathmatch/logic/CClientGame.h index 613c6b91d4..127b2fe37e 100644 --- a/Client/mods/deathmatch/logic/CClientGame.h +++ b/Client/mods/deathmatch/logic/CClientGame.h @@ -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; } diff --git a/Server/mods/deathmatch/logic/CGame.cpp b/Server/mods/deathmatch/logic/CGame.cpp index 784b6737b0..b63303ac9d 100644 --- a/Server/mods/deathmatch/logic/CGame.cpp +++ b/Server/mods/deathmatch/logic/CGame.cpp @@ -2345,11 +2345,11 @@ void CGame::Packet_ObjectBreak(CObjectBreakPacket& Packet) if (!pPlayer || !pPlayer->IsJoined()) return; - CObject* pObject = static_cast(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) @@ -2367,11 +2367,11 @@ void CGame::Packet_ObjectDamage(CObjectDamagePacket& Packet) if (!pPlayer || !pPlayer->IsJoined()) return; - CObject* pObject = static_cast(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); diff --git a/Server/mods/deathmatch/logic/packets/CObjectBreakPacket.cpp b/Server/mods/deathmatch/logic/packets/CObjectBreakPacket.cpp index 4ea2db51bb..c088ade19e 100644 --- a/Server/mods/deathmatch/logic/packets/CObjectBreakPacket.cpp +++ b/Server/mods/deathmatch/logic/packets/CObjectBreakPacket.cpp @@ -14,10 +14,8 @@ #include #include -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) diff --git a/Server/mods/deathmatch/logic/packets/CObjectDamagePacket.cpp b/Server/mods/deathmatch/logic/packets/CObjectDamagePacket.cpp index 9b72c3af19..1852ac674d 100644 --- a/Server/mods/deathmatch/logic/packets/CObjectDamagePacket.cpp +++ b/Server/mods/deathmatch/logic/packets/CObjectDamagePacket.cpp @@ -14,11 +14,8 @@ #include #include -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)