Merge pull request #8651 from Robyt3/Client-Saves-File-Header-Fix

Fix CSV header being written multiple times to `ddnet-saves.txt`
This commit is contained in:
archimede67 2024-07-25 22:02:06 +00:00 committed by GitHub
commit 08f955bff0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -604,6 +604,7 @@ void CChat::StoreSave(const char *pText)
} }
*/ */
const bool SavesFileExists = Storage()->FileExists(SAVES_FILE, IStorage::TYPE_SAVE);
IOHANDLE File = Storage()->OpenFile(SAVES_FILE, IOFLAG_APPEND, IStorage::TYPE_SAVE); IOHANDLE File = Storage()->OpenFile(SAVES_FILE, IOFLAG_APPEND, IStorage::TYPE_SAVE);
if(!File) if(!File)
return; return;
@ -615,7 +616,7 @@ void CChat::StoreSave(const char *pText)
aSaveCode, aSaveCode,
}; };
if(io_tell(File) == 0) if(!SavesFileExists)
{ {
CsvWrite(File, 4, SAVES_HEADER); CsvWrite(File, 4, SAVES_HEADER);
} }