Fix crash in bhv_lll_bowser_puzzle_piece_update()

This commit is contained in:
MysterD 2023-05-03 13:13:11 -07:00
parent e9ecf7a8f4
commit 0bb7adfd2d
1 changed files with 5 additions and 2 deletions

View File

@ -181,9 +181,10 @@ void bhv_lll_bowser_puzzle_piece_action_1(void) {
*/ */
void bhv_lll_bowser_puzzle_piece_update(void) { void bhv_lll_bowser_puzzle_piece_update(void) {
s8* nextAction = o->oBowserPuzzlePieceNextAction; s8* nextAction = o->oBowserPuzzlePieceNextAction;
if (!nextAction) { return; }
// If Mario is standing on this puzzle piece, set a flag in the parent. // If Mario is standing on this puzzle piece, set a flag in the parent.
if (cur_obj_is_any_player_on_platform()) if (cur_obj_is_any_player_on_platform() && o->parentObj)
o->parentObj->oBowserPuzzleCompletionFlags = 1; o->parentObj->oBowserPuzzleCompletionFlags = 1;
// If we should advance to the next action... // If we should advance to the next action...
@ -199,7 +200,9 @@ void bhv_lll_bowser_puzzle_piece_update(void) {
// If we're at the end of the list... // If we're at the end of the list...
if (*nextAction == -1) { if (*nextAction == -1) {
// Set the other completion flag in the parent. // Set the other completion flag in the parent.
o->parentObj->oBowserPuzzleCompletionFlags |= 2; if (o->parentObj) {
o->parentObj->oBowserPuzzleCompletionFlags |= 2;
}
// The next action is the first action in the list again. // The next action is the first action in the list again.
o->oBowserPuzzlePieceNextAction = o->oBowserPuzzlePieceActionList; o->oBowserPuzzlePieceNextAction = o->oBowserPuzzlePieceActionList;