diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index dcd9c0255..afb3a82a6 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1,4 +1,4 @@ -#include "OTRGlobals.h" +#include "OTRGlobals.h" #include "OTRAudio.h" #include #include @@ -1392,9 +1392,26 @@ extern "C" AnimationHeaderCommon* ResourceMgr_LoadAnimByName(const char* path) { return (AnimationHeaderCommon*)GetResourceDataByName(path, false); } -extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, SkelAnime* skelAnime) -{ - SkeletonHeader* skelHeader = (SkeletonHeader*)GetResourceDataByName(path, false); +extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, SkelAnime* skelAnime) { + std::string pathStr = std::string(path); + static const std::string sOtr = "__OTR__"; + + if (pathStr.starts_with(sOtr)) { + pathStr = pathStr.substr(sOtr.length()); + } + + bool isAlt = CVarGetInteger("gAltAssets", 0); + + if (isAlt) { + pathStr = Ship::Resource::gAltAssetPrefix + pathStr; + } + + SkeletonHeader* skelHeader = (SkeletonHeader*)GetResourceDataByName(pathStr.c_str(), false); + + // If there isn't an alternate model, load the regular one + if (isAlt && skelHeader == NULL) { + skelHeader = (SkeletonHeader*)GetResourceDataByName(path, false); + } // This function is only called when a skeleton is initialized. // Therefore we can take this oppurtunity to take note of the Skeleton that is created... @@ -1403,7 +1420,6 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel Ship::SkeletonPatcher::RegisterSkeleton(stringPath, skelAnime); } - return skelHeader; }