2
2
3
3
#include " NetworkClient.h"
4
4
#include " AudioMan.h"
5
+ #include " ConsoleMan.h"
5
6
#include " PresetMan.h"
6
7
7
8
using namespace RTE ;
@@ -51,17 +52,20 @@ void MusicMan::Update() {
51
52
CyclePlayingSoundContainers (false );
52
53
}
53
54
if (m_PreviousSoundContainerSetToFade && m_MusicFadeTimer.IsPastRealTimeLimit ()) {
54
- const int musicFadeOutTimeMs = 250 ;
55
- m_PreviousSoundContainer->FadeOut (musicFadeOutTimeMs);
56
55
m_PreviousSoundContainerSetToFade = false ;
56
+ if (m_PreviousSoundContainer) {
57
+ g_ConsoleMan.PrintString (" MusicMan: Faded PreviousSoundContainer due to SetToFade." );
58
+ const int musicFadeOutTimeMs = 250 ;
59
+ m_PreviousSoundContainer->FadeOut (musicFadeOutTimeMs);
60
+ }
57
61
}
58
- } else {
59
- if (m_PreviousSoundContainer && m_PreviousSoundContainer->GetAudibleVolume () == 0 .0F ) {
60
- m_PreviousSoundContainer = nullptr ;
61
- }
62
- if (m_CurrentSoundContainer && m_CurrentSoundContainer-> GetAudibleVolume () == 0 . 0F ) {
63
- m_CurrentSoundContainer = nullptr ;
64
- }
62
+ }
63
+ if (m_PreviousSoundContainer && m_PreviousSoundContainer->GetAudibleVolume () == 0 .0F ) {
64
+ g_ConsoleMan. PrintString ( " MusicMan: Inaudible PreviousSoundContainer is about to be deleted: " + m_PreviousSoundContainer-> GetPresetName ()) ;
65
+ m_PreviousSoundContainer = nullptr ;
66
+ }
67
+ if ( m_CurrentSoundContainer && m_CurrentSoundContainer-> GetAudibleVolume () == 0 . 0F ) {
68
+ m_CurrentSoundContainer = nullptr ;
65
69
}
66
70
}
67
71
@@ -104,6 +108,7 @@ bool MusicMan::PlayDynamicSong(const std::string& songName, const std::string& s
104
108
// If this isn't the case, then the MusicTimer's existing setup should make it play properly anyway, even if it's just instant
105
109
if (playImmediately) {
106
110
if (m_IsPlayingDynamicMusic) {
111
+ g_ConsoleMan.PrintString (" MusicMan: Immediately played DynamicSong has stopped PreviousSoundContainer." );
107
112
if (m_PreviousSoundContainer) {
108
113
m_PreviousSoundContainer->Stop ();
109
114
m_PreviousSoundContainer = nullptr ;
@@ -120,14 +125,24 @@ bool MusicMan::PlayDynamicSong(const std::string& songName, const std::string& s
120
125
}
121
126
122
127
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);
135
+
123
136
if (!m_IsPlayingDynamicMusic) {
124
137
return false ;
125
138
}
126
139
SetNextSongSectionType (newSongSectionType);
127
140
SelectNextSongSection ();
128
141
SelectNextSoundContainer (playTransition);
129
142
if (playImmediately) {
143
+ g_ConsoleMan.PrintString (" Playing new song section immediately!" );
130
144
if (m_PreviousSoundContainerSetToFade) {
145
+ g_ConsoleMan.PrintString (" MusicMan: Immediately played new song section has stopped PreviousSoundContainer." );
131
146
m_PreviousSoundContainerSetToFade = false ;
132
147
m_PreviousSoundContainer->Stop ();
133
148
m_PreviousSoundContainer = nullptr ;
@@ -138,15 +153,35 @@ bool MusicMan::SetNextDynamicSongSection(const std::string& newSongSectionType,
138
153
}
139
154
140
155
bool MusicMan::CyclePlayingSoundContainers (bool smoothFade) {
156
+ g_ConsoleMan.PrintString (" MusicMan: Cycling SoundContainers..." );
157
+ std::string currentSoundContainer = " None" ;
158
+ if (m_CurrentSoundContainer) {
159
+ currentSoundContainer = m_CurrentSoundContainer->GetPresetName ();
160
+ }
161
+ g_ConsoleMan.PrintString (" Current sound container: " + currentSoundContainer);
162
+ g_ConsoleMan.PrintString (" Next sound container: " + m_NextSoundContainer->GetPresetName ());
163
+ std::string previousSoundContainer = " None" ;
164
+ if (m_PreviousSoundContainer) {
165
+ previousSoundContainer = m_PreviousSoundContainer->GetPresetName ();
166
+ }
167
+ g_ConsoleMan.PrintString (" Previous sound container: " + previousSoundContainer);
168
+
141
169
if (m_CurrentSoundContainer && m_CurrentSoundContainer->IsBeingPlayed ()) {
142
170
if (smoothFade) {
143
171
m_CurrentSoundContainer->FadeOut (static_cast <int >(m_NextSoundContainer->GetMusicPreEntryTime ()));
144
172
} else {
173
+ g_ConsoleMan.PrintString (" No smoothFade means upcoming PreviousSoundContainer will be faded out at entry point." );
145
174
m_PreviousSoundContainerSetToFade = true ;
146
175
m_MusicFadeTimer.Reset ();
147
176
m_MusicFadeTimer.SetRealTimeLimitMS (static_cast <int >(m_NextSoundContainer->GetMusicPreEntryTime ()));
148
177
}
178
+ if (m_PreviousSoundContainer) {
179
+ g_ConsoleMan.PrintString (" Found unfaded PreviousSoundContainer. Stopping: " + m_PreviousSoundContainer->GetPresetName ());
180
+ m_PreviousSoundContainer->Stop ();
181
+ m_PreviousSoundContainer = nullptr ;
182
+ }
149
183
m_PreviousSoundContainer = std::unique_ptr<SoundContainer>(m_CurrentSoundContainer.release ());
184
+ g_ConsoleMan.PrintString (" Moved CurrentSoundContainer to PreviousSoundContainer while cycling, it is now: " + m_PreviousSoundContainer->GetPresetName ());
150
185
}
151
186
152
187
// Clone instead of just point to because we might wanna keep this around even if the DynamicSong is gone
0 commit comments