From 3b3ccefebb5929359bce7d01d5efc1876c80f3f1 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 13 Feb 2024 23:16:11 -0800 Subject: [PATCH] fix panic when no modes --- src/physics.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/physics.rs b/src/physics.rs index a15704c..b02e48a 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -1315,7 +1315,9 @@ fn run_teleport_behaviour(wormhole:&Option,models //check ground state.touching.insert(c); //I love making functions with 10 arguments to dodge the borrow checker - run_teleport_behaviour(&general.wormhole,&data.models,&data.modes.get_mode(state.mode_state.get_mode_id()).unwrap(),&state.style,&data.hitbox_mesh,&mut state.mode_state,&mut state.touching,&mut state.body,convex_mesh_id); + if let Some(mode)=data.modes.get_mode(state.mode_state.get_mode_id()){ + run_teleport_behaviour(&general.wormhole,&data.models,mode,&state.style,&data.hitbox_mesh,&mut state.mode_state,&mut state.touching,&mut state.body,convex_mesh_id); + } //flatten v state.touching.constrain_velocity(&data.models,&data.hitbox_mesh,&mut v); match &general.booster{ @@ -1359,7 +1361,9 @@ fn run_teleport_behaviour(wormhole:&Option,models (PhysicsCollisionAttributes::Intersect{intersecting: _,general},Collision::Intersect(intersect))=>{ //I think that setting the velocity to 0 was preventing surface contacts from entering an infinite loop state.touching.insert(c); - run_teleport_behaviour(&general.wormhole,&data.models,&data.modes.get_mode(state.mode_state.get_mode_id()).unwrap(),&state.style,&data.hitbox_mesh,&mut state.mode_state,&mut state.touching,&mut state.body,convex_mesh_id); + if let Some(mode)=data.modes.get_mode(state.mode_state.get_mode_id()){ + run_teleport_behaviour(&general.wormhole,&data.models,mode,&state.style,&data.hitbox_mesh,&mut state.mode_state,&mut state.touching,&mut state.body,convex_mesh_id); + } }, _=>panic!("invalid pair"), }