mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 13:35:12 +00:00
Force marioObj player indices to be well behaved
Fixes a crash when spawning the secret star in The Princess's Secret Slide. Fixes #32
This commit is contained in:
parent
95e9c1dc4c
commit
88b935e9dd
3 changed files with 20 additions and 9 deletions
|
@ -1990,7 +1990,7 @@ void pss_end_slide(struct MarioState *m) {
|
|||
if (sPssSlideStarted) {
|
||||
u16 slideTime = level_control_timer(TIMER_CONTROL_STOP);
|
||||
if (slideTime < 630) {
|
||||
m->marioObj->oBehParams = (1 << 24);
|
||||
//m->marioObj->oBehParams = (1 << 24);
|
||||
spawn_default_star(-6358.0f, -4300.0f, 4700.0f);
|
||||
}
|
||||
sPssSlideStarted = FALSE;
|
||||
|
|
|
@ -318,16 +318,20 @@ static Gfx *make_gfx_mario_alpha(struct GraphNodeGenerated *node, s16 alpha) {
|
|||
return gfxHead;
|
||||
}
|
||||
|
||||
struct MarioState* geo_get_mario_state(void) {
|
||||
return (gCurGraphNodeProcessingObject == NULL)
|
||||
? &gMarioStates[0]
|
||||
: &gMarioStates[gCurGraphNodeProcessingObject->oBehParams - 1];
|
||||
static u8 geo_get_processing_object_index(void) {
|
||||
if (gCurGraphNodeProcessingObject == NULL) { return 0; }
|
||||
u8 index = gCurGraphNodeProcessingObject->oBehParams - 1;
|
||||
return (index >= MAX_PLAYERS) ? 0 : index;
|
||||
}
|
||||
|
||||
struct MarioBodyState* geo_get_body_state(void) {
|
||||
return (gCurGraphNodeProcessingObject == NULL)
|
||||
? &gBodyStates[0]
|
||||
: &gBodyStates[gCurGraphNodeProcessingObject->oBehParams - 1];
|
||||
static struct MarioState* geo_get_mario_state(void) {
|
||||
u8 index = geo_get_processing_object_index();
|
||||
return &gMarioStates[index];
|
||||
}
|
||||
|
||||
static struct MarioBodyState* geo_get_body_state(void) {
|
||||
u8 index = geo_get_processing_object_index();
|
||||
return &gBodyStates[index];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -260,6 +260,13 @@ void spawn_particle(u32 activeParticleFlag, s16 model, const BehaviorScript *beh
|
|||
* Mario's primary behavior update function.
|
||||
*/
|
||||
void bhv_mario_update(void) {
|
||||
// force indices to be well behaved
|
||||
// this may cause unintended side effects
|
||||
for (int i = 0; i < MAX_PLAYERS; i++) {
|
||||
if (gMarioStates[i].marioObj == NULL) { continue; }
|
||||
gMarioStates[i].marioObj->oBehParams = i + 1;
|
||||
}
|
||||
|
||||
// set mario state to the current player
|
||||
gMarioState = &gMarioStates[gCurrentObject->oBehParams - 1];
|
||||
|
||||
|
|
Loading…
Reference in a new issue