| 1 | /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ |
|---|---|
| 2 | /* If you are missing that file, acquire a complete release at teeworlds.com. */ |
| 3 | |
| 4 | #include "pickup_data.h" |
| 5 | |
| 6 | #include <engine/shared/snapshot.h> |
| 7 | |
| 8 | #include <generated/protocol.h> |
| 9 | |
| 10 | #include <game/collision.h> |
| 11 | |
| 12 | CPickupData ExtractPickupInfo(int NetObjType, const void *pData, const CNetObj_EntityEx *pEntEx) |
| 13 | { |
| 14 | if(NetObjType == NETOBJTYPE_DDNETPICKUP) |
| 15 | { |
| 16 | return ExtractPickupInfoDDNet(pPickup: (CNetObj_DDNetPickup *)pData); |
| 17 | } |
| 18 | |
| 19 | CNetObj_Pickup *pPickup = (CNetObj_Pickup *)pData; |
| 20 | |
| 21 | CPickupData Result = {.m_Pos: vec2(0, 0)}; |
| 22 | |
| 23 | Result.m_Pos.x = pPickup->m_X; |
| 24 | Result.m_Pos.y = pPickup->m_Y; |
| 25 | Result.m_Type = pPickup->m_Type; |
| 26 | Result.m_Subtype = pPickup->m_Subtype; |
| 27 | Result.m_SwitchNumber = pEntEx ? pEntEx->m_SwitchNumber : 0; |
| 28 | |
| 29 | return Result; |
| 30 | } |
| 31 | |
| 32 | CPickupData ExtractPickupInfoDDNet(const CNetObj_DDNetPickup *pPickup) |
| 33 | { |
| 34 | CPickupData Result = {.m_Pos: vec2(0, 0)}; |
| 35 | |
| 36 | Result.m_Pos.x = pPickup->m_X; |
| 37 | Result.m_Pos.y = pPickup->m_Y; |
| 38 | Result.m_Type = pPickup->m_Type; |
| 39 | Result.m_Subtype = pPickup->m_Subtype; |
| 40 | Result.m_SwitchNumber = pPickup->m_SwitchNumber; |
| 41 | Result.m_Flags = pPickup->m_Flags; |
| 42 | |
| 43 | return Result; |
| 44 | } |
| 45 |