From 037a7c0d0da065ea4cb5642047302d6bda13c670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= <kzm@zkat.tech> Date: Thu, 22 Apr 2021 21:59:03 -0700 Subject: [PATCH] fix(thinker): Need to do proper ptr_eq comparison here --- src/actions.rs | 4 ++-- src/thinker.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/actions.rs b/src/actions.rs index 2dd5f82..2e69efe 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -54,11 +54,11 @@ impl ActionState { pub(crate) struct ActionBuilderId; #[derive(Debug, Clone)] -pub(crate) struct ActionBuilderWrapper(pub ActionBuilderId, pub Arc<dyn ActionBuilder>); +pub(crate) struct ActionBuilderWrapper(pub Arc<ActionBuilderId>, pub Arc<dyn ActionBuilder>); impl ActionBuilderWrapper { pub fn new(builder: Arc<dyn ActionBuilder>) -> Self { - ActionBuilderWrapper(ActionBuilderId, builder) + ActionBuilderWrapper(Arc::new(ActionBuilderId), builder) } } diff --git a/src/thinker.rs b/src/thinker.rs index b60286b..cbdcab5 100644 --- a/src/thinker.rs +++ b/src/thinker.rs @@ -310,7 +310,7 @@ fn exec_picked_action( // oscillation protection so we're not just bouncing back and // forth between the same couple of actions. if let Some((action_ent, ActionBuilderWrapper(current_id, _))) = &mut thinker.current_action { - if *current_id != picked_action.0 { + if !Arc::ptr_eq(current_id, &picked_action.0) { // So we've picked a different action than we were // currently executing. Just like before, we grab the // actual Action component (and we assume it exists). -- GitLab