mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Null checked heldObj in all mario actions
Bobomb clip no longer segfaults the game
This commit is contained in:
parent
72c4379d8a
commit
933ee68477
4 changed files with 15 additions and 10 deletions
|
|
@ -546,7 +546,7 @@ s32 act_hold_jump(struct MarioState *m) {
|
||||||
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
|
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m->input & INPUT_B_PRESSED) && !(m->heldObj->oInteractionSubtype & INT_SUBTYPE_HOLDABLE_NPC)) {
|
if ((m->input & INPUT_B_PRESSED) && !(m->heldObj != NULL && m->heldObj->oInteractionSubtype & INT_SUBTYPE_HOLDABLE_NPC)) {
|
||||||
return set_mario_action(m, ACT_AIR_THROW, 0);
|
return set_mario_action(m, ACT_AIR_THROW, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -572,7 +572,7 @@ s32 act_hold_freefall(struct MarioState *m) {
|
||||||
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
|
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m->input & INPUT_B_PRESSED) && !(m->heldObj->oInteractionSubtype & INT_SUBTYPE_HOLDABLE_NPC)) {
|
if ((m->input & INPUT_B_PRESSED) && !(m->heldObj != NULL && m->heldObj->oInteractionSubtype & INT_SUBTYPE_HOLDABLE_NPC)) {
|
||||||
return set_mario_action(m, ACT_AIR_THROW, 0);
|
return set_mario_action(m, ACT_AIR_THROW, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1065,8 +1065,10 @@ s32 act_crazy_box_bounce(struct MarioState *m) {
|
||||||
if (m->actionArg < 2) {
|
if (m->actionArg < 2) {
|
||||||
set_mario_action(m, ACT_CRAZY_BOX_BOUNCE, m->actionArg + 1);
|
set_mario_action(m, ACT_CRAZY_BOX_BOUNCE, m->actionArg + 1);
|
||||||
} else {
|
} else {
|
||||||
m->heldObj->oInteractStatus = INT_STATUS_STOP_RIDING;
|
if (m->heldObj != NULL) {
|
||||||
m->heldObj = NULL;
|
m->heldObj->oInteractStatus = INT_STATUS_STOP_RIDING;
|
||||||
|
m->heldObj = NULL;
|
||||||
|
}
|
||||||
set_mario_action(m, ACT_STOMACH_SLIDE, 0);
|
set_mario_action(m, ACT_STOMACH_SLIDE, 0);
|
||||||
}
|
}
|
||||||
queue_rumble_data_mario(m, 5, 80);
|
queue_rumble_data_mario(m, 5, 80);
|
||||||
|
|
|
||||||
|
|
@ -887,7 +887,7 @@ s32 act_move_punching(struct MarioState *m) {
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 act_hold_walking(struct MarioState *m) {
|
s32 act_hold_walking(struct MarioState *m) {
|
||||||
if (m->heldObj->behavior == segmented_to_virtual(bhvJumpingBox)) {
|
if (m->heldObj != NULL && m->heldObj->behavior == segmented_to_virtual(bhvJumpingBox)) {
|
||||||
return set_mario_action(m, ACT_CRAZY_BOX_BOUNCE, 0);
|
return set_mario_action(m, ACT_CRAZY_BOX_BOUNCE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ s32 check_common_hold_idle_cancels(struct MarioState *m) {
|
||||||
return mario_push_off_steep_floor(m, ACT_HOLD_FREEFALL, 0);
|
return mario_push_off_steep_floor(m, ACT_HOLD_FREEFALL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->heldObj->oInteractionSubtype & INT_SUBTYPE_DROP_IMMEDIATELY) {
|
if (m->heldObj != NULL && m->heldObj->oInteractionSubtype & INT_SUBTYPE_DROP_IMMEDIATELY) {
|
||||||
m->heldObj->oInteractionSubtype =
|
m->heldObj->oInteractionSubtype =
|
||||||
(s32)(m->heldObj->oInteractionSubtype & ~INT_SUBTYPE_DROP_IMMEDIATELY);
|
(s32)(m->heldObj->oInteractionSubtype & ~INT_SUBTYPE_DROP_IMMEDIATELY);
|
||||||
return set_mario_action(m, ACT_PLACING_DOWN, 0);
|
return set_mario_action(m, ACT_PLACING_DOWN, 0);
|
||||||
|
|
@ -448,7 +448,7 @@ s32 act_coughing(struct MarioState *m) {
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 act_hold_idle(struct MarioState *m) {
|
s32 act_hold_idle(struct MarioState *m) {
|
||||||
if (segmented_to_virtual(&bhvJumpingBox) == m->heldObj->behavior) {
|
if (m->heldObj != NULL && segmented_to_virtual(&bhvJumpingBox) == m->heldObj->behavior) {
|
||||||
return set_mario_action(m, ACT_CRAZY_BOX_BOUNCE, 0);
|
return set_mario_action(m, ACT_CRAZY_BOX_BOUNCE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -750,8 +750,10 @@ static s32 act_water_shell_swimming(struct MarioState *m) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->actionTimer++ == 240) {
|
if (m->actionTimer++ == 240) {
|
||||||
m->heldObj->oInteractStatus = INT_STATUS_STOP_RIDING;
|
if (m->heldObj != NULL) {
|
||||||
m->heldObj = NULL;
|
m->heldObj->oInteractStatus = INT_STATUS_STOP_RIDING;
|
||||||
|
m->heldObj = NULL;
|
||||||
|
}
|
||||||
stop_shell_music();
|
stop_shell_music();
|
||||||
set_mario_action(m, ACT_FLUTTER_KICK, 0);
|
set_mario_action(m, ACT_FLUTTER_KICK, 0);
|
||||||
}
|
}
|
||||||
|
|
@ -769,6 +771,7 @@ static s32 check_water_grab(struct MarioState *m) {
|
||||||
//! Heave hos have the grabbable interaction type but are not normally
|
//! Heave hos have the grabbable interaction type but are not normally
|
||||||
// grabbable. Since water grabbing doesn't check the appropriate input flag,
|
// grabbable. Since water grabbing doesn't check the appropriate input flag,
|
||||||
// you can use water grab to pick up heave ho.
|
// you can use water grab to pick up heave ho.
|
||||||
|
if (m->playerIndex != 0) { return FALSE; }
|
||||||
if (m->marioObj->collidedObjInteractTypes & INTERACT_GRABBABLE) {
|
if (m->marioObj->collidedObjInteractTypes & INTERACT_GRABBABLE) {
|
||||||
struct Object *object = mario_get_collided_object(m, INTERACT_GRABBABLE);
|
struct Object *object = mario_get_collided_object(m, INTERACT_GRABBABLE);
|
||||||
f32 dx = object->oPosX - m->pos[0];
|
f32 dx = object->oPosX - m->pos[0];
|
||||||
|
|
@ -845,7 +848,7 @@ static s32 act_water_punch(struct MarioState *m) {
|
||||||
case 2:
|
case 2:
|
||||||
set_mario_animation(m, MARIO_ANIM_WATER_PICK_UP_OBJ);
|
set_mario_animation(m, MARIO_ANIM_WATER_PICK_UP_OBJ);
|
||||||
if (is_anim_at_end(m)) {
|
if (is_anim_at_end(m)) {
|
||||||
if (m->heldObj->behavior == segmented_to_virtual(bhvKoopaShellUnderwater)) {
|
if (m->heldObj != NULL && m->heldObj->behavior == segmented_to_virtual(bhvKoopaShellUnderwater)) {
|
||||||
play_shell_music();
|
play_shell_music();
|
||||||
set_mario_action(m, ACT_WATER_SHELL_SWIMMING, 0);
|
set_mario_action(m, ACT_WATER_SHELL_SWIMMING, 0);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue