Skip to content

Commit 1c4d401

Browse files
committed
fix bad ExitTime, plus avoid the error it caused in the future
1 parent a5827aa commit 1c4d401

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

Data/Browncoats.rte/Music.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ AddSoundContainer = SoundContainer
7878
Immobile = 1
7979
BusRouting = Music
8080
MusicPreEntryTime = 10549.6
81-
MusicExitTime = 10022.1
81+
MusicExitTime = 100221.2
8282
AddSound = Browncoats.rte/Music/BC/BC_Ambient_91_4_38_004.ogg
8383

8484
AddSoundContainer = SoundContainer

Source/Managers/MusicMan.cpp

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "NetworkClient.h"
44
#include "AudioMan.h"
5-
//#include "ConsoleMan.h"
5+
#include "ConsoleMan.h"
66
#include "PresetMan.h"
77

88
using namespace RTE;
@@ -54,14 +54,14 @@ void MusicMan::Update() {
5454
if (m_PreviousSoundContainerSetToFade && m_MusicFadeTimer.IsPastRealTimeLimit()) {
5555
m_PreviousSoundContainerSetToFade = false;
5656
if (m_PreviousSoundContainer) {
57-
//g_ConsoleMan.PrintString("MusicMan: Faded PreviousSoundContainer due to SetToFade.");
57+
g_ConsoleMan.PrintString("MusicMan: Faded PreviousSoundContainer due to SetToFade.");
5858
const int musicFadeOutTimeMs = 250;
5959
m_PreviousSoundContainer->FadeOut(musicFadeOutTimeMs);
6060
}
6161
}
6262
}
6363
if (m_PreviousSoundContainer && m_PreviousSoundContainer->GetAudibleVolume() == 0.0F) {
64-
//g_ConsoleMan.PrintString("MusicMan: Inaudible PreviousSoundContainer is about to be deleted: " + m_PreviousSoundContainer->GetPresetName());
64+
g_ConsoleMan.PrintString("MusicMan: Inaudible PreviousSoundContainer is about to be deleted: " + m_PreviousSoundContainer->GetPresetName());
6565
m_PreviousSoundContainer = nullptr;
6666
}
6767
if (m_CurrentSoundContainer && m_CurrentSoundContainer->GetAudibleVolume() == 0.0F) {
@@ -108,7 +108,7 @@ bool MusicMan::PlayDynamicSong(const std::string& songName, const std::string& s
108108
// If this isn't the case, then the MusicTimer's existing setup should make it play properly anyway, even if it's just instant
109109
if (playImmediately) {
110110
if (m_IsPlayingDynamicMusic) {
111-
//g_ConsoleMan.PrintString("MusicMan: Immediately played DynamicSong has stopped PreviousSoundContainer.");
111+
g_ConsoleMan.PrintString("MusicMan: Immediately played DynamicSong has stopped PreviousSoundContainer.");
112112
if (m_PreviousSoundContainer) {
113113
m_PreviousSoundContainer->Stop();
114114
m_PreviousSoundContainer = nullptr;
@@ -125,13 +125,13 @@ bool MusicMan::PlayDynamicSong(const std::string& songName, const std::string& s
125125
}
126126

127127
bool MusicMan::SetNextDynamicSongSection(const std::string& newSongSectionType, bool playImmediately, bool playTransition, bool smoothFade) {
128-
//g_ConsoleMan.PrintString("MusicMan: Attempting to set next DynamicSongSection...");
129-
//std::string currentDynamicSongSection = "None";
130-
//if (m_NextSongSection) {
131-
// currentDynamicSongSection = m_NextSongSection->GetPresetName();
132-
//}
133-
//g_ConsoleMan.PrintString("Current DynamicSongSection: " + currentDynamicSongSection);
134-
//g_ConsoleMan.PrintString("Desired new DynamicSongSection: " + newSongSectionType);
128+
g_ConsoleMan.PrintString("MusicMan: Attempting to set next DynamicSongSection...");
129+
std::string currentDynamicSongSection = "None";
130+
if (m_NextSongSection) {
131+
currentDynamicSongSection = m_NextSongSection->GetPresetName();
132+
}
133+
g_ConsoleMan.PrintString("Current DynamicSongSection: " + currentDynamicSongSection);
134+
g_ConsoleMan.PrintString("Desired new DynamicSongSection: " + newSongSectionType);
135135

136136
if (!m_IsPlayingDynamicMusic) {
137137
return false;
@@ -140,9 +140,9 @@ bool MusicMan::SetNextDynamicSongSection(const std::string& newSongSectionType,
140140
SelectNextSongSection();
141141
SelectNextSoundContainer(playTransition);
142142
if (playImmediately) {
143-
//g_ConsoleMan.PrintString("Playing new song section immediately!");
143+
g_ConsoleMan.PrintString("Playing new song section immediately!");
144144
if (m_PreviousSoundContainerSetToFade) {
145-
//g_ConsoleMan.PrintString("MusicMan: Immediately played new song section has stopped PreviousSoundContainer.");
145+
g_ConsoleMan.PrintString("MusicMan: Immediately played new song section has stopped PreviousSoundContainer.");
146146
m_PreviousSoundContainerSetToFade = false;
147147
if (m_PreviousSoundContainer) {
148148
m_PreviousSoundContainer->Stop();
@@ -155,42 +155,43 @@ bool MusicMan::SetNextDynamicSongSection(const std::string& newSongSectionType,
155155
}
156156

157157
bool MusicMan::CyclePlayingSoundContainers(bool smoothFade) {
158-
//g_ConsoleMan.PrintString("MusicMan: Cycling SoundContainers...");
158+
g_ConsoleMan.PrintString("MusicMan: Cycling SoundContainers...");
159159
std::string currentSoundContainer = "None";
160160
if (m_CurrentSoundContainer) {
161161
currentSoundContainer = m_CurrentSoundContainer->GetPresetName();
162162
}
163-
//g_ConsoleMan.PrintString("Current sound container: " + currentSoundContainer);
164-
//g_ConsoleMan.PrintString("Next sound container: " + m_NextSoundContainer->GetPresetName());
165-
//std::string previousSoundContainer = "None";
166-
//if (m_PreviousSoundContainer) {
167-
// previousSoundContainer = m_PreviousSoundContainer->GetPresetName();
168-
//}
169-
//g_ConsoleMan.PrintString("Previous sound container: " + previousSoundContainer);
163+
g_ConsoleMan.PrintString("Current sound container: " + currentSoundContainer);
164+
g_ConsoleMan.PrintString("Next sound container: " + m_NextSoundContainer->GetPresetName());
165+
std::string previousSoundContainer = "None";
166+
if (m_PreviousSoundContainer) {
167+
previousSoundContainer = m_PreviousSoundContainer->GetPresetName();
168+
}
169+
g_ConsoleMan.PrintString("Previous sound container: " + previousSoundContainer);
170170

171171
if (m_CurrentSoundContainer && m_CurrentSoundContainer->IsBeingPlayed()) {
172172
if (smoothFade) {
173173
m_CurrentSoundContainer->FadeOut(static_cast<int>(m_NextSoundContainer->GetMusicPreEntryTime()));
174174
} else {
175-
//g_ConsoleMan.PrintString("No smoothFade means upcoming PreviousSoundContainer will be faded out at entry point.");
175+
g_ConsoleMan.PrintString("No smoothFade means upcoming PreviousSoundContainer will be faded out at entry point.");
176176
m_PreviousSoundContainerSetToFade = true;
177177
m_MusicFadeTimer.Reset();
178178
m_MusicFadeTimer.SetRealTimeLimitMS(static_cast<int>(m_NextSoundContainer->GetMusicPreEntryTime()));
179179
}
180180
if (m_PreviousSoundContainer) {
181-
//g_ConsoleMan.PrintString("Found unfaded PreviousSoundContainer. Stopping: " + m_PreviousSoundContainer->GetPresetName());
181+
g_ConsoleMan.PrintString("Found unfaded PreviousSoundContainer. Stopping: " + m_PreviousSoundContainer->GetPresetName());
182182
m_PreviousSoundContainer->Stop();
183183
m_PreviousSoundContainer = nullptr;
184184
}
185185
m_PreviousSoundContainer = std::unique_ptr<SoundContainer>(m_CurrentSoundContainer.release());
186-
//g_ConsoleMan.PrintString("Moved CurrentSoundContainer to PreviousSoundContainer while cycling, it is now: " + m_PreviousSoundContainer->GetPresetName());
186+
g_ConsoleMan.PrintString("Moved CurrentSoundContainer to PreviousSoundContainer while cycling, it is now: " + m_PreviousSoundContainer->GetPresetName());
187187
}
188188

189189
// Clone instead of just point to because we might wanna keep this around even if the DynamicSong is gone
190190
m_CurrentSoundContainer = std::unique_ptr<SoundContainer>(dynamic_cast<SoundContainer*>(m_NextSoundContainer->Clone()));
191191
SelectNextSoundContainer();
192192
m_MusicTimer.Reset();
193-
double timeUntilNextShouldBePlayed = m_CurrentSoundContainer->GetMusicExitTime() - m_NextSoundContainer->GetMusicPreEntryTime();
193+
double timeUntilNextShouldBePlayed = std::max(0.0F, m_CurrentSoundContainer->GetMusicExitTime() - m_NextSoundContainer->GetMusicPreEntryTime());
194+
g_ConsoleMan.PrintString("Time until next should be played:" + std::to_string(timeUntilNextShouldBePlayed));
194195
m_MusicTimer.SetRealTimeLimitMS(timeUntilNextShouldBePlayed);
195196
m_CurrentSoundContainer->Play();
196197
m_CurrentSongSectionType = m_NextSongSectionType;

0 commit comments

Comments
 (0)