From 166e74cfba32965fba0d6b7c31178b1e4d524799 Mon Sep 17 00:00:00 2001 From: Simon Etter Date: Mon, 9 Dec 2024 10:31:34 +0800 Subject: [PATCH] fix(FSMBehavior): Prevent state changes out of FINAL state --- src/main/java/org/arl/fjage/FSMBehavior.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/arl/fjage/FSMBehavior.java b/src/main/java/org/arl/fjage/FSMBehavior.java index 41737f32..3ed68fe6 100644 --- a/src/main/java/org/arl/fjage/FSMBehavior.java +++ b/src/main/java/org/arl/fjage/FSMBehavior.java @@ -162,6 +162,7 @@ public void setInitialState(Object name) { public void setNextState(Object name) { State state = (name instanceof State) ? (State)name : states.get(name); if (state == null) throw new FjageException("Unknown state: "+name); + if (next == FINAL) return; next = state; restart(); } @@ -171,6 +172,7 @@ public void setNextState(Object name) { * to be exited, and re-entered. */ public void reenterState() { + if (next == FINAL) return; next = REENTER; restart(); }