Skip to content

Commit fb4f2e2

Browse files
committed
Allow changing the keeper when there is no ball
1 parent deaab25 commit fb4f2e2

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

internal/app/rcon/server_team.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,9 @@ func (s *TeamServer) processRequest(teamClient TeamClient, request *TeamToContro
240240

241241
func mayChangeKeeper(gcState *engine.GcState, teamState *state.TeamInfo) error {
242242
ball := gcState.TrackerStateGc.Ball
243-
if ball == nil {
244-
return errors.New("GC does not know the ball position")
245-
}
246-
if (*teamState.OnPositiveHalf && *ball.Pos.X > 0) ||
247-
(!*teamState.OnPositiveHalf && *ball.Pos.X < 0) {
243+
if ball != nil &&
244+
((*teamState.OnPositiveHalf && *ball.Pos.X > 0) ||
245+
(!*teamState.OnPositiveHalf && *ball.Pos.X < 0)) {
248246
return errors.New("Ball is not in the opponents half")
249247
}
250248
return nil

0 commit comments

Comments
 (0)