diff --git a/src/game/client/components/maplayers.cpp b/src/game/client/components/maplayers.cpp index 62b32a1f2..9c93c771e 100644 --- a/src/game/client/components/maplayers.cpp +++ b/src/game/client/components/maplayers.cpp @@ -1,7 +1,8 @@ -#include #include -#include //temp +#include +#include #include +#include #include #include @@ -126,20 +127,30 @@ void CMapLayers::OnRender() Render = true; } - if(pLayer->m_Type == LAYERTYPE_TILES && Input()->KeyPressed(KEY_KP0)) + if(Render && pLayer->m_Type == LAYERTYPE_TILES && Input()->KeyPressed(KEY_LCTRL) && Input()->KeyPressed(KEY_LSHIFT) && Input()->KeyDown(KEY_KP0)) { CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer; CTile *pTiles = (CTile *)m_pLayers->Map()->GetData(pTMap->m_Data); - char buf[256]; - str_format(buf, sizeof(buf), "%d%d_%dx%d", g, l, pTMap->m_Width, pTMap->m_Height); - FILE *f = fopen(buf, "w"); - for(int y = 0; y < pTMap->m_Height; y++) + CServerInfo CurrentServerInfo; + Client()->GetServerInfo(&CurrentServerInfo); + char aFilename[256]; + str_format(aFilename, sizeof(aFilename), "dumps/tilelayer_dump_%s-%d-%d-%dx%d.txt", CurrentServerInfo.m_aMap, g, l, pTMap->m_Width, pTMap->m_Height); + IOHANDLE File = Storage()->OpenFile(aFilename, IOFLAG_WRITE); + if(File) { - for(int x = 0; x < pTMap->m_Width; x++) - fprintf(f, "%d,", pTiles[y*pTMap->m_Width + x].m_Index); - fprintf(f, "\n"); + #if defined(CONF_FAMILY_WINDOWS) + static const char Newline[] = "\r\n"; + #else + static const char Newline[] = "\n"; + #endif + for(int y = 0; y < pTMap->m_Height; y++) + { + for(int x = 0; x < pTMap->m_Width; x++) + io_write(File, &(pTiles[y*pTMap->m_Width + x].m_Index), sizeof(pTiles[y*pTMap->m_Width + x].m_Index)); + io_write(File, Newline, sizeof(Newline)-1); + } + io_close(File); } - fclose(f); } if(Render && !IsGameLayer)