Skip to content

Commit f404a2e

Browse files
committed
Avoid getting stuck due to missing ball placement command
It is currently possible, especially during dribble fouls, that the ball is still within the 1m radius where no ball placement is required. But if it is moving, it can get out of this radius. Currently, the check for ball placement is only done immediately after the STOP command. So the game is stuck in a situation, where ball placement is required, but no command is sent.
1 parent 4ef8240 commit f404a2e

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

internal/app/engine/process_runningtostop.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ func (e *Engine) processRunningToStop() {
1212
}
1313

1414
if e.ballPlacementRequired() {
15-
log.Printf("Ball placement is needed")
15+
log.Printf("Running -> Stop: Ball placement is needed")
1616
e.Enqueue(&statemachine.Change{
1717
Origin: &changeOriginEngine,
1818
Change: &statemachine.Change_StartBallPlacement{
1919
StartBallPlacement: &statemachine.StartBallPlacement{},
2020
},
2121
})
22+
} else {
23+
log.Printf("Running -> Stop: No ball placement needed")
2224
}
2325
}
2426

@@ -27,6 +29,13 @@ func (e *Engine) ballPlacementRequired() bool {
2729
// fallback if the fields are not set
2830
return false
2931
}
32+
33+
// The ball is stationary.
34+
// Else, checking the following position checks make no sense, as the ball may roll out of or in those
35+
if !e.ballSteady() {
36+
return true
37+
}
38+
3039
placementPos := e.currentState.PlacementPos
3140
ballPos := e.gcState.TrackerStateGc.Ball.Pos.ToVector2()
3241

@@ -50,10 +59,5 @@ func (e *Engine) ballPlacementRequired() bool {
5059
}
5160
}
5261

53-
// The ball is stationary.
54-
if !e.ballSteady() {
55-
return true
56-
}
57-
5862
return false
5963
}

proto/ssl_gc_engine.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ message GcState {
2121

2222
// can the match be continued right now?
2323
optional bool ready_to_continue = 5;
24-
24+
2525
// list of issues that hinders the game from continuing
2626
repeated string continuation_issues = 6;
2727
}
2828

29-
// The GC state for a singl eteam
29+
// The GC state for a single team
3030
message GcStateTeam {
3131
// true: The team is connected
3232
optional bool connected = 1;

0 commit comments

Comments
 (0)