Make Custom Tunic Local (#6065)

* Make Custom Tunic Local

* Guard against Anchor

* Make Pause Menu Model treated as a Local
This commit is contained in:
Reppan
2026-01-01 22:36:29 +01:00
committed by GitHub
parent 2e5a985745
commit 1a9ea03e00
2 changed files with 47 additions and 3 deletions

View File

@@ -5,6 +5,14 @@
#include <soh_assets.h>
#include <objects/object_link_child/object_link_child.h>
#include <objects/object_link_boy/object_link_boy.h>
#include "macros.h"
extern "C" {
#include "variables.h"
#include "z64.h"
#include "z64player.h"
extern PlayState* gPlayState;
}
extern "C" SaveContext gSaveContext;
extern "C" u16 gEquipMasks[4];
@@ -30,12 +38,32 @@ size_t Skeleton::GetPointerSize() {
std::vector<SkeletonPatchInfo> SkeletonPatcher::skeletons;
bool SkeletonPatcher::IsLinkSkeletonPath(const std::string& path) {
return (sOtr + path == std::string(gLinkAdultSkel)) || (sOtr + path == std::string(gLinkChildSkel));
}
bool SkeletonPatcher::IsLocalPlayerSkelAnime(SkelAnime* skelAnime) {
if (gPlayState == nullptr) {
return false;
}
Player* player = GET_PLAYER(gPlayState);
if (player == nullptr) {
return false;
}
PauseContext* pauseCtx = &gPlayState->pauseCtx;
return (skelAnime == &player->skelAnime) || (skelAnime == &player->upperSkelAnime) ||
(skelAnime == &pauseCtx->playerSkelAnime);
}
void SkeletonPatcher::RegisterSkeleton(std::string& path, SkelAnime* skelAnime) {
SkeletonPatchInfo info;
info.skelAnime = skelAnime;
static const std::string sOtr = "__OTR__";
info.isLocalPlayer = false;
if (path.starts_with(sOtr)) {
path = path.substr(sOtr.length());
@@ -49,6 +77,15 @@ void SkeletonPatcher::RegisterSkeleton(std::string& path, SkelAnime* skelAnime)
info.vanillaSkeletonPath = path;
}
if (IsLinkSkeletonPath(info.vanillaSkeletonPath)) {
info.isLocalPlayer = IsLocalPlayerSkelAnime(skelAnime);
// Skip registering skeletons that do not belong to the local player (e.g. Anchor dummy actors)
if (!info.isLocalPlayer) {
return;
}
}
skeletons.push_back(info);
}
@@ -88,6 +125,10 @@ void SkeletonPatcher::UpdateSkeletons() {
void SkeletonPatcher::UpdateCustomSkeletons() {
for (auto skel : skeletons) {
if (!skel.isLocalPlayer) {
continue;
}
UpdateTunicSkeletons(skel);
}
}

View File

@@ -78,6 +78,7 @@ class Skeleton : public Ship::Resource<SkeletonData> {
struct SkeletonPatchInfo {
SkelAnime* skelAnime;
std::string vanillaSkeletonPath;
bool isLocalPlayer;
};
class SkeletonPatcher {
@@ -92,8 +93,10 @@ class SkeletonPatcher {
private:
inline static const std::string sOtr = "__OTR__";
static bool IsLinkSkeletonPath(const std::string& path);
static bool IsLocalPlayerSkelAnime(SkelAnime* skelAnime);
static void UpdateTunicSkeletons(SkeletonPatchInfo& skel);
static void UpdateCustomSkeletonFromPath(const std::string& skeletonPath, SkeletonPatchInfo& skel);
};
} // namespace SOH
} // namespace SOH