MCPcopy Create free account
hub / github.com/StrongPC123/Far-Cry-1-Source-Full / GetSaveGameList

Method GetSaveGameList

CryGame/ScriptObjectGame.cpp:2680–2810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2678
2679
2680int CScriptObjectGame::GetSaveGameList(IFunctionHandler *pH)
2681{
2682 intptr_t hEnumFile = -1L;
2683 __finddata64_t sFindData;
2684 _SmartScriptObject cList(m_pSystem->GetIScriptSystem(), false);
2685 std::vector<SFoundSaveGame> vSaveList;
2686
2687 CHECK_PARAMETERS(1);
2688
2689 char *szProfileName;
2690
2691 pH->GetParam(1, szProfileName);
2692
2693 string szSaveGameDir = "Profiles/player/";
2694 szSaveGameDir+= szProfileName;
2695 szSaveGameDir += "/Savegames/";
2696
2697 //m_pSystem->GetILog()->Log("SEARCHING FOR SAVEGAMES (PROFILE: %s)!", szProfileName);
2698
2699 string pattern = szSaveGameDir + "*.sav";
2700
2701 if ((hEnumFile = _findfirst64(pattern.c_str(), &sFindData)) == -1L)
2702 {
2703 _findclose(hEnumFile);
2704 hEnumFile = -1L;
2705 return pH->EndFunction(cList);
2706 }
2707
2708 do
2709 {
2710 if(sFindData.attrib&_A_SUBDIR) continue;
2711
2712 string szSaveFilename = szSaveGameDir + sFindData.name;
2713
2714 CDefaultStreamAllocator sa;
2715 CStream stm(300, &sa);
2716
2717 int bitslen = m_pSystem->GetCompressedFileSize((char *)szSaveFilename.c_str());
2718
2719 if (bitslen)
2720 {
2721 stm.Resize(bitslen);
2722
2723 int bitsread = m_pSystem->ReadCompressedFile((char *)szSaveFilename.c_str(), stm.GetPtr(), stm.GetAllocatedSize());
2724
2725 if (bitsread)
2726 {
2727 stm.SetSize(bitsread);
2728
2729 string szMagic;
2730 int iVersion;
2731
2732 stm.Read(szMagic);
2733 stm.Read(iVersion);
2734
2735 if ((szMagic == SAVEMAGIC))
2736 {
2737 m_pSystem->GetILog()->Log("\tfound savegame: %s", sFindData.name);

Callers

nothing calls this directly

Calls 15

EndFunctionMethod · 0.80
GetCompressedFileSizeMethod · 0.80
ReadCompressedFileMethod · 0.80
GetILogMethod · 0.80
SetAtMethod · 0.80
sortFunction · 0.50
GetIScriptSystemMethod · 0.45
GetParamMethod · 0.45
c_strMethod · 0.45
ResizeMethod · 0.45
GetPtrMethod · 0.45
GetAllocatedSizeMethod · 0.45

Tested by

no test coverage detected