Prevent crash in vanish cap switch course

The segfault is hit while trying to render bhvCheckerboardElevatorGroup
when the player first enters the stage.

So here's some background: bhvCheckerboardElevatorGroup is the invisible
parent object that defines where the two platforms will rotate around. It
has a model, but it's never rendered in game. The entity only exists for
a few frames before being removed from the scene.

Here's the theory: Since it is only valid for a few frames, I believe the
model gets deallocated after removal. Since changing the camera precision
makes the camera end up in a slightly different spot, it could be trying
to render the object when precision is set to 3 but not to 1.

Here's the solution: Adding cur_obj_hide() to the start of
bhv_checkerboard_elevator_group_init() prevents the crash

fixes #437
This commit is contained in:
MysterD 2020-10-11 13:32:02 -07:00
parent c1ed30a2fa
commit 3908ff3954
2 changed files with 9 additions and 1 deletions

View File

@ -925,7 +925,7 @@ void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Ve
}
// increase collision checking precision (normally 1)
f32 precision = 3;
f32 precision = gCheckingSurfaceCollisionsForCamera ? 3 : 1;
// Get cells we cross using DDA
if (absx(dir[0]) >= absx(dir[2]))

View File

@ -4,6 +4,14 @@ struct Struct8032F754 D_8032F754[] = { { 145, { 0.7f, 1.5f, 0.7f }, 7.0f },
{ 235, { 1.2f, 2.0f, 1.2f }, 11.6f } };
void bhv_checkerboard_elevator_group_init(void) {
// Added to prevent a crash in the vanish cap stage
cur_obj_hide();
// Here's the theory: Since it is only valid for a few frames, I believe
// the model gets deallocated after removal. Since changing the camera
// precision makes the camera end up in a slightly different spot, it
// could be trying to render the object when `precision` is set to 3 but
// not to 1.
s32 sp3C;
s32 sp38;
s32 sp34;