From 5bce4a84cf3ddd09d4a897f83f7beb9e019ad4a1 Mon Sep 17 00:00:00 2001
From: Quaternions <krakow20@gmail.com>
Date: Tue, 21 Jan 2025 06:05:47 -0800
Subject: [PATCH] tweak ReachWalkTargetVelocity

---
 strafe-client/src/physics.rs | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/strafe-client/src/physics.rs b/strafe-client/src/physics.rs
index 41976cfe..f061b7bf 100644
--- a/strafe-client/src/physics.rs
+++ b/strafe-client/src/physics.rs
@@ -1774,19 +1774,19 @@ fn atomic_internal_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:Tim
 					|MoveState::Fly
 					=>println!("ReachWalkTargetVelocity fired for non-walking MoveState"),
 					MoveState::Walk(walk_state)|MoveState::Ladder(walk_state)=>{
-						match &walk_state.target{
+						//velocity is already handled by advance_time
+						//we know that the acceleration is precisely zero because the walk target is known to be reachable
+						//which means that gravity can be fully cancelled
+						//ignore moving platforms for now
+						let target=core::mem::replace(&mut walk_state.target,TransientAcceleration::Reached);
+						set_acceleration(&mut state.body,&state.touching,&data.models,&data.hitbox_mesh,vec3::ZERO);
+						// check what the target was to see if it was invalid
+						match target{
 							//you are not supposed to reach a walk target which is already reached!
-							TransientAcceleration::Reached=>unreachable!(),
-							TransientAcceleration::Reachable{acceleration:_,time:_}=>{
-								//velocity is already handled by advance_time
-								//we know that the acceleration is precisely zero because the walk target is known to be reachable
-								//which means that gravity can be fully cancelled
-								//ignore moving platforms for now
-								set_acceleration(&mut state.body,&state.touching,&data.models,&data.hitbox_mesh,vec3::ZERO);
-								walk_state.target=TransientAcceleration::Reached;
-							},
+							TransientAcceleration::Reached=>println!("Invalid walk target: Reached"),
+							TransientAcceleration::Reachable{..}=>(),
 							//you are not supposed to reach an unreachable walk target!
-							TransientAcceleration::Unreachable{acceleration:_}=>unreachable!(),
+							TransientAcceleration::Unreachable{..}=>println!("Invalid walk target: Unreachable"),
 						}
 					}
 				}