TODO: remove this in a few releases (in 2027 or later) it got deprecated by CGameClient::StoreSave
| 610 | // TODO: remove this in a few releases (in 2027 or later) |
| 611 | // it got deprecated by CGameClient::StoreSave |
| 612 | void 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 | |
| 652 | void CChat::AddLine(int ClientId, int Team, const char *pLine) |
| 653 | { |
nothing calls this directly
no test coverage detected