Persist one campaign's unlocked history to / .sqc so a future DisplayCampaignLoad sees it on next open. Mirrors the file format LoadCampaigns reads back: ParamArchive with a single "Campaign" entry holding the serialized CampaignHistory.
| 1686 | // file format LoadCampaigns reads back: ParamArchive with a single |
| 1687 | // "Campaign" entry holding the serialized CampaignHistory. |
| 1688 | static bool SaveCampaignHistoryToDisk(const CampaignHistory& campaign) |
| 1689 | { |
| 1690 | RString dir = GetTmpSaveDirectory(); |
| 1691 | char buffer[512]; |
| 1692 | snprintf(buffer, sizeof(buffer), "%s%s.sqc", (const char*)dir, (const char*)campaign.campaignName); |
| 1693 | |
| 1694 | ParamArchiveSave ar(UserInfoVersion); |
| 1695 | // const_cast because SerializeClass::Serialize is non-const but this |
| 1696 | // path is logically read-only — it's the standard write idiom used |
| 1697 | // elsewhere by SaveParams. |
| 1698 | CampaignHistory& nonConst = const_cast<CampaignHistory&>(campaign); |
| 1699 | if (ar.Serialize("Campaign", nonConst, 1) != LSOK) |
| 1700 | return false; |
| 1701 | return ar.Save(buffer) == LSOK; |
| 1702 | } |
| 1703 | |
| 1704 | // Bridge for DebugCheats::Cmd_UnlockCampaign — unlocks every campaign |
| 1705 | // found on disk (subdirs of Campaigns/ + .pb? banks), works regardless |
no test coverage detected