Merge pull request #956 from JustaPenguin/sign-up-fix · JustaPenguin/assetto-server-manager@ddbaae2 · GitHub
Skip to content
This repository was archived by the owner on Aug 21, 2026. It is now read-only.

Commit ddbaae2

Browse files
authored
Merge pull request #956 from JustaPenguin/sign-up-fix
don't stop sign ups for non-acsr enabled servers
2 parents 5cb595d + 1787325 commit ddbaae2

4 files changed

Lines changed: 64 additions & 27 deletions

File tree

championship_manager.go

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -213,31 +213,33 @@ func (cm *ChampionshipManager) BuildChampionshipOpts(r *http.Request) (champions
213213
opts.Championship = championship
214214
opts.ACSREnabled = cm.acsrClient.Enabled
215215

216-
ranges, err := cm.LoadACSRRanges()
216+
if opts.ACSREnabled {
217+
ranges, err := cm.LoadACSRRanges()
217218

218-
if err != nil {
219-
logrus.WithError(err).Errorf("couldn't load ACSR skill/safety range information")
220-
} else {
221-
highestSkillCount := 0
222-
highestSafetyCount := 0
223-
224-
for _, acsrRange := range ranges {
225-
switch acsrRange.RatingType {
226-
case "skill":
227-
if acsrRange.Count > highestSkillCount {
228-
highestSkillCount = acsrRange.Count
229-
}
230-
case "safety":
231-
if acsrRange.Count > highestSafetyCount {
232-
highestSafetyCount = acsrRange.Count
219+
if err != nil {
220+
logrus.WithError(err).Errorf("couldn't load ACSR skill/safety range information")
221+
} else {
222+
highestSkillCount := 0
223+
highestSafetyCount := 0
224+
225+
for _, acsrRange := range ranges {
226+
switch acsrRange.RatingType {
227+
case "skill":
228+
if acsrRange.Count > highestSkillCount {
229+
highestSkillCount = acsrRange.Count
230+
}
231+
case "safety":
232+
if acsrRange.Count > highestSafetyCount {
233+
highestSafetyCount = acsrRange.Count
234+
}
233235
}
234236
}
235-
}
236237

237-
opts.ACSRRanges = &ACSRRanges{
238-
Ranges: ranges,
239-
HighestSkillCount: highestSkillCount,
240-
HighestSafetyCount: highestSafetyCount,
238+
opts.ACSRRanges = &ACSRRanges{
239+
Ranges: ranges,
240+
HighestSkillCount: highestSkillCount,
241+
HighestSafetyCount: highestSafetyCount,
242+
}
241243
}
242244
}
243245

@@ -1698,15 +1700,23 @@ func (cm *ChampionshipManager) HandleChampionshipSignUp(r *http.Request) (respon
16981700
return signUpResponse, false, ValidationError("Please enter a valid SteamID64.")
16991701
}
17001702

1701-
rating, err := cm.LoadACSRRating(signUpResponse.GUID)
1703+
serverOptions, err := cm.store.LoadServerOptions()
17021704

17031705
if err != nil {
1704-
logrus.WithError(err).Errorf("Couldn't load ACSR rating for guid: %s", signUpResponse.GUID)
1705-
return signUpResponse, false, ValidationError("Please register your GUID to an account with ACSR.")
1706+
return signUpResponse, false, err
17061707
}
17071708

1708-
if !championship.DriverMeetsACSRGates(rating) {
1709-
return signUpResponse, false, ValidationError("You do not meet the minimum ACSR skill/safety requirements.")
1709+
if serverOptions.EnableACSR {
1710+
rating, err := cm.LoadACSRRating(signUpResponse.GUID)
1711+
1712+
if err != nil {
1713+
logrus.WithError(err).Errorf("Couldn't load ACSR rating for guid: %s", signUpResponse.GUID)
1714+
return signUpResponse, false, ValidationError("Please register your GUID to an account with ACSR.")
1715+
}
1716+
1717+
if !championship.DriverMeetsACSRGates(rating) {
1718+
return signUpResponse, false, ValidationError("You do not meet the minimum ACSR skill/safety requirements.")
1719+
}
17101720
}
17111721

17121722
for _, entrant := range championship.SignUpForm.Responses {

championships_handler.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,30 @@ func (ch *ChampionshipsHandler) view(w http.ResponseWriter, r *http.Request) {
188188
type ACSRRatingGateMet struct {
189189
ACSRDriverRating *ACSRDriverRating `json:"acsr_driver_rating"`
190190
GateMet bool `json:"gate_met"`
191+
ACSREnabled bool `json:"acsr_enabled"`
191192
}
192193

193194
func (ch *ChampionshipsHandler) acsrRating(w http.ResponseWriter, r *http.Request) {
195+
serverOptions, err := ch.championshipManager.store.LoadServerOptions()
196+
197+
if err != nil {
198+
logrus.WithError(err).Error("acsr rating: couldn't load server options")
199+
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
200+
return
201+
}
202+
203+
if !serverOptions.EnableACSR {
204+
ratingGateMet := &ACSRRatingGateMet{
205+
ACSRDriverRating: &ACSRDriverRating{},
206+
GateMet: true,
207+
ACSREnabled: false,
208+
}
209+
210+
_ = json.NewEncoder(w).Encode(ratingGateMet)
211+
212+
return
213+
}
214+
194215
guid := chi.URLParam(r, "guid")
195216
championshipID := chi.URLParam(r, "championshipID")
196217

@@ -215,6 +236,7 @@ func (ch *ChampionshipsHandler) acsrRating(w http.ResponseWriter, r *http.Reques
215236
ratingGateMet := &ACSRRatingGateMet{
216237
ACSRDriverRating: rating,
217238
GateMet: gateMet,
239+
ACSREnabled: true,
218240
}
219241

220242
_ = json.NewEncoder(w).Encode(ratingGateMet)

cmd/server-manager/typescript/src/Championship.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ declare var CanMoveChampionshipEvents: boolean;
77
interface ACSRDriverRatingGateMet {
88
acsr_driver_rating: ACSRDriverRating;
99
gate_met: boolean;
10+
acsr_enabled: boolean;
1011
}
1112

1213
interface ACSRDriverRating {
@@ -104,6 +105,10 @@ export namespace Championship {
104105
data: "",
105106
dataType: "json"
106107
}).then((response: ACSRDriverRatingGateMet) => {
108+
if (!response.acsr_enabled) {
109+
return
110+
}
111+
107112
if (response.acsr_driver_rating == null) {
108113
let notFoundSpan = $('<span />');
109114
let notFoundLink = $(`<a />`);

cmd/server-manager/views/pages/championships/sign-up.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ <h1 class="text-center">
208208
{{ end }}
209209

210210
<div class="mt-5">
211-
<button type="submit" disabled class="btn btn-success float-right" id="register-for-championship">Register</button>
211+
<button type="submit" {{ if $championship.ACSR }}disabled id="register-for-championship"{{ end }} class="btn btn-success float-right">Register</button>
212212
</div>
213213
</form>
214214

0 commit comments

Comments
 (0)