MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / revalidateCurrentTrack

Function revalidateCurrentTrack

src/OpenLoco/src/Audio/Music.cpp:15–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13 static AudioHandle _musicHandle = AudioHandle::null;
14
15 void revalidateCurrentTrack()
16 {
17 const auto currentTrack = Jukebox::getCurrentTrack();
18 if (currentTrack == Jukebox::kNoSong)
19 {
20 return;
21 }
22
23 using Config::MusicPlaylistType;
24 const auto& cfg = Config::get();
25
26 bool trackStillApplies = true;
27 switch (cfg.audio.playlist)
28 {
29 case MusicPlaylistType::currentEra:
30 {
31 auto currentYear = getCurrentYear();
32 const auto& info = Jukebox::getMusicInfo(currentTrack);
33 if (currentYear < info.startYear || currentYear > info.endYear)
34 {
35 trackStillApplies = false;
36 }
37 break;
38 }
39
40 case MusicPlaylistType::all:
41 return;
42
43 case MusicPlaylistType::custom:
44 if (!cfg.audio.customJukebox[currentTrack])
45 {
46 trackStillApplies = false;
47 }
48 break;
49 }
50
51 if (!trackStillApplies)
52 {
53 stopMusic();
54 Jukebox::resetJukebox();
55 }
56 }
57
58 void playBackgroundMusic()
59 {

Callers 2

onScrollMouseDownFunction · 0.85
musicPlaylistDropdownFunction · 0.85

Calls 5

getCurrentTrackFunction · 0.85
getCurrentYearFunction · 0.85
resetJukeboxFunction · 0.85
stopMusicFunction · 0.70
getFunction · 0.50

Tested by

no test coverage detected