Skip to content

Commit

Permalink
Avoid getting stuck due to missing ball placement command
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
g3force committed Mar 15, 2022
1 parent f404a2e commit 63add25
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/app/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,9 @@ func (e *Engine) postProcessChange(entry *statemachine.StateChange) {
}
if change.GetNewCommand() != nil &&
*change.GetNewCommand().Command.Type == state.Command_STOP &&
entry.StatePre.Command.IsRunning() {
// include STOP from last state as well, as game events may come in shortly after state changed to STOP
// for example if two robots dribbled ball to far, autoRefs will trigger two events after each other
(entry.StatePre.Command.IsRunning() || *entry.StatePre.Command.Type == state.Command_STOP) {
e.processRunningToStop()
}
}
Expand Down

0 comments on commit 63add25

Please sign in to comment.