diff options
| author | oy <Tom_Adams@web.de> | 2010-12-08 00:32:50 +0100 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2010-12-08 00:32:50 +0100 |
| commit | 665934ee098abca1c7b585476502462b94b1bdc8 (patch) | |
| tree | 657538cbb3457d66e4605f148d99b8d6bb09358e /src/game | |
| parent | 9ef5e64916deb3faae1fdee2f1be6f4b7f33f1f8 (diff) | |
| download | zcatch-665934ee098abca1c7b585476502462b94b1bdc8.tar.gz zcatch-665934ee098abca1c7b585476502462b94b1bdc8.zip | |
cleaned up several uses of timestamps for filenames
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/client/components/console.cpp | 38 | ||||
| -rw-r--r-- | src/game/client/components/menus_ingame.cpp | 10 |
2 files changed, 18 insertions, 30 deletions
diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 4d421970..7688d7fb 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -1,7 +1,6 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ #include <math.h> -#include <time.h> #include <game/generated/client_data.h> @@ -593,34 +592,25 @@ void CGameConsole::Dump(int Type) { CInstance *pConsole = Type == CONSOLETYPE_REMOTE ? &m_RemoteConsole : &m_LocalConsole; char aFilename[128]; - time_t Time; char aDate[20]; - time(&Time); - tm* TimeInfo = localtime(&Time); - strftime(aDate, sizeof(aDate), "%Y-%m-%d_%I-%M", TimeInfo); - - for(int i = 0; i < 10; i++) + str_timestamp(aDate, sizeof(aDate)); + str_format(aFilename, sizeof(aFilename), "dumps/%s_dump_%s.txt", Type==CONSOLETYPE_REMOTE?"remote_console":"local_console", aDate); + IOHANDLE io = Storage()->OpenFile(aFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE); + if(io) { - IOHANDLE io; - str_format(aFilename, sizeof(aFilename), "dumps/%s_dump%s-%05d.txt", Type==CONSOLETYPE_REMOTE?"remote_console":"local_console", aDate, i); - io = Storage()->OpenFile(aFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE); - if(io) - { - #if defined(CONF_FAMILY_WINDOWS) - static const char Newline[] = "\r\n"; - #else - static const char Newline[] = "\n"; - #endif + #if defined(CONF_FAMILY_WINDOWS) + static const char Newline[] = "\r\n"; + #else + static const char Newline[] = "\n"; + #endif - for(CInstance::CBacklogEntry *pEntry = pConsole->m_Backlog.First(); pEntry; pEntry = pConsole->m_Backlog.Next(pEntry)) - { - io_write(io, pEntry->m_aText, str_length(pEntry->m_aText)); - io_write(io, Newline, sizeof(Newline)-1); - } - io_close(io); - break; + for(CInstance::CBacklogEntry *pEntry = pConsole->m_Backlog.First(); pEntry; pEntry = pConsole->m_Backlog.Next(pEntry)) + { + io_write(io, pEntry->m_aText, str_length(pEntry->m_aText)); + io_write(io, Newline, sizeof(Newline)-1); } + io_close(io); } } diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index 75292249..14a19f12 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -1,7 +1,5 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ -#include <time.h> - #include <base/math.h> #include <engine/demo.h> @@ -103,10 +101,10 @@ void CMenus::RenderGame(CUIRect MainView) if(!Recording) { char aFilename[128]; - time_t Time; - time(&Time); - tm* TimeInfo = localtime(&Time); - strftime(aFilename, sizeof(aFilename), "demo-%Y-%m-%d_%H-%M-%S", TimeInfo); + char aDate[20]; + + str_timestamp(aDate, sizeof(aDate)); + str_format(aFilename, sizeof(aFilename), "demo_%s.png", aDate); Client()->DemoRecorder_Start(aFilename); } else |