Skip to content

Commit 5f4cb32

Browse files
committed
Switch timestamp fields from 32 to 64 bit
This is a wire-compatible change. The maximum duration that can be stored in a signed 32bit integer in microsecond precision is about 70 minutes. If the target language has no support for signed integers, it is only 35 minutes. With that, the stage time can easily run into an overflow.
1 parent 1eb18fd commit 5f4cb32

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

internal/app/publish/messagegenerator.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,15 @@ func newRefereeMessage() (m *state.Referee) {
145145
m.SourceIdentifier = new(string)
146146
m.PacketTimestamp = new(uint64)
147147
m.Stage = new(state.Referee_Stage)
148-
m.StageTimeLeft = new(int32)
148+
m.StageTimeLeft = new(int64)
149149
m.Command = new(state.Referee_Command)
150150
m.CommandCounter = new(uint32)
151151
m.CommandTimestamp = new(uint64)
152152
m.Yellow = newTeamInfo()
153153
m.Blue = newTeamInfo()
154154
m.BlueTeamOnPositiveHalf = new(bool)
155155
m.NextCommand = new(state.Referee_Command)
156-
m.CurrentActionTimeRemaining = new(int32)
156+
m.CurrentActionTimeRemaining = new(int64)
157157
return
158158
}
159159

@@ -189,6 +189,6 @@ func unsigned(v int) uint32 {
189189
return uint32(v)
190190
}
191191

192-
func microseconds(dur *durationpb.Duration) int32 {
193-
return int32(dur.Seconds)*1_000_000 + dur.Nanos/1000
192+
func microseconds(dur *durationpb.Duration) int64 {
193+
return int64(dur.Seconds)*1_000_000 + int64(dur.Nanos/1000)
194194
}

internal/app/state/ssl_gc_referee_message.pb.go

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

proto/ssl_gc_referee_message.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ message Referee {
7171
//
7272
// If the stage runs over its specified time, this value
7373
// becomes negative.
74-
optional sint32 stage_time_left = 3;
74+
optional sint64 stage_time_left = 3;
7575

7676
// These are the "fine" states of play on the field.
7777
enum Command {
@@ -205,7 +205,7 @@ message Referee {
205205
// * free kicks
206206
// * kickoff, penalty kick, force start
207207
// * ball placement
208-
optional int32 current_action_time_remaining = 15;
208+
optional int64 current_action_time_remaining = 15;
209209
}
210210

211211
// List of matching proposals

0 commit comments

Comments
 (0)