diff options
author | Max Horn | 2005-04-09 11:59:43 +0000 |
---|---|---|
committer | Max Horn | 2005-04-09 11:59:43 +0000 |
commit | 34098ae3c738b553c4b12377ba74b1d80072e41b (patch) | |
tree | da42f614fdce06e856fcfdd7c8afaebbc35f3830 /scumm | |
parent | db43946f05b299bfc480bca391106e9750f04c6a (diff) | |
download | scummvm-rg350-34098ae3c738b553c4b12377ba74b1d80072e41b.tar.gz scummvm-rg350-34098ae3c738b553c4b12377ba74b1d80072e41b.tar.bz2 scummvm-rg350-34098ae3c738b553c4b12377ba74b1d80072e41b.zip |
Simplify the substResFileName system a bit
svn-id: r17475
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/resource.cpp | 4 | ||||
-rw-r--r-- | scumm/resource_v7he.cpp | 4 | ||||
-rw-r--r-- | scumm/script_v72he.cpp | 2 | ||||
-rw-r--r-- | scumm/scumm.cpp | 33 | ||||
-rw-r--r-- | scumm/scumm.h | 2 | ||||
-rw-r--r-- | scumm/sound.cpp | 4 |
6 files changed, 18 insertions, 31 deletions
diff --git a/scumm/resource.cpp b/scumm/resource.cpp index a31676e536..0cedc49686 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -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); } diff --git a/scumm/resource_v7he.cpp b/scumm/resource_v7he.cpp index 11eed18fda..8580920dba 100644 --- a/scumm/resource_v7he.cpp +++ b/scumm/resource_v7he.cpp @@ -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)) { diff --git a/scumm/script_v72he.cpp b/scumm/script_v72he.cpp index 9b3b014080..c48b407d43 100644 --- a/scumm/script_v72he.cpp +++ b/scumm/script_v72he.cpp @@ -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); } diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp index 43adf669d2..e5cdb9856e 100644 --- a/scumm/scumm.cpp +++ b/scumm/scumm.cpp @@ -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 diff --git a/scumm/scumm.h b/scumm/scumm.h index 0c7482fbf4..55c3d5868a 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -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: diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 60d183bf47..263d6ed6cb 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -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) |