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 | #include <game/collision.h> |
8 | #include <game/generated/protocol.h> |
9 | |
10 | CPickupData ExtractPickupInfo(int NetObjType, const void *pData, const CNetObj_EntityEx *pEntEx) |
11 | { |
12 | if(NetObjType == NETOBJTYPE_DDNETPICKUP) |
13 | { |
14 | return ExtractPickupInfoDDNet(pPickup: (CNetObj_DDNetPickup *)pData); |
15 | } |
16 | |
17 | CNetObj_Pickup *pPickup = (CNetObj_Pickup *)pData; |
18 | |
19 | CPickupData Result = {.m_Pos: vec2(0, 0)}; |
20 | |
21 | Result.m_Pos.x = pPickup->m_X; |
22 | Result.m_Pos.y = pPickup->m_Y; |
23 | Result.m_Type = pPickup->m_Type; |
24 | Result.m_Subtype = pPickup->m_Subtype; |
25 | Result.m_SwitchNumber = pEntEx ? pEntEx->m_SwitchNumber : 0; |
26 | |
27 | return Result; |
28 | } |
29 | |
30 | CPickupData ExtractPickupInfoDDNet(const CNetObj_DDNetPickup *pPickup) |
31 | { |
32 | CPickupData Result = {.m_Pos: vec2(0, 0)}; |
33 | |
34 | Result.m_Pos.x = pPickup->m_X; |
35 | Result.m_Pos.y = pPickup->m_Y; |
36 | Result.m_Type = pPickup->m_Type; |
37 | Result.m_Subtype = pPickup->m_Subtype; |
38 | Result.m_SwitchNumber = pPickup->m_SwitchNumber; |
39 | |
40 | return Result; |
41 | } |
42 |