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

Method StoreSave

src/game/client/components/chat.cpp:612–650  ·  view source on GitHub ↗

TODO: remove this in a few releases (in 2027 or later) it got deprecated by CGameClient::StoreSave

Source from the content-addressed store, hash-verified

610// TODO: remove this in a few releases (in 2027 or later)
611// it got deprecated by CGameClient::StoreSave
612void CChat::StoreSave(const char *pText)
613{
614 const char *pStart = str_find(pText, "Team successfully saved by ");
615 const char *pMid = str_find(pText, ". Use '/load ");
616 const char *pOn = str_find(pText, "' on ");
617 const char *pEnd = str_find(pText, pOn ? " to continue" : "' to continue");
618
619 if(!pStart || !pMid || !pEnd || pMid < pStart || pEnd < pMid || (pOn && (pOn < pMid || pEnd < pOn)))
620 return;
621
622 char aName[16];
623 str_truncate(aName, sizeof(aName), pStart + 27, pMid - pStart - 27);
624
625 char aSaveCode[64];
626
627 str_truncate(aSaveCode, sizeof(aSaveCode), pMid + 13, (pOn ? pOn : pEnd) - pMid - 13);
628
629 char aTimestamp[20];
630 str_timestamp_format(aTimestamp, sizeof(aTimestamp), FORMAT_SPACE);
631
632 const bool SavesFileExists = Storage()->FileExists(SAVES_FILE, IStorage::TYPE_SAVE);
633 IOHANDLE File = Storage()->OpenFile(SAVES_FILE, IOFLAG_APPEND, IStorage::TYPE_SAVE);
634 if(!File)
635 return;
636
637 const char *apColumns[4] = {
638 aTimestamp,
639 aName,
640 GameClient()->Map()->BaseName(),
641 aSaveCode,
642 };
643
644 if(!SavesFileExists)
645 {
646 CsvWrite(File, 4, SAVES_HEADER);
647 }
648 CsvWrite(File, 4, apColumns);
649 io_close(File);
650}
651
652void CChat::AddLine(int ClientId, int Team, const char *pLine)
653{

Callers

nothing calls this directly

Calls 10

str_findFunction · 0.85
str_truncateFunction · 0.85
str_timestamp_formatFunction · 0.85
StorageFunction · 0.85
CsvWriteFunction · 0.85
io_closeFunction · 0.85
FileExistsMethod · 0.80
OpenFileMethod · 0.45
BaseNameMethod · 0.45
MapMethod · 0.45

Tested by

no test coverage detected