@@ -89,7 +89,7 @@ namespace RTE {
89
89
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
90
90
91
91
void ContentFile::SetDataPath (const std::string &newDataPath) {
92
- m_DataPath = CorrectBackslashesInPath (newDataPath);
92
+ m_DataPath = g_PresetMan. GetFullModulePath (newDataPath);
93
93
m_DataPathExtension = std::filesystem::path (m_DataPath).extension ().string ();
94
94
95
95
RTEAssert (!m_DataPathExtension.empty (), " Failed to find file extension when trying to find file with path and name:\n " + m_DataPath + " \n " + GetFormattedReaderPosition ());
@@ -126,8 +126,7 @@ namespace RTE {
126
126
}
127
127
}
128
128
if (fetchFileInfo) {
129
- std::string altDataPath = g_PresetMan.GetFullModulePath (m_DataPath);
130
- FILE *imageFile = fopen (altDataPath.c_str (), " rb" );
129
+ FILE *imageFile = fopen (m_DataPath.c_str (), " rb" );
131
130
RTEAssert (imageFile, " Failed to open file prior to reading info of image file with following path and name:\n\n " + m_DataPath + " \n\n The file may not exist or be corrupt." );
132
131
133
132
if (m_DataPathExtension == " .png" ) {
@@ -223,7 +222,6 @@ namespace RTE {
223
222
BITMAP *returnBitmap = nullptr ;
224
223
const int bitDepth = conversionMode == COLORCONV_8_TO_32 ? BitDepths::ThirtyTwo : BitDepths::Eight;
225
224
std::string dataPathToLoad = dataPathToSpecificFrame.empty () ? m_DataPath : dataPathToSpecificFrame;
226
- dataPathToLoad = g_PresetMan.GetFullModulePath (dataPathToLoad);
227
225
228
226
if (g_PresetMan.GetReloadEntityPresetCalledThisUpdate ()) {
229
227
ReloadBitmap (dataPathToLoad, conversionMode);
@@ -260,20 +258,18 @@ namespace RTE {
260
258
if (m_DataPath.empty () || frameCount < 1 ) {
261
259
return ;
262
260
}
263
- const std::string dataPathToLoad = g_PresetMan.GetFullModulePath (m_DataPath);
264
- const std::string dataPathWithoutExtensionToLoad = g_PresetMan.GetFullModulePath (m_DataPathWithoutExtension);
265
261
vectorToFill.reserve (frameCount);
266
262
267
263
if (frameCount == 1 ) {
268
264
// Check for 000 in the file name in case it is part of an animation but the FrameCount was set to 1. Do not warn about this because it's normal operation, but warn about incorrect extension.
269
- if (!System::PathExistsCaseSensitive (dataPathToLoad )) {
265
+ if (!System::PathExistsCaseSensitive (m_DataPath )) {
270
266
const std::string altFileExtension = (m_DataPathExtension == " .png" ) ? " .bmp" : " .png" ;
271
267
272
- if (System::PathExistsCaseSensitive (dataPathWithoutExtensionToLoad + " 000" + m_DataPathExtension)) {
273
- SetDataPath (dataPathWithoutExtensionToLoad + " 000" + m_DataPathExtension);
274
- } else if (System::PathExistsCaseSensitive (dataPathWithoutExtensionToLoad + " 000" + altFileExtension)) {
268
+ if (System::PathExistsCaseSensitive (m_DataPathWithoutExtension + " 000" + m_DataPathExtension)) {
269
+ SetDataPath (m_DataPathWithoutExtension + " 000" + m_DataPathExtension);
270
+ } else if (System::PathExistsCaseSensitive (m_DataPathWithoutExtension + " 000" + altFileExtension)) {
275
271
g_ConsoleMan.AddLoadWarningLogExtensionMismatchEntry (m_DataPath, m_FormattedReaderPosition, altFileExtension);
276
- SetDataPath (dataPathWithoutExtensionToLoad + " 000" + altFileExtension);
272
+ SetDataPath (m_DataPathWithoutExtension + " 000" + altFileExtension);
277
273
}
278
274
}
279
275
vectorToFill.emplace_back (GetAsBitmap (conversionMode));
@@ -312,18 +308,16 @@ namespace RTE {
312
308
if (m_DataPath.empty () || !g_AudioMan.IsAudioEnabled ()) {
313
309
return nullptr ;
314
310
}
315
- const std::string dataPathToLoad = g_PresetMan.GetFullModulePath (m_DataPath);
316
-
317
311
FMOD::Sound *returnSample = nullptr ;
318
312
319
- std::unordered_map<std::string, FMOD::Sound *>::iterator foundSound = s_LoadedSamples.find (dataPathToLoad );
313
+ std::unordered_map<std::string, FMOD::Sound *>::iterator foundSound = s_LoadedSamples.find (m_DataPath );
320
314
if (foundSound != s_LoadedSamples.end ()) {
321
315
returnSample = (*foundSound).second ;
322
316
} else {
323
317
returnSample = LoadAndReleaseSound (abortGameForInvalidSound, asyncLoading); // NOTE: This takes ownership of the sample file
324
318
325
319
// Insert the Sound object into the map, PASSING OVER OWNERSHIP OF THE LOADED FILE
326
- s_LoadedSamples.try_emplace (dataPathToLoad , returnSample);
320
+ s_LoadedSamples.try_emplace (m_DataPath , returnSample);
327
321
}
328
322
return returnSample;
329
323
}
@@ -334,11 +328,10 @@ namespace RTE {
334
328
if (m_DataPath.empty () || !g_AudioMan.IsAudioEnabled ()) {
335
329
return nullptr ;
336
330
}
337
- const std::string dataPathToLoad = g_PresetMan.GetFullModulePath (m_DataPath);
338
- if (!System::PathExistsCaseSensitive (dataPathToLoad)) {
331
+ if (!System::PathExistsCaseSensitive (m_DataPath)) {
339
332
bool foundAltExtension = false ;
340
333
for (const std::string &altFileExtension : c_SupportedAudioFormats) {
341
- const std::string altDataPathToLoad = g_PresetMan. GetFullModulePath ( m_DataPathWithoutExtension + altFileExtension) ;
334
+ const std::string altDataPathToLoad = m_DataPathWithoutExtension + altFileExtension;
342
335
if (System::PathExistsCaseSensitive (altDataPathToLoad)) {
343
336
g_ConsoleMan.AddLoadWarningLogExtensionMismatchEntry (m_DataPath, m_FormattedReaderPosition, altFileExtension);
344
337
SetDataPath (altDataPathToLoad);
@@ -353,7 +346,7 @@ namespace RTE {
353
346
return nullptr ;
354
347
}
355
348
}
356
- if (std::filesystem::file_size (dataPathToLoad ) == 0 ) {
349
+ if (std::filesystem::file_size (m_DataPath ) == 0 ) {
357
350
const std::string errorMessage = " Failed to create sound because the file was empty. The path and name were: " ;
358
351
RTEAssert (!abortGameForInvalidSound, errorMessage + " \n\n " + m_DataPathAndReaderPosition);
359
352
g_ConsoleMan.PrintString (" ERROR: " + errorMessage + m_DataPath);
@@ -362,7 +355,7 @@ namespace RTE {
362
355
FMOD::Sound *returnSample = nullptr ;
363
356
364
357
FMOD_MODE fmodFlags = FMOD_CREATESAMPLE | FMOD_3D | (asyncLoading ? FMOD_NONBLOCKING : FMOD_DEFAULT);
365
- FMOD_RESULT result = g_AudioMan.GetAudioSystem ()->createSound (dataPathToLoad .c_str (), fmodFlags, nullptr , &returnSample);
358
+ FMOD_RESULT result = g_AudioMan.GetAudioSystem ()->createSound (m_DataPath .c_str (), fmodFlags, nullptr , &returnSample);
366
359
367
360
if (result != FMOD_OK) {
368
361
const std::string errorMessage = " Failed to create sound because of FMOD error:\n " + std::string (FMOD_ErrorString (result)) + " \n The path and name were: " ;
0 commit comments