revise my latest changes
Some checks are pending
Build coop / build-windows-directx (push) Waiting to run
Build coop / build-macos-arm (push) Waiting to run
Build coop / build-macos-intel (push) Waiting to run
Build coop / build-linux (push) Waiting to run
Build coop / build-steamos (push) Waiting to run
Build coop / build-windows-opengl (push) Waiting to run

This commit is contained in:
Isaac0-dev 2025-06-04 07:58:02 +10:00
parent f0d6e4331d
commit d6508def28
3 changed files with 14 additions and 12 deletions

View file

@ -22,7 +22,7 @@ static Array<Pair<const char*, void *>>& DynosCustomActors() {
return sDynosCustomActors; return sDynosCustomActors;
} }
static std::map<struct GraphNode *, struct GraphNode *> sModifiedModels; static std::map<struct GraphNode *, struct GraphNode *> sModifiedGraphNodes;
// TODO: the cleanup/refactor didn't really go as planned. // TODO: the cleanup/refactor didn't really go as planned.
// clean up the actor management code more // clean up the actor management code more
@ -237,7 +237,7 @@ void DynOS_Actor_Override_All(void) {
} }
} }
std::unordered_map<uint16_t, size_t> graphNodeInitMap = { static std::unordered_map<s16, size_t> sGraphNodeSizeMap = {
{ GRAPH_NODE_TYPE_ROOT, sizeof(GraphNodeRoot) }, { GRAPH_NODE_TYPE_ROOT, sizeof(GraphNodeRoot) },
{ GRAPH_NODE_TYPE_ORTHO_PROJECTION, sizeof(GraphNodeOrthoProjection) }, { GRAPH_NODE_TYPE_ORTHO_PROJECTION, sizeof(GraphNodeOrthoProjection) },
{ GRAPH_NODE_TYPE_PERSPECTIVE, sizeof(GraphNodePerspective) }, { GRAPH_NODE_TYPE_PERSPECTIVE, sizeof(GraphNodePerspective) },
@ -262,17 +262,18 @@ std::unordered_map<uint16_t, size_t> graphNodeInitMap = {
{ GRAPH_NODE_TYPE_HELD_OBJ, sizeof(GraphNodeHeldObject) }, { GRAPH_NODE_TYPE_HELD_OBJ, sizeof(GraphNodeHeldObject) },
}; };
size_t get_graph_node_size(uint16_t nodeType) { size_t get_graph_node_size(s16 nodeType) {
auto it = graphNodeInitMap.find(nodeType); auto it = sGraphNodeSizeMap.find(nodeType);
return it != graphNodeInitMap.end() ? it->second : 0; return it != sGraphNodeSizeMap.end() ? it->second : 0;
} }
void DynOS_Actor_RegisterModifiedGraphNode(GraphNode *aNode) { void DynOS_Actor_RegisterModifiedGraphNode(GraphNode *aNode) {
if (sModifiedModels.find(aNode) == sModifiedModels.end()) { if (sModifiedGraphNodes.find(aNode) == sModifiedGraphNodes.end()) {
size_t size = get_graph_node_size(aNode->type); size_t size = get_graph_node_size(aNode->type);
if (size == 0) { return; } // Unexpected
GraphNode *graphNodeCopy = (GraphNode *) malloc(size); GraphNode *graphNodeCopy = (GraphNode *) malloc(size);
memcpy(graphNodeCopy, aNode, size); memcpy(graphNodeCopy, aNode, size);
sModifiedModels[aNode] = graphNodeCopy; sModifiedGraphNodes[aNode] = graphNodeCopy;
} }
} }
@ -299,10 +300,11 @@ void DynOS_Actor_ModShutdown() {
DynOS_Actor_Override_All(); DynOS_Actor_Override_All();
// Reset modified graph nodes // Reset modified graph nodes
for (auto& node : sModifiedModels) { for (auto& node : sModifiedGraphNodes) {
size_t size = get_graph_node_size(node.second->type); size_t size = get_graph_node_size(node.second->type);
if (size == 0) { continue; } // Unexpected
memcpy(node.first, node.second, size); memcpy(node.first, node.second, size);
free(node.second); free(node.second);
} }
sModifiedModels.clear(); sModifiedGraphNodes.clear();
} }

View file

@ -8,7 +8,7 @@ extern "C" {
#include "behavior_data.h" #include "behavior_data.h"
#include "pc/lua/smlua_hooks.h" #include "pc/lua/smlua_hooks.h"
s16 geo_get_processing_mario_index(void); s8 geo_get_processing_mario_index(void);
} }
// //
@ -77,7 +77,7 @@ void DynOS_Anim_Swap(void *aPtr) {
// Animation index // Animation index
s32 _AnimIndex = -1; s32 _AnimIndex = -1;
u8 index = geo_get_processing_mario_index(); s8 index = geo_get_processing_mario_index();
if (index != -1) { if (index != -1) {
_AnimIndex = RetrieveCurrentMarioAnimationIndex(index); _AnimIndex = RetrieveCurrentMarioAnimationIndex(index);

View file

@ -351,7 +351,7 @@ static u8 geo_get_processing_object_index(void) {
return (index >= MAX_PLAYERS) ? 0 : index; return (index >= MAX_PLAYERS) ? 0 : index;
} }
s16 geo_get_processing_mario_index(void) { s8 geo_get_processing_mario_index(void) {
if (gCurGraphNodeProcessingObject == NULL) { return -1; } if (gCurGraphNodeProcessingObject == NULL) { return -1; }
s8 index = geo_get_processing_mirror_mario_index(); s8 index = geo_get_processing_mirror_mario_index();