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

Method GetExtendedItemTypeIndex

src/engine/shared/datafile.cpp:995–1032  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

993}
994
995int CDataFileWriter::GetExtendedItemTypeIndex(int Type, const CUuid *pUuid)
996{
997 int Index = 0;
998 if(Type == -1)
999 {
1000 // Unknown type, search for UUID
1001 for(const auto &ExtendedItemType : m_vExtendedItemTypes)
1002 {
1003 if(ExtendedItemType.m_Uuid == *pUuid)
1004 {
1005 return Index;
1006 }
1007 ++Index;
1008 }
1009 }
1010 else
1011 {
1012 for(const auto &ExtendedItemType : m_vExtendedItemTypes)
1013 {
1014 if(ExtendedItemType.m_Type == Type)
1015 {
1016 return Index;
1017 }
1018 ++Index;
1019 }
1020 }
1021
1022 // Type not found, add it.
1023 const CUuid Uuid = Type == -1 ? *pUuid : g_UuidManager.GetUuid(Type);
1024 CExtendedItemType ExtendedType;
1025 ExtendedType.m_Type = Type;
1026 ExtendedType.m_Uuid = Uuid;
1027 m_vExtendedItemTypes.emplace_back(ExtendedType);
1028
1029 const CItemEx ItemEx = CItemEx::FromUuid(Uuid);
1030 AddItem(ITEMTYPE_EX, GetTypeFromIndex(Index), sizeof(ItemEx), &ItemEx);
1031 return Index;
1032}
1033
1034int CDataFileWriter::AddItem(int Type, int Id, size_t Size, const void *pData, const CUuid *pUuid)
1035{

Callers

nothing calls this directly

Calls 1

GetUuidMethod · 0.80

Tested by

no test coverage detected