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

Method FindItem

src/engine/shared/snapshot.cpp:78–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78const void *CSnapshot::FindItem(int Type, int Id) const
79{
80 int InternalType = Type;
81 if(Type >= OFFSET_UUID)
82 {
83 CUuid TypeUuid = g_UuidManager.GetUuid(Type);
84 int aTypeUuidItem[sizeof(CUuid) / sizeof(int32_t)];
85 for(size_t i = 0; i < sizeof(CUuid) / sizeof(int32_t); i++)
86 aTypeUuidItem[i] = bytes_be_to_uint(&TypeUuid.m_aData[i * sizeof(int32_t)]);
87
88 bool Found = false;
89 for(int i = 0; i < m_NumItems; i++)
90 {
91 const CSnapshotItem *pItem = GetItem(i);
92 if(pItem->Type() == 0 && pItem->Id() >= OFFSET_UUID_TYPE) // NETOBJTYPE_EX
93 {
94 if(mem_comp(pItem->Data(), aTypeUuidItem, sizeof(CUuid)) == 0)
95 {
96 InternalType = pItem->Id();
97 Found = true;
98 break;
99 }
100 }
101 }
102 if(!Found)
103 {
104 return nullptr;
105 }
106 }
107 int Index = GetItemIndex((InternalType << 16) | Id);
108 return Index < 0 ? nullptr : GetItem(Index)->Data();
109}
110
111unsigned CSnapshot::Crc() const
112{

Callers

nothing calls this directly

Calls 6

bytes_be_to_uintFunction · 0.85
mem_compFunction · 0.85
GetUuidMethod · 0.80
TypeMethod · 0.45
IdMethod · 0.45
DataMethod · 0.45

Tested by

no test coverage detected