Skip to content

Commit

Permalink
Merge pull request #838 from JustaPenguin/time-attack-fix
Browse files Browse the repository at this point in the history
start time attack events properly if initiated from the custom race f…
  • Loading branch information
Hecrer authored Apr 10, 2020
2 parents 4fae807 + 0abbd2c commit 08822fb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion cmd/server-manager/views/pages/results/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ <h1 class="text-center">Results</h1>
{{ $result.GetDate }}
</td>
<td>
{{ $result.Type }}
{{ if $result.IsTimeAttack }}
Time Attack
{{ else }}
{{ $result.Type }}
{{ end }}
</td>
<td>
{{ prettify $result.TrackName false }}
Expand Down
2 changes: 1 addition & 1 deletion cmd/server-manager/views/pages/results/result.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{{ $useMPH := .UseMPH }}

<h1 class="text-center">{{ prettify $sessionResults.TrackName false }} {{ with $sessionResults.TrackConfig }} - {{ prettify . true }} {{ end }}</h1>
<div class="text-center">{{ $sessionResults.GetDate }}</div>
<div class="text-center">{{ if $sessionResults.IsTimeAttack }}Time Attack - {{ end }}{{ $sessionResults.GetDate }}</div>

<a class="btn btn-primary float-left" href="/results">
Back to Results
Expand Down
5 changes: 5 additions & 0 deletions race_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,11 @@ func (rm *RaceManager) SetupCustomRace(r *http.Request) error {
return nil
}

if race.RaceConfig.TimeAttack && Premium() {
logrus.Info("Time Attack event started")
rm.raceControl.currentTimeAttackEvent = race
}

if saveAsPresetWithoutStartingRace {
return nil
}
Expand Down
4 changes: 4 additions & 0 deletions results.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ func (s *SessionResults) Anonymize() {
}
}

func (s *SessionResults) IsTimeAttack() bool {
return strings.HasSuffix(s.SessionFile, timeAttackSuffix)
}

func AnonymiseDriverGUID(guid string) string {
hasher := md5.New()
_, _ = hasher.Write([]byte(guid))
Expand Down

0 comments on commit 08822fb

Please sign in to comment.