mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
fix mirror mario with custom animations again [build]
Some checks are pending
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
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
Some checks are pending
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
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
This commit is contained in:
parent
2dfcb39704
commit
73e72e1b77
2 changed files with 38 additions and 12 deletions
|
|
@ -5,6 +5,10 @@ extern "C" {
|
|||
#include "game/object_list_processor.h"
|
||||
#include "pc/configfile.h"
|
||||
#include "pc/lua/utils/smlua_anim_utils.h"
|
||||
#include "behavior_data.h"
|
||||
#include "pc/lua/smlua_hooks.h"
|
||||
|
||||
s16 geo_get_processing_mario_index(void);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -24,7 +28,6 @@ static s32 RetrieveCurrentMarioAnimationIndex(u32 aPlayerIndex) {
|
|||
}
|
||||
|
||||
// Retrieve the current animation index
|
||||
// As we don't know the length of the table, let's hope that we'll always find the animation...
|
||||
static s32 RetrieveCurrentAnimationIndex(struct Object *aObject) {
|
||||
if (!aObject->oAnimations || !aObject->header.gfx.animInfo.curAnim || smlua_anim_util_get_current_animation_name(aObject)) {
|
||||
return -1;
|
||||
|
|
@ -74,11 +77,14 @@ void DynOS_Anim_Swap(void *aPtr) {
|
|||
|
||||
// Animation index
|
||||
s32 _AnimIndex = -1;
|
||||
for (u32 i = 0; i < MAX_PLAYERS; i++) {
|
||||
if (gMarioStates[i].marioObj == NULL) { continue; }
|
||||
if (_Object == gMarioStates[i].marioObj) {
|
||||
_AnimIndex = RetrieveCurrentMarioAnimationIndex(i);
|
||||
break;
|
||||
u8 index = geo_get_processing_mario_index();
|
||||
if (index != -1) {
|
||||
_AnimIndex = RetrieveCurrentMarioAnimationIndex(index);
|
||||
|
||||
// Don't allow Mario animations to be treated as regular objects
|
||||
// because DynOS doesn't properly build an AnimationTable
|
||||
if (_AnimIndex == -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (_AnimIndex == -1) {
|
||||
|
|
|
|||
|
|
@ -333,20 +333,40 @@ static Gfx *make_gfx_mario_alpha(struct GraphNodeGenerated *node, s16 alpha) {
|
|||
return gfxHead;
|
||||
}
|
||||
|
||||
static u8 geo_get_processing_object_index(void) {
|
||||
// sloppy way to fix mirror marios
|
||||
for (s32 i = 0; i < MAX_PLAYERS; i++) {
|
||||
if ((struct GraphNodeObject*)gCurGraphNodeObject == &gMirrorMario[i]) {
|
||||
return i;
|
||||
// Calculates if the processing geo is a mirror mario
|
||||
static s8 geo_get_processing_mirror_mario_index() {
|
||||
ptrdiff_t ptrDiff = (struct GraphNodeObject *) gCurGraphNodeProcessingObject - gMirrorMario;
|
||||
return (ptrDiff >= 0 && ptrDiff < MAX_PLAYERS) ? ptrDiff : -1;
|
||||
}
|
||||
|
||||
static u8 geo_get_processing_object_index(void) {
|
||||
s8 index = geo_get_processing_mirror_mario_index();
|
||||
if (index != -1) {
|
||||
return index;
|
||||
}
|
||||
if (gCurGraphNodeProcessingObject == NULL) { return 0; }
|
||||
|
||||
struct NetworkPlayer* np = network_player_from_global_index(gCurGraphNodeProcessingObject->globalPlayerIndex);
|
||||
u8 index = (np == NULL) ? 0 : np->localIndex;
|
||||
index = (np == NULL) ? 0 : np->localIndex;
|
||||
return (index >= MAX_PLAYERS) ? 0 : index;
|
||||
}
|
||||
|
||||
s16 geo_get_processing_mario_index(void) {
|
||||
if (gCurGraphNodeProcessingObject == NULL) { return -1; }
|
||||
|
||||
s8 index = geo_get_processing_mirror_mario_index();
|
||||
if (index != -1) {
|
||||
return index;
|
||||
}
|
||||
|
||||
if (gCurGraphNodeProcessingObject->behavior != smlua_override_behavior(bhvMario)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
index = gCurGraphNodeProcessingObject->oBehParams - 1;
|
||||
return (index >= MAX_PLAYERS) ? -1 : index;
|
||||
}
|
||||
|
||||
struct MarioState *geo_get_mario_state(void) {
|
||||
u8 index = geo_get_processing_object_index();
|
||||
return &gMarioStates[index];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue