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 6
6
"github.com/RoboCup-SSL/ssl-game-controller/pkg/timer"
7
7
"github.com/pkg/errors"
8
8
"log"
9
+ "math"
9
10
"math/rand"
10
11
"strconv"
11
12
"strings"
@@ -348,9 +349,12 @@ func (e *Engine) Process(event Event) error {
348
349
if err != nil {
349
350
return err
350
351
}
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
+ }
354
358
return nil
355
359
}
356
360
@@ -458,12 +462,21 @@ func (e *Engine) processModify(m *EventModifyValue) error {
458
462
return errors .Errorf ("Game event id %d is too large." , i )
459
463
}
460
464
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
+ }
461
471
} else if err := e .processTeamModify (m ); err != nil {
462
472
return err
463
473
}
464
474
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
+ }
467
480
return nil
468
481
}
469
482
Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ type EventModifyValue struct {
122
122
GameEventBehavior * EventModifyGameEventBehavior `json:"gameEventBehavior,omitempty" yaml:"gameEventBehavior"`
123
123
BotSubstitutionIntend * bool `json:"botSubstitutionIntend,omitempty" yaml:"botSubstitutionIntend"`
124
124
RemoveGameEvent * int `json:"removeGameEvent,omitempty" yaml:"removeGameEvent"`
125
+ Timestamp * int64 `json:"timestamp,omitempty" yaml:"timestamp"`
125
126
}
126
127
127
128
func (m EventModifyValue ) String () string {
You can’t perform that action at this time.
0 commit comments