diff --git a/internal/simctl/handler_robot_specs.go b/internal/simctl/handler_robot_specs.go index 0b73519..386e6ef 100644 --- a/internal/simctl/handler_robot_specs.go +++ b/internal/simctl/handler_robot_specs.go @@ -84,22 +84,31 @@ func (r *RobotSpecHandler) handleRobotSpecs() { func (r *RobotSpecHandler) updateTeam(team referee.Team, teamName string) { if r.appliedTeams[team] != teamName { if spec, ok := r.teamRobotSpecs.Teams[teamName]; ok { - var protoSpecs []*RobotSpecs - for id := 0; id < 16; id++ { - protoSpec := mapRobotSpec(spec) - protoSpec.Id = new(referee.RobotId) - protoSpec.Id.Id = new(uint32) - protoSpec.Id.Team = new(referee.Team) - *protoSpec.Id.Team = team - *protoSpec.Id.Id = uint32(id) - protoSpecs = append(protoSpecs, protoSpec) - } - r.sendConfig(protoSpecs) - r.appliedTeams[team] = teamName + r.applySpecs(team, teamName, spec) + } else if spec, ok := r.teamRobotSpecs.Teams["Unknown"]; ok { + log.Printf("Team %v not found, using fallback", teamName) + r.applySpecs(team, teamName, spec) + } else { + log.Printf("Team %v not found and also no fallback found", teamName) } } } +func (r *RobotSpecHandler) applySpecs(team referee.Team, teamName string, spec RobotSpec) { + var protoSpecs []*RobotSpecs + for id := 0; id < 16; id++ { + protoSpec := mapRobotSpec(spec) + protoSpec.Id = new(referee.RobotId) + protoSpec.Id.Id = new(uint32) + protoSpec.Id.Team = new(referee.Team) + *protoSpec.Id.Team = team + *protoSpec.Id.Id = uint32(id) + protoSpecs = append(protoSpecs, protoSpec) + } + r.sendConfig(protoSpecs) + r.appliedTeams[team] = teamName +} + func (r *RobotSpecHandler) sendConfig(robotSpec []*RobotSpecs) { log.Printf("Sending robot spec %v", robotSpec)