| 5240 | } |
| 5241 | |
| 5242 | void 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 | } |
nothing calls this directly
no test coverage detected