File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 66 "github.com/RoboCup-SSL/ssl-game-controller/pkg/timer"
77 "github.com/pkg/errors"
88 "log"
9+ "math"
910 "math/rand"
1011 "strconv"
1112 "strings"
@@ -348,9 +349,12 @@ func (e *Engine) Process(event Event) error {
348349 if err != nil {
349350 return err
350351 }
351- e .updateMaxBots ()
352- e .updateNextCommand ()
353- e .appendHistory ()
352+ if event .Modify == nil || event .Modify .Timestamp == nil {
353+ // do not execute this for timestamp updates
354+ e .updateMaxBots ()
355+ e .updateNextCommand ()
356+ e .appendHistory ()
357+ }
354358 return nil
355359}
356360
@@ -458,12 +462,21 @@ func (e *Engine) processModify(m *EventModifyValue) error {
458462 return errors .Errorf ("Game event id %d is too large." , i )
459463 }
460464 e .State .GameEvents = append (e .State .GameEvents [:i ], e .State .GameEvents [i + 1 :]... )
465+ } else if m .Timestamp != nil {
466+ e .TimeProvider = timer .NewFixedTimeProviderFromNanoSeconds (* m .Timestamp )
467+ if math .Abs (e .TimeProvider ().Sub (e .LastTimeUpdate ).Seconds ()) > 1 {
468+ // reset last time update - it might be in another time range
469+ e .LastTimeUpdate = e .TimeProvider ()
470+ }
461471 } else if err := e .processTeamModify (m ); err != nil {
462472 return err
463473 }
464474
465- e .LogModify (* m )
466- log .Printf ("Processed %v" , m )
475+ if m .Timestamp == nil {
476+ // do not log timestamp modification - it will be send very often, if sent
477+ e .LogModify (* m )
478+ log .Printf ("Processed %v" , m )
479+ }
467480 return nil
468481}
469482
Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ type EventModifyValue struct {
122122 GameEventBehavior * EventModifyGameEventBehavior `json:"gameEventBehavior,omitempty" yaml:"gameEventBehavior"`
123123 BotSubstitutionIntend * bool `json:"botSubstitutionIntend,omitempty" yaml:"botSubstitutionIntend"`
124124 RemoveGameEvent * int `json:"removeGameEvent,omitempty" yaml:"removeGameEvent"`
125+ Timestamp * int64 `json:"timestamp,omitempty" yaml:"timestamp"`
125126}
126127
127128func (m EventModifyValue ) String () string {
You can’t perform that action at this time.
0 commit comments