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:
@@ -5,6 +5,14 @@
|
|||||||
#include <soh_assets.h>
|
#include <soh_assets.h>
|
||||||
#include <objects/object_link_child/object_link_child.h>
|
#include <objects/object_link_child/object_link_child.h>
|
||||||
#include <objects/object_link_boy/object_link_boy.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" SaveContext gSaveContext;
|
||||||
extern "C" u16 gEquipMasks[4];
|
extern "C" u16 gEquipMasks[4];
|
||||||
@@ -30,12 +38,32 @@ size_t Skeleton::GetPointerSize() {
|
|||||||
|
|
||||||
std::vector<SkeletonPatchInfo> SkeletonPatcher::skeletons;
|
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) {
|
void SkeletonPatcher::RegisterSkeleton(std::string& path, SkelAnime* skelAnime) {
|
||||||
SkeletonPatchInfo info;
|
SkeletonPatchInfo info;
|
||||||
|
|
||||||
info.skelAnime = skelAnime;
|
info.skelAnime = skelAnime;
|
||||||
|
info.isLocalPlayer = false;
|
||||||
static const std::string sOtr = "__OTR__";
|
|
||||||
|
|
||||||
if (path.starts_with(sOtr)) {
|
if (path.starts_with(sOtr)) {
|
||||||
path = path.substr(sOtr.length());
|
path = path.substr(sOtr.length());
|
||||||
@@ -49,6 +77,15 @@ void SkeletonPatcher::RegisterSkeleton(std::string& path, SkelAnime* skelAnime)
|
|||||||
info.vanillaSkeletonPath = path;
|
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);
|
skeletons.push_back(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,6 +125,10 @@ void SkeletonPatcher::UpdateSkeletons() {
|
|||||||
|
|
||||||
void SkeletonPatcher::UpdateCustomSkeletons() {
|
void SkeletonPatcher::UpdateCustomSkeletons() {
|
||||||
for (auto skel : skeletons) {
|
for (auto skel : skeletons) {
|
||||||
|
if (!skel.isLocalPlayer) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
UpdateTunicSkeletons(skel);
|
UpdateTunicSkeletons(skel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ class Skeleton : public Ship::Resource<SkeletonData> {
|
|||||||
struct SkeletonPatchInfo {
|
struct SkeletonPatchInfo {
|
||||||
SkelAnime* skelAnime;
|
SkelAnime* skelAnime;
|
||||||
std::string vanillaSkeletonPath;
|
std::string vanillaSkeletonPath;
|
||||||
|
bool isLocalPlayer;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SkeletonPatcher {
|
class SkeletonPatcher {
|
||||||
@@ -92,6 +93,8 @@ class SkeletonPatcher {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
inline static const std::string sOtr = "__OTR__";
|
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 UpdateTunicSkeletons(SkeletonPatchInfo& skel);
|
||||||
static void UpdateCustomSkeletonFromPath(const std::string& skeletonPath, SkeletonPatchInfo& skel);
|
static void UpdateCustomSkeletonFromPath(const std::string& skeletonPath, SkeletonPatchInfo& skel);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user