diff options
author | Strangerke | 2013-04-03 23:57:38 +0200 |
---|---|---|
committer | Strangerke | 2013-04-03 23:58:11 +0200 |
commit | 4b21ec23d0e445d8364bcab5732318734f4c27cc (patch) | |
tree | 9b6236f189d1e767a2eeda0aa0b499db9f75ee30 /engines/hopkins/files.cpp | |
parent | f019d5a4881c8ee42fa36ef0613d9e82b3b36297 (diff) | |
download | scummvm-rg350-4b21ec23d0e445d8364bcab5732318734f4c27cc.tar.gz scummvm-rg350-4b21ec23d0e445d8364bcab5732318734f4c27cc.tar.bz2 scummvm-rg350-4b21ec23d0e445d8364bcab5732318734f4c27cc.zip |
HOPKINS: Refactor searchCat to remove the use of g_PTRNUL, add a parameter to clarify the result of the function
Diffstat (limited to 'engines/hopkins/files.cpp')
-rw-r--r-- | engines/hopkins/files.cpp | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/engines/hopkins/files.cpp b/engines/hopkins/files.cpp index 13d30029ca..3f7c4e48dd 100644 --- a/engines/hopkins/files.cpp +++ b/engines/hopkins/files.cpp @@ -96,8 +96,9 @@ bool FileManager::fileExists(const Common::String &file) { /** * Search file in Cat file */ -byte *FileManager::searchCat(const Common::String &file, CatMode mode) { +byte *FileManager::searchCat(const Common::String &file, CatMode mode, bool &fileFoundFl) { byte *ptr = NULL; + fileFoundFl = true; Common::File f; Common::String filename = file; @@ -106,54 +107,68 @@ byte *FileManager::searchCat(const Common::String &file, CatMode mode) { switch (mode) { case RES_INI: - if (!f.exists("RES_INI.CAT")) - return g_PTRNUL; + if (!f.exists("RES_INI.CAT")) { + fileFoundFl = false; + return NULL; + } ptr = loadFile("RES_INI.CAT"); secondaryFilename = "RES_INI.RES"; break; case RES_REP: - if (!f.exists("RES_REP.CAT")) - return g_PTRNUL; + if (!f.exists("RES_REP.CAT")) { + fileFoundFl = false; + return NULL; + } ptr = loadFile("RES_REP.CAT"); secondaryFilename = "RES_REP.RES"; break; case RES_LIN: - if (!f.exists("RES_LIN.CAT")) - return g_PTRNUL; + if (!f.exists("RES_LIN.CAT")) { + fileFoundFl = false; + return NULL; + } ptr = loadFile("RES_LIN.CAT"); secondaryFilename = "RES_LIN.RES"; break; case RES_PER: - if (!f.exists("RES_PER.CAT")) - return g_PTRNUL; + if (!f.exists("RES_PER.CAT")) { + fileFoundFl = false; + return NULL; + } ptr = loadFile("RES_PER.CAT"); secondaryFilename = "RES_PER.RES"; break; case RES_PIC: - if (!f.exists("PIC.CAT")) - return g_PTRNUL; + if (!f.exists("PIC.CAT")) { + fileFoundFl = false; + return NULL; + } ptr = loadFile("PIC.CAT"); break; case RES_SAN: - if (!f.exists("RES_SAN.CAT")) - return g_PTRNUL; + if (!f.exists("RES_SAN.CAT")) { + fileFoundFl = false; + return NULL; + } ptr = loadFile("RES_SAN.CAT"); break; case RES_SLI: - if (!f.exists("RES_SLI.CAT")) - return g_PTRNUL; + if (!f.exists("RES_SLI.CAT")) { + fileFoundFl = false; + return NULL; + } ptr = loadFile("RES_SLI.CAT"); break; @@ -177,8 +192,10 @@ byte *FileManager::searchCat(const Common::String &file, CatMode mode) { } } - if (!f.exists(tmpFilename)) - return g_PTRNUL; + if (!f.exists(tmpFilename)) { + fileFoundFl = false; + return NULL; + } ptr = loadFile(tmpFilename); break; @@ -206,7 +223,8 @@ byte *FileManager::searchCat(const Common::String &file, CatMode mode) { if (name == "FINIS") { _vm->_globals->freeMemory(ptr); - return g_PTRNUL; + fileFoundFl = false; + return NULL; } offsetVal += 23; |