Fixed DisplayList Binary extraction and some other factories

This commit is contained in:
KiritoDv
2024-04-08 18:09:34 -06:00
committed by Lywx
parent 3918fde51a
commit 6d5f37db33
6 changed files with 28 additions and 16 deletions
+6
View File
@@ -1182,6 +1182,12 @@ std::string Companion::NormalizeAsset(const std::string& name) const {
return path;
}
std::string Companion::RelativePath(const std::string& path) const {
std::string doutput = (this->gCurrentDirectory / path).string();
std::replace(doutput.begin(), doutput.end(), '\\', '/');
return doutput;
}
std::string Companion::CalculateHash(const std::vector<uint8_t>& data) {
return Chocobo1::SHA1().addData(data).finalize().toString();
}
+1
View File
@@ -120,6 +120,7 @@ public:
static std::string CalculateHash(const std::vector<uint8_t>& data);
static void Pack(const std::string& folder, const std::string& output);
std::string NormalizeAsset(const std::string& name) const;
std::string RelativePath(const std::string& path) const;
TorchConfig& GetConfig() { return this->gConfig; }
SWrapper* GetCurrentWrapper() { return this->gCurrentWrapper; }
+4 -3
View File
@@ -233,14 +233,15 @@ ExportResult DListBinaryExporter::Export(std::ostream &write, std::shared_ptr<IP
if(overlap.has_value()){
auto ovnode = std::get<1>(overlap.value());
uint64_t hash = CRC64(std::get<0>(overlap.value()).c_str());
SPDLOG_INFO("Found vtx: 0x{:X} Hash: 0x{:X} Path: {}", ptr, hash, std::get<0>(overlap.value()));
auto path = Companion::Instance->RelativePath(std::get<0>(overlap.value()));
uint64_t hash = CRC64(path.c_str());
SPDLOG_INFO("Found vtx: 0x{:X} Hash: 0x{:X} Path: {}", ptr, hash, path);
auto offset = GetSafeNode<uint32_t>(ovnode, "offset");
auto count = GetSafeNode<uint32_t>(ovnode, "count");
auto diff = ASSET_PTR(ptr) - ASSET_PTR(offset);
Gfx value = gsSPVertexOTR(diff, nvtx, ((didx >> 1) - nvtx));
Gfx value = gsSPVertexOTR(diff, nvtx, didx);
SPDLOG_INFO("gsSPVertexOTR({}, {}, {})", diff, nvtx, didx);
+5 -2
View File
@@ -100,8 +100,11 @@ ExportResult SF64::HitboxBinaryExporter::Export(std::ostream &write, std::shared
auto writer = LUS::BinaryWriter();
WriteHeader(writer, LUS::ResourceType::Hitbox, 0);
for (float value : hitbox->mData) {
writer.Write(value);
auto count = hitbox->mData.size();
writer.Write((uint32_t) count);
for(size_t i = 0; i < hitbox->mData.size(); i++) {
writer.Write(hitbox->mData[i]);
}
writer.Finish(write);
return std::nullopt;
+11 -10
View File
@@ -50,16 +50,17 @@ ExportResult SF64::ObjInitBinaryExporter::Export(std::ostream &write, std::share
auto data = std::static_pointer_cast<ObjInitData>(raw)->mObjInit;
WriteHeader(writer, LUS::ResourceType::ObjectInit, 0);
writer.Write((uint32_t) data.size());
for(auto& obj : data) {
writer.Write(obj.zPos1);
writer.Write(obj.zPos2);
writer.Write(obj.xPos);
writer.Write(obj.yPos);
writer.Write(obj.rot.x);
writer.Write(obj.rot.y);
writer.Write(obj.rot.z);
writer.Write(obj.id);
auto count = data.size();
writer.Write((uint32_t) count);
for(size_t i = 0; i < data.size(); i++) {
writer.Write(data[i].zPos1);
writer.Write(data[i].zPos2);
writer.Write(data[i].xPos);
writer.Write(data[i].yPos);
writer.Write(data[i].rot.x);
writer.Write(data[i].rot.y);
writer.Write(data[i].rot.z);
writer.Write(data[i].id);
}
writer.Finish(write);
return std::nullopt;
+1 -1
View File
@@ -13,7 +13,7 @@ SWrapper::SWrapper(const std::string& path) {
fs::remove(path);
}
if(!SFileCreateArchive(path.c_str(), MPQ_CREATE_LISTFILE | MPQ_CREATE_ATTRIBUTES | MPQ_CREATE_ARCHIVE_V2, 8 * 1024, &this->hMpq)){
if(!SFileCreateArchive(path.c_str(), MPQ_CREATE_LISTFILE | MPQ_CREATE_ATTRIBUTES | MPQ_CREATE_ARCHIVE_V2, 16 * 1024, &this->hMpq)){
SPDLOG_ERROR("Failed to create archive {} with error code {}", path, GetLastError());
return;
}