summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrozlette <Rozelette@users.noreply.github.com>2022-02-07 00:16:53 -0600
committerM4xw <m4x@m4xw.net>2022-02-17 21:03:29 +0100
commit8f3f59c18572e0baf80c5ccf206e8d2950c0b4e9 (patch)
treef8b405d83077da6e4b274c039fe7d8d6f8f1ed07
parent298ac2bf48cbbdcc8af704ff64b0169afa926ba7 (diff)
Fix Farore's wind crashing due to a non-existant skeleton
-rw-r--r--OTRExporter/SkeletonExporter.cpp10
-rw-r--r--OTRExporter/SkeletonLimbExporter.cpp55
2 files changed, 50 insertions, 15 deletions
diff --git a/OTRExporter/SkeletonExporter.cpp b/OTRExporter/SkeletonExporter.cpp
index 338466c..23ae853 100644
--- a/OTRExporter/SkeletonExporter.cpp
+++ b/OTRExporter/SkeletonExporter.cpp
@@ -1,5 +1,6 @@
#include "SkeletonExporter.h"
#include <Resource.h>
+#include <Globals.h>
void OTRExporter_Skeleton::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer)
{
@@ -20,9 +21,14 @@ void OTRExporter_Skeleton::Save(ZResource* res, const fs::path& outPath, BinaryW
{
Declaration* skelDecl = skel->parent->GetDeclarationRanged(GETSEGOFFSET(skel->limbsTable.limbsAddresses[i]));
- if (skelDecl != nullptr)
+ std::string name;
+ bool foundDecl = Globals::Instance->GetSegmentedPtrName(skel->limbsTable.limbsAddresses[i], skel->parent, "", name);
+ if (foundDecl)
{
- std::string fName = StringHelper::Sprintf("%s\\%s", skel->parent->GetOutName().c_str(), skelDecl->varName.c_str());
+ if (name.at(0) == '&')
+ name.erase(0, 1);
+
+ std::string fName = StringHelper::Sprintf("%s\\%s", skel->parent->GetOutName().c_str(), name.c_str());
writer->Write(fName);
}
else
diff --git a/OTRExporter/SkeletonLimbExporter.cpp b/OTRExporter/SkeletonLimbExporter.cpp
index 9a602f8..d22c3d0 100644
--- a/OTRExporter/SkeletonLimbExporter.cpp
+++ b/OTRExporter/SkeletonLimbExporter.cpp
@@ -1,6 +1,7 @@
#include "SkeletonLimbExporter.h"
#include "DisplayListExporter.h"
#include <Resource.h>
+#include <Globals.h>
void OTRExporter_SkeletonLimb::Save(ZResource* res, const fs::path& outPath, BinaryWriter* writer)
{
@@ -84,12 +85,19 @@ void OTRExporter_SkeletonLimb::Save(ZResource* res, const fs::path& outPath, Bin
if (limb->childPtr != 0)
{
- auto childDecl = limb->parent->GetDeclaration(GETSEGOFFSET(limb->childPtr));
-
- if (childDecl != nullptr)
- writer->Write(OTRExporter_DisplayList::GetPathToRes(limb, childDecl->varName));
+ std::string name;
+ bool foundDecl = Globals::Instance->GetSegmentedPtrName(limb->childPtr, limb->parent, "", name);
+ if (foundDecl)
+ {
+ if (name.at(0) == '&')
+ name.erase(0, 1);
+
+ writer->Write(OTRExporter_DisplayList::GetPathToRes(limb, name));
+ }
else
+ {
writer->Write("");
+ }
}
else
{
@@ -98,12 +106,19 @@ void OTRExporter_SkeletonLimb::Save(ZResource* res, const fs::path& outPath, Bin
if (limb->siblingPtr != 0)
{
- auto siblingDecl = limb->parent->GetDeclaration(GETSEGOFFSET(limb->siblingPtr));
+ std::string name;
+ bool foundDecl = Globals::Instance->GetSegmentedPtrName(limb->siblingPtr, limb->parent, "", name);
+ if (foundDecl)
+ {
+ if (name.at(0) == '&')
+ name.erase(0, 1);
- if (siblingDecl != nullptr)
- writer->Write(OTRExporter_DisplayList::GetPathToRes(limb, siblingDecl->varName));
+ writer->Write(OTRExporter_DisplayList::GetPathToRes(limb, name));
+ }
else
+ {
writer->Write("");
+ }
}
else
{
@@ -112,12 +127,19 @@ void OTRExporter_SkeletonLimb::Save(ZResource* res, const fs::path& outPath, Bin
if (limb->dListPtr != 0)
{
- auto dlDecl = limb->parent->GetDeclaration(GETSEGOFFSET(limb->dListPtr));
+ std::string name;
+ bool foundDecl = Globals::Instance->GetSegmentedPtrName(limb->dListPtr, limb->parent, "", name);
+ if (foundDecl)
+ {
+ if (name.at(0) == '&')
+ name.erase(0, 1);
- if (dlDecl != nullptr)
- writer->Write(OTRExporter_DisplayList::GetPathToRes(limb, dlDecl->varName));
+ writer->Write(OTRExporter_DisplayList::GetPathToRes(limb, name));
+ }
else
+ {
writer->Write("");
+ }
}
else
{
@@ -126,12 +148,19 @@ void OTRExporter_SkeletonLimb::Save(ZResource* res, const fs::path& outPath, Bin
if (limb->dList2Ptr != 0)
{
- auto dlDecl = limb->parent->GetDeclaration(GETSEGOFFSET(limb->dList2Ptr));
+ std::string name;
+ bool foundDecl = Globals::Instance->GetSegmentedPtrName(limb->dList2Ptr, limb->parent, "", name);
+ if (foundDecl)
+ {
+ if (name.at(0) == '&')
+ name.erase(0, 1);
- if (dlDecl != nullptr)
- writer->Write(OTRExporter_DisplayList::GetPathToRes(limb, dlDecl->varName));
+ writer->Write(OTRExporter_DisplayList::GetPathToRes(limb, name));
+ }
else
+ {
writer->Write("");
+ }
}
else
{