| 49 | } |
| 50 | |
| 51 | int CGhostRecorder::Start(const char *pFilename, const char *pMap, const SHA256_DIGEST &MapSha256, const char *pName) |
| 52 | { |
| 53 | dbg_assert(!m_File, "File already open"); |
| 54 | |
| 55 | m_File = m_pStorage->OpenFile(pFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE); |
| 56 | if(!m_File) |
| 57 | { |
| 58 | log_info_color(LOG_COLOR_GHOST, "ghost_recorder", "Unable to open '%s' for recording", pFilename); |
| 59 | return -1; |
| 60 | } |
| 61 | str_copy(m_aFilename, pFilename); |
| 62 | |
| 63 | // write header |
| 64 | CGhostHeader Header; |
| 65 | mem_zero(&Header, sizeof(Header)); |
| 66 | mem_copy(Header.m_aMarker, gs_aHeaderMarker, sizeof(Header.m_aMarker)); |
| 67 | Header.m_Version = gs_CurVersion; |
| 68 | str_copy(Header.m_aOwner, pName); |
| 69 | str_copy(Header.m_aMap, pMap); |
| 70 | Header.m_MapSha256 = MapSha256; |
| 71 | io_write(m_File, &Header, sizeof(Header)); |
| 72 | |
| 73 | m_LastItem.Reset(); |
| 74 | ResetBuffer(); |
| 75 | |
| 76 | log_info_color(LOG_COLOR_GHOST, "ghost_recorder", "Recording to '%s'", pFilename); |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | void CGhostRecorder::ResetBuffer() |
| 81 | { |