You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 5, 2024. It is now read-only.
Renamed ContentFile GetSample to GetSound to be more consistent
Cleaned up contentfile comments and errors a little
Added safety checking for empty soundfiles when loading them
Fixed some safety problems in AudioMan and made SoundContainer create properly abort on failure
Copy file name to clipboardExpand all lines: Entities/SoundContainer.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ namespace RTE {
65
65
/// <param name="immobile">Whether this SoundContainer's sounds will be treated as immobile, i.e. they won't be affected by 3D sound manipulation.</param>
66
66
/// <param name="affectedByGlobalPitch">Whether this SoundContainer's sounds' frequency will be affected by the global pitch.</param>
67
67
/// <returns>An error return value signaing success or any particular failure. Anything below 0 is an error signal.</returns>
if (m_DataPath.empty() || !g_AudioMan.IsAudioEnabled()) {
209
209
returnnullptr;
210
210
}
@@ -218,18 +218,24 @@ namespace RTE {
218
218
if (abortGameForInvalidSound) {
219
219
RTEAbort("Failed to find audio file with following path and name:\n\n" + m_DataPath + " or " + altFileExtension + "\n" + m_FormattedReaderPosition);
220
220
} else {
221
-
g_ConsoleMan.PrintString("Failed to find audio file with following path and name:\n\n" + m_DataPath + " or " + altFileExtension + ". The file was not loaded!");
221
+
g_ConsoleMan.PrintString("Failed to find audio file with following path and name:\n" + m_DataPath + " or " + altFileExtension + ". The file was not loaded!");
222
222
returnnullptr;
223
223
}
224
224
}
225
225
}
226
+
if (std::filesystem::file_size(m_DataPath) == 0) {
227
+
const std::string errorMessage = "Failed to create sound because because the file was empty. The path and name were: ";
FMOD_RESULT result = g_AudioMan.GetAudioSystem()->createSound(m_DataPath.c_str(), fmodFlags, nullptr, &returnSample);
230
236
231
237
if (result != FMOD_OK) {
232
-
const std::string errorMessage = "Failed to create sound because of FMOD error: " + std::string(FMOD_ErrorString(result)) + "\nThe path and name were: ";
238
+
const std::string errorMessage = "Failed to create sound because of FMOD error: " + std::string(FMOD_ErrorString(result)) + " The path and name were: ";
Copy file name to clipboardExpand all lines: System/ContentFile.h
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -145,15 +145,15 @@ namespace RTE {
145
145
/// <param name="abortGameForInvalidSound">Whether to abort the game if the sound couldn't be added, or just show a console error. Default true.</param>
146
146
/// <param name="asyncLoading">Whether to enable FMOD asynchronous loading or not. Should be disabled for loading audio files with Lua AddSound.
147
147
/// <returns>Pointer to the FSOUND_SAMPLE loaded from disk.</returns>
0 commit comments