| 2678 | |
| 2679 | |
| 2680 | int 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); |
nothing calls this directly
no test coverage detected