Skip to content

Commit 63add25

Browse files
committed
Avoid getting stuck due to missing ball placement command
It is still possible to get stuck if there are two game events after each other, both stopping the game. The second one will cancel the ball placement in this case.
1 parent f404a2e commit 63add25

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

internal/app/engine/engine.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,9 @@ func (e *Engine) postProcessChange(entry *statemachine.StateChange) {
382382
}
383383
if change.GetNewCommand() != nil &&
384384
*change.GetNewCommand().Command.Type == state.Command_STOP &&
385-
entry.StatePre.Command.IsRunning() {
385+
// include STOP from last state as well, as game events may come in shortly after state changed to STOP
386+
// for example if two robots dribbled ball to far, autoRefs will trigger two events after each other
387+
(entry.StatePre.Command.IsRunning() || *entry.StatePre.Command.Type == state.Command_STOP) {
386388
e.processRunningToStop()
387389
}
388390
}

0 commit comments

Comments
 (0)