MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / SaveCampaignHistoryToDisk

Function SaveCampaignHistoryToDisk

engine/Poseidon/UI/OptionsUIImpl.cpp:1688–1702  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

1686// file format LoadCampaigns reads back: ParamArchive with a single
1687// "Campaign" entry holding the serialized CampaignHistory.
1688static 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

Callers 1

DebugUnlockAllCampaignsFunction · 0.85

Calls 3

GetTmpSaveDirectoryFunction · 0.85
SerializeMethod · 0.45
SaveMethod · 0.45

Tested by

no test coverage detected