@@ -64,37 +64,43 @@ bool LoadFile(const char *filePath, FileInfo *fileInfo)
64
64
65
65
Engine.usingDataFileStore = Engine.usingBinFile ;
66
66
67
+ #if RETRO_USE_MOD_LOADER
67
68
fileInfo->isMod = false ;
68
69
isModdedFile = false ;
70
+ #endif
71
+ bool addPath = true ;
72
+ // Fixes any case differences
73
+ char pathLower[0x100 ];
74
+ memset (pathLower, 0 , sizeof (char ) * 0x100 );
75
+ for (int c = 0 ; c < strlen (filePathBuf); ++c) {
76
+ pathLower[c] = tolower (filePathBuf[c]);
77
+ }
78
+
69
79
for (int m = 0 ; m < modCount; ++m) {
70
80
if (modList[m].active ) {
71
- std::map<std::string, std::string>::const_iterator iter = modList[m].fileMap .find (filePathBuf );
81
+ std::map<std::string, std::string>::const_iterator iter = modList[m].fileMap .find (pathLower );
72
82
if (iter != modList[m].fileMap .cend ()) {
73
83
StrCopy (filePathBuf, iter->second .c_str ());
74
84
Engine.forceFolder = true ;
75
85
Engine.usingBinFile = false ;
76
86
fileInfo->isMod = true ;
77
87
isModdedFile = true ;
88
+ addPath = false ;
78
89
break ;
79
90
}
80
91
}
81
92
}
82
93
83
- if (forceUseScripts && !Engine.forceFolder ) {
84
- if (std::string (filePathBuf).rfind (" Data/Scripts/" , 0 ) == 0 && ends_with (std::string (filePathBuf), " txt" )) {
85
- // is a script, since those dont exist normally, load them from "scripts/"
86
- Engine.forceFolder = true ;
87
- Engine.usingBinFile = false ;
88
- fileInfo->isMod = true ;
89
- isModdedFile = true ;
90
- std::string fStr = std::string (filePathBuf);
91
- fStr .erase (fStr .begin (), fStr .begin () + 5 ); // remove "Data/"
92
- StrCopy (filePathBuf, fStr .c_str ());
93
- }
94
+ #if RETRO_PLATFORM == RETRO_OSX
95
+ if (addPath) {
96
+ char pathBuf[0x100 ];
97
+ sprintf (pathBuf, " %s/%s" , gamePath, filePathBuf);
98
+ sprintf (filePathBuf, " %s" , pathBuf);
94
99
}
100
+ #endif
95
101
96
- StrCopy (fileInfo->fileName , filePathBuf );
97
- StrCopy (fileName, filePathBuf );
102
+ StrCopy (fileInfo->fileName , " " );
103
+ StrCopy (fileName, " " );
98
104
99
105
if (Engine.usingBinFile && !Engine.forceFolder ) {
100
106
cFileHandle = fOpen (binFileName, " rb" );
@@ -103,6 +109,9 @@ bool LoadFile(const char *filePath, FileInfo *fileInfo)
103
109
bufferPosition = 0 ;
104
110
readSize = 0 ;
105
111
readPos = 0 ;
112
+
113
+ StrCopy (fileInfo->fileName , filePath);
114
+ StrCopy (fileName, filePath);
106
115
if (!ParseVirtualFileSystem (fileInfo)) {
107
116
fClose (cFileHandle);
108
117
cFileHandle = NULL ;
@@ -116,11 +125,14 @@ bool LoadFile(const char *filePath, FileInfo *fileInfo)
116
125
fileInfo->encrypted = true ;
117
126
}
118
127
else {
128
+ StrCopy (fileInfo->fileName , filePathBuf);
129
+ StrCopy (fileName, filePathBuf);
119
130
cFileHandle = fOpen (fileInfo->fileName , " rb" );
120
131
if (!cFileHandle) {
121
132
printLog (" Couldn't load file '%s'" , filePathBuf);
122
133
return false ;
123
134
}
135
+
124
136
virtualFileOffset = 0 ;
125
137
fSeek (cFileHandle, 0 , SEEK_END);
126
138
fileInfo->fileSize = (int )fTell (cFileHandle);
@@ -411,35 +423,44 @@ bool LoadFile2(const char *filePath, FileInfo *fileInfo)
411
423
412
424
Engine.usingDataFileStore = Engine.usingBinFile ;
413
425
426
+ #if RETRO_USE_MOD_LOADER
414
427
fileInfo->isMod = false ;
415
428
isModdedFile = false ;
429
+ #endif
430
+ bool addPath = true ;
431
+ // Fixes ".ani" ".Ani" bug and any other case differences
432
+ char pathLower[0x100 ];
433
+ memset (pathLower, 0 , sizeof (char ) * 0x100 );
434
+ for (int c = 0 ; c < strlen (filePathBuf); ++c) {
435
+ pathLower[c] = tolower (filePathBuf[c]);
436
+ }
437
+
438
+ #if RETRO_USE_MOD_LOADER
416
439
for (int m = 0 ; m < modCount; ++m) {
417
440
if (modList[m].active ) {
418
- std::map<std::string, std::string>::const_iterator iter = modList[m].fileMap .find (filePathBuf );
441
+ std::map<std::string, std::string>::const_iterator iter = modList[m].fileMap .find (pathLower );
419
442
if (iter != modList[m].fileMap .cend ()) {
420
443
StrCopy (filePathBuf, iter->second .c_str ());
421
- Engine.forceFolder = true ;
444
+ Engine.forceFolder = true ;
422
445
Engine.usingBinFile = false ;
423
- fileInfo->isMod = true ;
424
- isModdedFile = true ;
446
+ fileInfo->isMod = true ;
447
+ isModdedFile = true ;
448
+ addPath = false ;
425
449
break ;
426
450
}
427
451
}
428
452
}
429
- if (forceUseScripts && !Engine.forceFolder ) {
430
- if (std::string (filePathBuf).rfind (" Data/Scripts/" , 0 ) == 0 && ends_with (std::string (filePathBuf), " txt" )) {
431
- // is a script, since those dont exist normally, load them from "scripts/"
432
- Engine.forceFolder = true ;
433
- Engine.usingBinFile = false ;
434
- fileInfo->isMod = true ;
435
- isModdedFile = true ;
436
- std::string fStr = std::string (filePathBuf);
437
- fStr .erase (fStr .begin (), fStr .begin () + 5 ); // remove "Data/"
438
- StrCopy (filePathBuf, fStr .c_str ());
439
- }
453
+ #endif
454
+
455
+ #if RETRO_PLATFORM == RETRO_OSX
456
+ if (addPath) {
457
+ char pathBuf[0x100 ];
458
+ sprintf (pathBuf, " %s/%s" , gamePath, filePathBuf);
459
+ sprintf (filePathBuf, " %s" , pathBuf);
440
460
}
461
+ #endif
441
462
442
- StrCopy (fileInfo->fileName , filePathBuf );
463
+ StrCopy (fileInfo->fileName , " " );
443
464
444
465
if (Engine.usingBinFile && !Engine.forceFolder ) {
445
466
fileInfo->cFileHandle = fOpen (binFileName, " rb" );
@@ -449,6 +470,8 @@ bool LoadFile2(const char *filePath, FileInfo *fileInfo)
449
470
// readSize = 0;
450
471
fileInfo->readPos = 0 ;
451
472
fileInfo->encrypted = true ;
473
+
474
+ StrCopy (fileInfo->fileName , filePath);
452
475
if (!ParseVirtualFileSystem2 (fileInfo)) {
453
476
fClose (fileInfo->cFileHandle );
454
477
fileInfo->cFileHandle = NULL ;
@@ -457,11 +480,13 @@ bool LoadFile2(const char *filePath, FileInfo *fileInfo)
457
480
}
458
481
}
459
482
else {
483
+ StrCopy (fileInfo->fileName , filePathBuf);
460
484
fileInfo->cFileHandle = fOpen (fileInfo->fileName , " rb" );
461
485
if (!fileInfo->cFileHandle ) {
462
486
printLog (" Couldn't load file '%s'" , filePathBuf);
463
487
return false ;
464
488
}
489
+
465
490
fSeek (fileInfo->cFileHandle , 0 , SEEK_END);
466
491
fileInfo->vFileSize = (int )fTell (fileInfo->cFileHandle );
467
492
fileInfo->fileSize = fileInfo->vFileSize ;
0 commit comments