Skip to content

Commit

Permalink
Merge pull request #629 from cj123/race-weekend-practice-placeholder-…
Browse files Browse the repository at this point in the history
…entrants

improve entrylist handling when starting race weekend practice sessions
  • Loading branch information
cj123 authored Nov 4, 2019
2 parents a586d6d + b351d34 commit 68baf52
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Fixes:
* Fixes an issue where drivers who switched teams mid-Championship had an incorrect number of races shown for their teams.
* Championship event inheritance now correctly uses the previous event setup, not the first event setup
* Fixes an issue where tyres did not show correctly in Session configuration for Championship Race Weekend events.
* Fixes an issue where placeholder entrants were incorrectly added to the entrylist of a Race Weekend practice session.

---

Expand Down
16 changes: 14 additions & 2 deletions cmd/server-manager/views/pages/race-weekend/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,23 @@ <h2>Sessions</h2>
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="/race-weekend/{{ $.RaceWeekend.ID.String }}/session/{{ $session.ID.String }}/practice">Start Practice Session</a>
<a class="dropdown-item"
href="/race-weekend/{{ $.RaceWeekend.ID.String }}/session/{{ $session.ID.String }}/practice"
data-toggle="tooltip"
title="Loads the configured session onto the server as a 2 hour looping practice, but doesn't track its progress as a Race Weekend session."
>
Start Practice Session
</a>
</div>
</div>
{{ else }}
<a class="btn btn-success btn-sm" href="/race-weekend/{{ $.RaceWeekend.ID.String }}/session/{{ $session.ID.String }}/practice">Start Practice Session</a>
<a class="btn btn-success btn-sm"
href="/race-weekend/{{ $.RaceWeekend.ID.String }}/session/{{ $session.ID.String }}/practice"
data-toggle="tooltip"
title="Loads the configured session onto the server as a 2 hour looping practice, but doesn't track its progress as a Race Weekend session."
>
Start Practice Session
</a>
{{ end }}

<button type="button" class="btn btn-info btn-sm dropdown-toggle popover-external-html" data-placement="bottom"
Expand Down
43 changes: 21 additions & 22 deletions race_weekend_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,22 +446,9 @@ func (rwm *RaceWeekendManager) StartSession(raceWeekendID string, raceWeekendSes

entryList := raceWeekendEntryList.AsEntryList()

session.RaceConfig.MaxClients = len(entryList)
session.RaceConfig.Cars = strings.Join(entryList.CarIDs(), ";")
session.RaceConfig.LockedEntryList = 1
session.RaceConfig.PickupModeEnabled = 0

// all race weekend sessions must be open so players can join
for _, acSession := range session.RaceConfig.Sessions {
acSession.IsOpen = 1
}

overridePassword := session.OverridePassword
replacementPassword := session.ReplacementPassword

if raceWeekend.HasLinkedChampionship() {
overridePassword = raceWeekend.Championship.OverridePassword
replacementPassword = raceWeekend.Championship.ReplacementPassword
if isPracticeSession && !raceWeekend.SessionCanBeRun(session) {
// practice sessions run with the whole race weekend entry list if they are not yet available
entryList = raceWeekend.GetEntryList()
}

for k, entrant := range entryList {
Expand All @@ -486,6 +473,24 @@ func (rwm *RaceWeekendManager) StartSession(raceWeekendID string, raceWeekendSes
}
}

session.RaceConfig.MaxClients = len(entryList)
session.RaceConfig.Cars = strings.Join(entryList.CarIDs(), ";")
session.RaceConfig.LockedEntryList = 1
session.RaceConfig.PickupModeEnabled = 0

// all race weekend sessions must be open so players can join
for _, acSession := range session.RaceConfig.Sessions {
acSession.IsOpen = 1
}

overridePassword := session.OverridePassword
replacementPassword := session.ReplacementPassword

if raceWeekend.HasLinkedChampionship() {
overridePassword = raceWeekend.Championship.OverridePassword
replacementPassword = raceWeekend.Championship.ReplacementPassword
}

raceWeekendRaceEvent := &ActiveRaceWeekend{
Name: raceWeekend.Name,
RaceWeekendID: raceWeekend.ID,
Expand All @@ -511,12 +516,6 @@ func (rwm *RaceWeekendManager) StartSession(raceWeekendID string, raceWeekendSes
session.RaceConfig.LoopMode = 1

raceWeekendRaceEvent.IsPracticeSession = true

if !raceWeekend.SessionCanBeRun(session) {
// practice sessions run with the whole race weekend entry list if they are not yet available
entryList = raceWeekend.GetEntryList()
}

raceWeekendRaceEvent.RaceConfig = session.RaceConfig
raceWeekendRaceEvent.EntryList = entryList

Expand Down

0 comments on commit 68baf52

Please sign in to comment.