diff --git a/include/gamedata.h b/include/gamedata.h index 88032a5..9940255 100644 --- a/include/gamedata.h +++ b/include/gamedata.h @@ -8,6 +8,7 @@ #include "indexparser.h" #include "sqpack.h" #include "memorybuffer.h" +#include "types/race.h" /* * This handles reading/extracting the raw data from game data packs, such as dat0, index and index2 files. @@ -34,7 +35,7 @@ public: IndexFile getIndexListing(std::string_view folder); - void extractSkeleton(); + void extractSkeleton(Race race); std::optional readExcelSheet(std::string_view name); diff --git a/src/gamedata.cpp b/src/gamedata.cpp index 285d022..f1c9f7e 100644 --- a/src/gamedata.cpp +++ b/src/gamedata.cpp @@ -397,8 +397,9 @@ std::optional GameData::readExcelSheet(std::string_view name) { return {}; } -void GameData::extractSkeleton() { - const std::string path = fmt::format("chara/human/c0201/skeleton/base/b0001/skl_c0201b0001.sklb"); +void GameData::extractSkeleton(Race race) { + const std::string path = fmt::format("chara/human/c{race:04d}/skeleton/base/b0001/skl_c{race:04d}b0001.sklb", + fmt::arg("race", get_race_id(race))); auto skel_data = extractFile(path); auto skel_span = MemorySpan(*skel_data); @@ -433,7 +434,10 @@ void GameData::extractSkeleton() { std::vector havokData(skel_span.size() - dataOffset); skel_span.read_structures(&havokData, havokData.size()); - FILE* newFile = fopen("test.sklb.havok", "wb"); + const std::string outputName = fmt::format("skl_c{race:04d}b0001.sklb", + fmt::arg("race", get_race_id(race))); + + FILE* newFile = fopen(outputName.c_str(), "wb"); fwrite(havokData.data(), havokData.size(), 1, newFile); fclose(newFile); diff --git a/src/havokxmlparser.cpp b/src/havokxmlparser.cpp index 289d3f2..06712cd 100644 --- a/src/havokxmlparser.cpp +++ b/src/havokxmlparser.cpp @@ -33,7 +33,7 @@ Skeleton parseHavokXML(const std::string_view path) { pugi::xml_document doc; doc.load_file(path.data()); - pugi::xpath_node build_tool = doc.select_node("//hkobject[@name=\"#0052\"]/hkparam[@name=\"bones\"]"); + pugi::xpath_node build_tool = doc.select_node("//hkobject/hkparam[@name=\"bones\"]"); auto bonesNode = build_tool.node(); @@ -71,7 +71,7 @@ Skeleton parseHavokXML(const std::string_view path) { walkSkeleton(skeleton, skeleton.root_bone); - pugi::xpath_node build_tool2 = doc.select_node("//hkobject[@name=\"#0052\"]/hkparam[@name=\"referencePose\"]"); + pugi::xpath_node build_tool2 = doc.select_node("//hkobject/hkparam[@name=\"referencePose\"]"); fmt::print("num ref poses: {}\n", build_tool2.node().attribute("numelements").as_int());