Skip to content

Commit 5c9e3d7

Browse files
committed
bugfix: Keep compatible to older clients
GameEvent.type was a required field, so new enum values causes the protobuf parser to raise an error. To avoid errors on older clients, game events and proposed game events were added to new lists in the Referee message. That way, old clients will not receive any game events, but they will also not crash.
1 parent bc4520c commit 5c9e3d7

File tree

7 files changed

+517
-559
lines changed

7 files changed

+517
-559
lines changed

internal/app/publish/datamapper.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,17 @@ import (
88
"time"
99
)
1010

11-
func mapProposals(groups []*state.ProposalGroup) []*state.ProposedGameEvent {
12-
var mappedEvents []*state.ProposedGameEvent
11+
func mapProposals(groups []*state.ProposalGroup) []*state.GameEventProposalGroup {
12+
var mappedGroups []*state.GameEventProposalGroup
1313
for _, group := range groups {
14+
mappedGroup := state.GameEventProposalGroup{}
15+
mappedGroup.GameEvent = []*state.GameEvent{}
1416
for _, proposal := range group.Proposals {
15-
proposer := ""
16-
if len(proposal.GameEvent.Origin) > 0 {
17-
proposer = proposal.GameEvent.Origin[0]
18-
}
19-
var validUntil uint64
20-
//noinspection GoDeprecation
21-
mappedEvents = append(mappedEvents, &state.ProposedGameEvent{
22-
ValidUntil: &validUntil, // required in protobuf ref msg... Add zero value
23-
ProposerId: &proposer,
24-
GameEvent: proposal.GameEvent,
25-
})
17+
mappedGroup.GameEvent = append(mappedGroup.GameEvent, proposal.GameEvent)
2618
}
19+
mappedGroups = append(mappedGroups, &mappedGroup)
2720
}
28-
return mappedEvents
21+
return mappedGroups
2922
}
3023

3124
func mapCommand(command *state.Command) (c *state.Referee_Command) {

internal/app/publish/messagegenerator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (g *MessageGenerator) StateToRefereeMessage(matchState *state.State) (r *st
9393
r = newRefereeMessage()
9494
r.DesignatedPosition = mapLocation(matchState.PlacementPos)
9595
r.GameEvents = matchState.GameEvents
96-
r.ProposedGameEvents = mapProposals(matchState.ProposalGroups)
96+
r.GameEventProposals = mapProposals(matchState.ProposalGroups)
9797

9898
r.Command = mapCommand(matchState.Command)
9999
*r.CommandCounter = g.commandCounter

internal/app/state/ssl_gc_game_event.pb.go

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

internal/app/state/ssl_gc_referee_message.pb.go

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

proto/ssl_gc_game_event.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import "ssl_gc_geometry.proto";
1313
// An autoRef should ideally set all fields, except if there are good reasons to not do so.
1414
message GameEvent {
1515

16-
required Type type = 40;
16+
optional Type type = 40;
1717

1818
// The origins of this game event.
1919
// Empty, if it originates from game controller.

proto/ssl_gc_referee_message.proto

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,12 @@ message Referee {
183183

184184
// All game events that were detected since the last RUNNING state.
185185
// Will be cleared as soon as the game is continued.
186-
repeated GameEvent game_events = 13;
186+
reserved 13;
187+
repeated GameEvent game_events = 16;
187188

188189
// All non-finished proposed game events that may be processed next.
189-
repeated ProposedGameEvent proposed_game_events = 14;
190+
reserved 14;
191+
repeated GameEventProposalGroup game_event_proposals = 17;
190192

191193
// The time in microseconds that is remaining until the current action times out
192194
// The time will not be reset. It can get negative.
@@ -198,12 +200,10 @@ message Referee {
198200
optional int32 current_action_time_remaining = 15;
199201
}
200202

201-
message ProposedGameEvent {
202-
// The UNIX timestamp when the game event proposal will time out, in microseconds.
203-
// Deprecated: Value will always be zero
204-
required uint64 valid_until = 1 [deprecated = true];
205-
// The identifier of the proposer.
206-
required string proposer_id = 2;
203+
// List of matching proposals
204+
message GameEventProposalGroup {
207205
// The proposed game event.
208-
required GameEvent game_event = 3;
206+
repeated GameEvent game_event = 1;
207+
// Whether the proposal group was accepted
208+
optional bool accepted = 2;
209209
}

0 commit comments

Comments
 (0)