summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKiritoDv <kiritodev01@gmail.com>2024-04-06 12:28:51 -0600
committerLywx <kiritodev01@gmail.com>2024-04-08 18:09:34 -0600
commit6d5f37db337ac10be180527d98d1676c2be3344d (patch)
tree48571e27aff74261a921c6e9eee8c99592b485b4 /src
parent3918fde51a84f5035d6f74740195f0d91dd5c604 (diff)
Fixed DisplayList Binary extraction and some other factories
Diffstat (limited to 'src')
-rw-r--r--src/Companion.cpp6
-rw-r--r--src/Companion.h1
-rw-r--r--src/factories/DisplayListFactory.cpp7
-rw-r--r--src/factories/sf64/HitboxFactory.cpp7
-rw-r--r--src/factories/sf64/ObjInitFactory.cpp21
-rw-r--r--src/storm/SWrapper.cpp2
6 files changed, 28 insertions, 16 deletions
diff --git a/src/Companion.cpp b/src/Companion.cpp
index 314d86a..b244d56 100644
--- a/src/Companion.cpp
+++ b/src/Companion.cpp
@@ -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();
}
diff --git a/src/Companion.h b/src/Companion.h
index 8d9b9e8..93b3dde 100644
--- a/src/Companion.h
+++ b/src/Companion.h
@@ -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; }
diff --git a/src/factories/DisplayListFactory.cpp b/src/factories/DisplayListFactory.cpp
index 8886d7d..02df2a5 100644
--- a/src/factories/DisplayListFactory.cpp
+++ b/src/factories/DisplayListFactory.cpp
@@ -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);
diff --git a/src/factories/sf64/HitboxFactory.cpp b/src/factories/sf64/HitboxFactory.cpp
index 150d21f..24af087 100644
--- a/src/factories/sf64/HitboxFactory.cpp
+++ b/src/factories/sf64/HitboxFactory.cpp
@@ -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;
diff --git a/src/factories/sf64/ObjInitFactory.cpp b/src/factories/sf64/ObjInitFactory.cpp
index 38d03df..a5c0c1c 100644
--- a/src/factories/sf64/ObjInitFactory.cpp
+++ b/src/factories/sf64/ObjInitFactory.cpp
@@ -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;
diff --git a/src/storm/SWrapper.cpp b/src/storm/SWrapper.cpp
index 788c273..7abf1be 100644
--- a/src/storm/SWrapper.cpp
+++ b/src/storm/SWrapper.cpp
@@ -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;
}