mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
server/pickup: Use enum values and struct size instead of magic numbers
This commit is contained in:
parent
911bd0e69a
commit
971e1b0093
|
@ -191,7 +191,7 @@ void CPickup::Snap(int SnappingClient)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Size = Server()->IsSixup(SnappingClient) ? 3 * 4 : sizeof(CNetObj_Pickup);
|
int Size = Server()->IsSixup(SnappingClient) ? sizeof(protocol7::CNetObj_Pickup) : sizeof(CNetObj_Pickup);
|
||||||
CNetObj_Pickup *pPickup = static_cast<CNetObj_Pickup *>(Server()->SnapNewItem(NETOBJTYPE_PICKUP, GetID(), Size));
|
CNetObj_Pickup *pPickup = static_cast<CNetObj_Pickup *>(Server()->SnapNewItem(NETOBJTYPE_PICKUP, GetID(), Size));
|
||||||
if(!pPickup)
|
if(!pPickup)
|
||||||
return;
|
return;
|
||||||
|
@ -209,9 +209,9 @@ void CPickup::Snap(int SnappingClient)
|
||||||
if(Server()->IsSixup(SnappingClient))
|
if(Server()->IsSixup(SnappingClient))
|
||||||
{
|
{
|
||||||
if(m_Type == POWERUP_WEAPON)
|
if(m_Type == POWERUP_WEAPON)
|
||||||
pPickup->m_Type = m_Subtype == WEAPON_SHOTGUN ? 3 : m_Subtype == WEAPON_GRENADE ? 2 : 4;
|
pPickup->m_Type = m_Subtype == WEAPON_SHOTGUN ? protocol7::PICKUP_SHOTGUN : m_Subtype == WEAPON_GRENADE ? protocol7::PICKUP_GRENADE : protocol7::PICKUP_LASER;
|
||||||
else if(m_Type == POWERUP_NINJA)
|
else if(m_Type == POWERUP_NINJA)
|
||||||
pPickup->m_Type = 5;
|
pPickup->m_Type = protocol7::PICKUP_NINJA;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pPickup->m_Subtype = m_Subtype;
|
pPickup->m_Subtype = m_Subtype;
|
||||||
|
|
Loading…
Reference in a new issue