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

Function CheckImageDimensions

src/tools/map_convert_07.cpp:31–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29static int g_aImageIds[MAX_MAPIMAGES];
30
31static bool CheckImageDimensions(void *pLayerItem, int LayerType, const char *pFilename)
32{
33 if(LayerType != MAPITEMTYPE_LAYER)
34 return true;
35
36 CMapItemLayer *pImgLayer = (CMapItemLayer *)pLayerItem;
37 if(pImgLayer->m_Type != LAYERTYPE_TILES)
38 return true;
39
40 CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pImgLayer;
41 if(pTMap->m_Image == -1)
42 return true;
43
44 int Type;
45 void *pItem = g_DataReader.GetItem(g_aImageIds[pTMap->m_Image], &Type);
46 if(Type != MAPITEMTYPE_IMAGE)
47 return true;
48
49 CMapItemImage *pImgItem = (CMapItemImage *)pItem;
50
51 if(pImgItem->m_Width % 16 == 0 && pImgItem->m_Height % 16 == 0 && pImgItem->m_Width > 0 && pImgItem->m_Height > 0)
52 return true;
53
54 char aTileLayerName[12];
55 IntsToStr(pTMap->m_aName, std::size(pTMap->m_aName), aTileLayerName, std::size(aTileLayerName));
56
57 const char *pName = g_DataReader.GetDataString(pImgItem->m_ImageName);
58 dbg_msg("map_convert_07", "%s: Tile layer \"%s\" uses image \"%s\" with width %d, height %d, which is not divisible by 16. This is not supported in Teeworlds 0.7. Please scale the image and replace it manually.", pFilename, aTileLayerName, pName == nullptr ? "(error)" : pName, pImgItem->m_Width, pImgItem->m_Height);
59 return false;
60}
61
62static void *ReplaceImageItem(int Index, CMapItemImage *pImgItem, CMapItemImage *pNewImgItem)
63{

Callers 1

mainFunction · 0.85

Calls 4

IntsToStrFunction · 0.85
dbg_msgFunction · 0.85
GetItemMethod · 0.45
GetDataStringMethod · 0.45

Tested by

no test coverage detected