~redstrate/libxiv

ce7c99c3de4853758bd37d46b3e582b27681797a — Joshua Goins 2 years ago 0e653bf
Add method to get index file directly
2 files changed, 21 insertions(+), 7 deletions(-)

M include/gamedata.h
M src/gamedata.cpp
M include/gamedata.h => include/gamedata.h +8 -5
@@ 5,6 5,7 @@
#include <optional>
#include "exhparser.h"
#include "exlparser.h"
#include "indexparser.h"

/*
 * This handles reading/extracting the raw data from game data packs, such as dat0, index and index2 files.


@@ 26,12 27,19 @@ public:
     */
    void extractFile(std::string_view dataFilePath, std::string_view outPath);

    IndexFile<IndexHashTableEntry> getIndexListing(std::string_view folder);

    void extractSkeleton();

    std::optional<EXH> readExcelSheet(std::string_view name);

    std::vector<std::string> getAllSheetNames();

    /*
     * Calculates a uint64 hash from a given game path.
     */
    uint64_t calculateHash(std::string_view path);

private:
    /*
     * This returns a proper SQEX-style filename for index, index2, and dat files.


@@ 44,11 52,6 @@ private:
     */
    std::tuple<std::string, std::string> calculateRepositoryCategory(std::string_view path);

    /*
     * Calculates a uint64 hash from a given game path.
     */
    uint64_t calculateHash(std::string_view path);

    std::string dataDirectory;

    EXL rootEXL;

M src/gamedata.cpp => src/gamedata.cpp +13 -2
@@ 436,11 436,14 @@ std::optional<EXH> GameData::readExcelSheet(std::string_view name) {

            std::string exhFilename = "exd/" + newFilename + ".exh";

            extractFile(exhFilename, newFilename + ".exh");
            std::string outPath = newFilename + ".exh";
            std::replace(outPath.begin(), outPath.end(), '/', '_');

            extractFile(exhFilename, outPath);

            fmt::print("Done extracting files, now parsing...\n");

            return readEXH(newFilename + ".exh");
            return readEXH(outPath);
        }
    }



@@ 498,3 501,11 @@ void GameData::extractSkeleton() {
    fclose(newFile);
    fclose(file);
}

IndexFile<IndexHashTableEntry> GameData::getIndexListing(std::string_view folder) {
    auto [repository, category] = calculateRepositoryCategory(fmt::format("{}/{}", folder, "a"));

    auto indexFilename = calculateFilename(categoryToID[category], getExpansionID(repository), 0, "win32", "index");

    return readIndexFile(dataDirectory + "/" + repository + "/" + indexFilename);
}