f1_api/packet/
participants.rs

1//! Data about all participants in a session
2//!
3//! The F1 games provide information about each participant in a session, for example their name,
4//! team, and nationality. The data is updated every 5 seconds.
5
6use crate::packet::header::Header;
7use derive_new::new;
8use getset::{CopyGetters, Getters};
9
10/// Controller of a car
11///
12/// Cars can either be controlled by a human player or the AI.
13#[derive(Debug, PartialEq, Copy, Clone, Eq, Ord, PartialOrd, Hash)]
14pub enum Controller {
15    AI,
16    Human,
17}
18
19impl Default for Controller {
20    fn default() -> Self {
21        Controller::AI
22    }
23}
24
25/// Drivers that appear in the F1 games
26///
27/// The F1 games feature a long list of drivers that appear in the games. Not every driver is
28/// available in every game, and some drivers might be in a F2 championship in one game, and in F1
29/// in the next.
30#[derive(Debug, PartialEq, Copy, Clone, Eq, Ord, PartialOrd, Hash)]
31pub enum Driver {
32    AlainForest,
33    AlessioLorandi,
34    AlexMurray,
35    AlexanderAlbon,
36    AnthoineHubert,
37    AntonioFuoco,
38    AntonioGiovinazzi,
39    ArjunMaini,
40    ArronBarnes,
41    ArtemMarkelov,
42    BenjaminCoppens,
43    CallistoCalabresi,
44    CallumIlott,
45    CarlosSainz,
46    CharlesLeclerc,
47    DanielJones,
48    DanielRicciardo,
49    DaniilKvyat,
50    DorianBoccolacci,
51    EstoSaari,
52    FlavioNieves,
53    GeorgeRussell,
54    GertWaldmuller,
55    GuanyaZhou,
56    GuilianoAlesi,
57    HowardClarke,
58    IgorCorreia,
59    JackAitken,
60    JackTremblay,
61    JayLetourneau,
62    JonasSchiffer,
63    JordanKing,
64    JuanManuelCorrea,
65    JulianQuesada,
66    KevinMagnussen,
67    KimiRaikkonen,
68    KlimekMichalski,
69    LanceStroll,
70    LandoNorris,
71    LewisHamilton,
72    LouisDeletraz,
73    LucaGhiotto,
74    LucasRoth,
75    MahaveerRaghunathan,
76    MarieLaursen,
77    MartinGiles,
78    MaxVerstappen,
79    MaximilianGunther,
80    MickSchumacher,
81    NaotaIzum,
82    NicholasLatifi,
83    NicoHulkenburg,
84    NikitaMazepin,
85    NikoKari,
86    NireiFukuzumi,
87    NoahVisser,
88    NobuharuMatsushita,
89    NyckDeVries,
90    PeterBelousov,
91    PierreGasly,
92    RalphBoschung,
93    RashidNair,
94    RobertKubica,
95    RobertoMerhi,
96    RomainGrosjean,
97    RubenMeijer,
98    SantiagoMoreno,
99    SeanGelael,
100    SebastianVettel,
101    SergioPerez,
102    SergioSetteCamara,
103    SophieLevasseur,
104    TadasukeMakino,
105    TatianaCalderon,
106    ValtteriBottas,
107    WilheimKaufmann,
108    YasarAtiyeh,
109}
110
111impl Default for Driver {
112    fn default() -> Self {
113        // Open a PR to change this and I will block you!
114        Driver::NicoHulkenburg
115    }
116}
117
118/// Teams that appear in the F1 games
119///
120/// The F1 games feature a long list of teams that appear in the games, with some teams only being
121/// available in certain games.
122#[derive(Debug, PartialEq, Copy, Clone, Eq, Ord, PartialOrd, Hash)]
123pub enum Team {
124    ARTGrandPrix,
125    AlfaRomeo,
126    Arden2019,
127    ArtGP2019,
128    BWTArden,
129    Brawn2009,
130    Campos2019,
131    CamposVexatecRacing,
132    Carlin,
133    Carlin2019,
134    CharouzRacingSystem,
135    DAMS,
136    Dams2019,
137    Ferrari,
138    Ferrari1976,
139    Ferrari1979,
140    Ferrari1990,
141    Ferrari1995,
142    Ferrari2002,
143    Ferrari2004,
144    Ferrari2007,
145    Ferrari2010,
146    Haas,
147    Lotus1972,
148    Lotus1978,
149    MPMotorsport,
150    MPMotorsport2019,
151    McLaren,
152    McLaren1976,
153    McLaren1982,
154    McLaren1988,
155    McLaren1990,
156    McLaren1991,
157    McLaren1998,
158    McLaren2010,
159    Mercedes,
160    Pertamina,
161    Prema2019,
162    RacingPoint,
163    RedBull2010,
164    RedBullRacing,
165    Renault,
166    Renault2006,
167    RussianTime,
168    SauberJuniorCharouz2019,
169    ToroRosso,
170    Trident,
171    Trident2019,
172    UniVirtuosi2019,
173    Williams,
174    Williams1992,
175    Williams1996,
176    Williams2003,
177}
178
179impl Default for Team {
180    fn default() -> Self {
181        // We don't really have a choice in the hybrid area.
182        Team::Mercedes
183    }
184}
185
186/// Nationalities that appear in the F1 games
187///
188/// The F1 games feature a long list of drivers and teams, all of which have different
189/// nationalities.
190#[derive(Debug, PartialEq, Copy, Clone, Eq, Ord, PartialOrd, Hash)]
191pub enum Nationality {
192    American,
193    Argentinean,
194    Australian,
195    Austrian,
196    Azerbaijani,
197    Bahraini,
198    Belgian,
199    Bolivian,
200    Brazilian,
201    British,
202    Bulgarian,
203    Cameroonian,
204    Canadian,
205    Chilean,
206    Chinese,
207    Colombian,
208    CostaRican,
209    Croatian,
210    Cypriot,
211    Czech,
212    Danish,
213    Dutch,
214    Ecuadorian,
215    Emirian,
216    English,
217    Estonian,
218    Finnish,
219    French,
220    German,
221    Ghanaian,
222    Greek,
223    Guatemalan,
224    Honduran,
225    HongKonger,
226    Hungarian,
227    Icelander,
228    Indian,
229    Indonesian,
230    Irish,
231    Israeli,
232    Italian,
233    Jamaican,
234    Japanese,
235    Jordanian,
236    Kuwaiti,
237    Latvian,
238    Lebanese,
239    Lithuanian,
240    Luxembourger,
241    Malaysian,
242    Maltese,
243    Mexican,
244    Monegasque,
245    NewZealander,
246    Nicaraguan,
247    NorthKorean,
248    NorthernIrish,
249    Norwegian,
250    Omani,
251    Pakistani,
252    Panamanian,
253    Paraguayan,
254    Peruvian,
255    Polish,
256    Portuguese,
257    Qatari,
258    Romanian,
259    Russian,
260    Salvadoran,
261    Saudi,
262    Scottish,
263    Serbian,
264    Singaporean,
265    Slovakian,
266    Slovenian,
267    SouthAfrican,
268    SouthKorean,
269    Spanish,
270    Swedish,
271    Swiss,
272    Thai,
273    Turkish,
274    Ukrainian,
275    Uruguayan,
276    Venezuelan,
277    Welsh,
278}
279
280impl Default for Nationality {
281    fn default() -> Self {
282        // Greetings from the Nürburg!
283        Nationality::German
284    }
285}
286
287/// Privacy setting for telemetry data
288///
289/// In multiplayer sessions, only the player's telemetry data is broadcast over UDP. Telemetry data
290/// of other cars is restricted to prevent players gaining an unfair advantage.
291#[derive(Debug, PartialEq, Copy, Clone, Eq, Ord, PartialOrd, Hash)]
292pub enum TelemetryPrivacy {
293    Public,
294    Restricted,
295}
296
297impl Default for TelemetryPrivacy {
298    fn default() -> Self {
299        TelemetryPrivacy::Public
300    }
301}
302
303/// Data about a participant in the session
304///
305/// The F1 games publish data for each participant in a session that identifies them. This data
306/// includes the participant's name, team, and nationality among others.
307#[derive(
308    new, Debug, CopyGetters, Getters, PartialEq, Clone, Eq, Ord, PartialOrd, Hash, Default,
309)]
310pub struct Participant {
311    /// Returns the type of controller.
312    #[getset(get_copy = "pub")]
313    controller: Controller,
314
315    /// Returns the driver.
316    #[getset(get_copy = "pub")]
317    driver: Driver,
318
319    /// Returns the participant's team.
320    #[getset(get_copy = "pub")]
321    team: Team,
322
323    /// Returns the number of the participant's car.
324    #[getset(get_copy = "pub")]
325    race_number: u8,
326
327    /// Returns the participant's nationality.
328    #[getset(get_copy = "pub")]
329    nationality: Nationality,
330
331    /// Returns the participant's name.
332    ///
333    /// In single player sessions, the AI is always named after the driver. In multiplayer sessions
334    /// on PC, a player's SteamID or LAN name is used. On PlayStation, the LAN name is used. On
335    /// Xbox, the driver name is always used.
336    #[getset(get = "pub")]
337    name: String,
338
339    /// Returns the privacy setting for the participant's telemetry data.
340    #[getset(get_copy = "pub")]
341    telemetry_privacy: Option<TelemetryPrivacy>,
342}
343
344/// Packet containing information about each participant in the session
345///
346/// The F1 games provide information about each participant in a session, for example their name,
347/// team, and nationality. The data is updated every 5 seconds.
348#[derive(new, Debug, CopyGetters, Getters, PartialEq, Clone, Eq, Ord, PartialOrd, Hash)]
349pub struct ParticipantsPacket {
350    /// Returns the packet header prefixing the participants packet.
351    #[getset(get = "pub")]
352    header: Header,
353
354    /// Returns the number of active participant in the session.
355    ///
356    /// The number of active participants in the packet should match the number of cars on the HUD
357    /// in-game.
358    #[getset(get_copy = "pub")]
359    active_participants_count: u8,
360
361    /// Returns the participants in the session.
362    ///
363    /// As is the case in other packets, the participants packet always contain 20 entries. This is
364    /// also the case when there are less then 20 active participants in the session.
365    #[getset(get = "pub")]
366    participants: Vec<Participant>,
367}