mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-04 09:56:30 +00:00
Simplify the substResFileName system a bit
svn-id: r17475
This commit is contained in:
parent
db43946f05
commit
34098ae3c7
@ -134,9 +134,9 @@ void ScummEngine::openRoom(int room) {
|
||||
if (_substResFileNameIndex > 0 && !(_features & GF_NES)) {
|
||||
char tmpBuf[128];
|
||||
|
||||
generateSubstResFileName(buf, tmpBuf, 128, 0, _substResFileNameIndex);
|
||||
generateSubstResFileName(buf, tmpBuf, sizeof(tmpBuf));
|
||||
strcpy(buf, tmpBuf);
|
||||
generateSubstResFileName(buf2, tmpBuf, 128, 0, _substResFileNameIndex);
|
||||
generateSubstResFileName(buf2, tmpBuf, sizeof(tmpBuf));
|
||||
strcpy(buf2, tmpBuf);
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ int Win32ResExtractor::extractResource(const char *resType, char *resName, byte
|
||||
if (_vm->_substResFileNameIndex > 0) {
|
||||
char buf1[128];
|
||||
|
||||
_vm->generateSubstResFileName(_fileName, buf1, 128, 0, _vm->_substResFileNameIndex);
|
||||
_vm->generateSubstResFileName(_fileName, buf1, sizeof(buf1));
|
||||
strcpy(_fileName, buf1);
|
||||
}
|
||||
}
|
||||
@ -1282,7 +1282,7 @@ void MacResExtractor::setCursor(int id) {
|
||||
char buf1[128];
|
||||
|
||||
snprintf(buf1, 128, "%s.he3", _vm->getGameName());
|
||||
_vm->generateSubstResFileName(buf1, _fileName, 128, 0, _vm->_substResFileNameIndex);
|
||||
_vm->generateSubstResFileName(buf1, _fileName, sizeof(buf1));
|
||||
|
||||
// Some programs write it as .bin. Try that too
|
||||
if (!f.exists(_fileName)) {
|
||||
|
@ -1679,7 +1679,7 @@ void ScummEngine_v72he::o72_openFile() {
|
||||
if (_substResFileNameIndex > 0) {
|
||||
char buf1[128];
|
||||
|
||||
generateSubstResFileName((char *)filename, buf1, 256, 0, _substResFileNameIndex);
|
||||
generateSubstResFileName((char *)filename, buf1, sizeof(buf1));
|
||||
strcpy((char *)filename, buf1);
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@
|
||||
extern bool isSmartphone(void);
|
||||
#endif
|
||||
|
||||
static int generateSubstResFileName_(const char *filename, char *buf, int bufsize, int cont = 0, int index = 0);
|
||||
static int generateSubstResFileName_(const char *filename, char *buf, int bufsize, int index);
|
||||
|
||||
namespace Scumm {
|
||||
|
||||
@ -2958,8 +2958,8 @@ void ScummEngine::errorString(const char *buf1, char *buf2) {
|
||||
}
|
||||
}
|
||||
|
||||
int ScummEngine::generateSubstResFileName(const char *filename, char *buf, int bufsize, int cont, int index) {
|
||||
return generateSubstResFileName_(filename, buf, bufsize, cont, index);
|
||||
int ScummEngine::generateSubstResFileName(const char *filename, char *buf, int bufsize) {
|
||||
return generateSubstResFileName_(filename, buf, bufsize, _substResFileNameIndex);
|
||||
}
|
||||
|
||||
|
||||
@ -2982,7 +2982,6 @@ DetectedGameList Engine_SCUMM_detectGames(const FSList &fslist) {
|
||||
const ScummGameSettings *g;
|
||||
char detectName[128];
|
||||
char tempName[128];
|
||||
bool substIsOver;
|
||||
int substLastIndex = 0;
|
||||
|
||||
typedef Common::Map<Common::String, bool> StringSet;
|
||||
@ -3015,10 +3014,9 @@ DetectedGameList Engine_SCUMM_detectGames(const FSList &fslist) {
|
||||
}
|
||||
strcpy(tempName, detectName);
|
||||
|
||||
substIsOver = false;
|
||||
substLastIndex = 0;
|
||||
|
||||
while (!substIsOver) {
|
||||
while (substLastIndex != -1) {
|
||||
// Iterate over all files in the given directory
|
||||
for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
|
||||
if (!file->isDirectory()) {
|
||||
@ -3042,9 +3040,7 @@ DetectedGameList Engine_SCUMM_detectGames(const FSList &fslist) {
|
||||
}
|
||||
}
|
||||
|
||||
if ((substLastIndex = generateSubstResFileName_(tempName, detectName, 128,
|
||||
substLastIndex)) == -1)
|
||||
substIsOver = true;
|
||||
substLastIndex = generateSubstResFileName_(tempName, detectName, sizeof(detectName), substLastIndex+1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3101,13 +3097,10 @@ DetectedGameList Engine_SCUMM_detectGames(const FSList &fslist) {
|
||||
return detectedGames;
|
||||
}
|
||||
|
||||
static int generateSubstResFileName_(const char *filename, char *buf, int bufsize, int cont, int index) {
|
||||
if (cont == -1)
|
||||
static int generateSubstResFileName_(const char *filename, char *buf, int bufsize, int index) {
|
||||
if (index <= 0)
|
||||
return -1;
|
||||
|
||||
if (cont >= 0)
|
||||
cont++;
|
||||
|
||||
char num = filename[strlen(filename) - 1];
|
||||
|
||||
// In some cases we have .(a) and .(b) extensions
|
||||
@ -3117,10 +3110,7 @@ static int generateSubstResFileName_(const char *filename, char *buf, int bufsiz
|
||||
const char *ext = strrchr(filename, '.');
|
||||
int len = ext - filename;
|
||||
|
||||
if (index > 0)
|
||||
cont = index;
|
||||
|
||||
for (int i = cont; i < ARRAYSIZE(substResFileNameTable); i++) {
|
||||
for (int i = index; i < ARRAYSIZE(substResFileNameTable); i++) {
|
||||
if (!scumm_strnicmp(filename, substResFileNameTable[i].winName, len)) {
|
||||
switch (substResFileNameTable[i].genMethod) {
|
||||
case kGenMac:
|
||||
@ -3194,16 +3184,13 @@ Engine *Engine_SCUMM_create(GameDetector *detector, OSystem *syst) {
|
||||
}
|
||||
strcpy(tempName, detectName);
|
||||
|
||||
bool substIsOver = false;
|
||||
File f;
|
||||
|
||||
while (!substIsOver) {
|
||||
while (substLastIndex != -1) {
|
||||
if (f.exists(detectName, ConfMan.get("path").c_str()))
|
||||
break;
|
||||
|
||||
if ((substLastIndex = generateSubstResFileName_(tempName, detectName, 256,
|
||||
substLastIndex)) == -1)
|
||||
substIsOver = true;
|
||||
substLastIndex = generateSubstResFileName_(tempName, detectName, sizeof(detectName), substLastIndex + 1);
|
||||
}
|
||||
|
||||
// Force game to have Mac platform if needed
|
||||
|
@ -551,7 +551,7 @@ public:
|
||||
int _roomResource; // FIXME - should be protected but Sound::pauseSounds uses it
|
||||
bool _egoPositioned; // Used by Actor::putActor, hence public
|
||||
|
||||
int generateSubstResFileName(const char *filename, char *buf, int bufsize, int cont = 0, int index = 0);
|
||||
int generateSubstResFileName(const char *filename, char *buf, int bufsize);
|
||||
int _substResFileNameIndex;
|
||||
|
||||
protected:
|
||||
|
@ -183,7 +183,7 @@ void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) {
|
||||
sprintf(buf, "%s.he4", _vm->getGameName());
|
||||
|
||||
if (_vm->_substResFileNameIndex > 0) {
|
||||
_vm->generateSubstResFileName(buf, buf1, 128, 0, _vm->_substResFileNameIndex);
|
||||
_vm->generateSubstResFileName(buf, buf1, sizeof(buf1));
|
||||
strcpy(buf, buf1);
|
||||
}
|
||||
if (musicFile.open(buf) == false) {
|
||||
@ -1121,7 +1121,7 @@ ScummFile *Sound::openSfxFile() {
|
||||
if (_vm->_substResFileNameIndex > 0) {
|
||||
char buf1[128];
|
||||
|
||||
_vm->generateSubstResFileName(buf, buf1, 128, 0, _vm->_substResFileNameIndex);
|
||||
_vm->generateSubstResFileName(buf, buf1, sizeof(buf1));
|
||||
strcpy(buf, buf1);
|
||||
}
|
||||
if (file->open(buf) && _vm->_heversion <= 72)
|
||||
|
Loading…
x
Reference in New Issue
Block a user