Skip to content

Commit 69095fe

Browse files
committed
temporary fixes to make dynamic music less buggy
1 parent ded0091 commit 69095fe

File tree

3 files changed

+72
-11
lines changed

3 files changed

+72
-11
lines changed

Data/Browncoats.rte/Activities/RefineryAssault.lua

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ end
9999
function RefineryAssault:StartActivity(newGame)
100100
print("START! -- RefineryAssault:StartActivity()!");
101101

102-
self.verboseLogging = true;
102+
self.verboseLogging = false;
103103

104104
self.humansAreControllingAlliedActors = false;
105105

@@ -486,6 +486,29 @@ function RefineryAssault:UpdateActivity()
486486

487487
-- Debug
488488
if UInputMan.FlagAltState then
489+
490+
-- Force music state
491+
492+
if UInputMan:KeyPressed(Key.H) then
493+
self.forcedGameIntensity = nil;
494+
print("REFINERY ASSAULT: Cleared forced music intensity")
495+
end
496+
497+
if UInputMan:KeyPressed(Key.J) then
498+
self.forcedGameIntensity = -0;
499+
print("REFINERY ASSAULT: Ambient forced music intensity")
500+
end
501+
502+
if UInputMan:KeyPressed(Key.K) then
503+
self.forcedGameIntensity = 0.5;
504+
print("REFINERY ASSAULT: Tense forced music intensity")
505+
end
506+
507+
if UInputMan:KeyPressed(Key.L) then
508+
self.forcedGameIntensity = 1.0;
509+
print("REFINERY ASSAULT: Intense forced music intensity")
510+
end
511+
489512
-- Unlimit camera
490513
if UInputMan:KeyPressed(Key.KP_8) then
491514
self.HUDHandler:SetCameraMinimumAndMaximumX(self.humanTeam, 0, 999999);
@@ -540,6 +563,9 @@ function RefineryAssault:UpdateActivity()
540563

541564
-- Music
542565
local gameIntensity = self.GameIntensityCalculator:UpdateGameIntensityCalculator();
566+
if self.forcedGameIntensity then
567+
gameIntensity = self.forcedGameIntensity;
568+
end
543569
if self.saveTable.musicState ~= "Boss" and self.musicGraceTimer:IsPastRealMS(20000) then
544570
if gameIntensity > 0.67 then
545571
if self.saveTable.musicState ~= "Intense" then

Data/Browncoats.rte/Activities/RefineryAssaultFunctions.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,7 @@ function RefineryAssault:MonitorStage3()
15421542
end
15431543
end
15441544

1545-
print(#self.saveTable.stage3Consoles)
1545+
--print(#self.saveTable.stage3Consoles)
15461546

15471547
if #self.saveTable.stage3Consoles == 0 then
15481548
self.stage3AllConsolesBroken = true;

Source/Managers/MusicMan.cpp

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "NetworkClient.h"
44
#include "AudioMan.h"
5+
#include "ConsoleMan.h"
56
#include "PresetMan.h"
67

78
using namespace RTE;
@@ -51,17 +52,20 @@ void MusicMan::Update() {
5152
CyclePlayingSoundContainers(false);
5253
}
5354
if (m_PreviousSoundContainerSetToFade && m_MusicFadeTimer.IsPastRealTimeLimit()) {
54-
const int musicFadeOutTimeMs = 250;
55-
m_PreviousSoundContainer->FadeOut(musicFadeOutTimeMs);
5655
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+
}
5761
}
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;
6569
}
6670
}
6771

@@ -104,6 +108,7 @@ bool MusicMan::PlayDynamicSong(const std::string& songName, const std::string& s
104108
// If this isn't the case, then the MusicTimer's existing setup should make it play properly anyway, even if it's just instant
105109
if (playImmediately) {
106110
if (m_IsPlayingDynamicMusic) {
111+
g_ConsoleMan.PrintString("MusicMan: Immediately played DynamicSong has stopped PreviousSoundContainer.");
107112
if (m_PreviousSoundContainer) {
108113
m_PreviousSoundContainer->Stop();
109114
m_PreviousSoundContainer = nullptr;
@@ -120,14 +125,24 @@ bool MusicMan::PlayDynamicSong(const std::string& songName, const std::string& s
120125
}
121126

122127
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+
123136
if (!m_IsPlayingDynamicMusic) {
124137
return false;
125138
}
126139
SetNextSongSectionType(newSongSectionType);
127140
SelectNextSongSection();
128141
SelectNextSoundContainer(playTransition);
129142
if (playImmediately) {
143+
g_ConsoleMan.PrintString("Playing new song section immediately!");
130144
if (m_PreviousSoundContainerSetToFade) {
145+
g_ConsoleMan.PrintString("MusicMan: Immediately played new song section has stopped PreviousSoundContainer.");
131146
m_PreviousSoundContainerSetToFade = false;
132147
m_PreviousSoundContainer->Stop();
133148
m_PreviousSoundContainer = nullptr;
@@ -138,15 +153,35 @@ bool MusicMan::SetNextDynamicSongSection(const std::string& newSongSectionType,
138153
}
139154

140155
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+
141169
if (m_CurrentSoundContainer && m_CurrentSoundContainer->IsBeingPlayed()) {
142170
if (smoothFade) {
143171
m_CurrentSoundContainer->FadeOut(static_cast<int>(m_NextSoundContainer->GetMusicPreEntryTime()));
144172
} else {
173+
g_ConsoleMan.PrintString("No smoothFade means upcoming PreviousSoundContainer will be faded out at entry point.");
145174
m_PreviousSoundContainerSetToFade = true;
146175
m_MusicFadeTimer.Reset();
147176
m_MusicFadeTimer.SetRealTimeLimitMS(static_cast<int>(m_NextSoundContainer->GetMusicPreEntryTime()));
148177
}
178+
if (m_PreviousSoundContainer) {
179+
g_ConsoleMan.PrintString("Found unfaded PreviousSoundContainer. Stopping: " + m_PreviousSoundContainer->GetPresetName());
180+
m_PreviousSoundContainer->Stop();
181+
m_PreviousSoundContainer = nullptr;
182+
}
149183
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());
150185
}
151186

152187
// Clone instead of just point to because we might wanna keep this around even if the DynamicSong is gone

0 commit comments

Comments
 (0)