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

Method Stop

src/engine/client/ghost.cpp:173–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173void CGhostRecorder::Stop(int Ticks, int Time)
174{
175 if(!m_File)
176 {
177 return;
178 }
179
180 const bool DiscardFile = Ticks <= 0 || Time <= 0;
181
182 if(!DiscardFile)
183 {
184 FlushChunk();
185
186 // write number of ticks and time
187 io_seek(m_File, offsetof(CGhostHeader, m_aNumTicks), IOSEEK_START);
188
189 unsigned char aNumTicks[sizeof(int32_t)];
190 uint_to_bytes_be(aNumTicks, Ticks);
191 io_write(m_File, aNumTicks, sizeof(aNumTicks));
192
193 unsigned char aTime[sizeof(int32_t)];
194 uint_to_bytes_be(aTime, Time);
195 io_write(m_File, aTime, sizeof(aTime));
196 }
197
198 io_close(m_File);
199 m_File = nullptr;
200
201 if(DiscardFile)
202 {
203 m_pStorage->RemoveFile(m_aFilename, IStorage::TYPE_SAVE);
204 }
205
206 log_info_color(LOG_COLOR_GHOST, "ghost_recorder", "Stopped recording to '%s'", m_aFilename);
207 m_aFilename[0] = '\0';
208}
209
210CGhostLoader::CGhostLoader()
211{

Callers

nothing calls this directly

Calls 5

io_seekFunction · 0.85
uint_to_bytes_beFunction · 0.85
io_writeFunction · 0.85
io_closeFunction · 0.85
RemoveFileMethod · 0.80

Tested by

no test coverage detected