/
config.go
195 lines (175 loc) · 8.15 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
package instance
import "time"
const (
accwebConfigJsonName = "accwebConfig.json"
configurationJsonName = "configuration.json"
settingsJsonName = "settings.json"
eventJsonName = "event.json"
eventRulesJsonName = "eventRules.json"
entrylistJsonName = "entrylist.json"
bopJsonName = "bop.json"
assistRulesJsonName = "assistRules.json"
configVersion = 1
WinCpuPriorityRealtime = 256
WinCpuPriorityHigh = 128
WinCpuPriorityAboveNormal = 32768
WinCpuPriorityNormal = 32
WinCpuPriorityBelowNormal = 16384
WinCpuPriorityLow = 64
)
var (
CpuPriorities = map[int]bool{
WinCpuPriorityRealtime: true,
WinCpuPriorityHigh: true,
WinCpuPriorityAboveNormal: true,
WinCpuPriorityNormal: true,
WinCpuPriorityBelowNormal: true,
WinCpuPriorityLow: true,
}
)
type AccConfigFiles struct {
Configuration ConfigurationJson `json:"configuration"`
Settings SettingsJson `json:"settings"`
Event EventJson `json:"event"`
EventRules EventRulesJson `json:"eventRules"`
Entrylist EntrylistJson `json:"entrylist"`
Bop BopJson `json:"bop"`
AssistRules AssistRulesJson `json:"assistRules"`
}
type AccWebConfigJson struct {
ID string `json:"id"`
Md5Sum string `json:"md5Sum"`
AutoStart bool `json:"autoStart"` // backward compatibility
Settings AccWebSettingsJson `json:"settings"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
type AccWebSettingsJson struct {
AutoStart bool `json:"autoStart"`
EnableAdvWinCfg bool `json:"enableAdvWindowsCfg"`
AdvWindowsCfg *AccWebAdvWindowsSettingsJson `json:"advWindowsCfg"`
}
type AccWebAdvWindowsSettingsJson struct {
CpuPriority uint `json:"cpuPriority"`
CoreAffinity uint `json:"coreAffinity"`
EnableWinFW bool `json:"enableWindowsFirewall"`
}
func (a *AccWebConfigJson) SetUpdateAt() {
a.UpdatedAt = time.Now().UTC()
}
type ConfigurationJson struct {
ConfigVersion int `json:"configVersion"`
UdpPort int `json:"udpPort"`
TcpPort int `json:"tcpPort"`
MaxConnections int `json:"maxConnections"`
RegisterToLobby int `json:"registerToLobby"`
LanDiscovery int `json:"lanDiscovery"`
PublicIP string `json:"publicIP"`
}
type SettingsJson struct {
ConfigVersion int `json:"configVersion"`
ServerName string `json:"serverName"`
Password string `json:"password"`
AdminPassword string `json:"adminPassword"`
SpectatorPassword string `json:"spectatorPassword"`
TrackMedalsRequirement int `json:"trackMedalsRequirement"`
SafetyRatingRequirement int `json:"safetyRatingRequirement"`
RacecraftRatingRequirement int `json:"racecraftRatingRequirement"`
IgnorePrematureDisconnects int `json:"ignorePrematureDisconnects"`
DumpLeaderboards int `json:"dumpLeaderboards"`
IsRaceLocked int `json:"isRaceLocked"`
RandomizeTrackWhenEmpty int `json:"randomizeTrackWhenEmpty"`
MaxCarSlots int `json:"maxCarSlots"`
CentralEntryListPath string `json:"centralEntryListPath"`
ShortFormationLap int `json:"shortFormationLap"`
AllowAutoDQ int `json:"allowAutoDQ"`
DumpEntryList int `json:"dumpEntryList"`
FormationLapType int `json:"formationLapType"`
CarGroup string `json:"carGroup"`
}
type EventJson struct {
ConfigVersion int `json:"configVersion"`
Track string `json:"track"`
PreRaceWaitingTimeSeconds int `json:"preRaceWaitingTimeSeconds"`
SessionOverTimeSeconds int `json:"sessionOverTimeSeconds"`
AmbientTemp int `json:"ambientTemp"`
TrackTemp int `json:"trackTemp,omitempty"`
CloudLevel float64 `json:"cloudLevel"`
Rain float64 `json:"rain"`
WeatherRandomness int `json:"weatherRandomness"`
Sessions []SessionSettings `json:"sessions"`
MetaData string `json:"metaData"`
PostQualySeconds int `json:"postQualySeconds"`
PostRaceSeconds int `json:"postRaceSeconds"`
SimracerWeatherConditions int `json:"simracerWeatherConditions"`
IsFixedConditionQualification int `json:"isFixedConditionQualification"`
}
type EventRulesJson struct {
ConfigVersion int `json:"configVersion"`
QualifyStandingType int `json:"qualifyStandingType"`
PitWindowLengthSec int `json:"pitWindowLengthSec"`
DriverStintTimeSec int `json:"driverStintTimeSec"`
MandatoryPitstopCount int `json:"mandatoryPitstopCount"`
MaxTotalDrivingTime int `json:"maxTotalDrivingTime"`
MaxDriversCount int `json:"maxDriversCount"`
IsRefuellingAllowedInRace bool `json:"isRefuellingAllowedInRace"`
IsRefuellingTimeFixed bool `json:"isRefuellingTimeFixed"`
IsMandatoryPitstopRefuellingRequired bool `json:"isMandatoryPitstopRefuellingRequired"`
IsMandatoryPitstopTyreChangeRequired bool `json:"isMandatoryPitstopTyreChangeRequired"`
IsMandatoryPitstopSwapDriverRequired bool `json:"isMandatoryPitstopSwapDriverRequired"`
TyreSetCount int `json:"tyreSetCount"`
}
type SessionSettings struct {
HourOfDay int `json:"hourOfDay"`
DayOfWeekend int `json:"dayOfWeekend"`
TimeMultiplier int `json:"timeMultiplier"`
SessionType string `json:"sessionType"`
SessionDurationMinutes int `json:"sessionDurationMinutes"`
}
type EntrylistJson struct {
ConfigVersion int `json:"configVersion"`
Entries []EntrySettings `json:"entries"`
ForceEntryList int `json:"forceEntryList"`
}
type EntrySettings struct {
Drivers []DriverSettings `json:"drivers"`
RaceNumber *int `json:"raceNumber,omitempty"`
ForcedCarModel *int `json:"forcedCarModel,omitempty"`
OverrideDriverInfo int `json:"overrideDriverInfo"`
IsServerAdmin *int `json:"isServerAdmin,omitempty"`
CustomCar *string `json:"customCar,omitempty"`
OverrideCarModelForCustomCar int `json:"overrideCarModelForCustomCar"`
BallastKg *int `json:"ballastKg,omitempty"`
Restrictor *int `json:"restrictor,omitempty"`
DefaultGridPosition *int `json:"defaultGridPosition,omitempty"`
}
type DriverSettings struct {
FirstName *string `json:"firstName,omitempty"`
LastName *string `json:"lastName,omitempty"`
ShortName *string `json:"shortName,omitempty"`
DriverCategory *int `json:"driverCategory,omitempty"`
PlayerID string `json:"playerID"`
Nationality *int `json:"nationality,omitempty"`
}
type BopJson struct {
ConfigVersion int `json:"configVersion"`
Entries []BopSettings `json:"entries"`
}
type BopSettings struct {
Track string `json:"track"`
CarModel int `json:"carModel"`
BallastKg int `json:"ballastKg"`
Restrictor int `json:"restrictor"`
}
type AssistRulesJson struct {
ConfigVersion int `json:"configVersion"`
StabilityControlLevelMax int `json:"stabilityControlLevelMax"`
DisableAutosteer int `json:"disableAutosteer"`
DisableAutoLights int `json:"disableAutoLights"`
DisableAutoWiper int `json:"disableAutoWiper"`
DisableAutoEngineStart int `json:"disableAutoEngineStart"`
DisableAutoPitLimiter int `json:"disableAutoPitLimiter"`
DisableAutoGear int `json:"disableAutoGear"`
DisableAutoClutch int `json:"disableAutoClutch"`
DisableIdealLine int `json:"disableIdealLine"`
}