MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / Game_Load

Method Game_Load

Source/Fodder.cpp:9569–9604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9567}
9568
9569void cFodder::Game_Load() {
9570 auto Files = g_ResourceMan->GetSaves();
9571 std::vector<sSavedGame> SaveFiles;
9572
9573 SaveFiles = Game_Load_Filter(Files);
9574 Files.clear();
9575
9576
9577 const std::string File = GUI_Select_File("SELECT SAVED GAME", SaveFiles, Files);
9578 if (!File.size())
9579 return;
9580
9581 auto SaveData = g_ResourceMan->FileReadStr(g_ResourceMan->GetSave(File));
9582
9583 // Load the game data from the JSONstd::string((char*)SaveData->data(), SaveData->size()))
9584 if (!mGame_Data.FromJson(SaveData)) {
9585 return;
9586 }
9587
9588 // If the game was saved on a different platform, lets look for it and attempt to switch
9589 if (mGame_Data.mSavedVersion.mPlatform != mVersionCurrent->mPlatform) {
9590
9591 VersionSwitch( mVersions->GetForCampaign(mGame_Data.mCampaignName, mGame_Data.mSavedVersion.mPlatform) );
9592 }
9593
9594 mMouse_Exit_Loop = false;
9595
9596 for (int16 x = 0; x < 8; ++x)
9597 mMission_Troops_SpritePtrs[x] = INVALID_SPRITE_PTR;
9598
9599 for (auto& Troop : mGame_Data.mSoldiers_Allocated)
9600 Troop.mSprite = INVALID_SPRITE_PTR;
9601
9602 GameData_Backup();
9603 GameData_Restore();
9604}
9605
9606std::vector<sSavedGame> cFodder::Game_Load_Filter(const std::vector<std::string>& pFiles) {
9607 std::vector<sSavedGame> Results;

Callers

nothing calls this directly

Calls 7

GetSavesMethod · 0.80
FileReadStrMethod · 0.80
GetSaveMethod · 0.80
GetForCampaignMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45
FromJsonMethod · 0.45

Tested by

no test coverage detected