mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 22:18:19 +00:00
Merge pull request #7693 from Robyt3/Tools-Invalid-Map-Item-Fixes
Fix map tools crashing on maps with unknown UUID-based map items
This commit is contained in:
commit
3fa130f3b3
|
@ -219,14 +219,15 @@ int main(int argc, const char **argv)
|
|||
{
|
||||
int Type, ID;
|
||||
void *pItem = g_DataReader.GetItem(Index, &Type, &ID);
|
||||
int Size = g_DataReader.GetItemSize(Index);
|
||||
|
||||
// filter ITEMTYPE_EX items, they will be automatically added again
|
||||
if(Type == ITEMTYPE_EX)
|
||||
// Filter items with unknown type, as we can't write them back.
|
||||
// Filter ITEMTYPE_EX items, they will be automatically added again.
|
||||
if(Type < 0 || Type == ITEMTYPE_EX)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int Size = g_DataReader.GetItemSize(Index);
|
||||
Success &= CheckImageDimensions(pItem, Type, pSourceFileName);
|
||||
|
||||
CMapItemImage NewImageItem;
|
||||
|
|
|
@ -377,8 +377,13 @@ void SaveOutputMap(CDataFileReader &InputMap, CDataFileWriter &OutputMap, CMapIt
|
|||
int ID, Type;
|
||||
void *pItem = InputMap.GetItem(i, &Type, &ID);
|
||||
|
||||
if(Type == ITEMTYPE_EX)
|
||||
// Filter items with unknown type, as we can't write them back.
|
||||
// Filter ITEMTYPE_EX items, they will be automatically added again.
|
||||
if(Type < 0 || Type == ITEMTYPE_EX)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(i == NewItemNumber)
|
||||
pItem = pNewItem;
|
||||
|
||||
|
|
|
@ -140,13 +140,14 @@ int main(int argc, const char **argv)
|
|||
{
|
||||
int Type, ID;
|
||||
void *pPtr = Reader.GetItem(Index, &Type, &ID);
|
||||
int Size = Reader.GetItemSize(Index);
|
||||
|
||||
// filter ITEMTYPE_EX items, they will be automatically added again
|
||||
if(Type == ITEMTYPE_EX)
|
||||
// Filter items with unknown type, as we can't write them back.
|
||||
// Filter ITEMTYPE_EX items, they will be automatically added again.
|
||||
if(Type < 0 || Type == ITEMTYPE_EX)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// for all layers, check if it uses a image and set the corresponding flag
|
||||
if(Type == MAPITEMTYPE_LAYER)
|
||||
{
|
||||
|
@ -203,6 +204,7 @@ int main(int argc, const char **argv)
|
|||
++i;
|
||||
}
|
||||
|
||||
int Size = Reader.GetItemSize(Index);
|
||||
Writer.AddItem(Type, ID, Size, pPtr);
|
||||
}
|
||||
|
||||
|
|
|
@ -168,8 +168,13 @@ void SaveOutputMap(CDataFileReader &InputMap, CDataFileWriter &OutputMap)
|
|||
int ID, Type;
|
||||
void *pItem = InputMap.GetItem(i, &Type, &ID);
|
||||
|
||||
if(Type == ITEMTYPE_EX)
|
||||
// Filter items with unknown type, as we can't write them back.
|
||||
// Filter ITEMTYPE_EX items, they will be automatically added again.
|
||||
if(Type < 0 || Type == ITEMTYPE_EX)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(g_apNewItem[i])
|
||||
pItem = g_apNewItem[i];
|
||||
|
||||
|
|
|
@ -150,9 +150,12 @@ int main(int argc, const char **argv)
|
|||
int Type, ID;
|
||||
void *pItem = g_DataReader.GetItem(Index, &Type, &ID);
|
||||
|
||||
// filter ITEMTYPE_EX items, they will be automatically added again
|
||||
if(Type == ITEMTYPE_EX)
|
||||
// Filter items with unknown type, as we can't write them back.
|
||||
// Filter ITEMTYPE_EX items, they will be automatically added again.
|
||||
if(Type < 0 || Type == ITEMTYPE_EX)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int Size = g_DataReader.GetItemSize(Index);
|
||||
|
||||
|
|
|
@ -32,9 +32,12 @@ static int ResaveMap(const char *pSourceMap, const char *pDestinationMap, IStora
|
|||
int Type, ID;
|
||||
const void *pPtr = Reader.GetItem(Index, &Type, &ID);
|
||||
|
||||
// filter ITEMTYPE_EX items, they will be automatically added again
|
||||
if(Type == ITEMTYPE_EX)
|
||||
// Filter items with unknown type, as we can't write them back.
|
||||
// Filter ITEMTYPE_EX items, they will be automatically added again.
|
||||
if(Type < 0 || Type == ITEMTYPE_EX)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int Size = Reader.GetItemSize(Index);
|
||||
Writer.AddItem(Type, ID, Size, pPtr);
|
||||
|
|
Loading…
Reference in a new issue