Archived
1
Fork 0

Add method to get index file directly

This commit is contained in:
Joshua Goins 2022-04-14 08:22:10 -04:00
parent 0e653bf6e9
commit ce7c99c3de
2 changed files with 21 additions and 7 deletions

View file

@ -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;

View file

@ -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);
}