diff --git a/src/tools/map_convert_07.cpp b/src/tools/map_convert_07.cpp index ebd6f5678..2794ed0f8 100644 --- a/src/tools/map_convert_07.cpp +++ b/src/tools/map_convert_07.cpp @@ -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; diff --git a/src/tools/map_create_pixelart.cpp b/src/tools/map_create_pixelart.cpp index 52d54d471..18d51b524 100644 --- a/src/tools/map_create_pixelart.cpp +++ b/src/tools/map_create_pixelart.cpp @@ -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; diff --git a/src/tools/map_optimize.cpp b/src/tools/map_optimize.cpp index 2da28b1c0..f08334f57 100644 --- a/src/tools/map_optimize.cpp +++ b/src/tools/map_optimize.cpp @@ -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); } diff --git a/src/tools/map_replace_area.cpp b/src/tools/map_replace_area.cpp index f0d4aed3a..89187922c 100644 --- a/src/tools/map_replace_area.cpp +++ b/src/tools/map_replace_area.cpp @@ -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]; diff --git a/src/tools/map_replace_image.cpp b/src/tools/map_replace_image.cpp index b67ce18ae..01aef691a 100644 --- a/src/tools/map_replace_image.cpp +++ b/src/tools/map_replace_image.cpp @@ -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); diff --git a/src/tools/map_resave.cpp b/src/tools/map_resave.cpp index 5ff209050..206085198 100644 --- a/src/tools/map_resave.cpp +++ b/src/tools/map_resave.cpp @@ -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);