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

Method StoreSave

src/game/client/gameclient.cpp:5242–5275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5240}
5241
5242void CGameClient::StoreSave(const char *pTeamMembers, const char *pGeneratedCode) const
5243{
5244 static constexpr const char *SAVES_HEADER[] = {
5245 "Time",
5246 "Players",
5247 "Map",
5248 "Code",
5249 };
5250
5251 char aTimestamp[20];
5252 str_timestamp_format(aTimestamp, sizeof(aTimestamp), FORMAT_SPACE);
5253
5254 const bool SavesFileExists = Storage()->FileExists(SAVES_FILE, IStorage::TYPE_SAVE);
5255 IOHANDLE File = Storage()->OpenFile(SAVES_FILE, IOFLAG_APPEND, IStorage::TYPE_SAVE);
5256 if(!File)
5257 {
5258 log_error("saves", "Failed to open the saves file '%s'", SAVES_FILE);
5259 return;
5260 }
5261
5262 const char *apColumns[std::size(SAVES_HEADER)] = {
5263 aTimestamp,
5264 pTeamMembers,
5265 Map()->BaseName(),
5266 pGeneratedCode,
5267 };
5268
5269 if(!SavesFileExists)
5270 {
5271 CsvWrite(File, std::size(SAVES_HEADER), SAVES_HEADER);
5272 }
5273 CsvWrite(File, std::size(SAVES_HEADER), apColumns);
5274 io_close(File);
5275}

Callers

nothing calls this directly

Calls 8

str_timestamp_formatFunction · 0.85
StorageFunction · 0.85
MapFunction · 0.85
CsvWriteFunction · 0.85
io_closeFunction · 0.85
FileExistsMethod · 0.80
OpenFileMethod · 0.45
BaseNameMethod · 0.45

Tested by

no test coverage detected