MCPcopy Create free account
hub / github.com/ddnet/ddnet / SnapPickup

Method SnapPickup

src/game/server/gamecontext.cpp:525–571  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

523}
524
525bool CGameContext::SnapPickup(const CSnapContext &Context, int SnapId, const vec2 &Pos, int Type, int SubType, int SwitchNumber, int Flags) const
526{
527 if(Context.IsSixup())
528 {
529 protocol7::CNetObj_Pickup *pPickup = Server()->SnapNewItem<protocol7::CNetObj_Pickup>(SnapId);
530 if(!pPickup)
531 return false;
532
533 pPickup->m_X = (int)Pos.x;
534 pPickup->m_Y = (int)Pos.y;
535 pPickup->m_Type = PickupType_SixToSeven(Type, SubType);
536 }
537 else if(Context.GetClientVersion() >= VERSION_DDNET_ENTITY_NETOBJS)
538 {
539 CNetObj_DDNetPickup *pPickup = Server()->SnapNewItem<CNetObj_DDNetPickup>(SnapId);
540 if(!pPickup)
541 return false;
542
543 pPickup->m_X = (int)Pos.x;
544 pPickup->m_Y = (int)Pos.y;
545 pPickup->m_Type = Type;
546 pPickup->m_Subtype = SubType;
547 pPickup->m_SwitchNumber = SwitchNumber;
548 pPickup->m_Flags = Flags;
549 }
550 else
551 {
552 CNetObj_Pickup *pPickup = Server()->SnapNewItem<CNetObj_Pickup>(SnapId);
553 if(!pPickup)
554 return false;
555
556 pPickup->m_X = (int)Pos.x;
557 pPickup->m_Y = (int)Pos.y;
558
559 pPickup->m_Type = Type;
560 if(Context.GetClientVersion() < VERSION_DDNET_WEAPON_SHIELDS)
561 {
562 if(Type >= POWERUP_ARMOR_SHOTGUN && Type <= POWERUP_ARMOR_LASER)
563 {
564 pPickup->m_Type = POWERUP_ARMOR;
565 }
566 }
567 pPickup->m_Subtype = SubType;
568 }
569
570 return true;
571}
572
573void CGameContext::CallVote(int ClientId, const char *pDesc, const char *pCmd, const char *pReason, const char *pChatmsg, const char *pSixupDesc)
574{

Callers 1

SnapMethod · 0.80

Calls 4

PickupType_SixToSevenFunction · 0.85
ServerClass · 0.50
IsSixupMethod · 0.45
GetClientVersionMethod · 0.45

Tested by

no test coverage detected