diff options
Diffstat (limited to 'src/game/client/components/maplayers.cpp')
| -rw-r--r-- | src/game/client/components/maplayers.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/game/client/components/maplayers.cpp b/src/game/client/components/maplayers.cpp index 62b32a1f..9c93c771 100644 --- a/src/game/client/components/maplayers.cpp +++ b/src/game/client/components/maplayers.cpp @@ -1,7 +1,8 @@ -#include <stdio.h> #include <engine/graphics.h> -#include <engine/keys.h> //temp +#include <engine/keys.h> +#include <engine/serverbrowser.h> #include <engine/shared/config.h> +#include <engine/storage.h> #include <game/layers.h> #include <game/client/gameclient.h> @@ -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) |