coastline 0.0.4
Loading...
Searching...
No Matches
racesession.h
Go to the documentation of this file.
1#pragma once
2
9
10#include <array>
11#include <filesystem>
12#include <optional>
13#include <vector>
14
15#include "common/types.h"
16#include "raceview.h"
17
18namespace coastline {
19
21constexpr int PC_RECORD_TRACKS = 15;
22
24constexpr int RESULT_LAPS = 12;
25
42
78
88
101
111
114public:
116 RaceSession() = default;
120 RaceSession(const RaceSession &) = delete;
123
133 void Start(const RaceSetup &setup, const std::filesystem::path &music, bool cdAudio);
134
141
143 void Abandon();
144
146 const RaceResults &Results() const;
149 return m_cameraChoices;
150 }
151
154 bool SfxVolumeAdjusted() const {
155 return m_sfxVolumeAdjusted;
156 }
157
158private:
159 void StopMusic();
160 void ReadResults();
161 void HoldSoundUntilShown();
162
163 RaceResults m_results;
164 std::vector<u8> m_consoleGhostRecording;
165 std::array<int, 2> m_cameraChoices{-1, -1};
166 bool m_musicStarted = false;
167 bool m_waitForStart = false;
168 bool m_autopilot = false;
169 bool m_soundHeld = false;
170 int m_previousSfxVolume = 0;
171 bool m_sfxVolumeAdjusted = false;
172};
173
179
185
191
192} // namespace coastline
RaceSession()=default
Prepare an inactive session without starting a race or music.
std::array< int, 2 > CameraChoices() const
Definition racesession.h:148
void Abandon()
End the race that Start() started without running it, and stop its music.
bool SfxVolumeAdjusted() const
Definition racesession.h:154
~RaceSession()
Release the session's race music reference before the race music context is destroyed.
void Start(const RaceSetup &setup, const std::filesystem::path &music, bool cdAudio)
Start a race as the front end of the PC release starts one.
RaceSession & operator=(const RaceSession &)=delete
Prevent assignment of race progress and active engine resources.
const RaceResults & Results() const
RaceSession(const RaceSession &)=delete
Prevent copying race progress and active engine resources.
RaceEnd Step()
Run one frame of the race, a 30th of a second.
Definition assetimport.h:11
std::vector< RaceCar > RaceCars()
constexpr int RESULT_LAPS
The most laps of a race the results record.
Definition racesession.h:24
@ Credits
Definition menus.h:136
constexpr int PC_RECORD_TRACKS
Track record slots in race-engine order, including the SDL Bonus Track.
Definition racesession.h:21
std::array< int, 2 > RaceVolumeLevels()
@ Running
Definition setupwizard.h:179
int RaceTrack()
RaceEnd
How a race ends.
Definition racesession.h:103
@ SeasonMenu
Definition racesession.h:107
@ Menu
Definition racesession.h:106
@ Results
Definition racesession.h:105
The view of a race of the PC release: the converted track and car drawn where the race engine places ...
How a player finished a race.
Definition racesession.h:80
int position
Definition racesession.h:82
int lap
Definition racesession.h:81
f32 bestLapTime
Definition racesession.h:85
f32 totalTime
Definition racesession.h:84
std::array< f32, RESULT_LAPS > lapTimes
Definition racesession.h:86
int bestLap
Definition racesession.h:83
The car and the setup of a player.
Definition racesession.h:27
int car
Definition racesession.h:28
std::optional< std::filesystem::path > images
The images of the car with the custom decals of the player, or none for the asset pack.
Definition racesession.h:34
int camera
Definition racesession.h:40
int suspension
Definition racesession.h:32
std::optional< std::array< u8, 3 > > color
The colour of the paint, from the car select screen or the custom decals, or none for the colour of t...
Definition racesession.h:37
int tires
Definition racesession.h:31
bool otherLook
Whether the car races in its other look, as Vehicle.otherLook of the console.
Definition racesession.h:39
int handling
Definition racesession.h:29
int transmission
Definition racesession.h:30
The results of a race, as the race engine records them.
Definition racesession.h:90
std::vector< u8 > ghostRecording
The input of the first player of a time attack up to the finish, its header first,...
Definition racesession.h:97
std::array< f32, PC_RECORD_TRACKS > raceRecords
Definition racesession.h:94
int totalLaps
Definition racesession.h:91
std::array< RacePlayerResult, 2 > players
Definition racesession.h:92
std::vector< u8 > ghostFrames
The frames of the race engine recorded with ghostRecording, GHOST_FRAME_SIZE bytes each.
Definition racesession.h:99
std::array< f32, PC_RECORD_TRACKS > lapRecords
Definition racesession.h:93
What a race is, in the terms of the race engine.
Definition racesession.h:44
int track
Definition racesession.h:47
std::array< f32, PC_RECORD_TRACKS > raceRecords
The best race on each track of the engine, or 0 for none.
Definition racesession.h:59
s32 championshipFlags
Definition racesession.h:55
bool autopilot
Whether the computer drives the car of the first player, for unattended checks.
Definition racesession.h:64
int gameMode
Definition racesession.h:45
int musicTrack
The engine track selecting XM music, or -1 to use the race track.
Definition racesession.h:49
std::vector< u8 > ghostFrames
The frames of the race engine the ghost car of a time attack plays, or none for no ghost.
Definition racesession.h:76
int players
Definition racesession.h:46
int round
Definition racesession.h:54
int weather
Definition racesession.h:50
int season
Definition racesession.h:53
std::array< RacePlayerSetup, 2 > cars
Definition racesession.h:52
int laps
Definition racesession.h:51
int musicVolume
The level of the music, from 0 to 9.
Definition racesession.h:66
bool speedInMph
Whether speeds show in miles an hour rather than kilometres.
Definition racesession.h:70
bool waitForStart
Whether the race waits for the start binding before the countdown, as the PC release does.
Definition racesession.h:62
int sfxVolume
The level of the sound effects, from 0 to 9.
Definition racesession.h:68
std::array< f32, PC_RECORD_TRACKS > lapRecords
The best lap on each track of the engine, or 0 for none.
Definition racesession.h:57
std::array< u8, 8 > ghostHeader
The header of the recording of the ghost car of a time attack, as the console writes it.
Definition racesession.h:72
std::vector< u8 > ghostRecording
Console controller recording, including its header, for ghosts without recorded poses.
Definition racesession.h:74
The integer and floating-point types of the console, for headers shared with Windows.
float f32
Definition ultratypes.h:38
int s32
Definition ultratypes.h:25