Skip to content

Commit 54a2a53

Browse files
committed
[feature] Publish proposed game events through referee message
1 parent 9848a82 commit 54a2a53

File tree

3 files changed

+109
-96
lines changed

3 files changed

+109
-96
lines changed

internal/app/controller/publisher.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ func (p *Publisher) send() {
105105
func (p *RefMessage) setState(state *State) (republish bool) {
106106
p.referee.GameEvents = mapGameEvents(state.GameEvents)
107107
p.referee.DesignatedPosition = mapLocation(state.PlacementPos)
108+
p.referee.ProposedGameEvents = mapProposals(state.GameEventProposals)
108109

109110
*p.referee.PacketTimestamp = uint64(time.Now().UnixNano() / 1000)
110111
*p.referee.Stage = mapStage(state.Stage)
@@ -117,6 +118,18 @@ func (p *RefMessage) setState(state *State) (republish bool) {
117118
return
118119
}
119120

121+
func mapProposals(proposals []*GameEventProposal) []*refproto.ProposedGameEvent {
122+
mappedProposals := make([]*refproto.ProposedGameEvent, len(proposals))
123+
for i, proposal := range proposals {
124+
mappedProposals[i] = new(refproto.ProposedGameEvent)
125+
mappedProposals[i].ProposerId = &proposal.ProposerId
126+
mappedProposals[i].ValidUntil = new(uint64)
127+
*mappedProposals[i].ValidUntil = uint64(proposal.ValidUntil.UnixNano() / 1000)
128+
mappedProposals[i].GameEvent = proposal.GameEvent.ToProto()
129+
}
130+
return mappedProposals
131+
}
132+
120133
func (p *RefMessage) sendCommands(state *State) {
121134
newCommand := mapCommand(state.Command, state.CommandFor)
122135

pkg/refproto/ssl_referee.pb.go

Lines changed: 83 additions & 83 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/refproto/ssl_referee.proto

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,31 +164,31 @@ message Referee {
164164
optional Point designated_position = 9;
165165

166166
// Information about the direction of play.
167-
// True, if the blue team will have it's goal on the positive x-axis of the ssl-vision coordinate system
168-
// Obviously, the yellow team will play on the opposide half
169-
// For compatibility, this field is optional
167+
// True, if the blue team will have it's goal on the positive x-axis of the ssl-vision coordinate system.
168+
// Obviously, the yellow team will play on the opposide half.
169+
// For compatibility, this field is optional.
170170
optional bool blue_team_on_positive_half = 10;
171171

172-
// The game event that caused the referee command
173-
// deprecated in favor of current_game_event
172+
// The game event that caused the referee command.
173+
// deprecated in favor of current_game_event.
174174
optional Game_Event game_event = 11 [deprecated = true];
175175

176-
// The command that will be issued after the current stoppage and ball placement to continue the game
176+
// The command that will be issued after the current stoppage and ball placement to continue the game.
177177
optional Command next_command = 12;
178178

179-
// all game events that were detected since the last RUNNING state
180-
// will be cleared as soon as the game is continued
179+
// All game events that were detected since the last RUNNING state.
180+
// Will be cleared as soon as the game is continued.
181181
repeated GameEvent game_events = 13;
182182

183-
// all non-finished proposed game events that may be processed next
183+
// All non-finished proposed game events that may be processed next.
184184
repeated ProposedGameEvent proposed_game_events = 14;
185185
}
186186

187187
message ProposedGameEvent {
188-
// the UNIX timestamp when the game event was proposed
189-
required uint64 timestamp = 1;
190-
// the identifier of the proposer
188+
// The UNIX timestamp when the game event proposal will time out, in microseconds.
189+
required uint64 valid_until = 1;
190+
// The identifier of the proposer.
191191
required string proposer_id = 2;
192-
// the actual game event
192+
// The proposed game event.
193193
required GameEvent game_event = 3;
194194
}

0 commit comments

Comments
 (0)