diff options
author | Strangerke | 2013-01-07 23:56:39 +0100 |
---|---|---|
committer | Strangerke | 2013-01-08 00:03:08 +0100 |
commit | 495ecaafbcf1620901d270a65394ca312f2b5a37 (patch) | |
tree | 81973080b68ae9f8c1af67320b0cd3554373deb2 /engines/hopkins | |
parent | 337c5d0e8d5d3f7fe20150aff0ee1703dc230455 (diff) | |
download | scummvm-rg350-495ecaafbcf1620901d270a65394ca312f2b5a37.tar.gz scummvm-rg350-495ecaafbcf1620901d270a65394ca312f2b5a37.tar.bz2 scummvm-rg350-495ecaafbcf1620901d270a65394ca312f2b5a37.zip |
HOPKINS: Remove global filename and constructFilename
Diffstat (limited to 'engines/hopkins')
-rw-r--r-- | engines/hopkins/anim.cpp | 57 | ||||
-rw-r--r-- | engines/hopkins/computer.cpp | 48 | ||||
-rw-r--r-- | engines/hopkins/dialogs.cpp | 35 | ||||
-rw-r--r-- | engines/hopkins/files.cpp | 113 | ||||
-rw-r--r-- | engines/hopkins/files.h | 6 | ||||
-rw-r--r-- | engines/hopkins/font.cpp | 4 | ||||
-rw-r--r-- | engines/hopkins/globals.cpp | 12 | ||||
-rw-r--r-- | engines/hopkins/globals.h | 1 | ||||
-rw-r--r-- | engines/hopkins/graphics.cpp | 24 | ||||
-rw-r--r-- | engines/hopkins/hopkins.cpp | 92 | ||||
-rw-r--r-- | engines/hopkins/menu.cpp | 9 | ||||
-rw-r--r-- | engines/hopkins/objects.cpp | 65 | ||||
-rw-r--r-- | engines/hopkins/script.cpp | 6 | ||||
-rw-r--r-- | engines/hopkins/sound.cpp | 43 | ||||
-rw-r--r-- | engines/hopkins/sound.h | 2 | ||||
-rw-r--r-- | engines/hopkins/talk.cpp | 39 |
16 files changed, 224 insertions, 332 deletions
diff --git a/engines/hopkins/anim.cpp b/engines/hopkins/anim.cpp index 539586c433..780fdd9eca 100644 --- a/engines/hopkins/anim.cpp +++ b/engines/hopkins/anim.cpp @@ -58,15 +58,16 @@ void AnimationManager::playAnim(const Common::String &filename, uint32 rate1, ui byte *screenP = _vm->_graphicsManager._vesaScreen; byte *ptr = _vm->_globals.allocMemory(20); + Common::String tmpStr; // The Windows 95 demo only contains the interlaced version of the BOMBE1 and BOMBE2 videos if (_vm->getPlatform() == Common::kPlatformWindows && _vm->getIsDemo() && filename == "BOMBE1A.ANM") - _vm->_fileManager.constructFilename("ANM", "BOMBE1.ANM"); + tmpStr = "BOMBE1.ANM"; else if (_vm->getPlatform() == Common::kPlatformWindows && _vm->getIsDemo() && filename == "BOMBE2A.ANM") - _vm->_fileManager.constructFilename("ANM", "BOMBE2.ANM"); + tmpStr = "BOMBE2.ANM"; else - _vm->_fileManager.constructFilename("ANM", filename); - if (!f.open(_vm->_globals._curFilename)) - error("File not found - %s", _vm->_globals._curFilename.c_str()); + tmpStr = filename; + if (!f.open(tmpStr)) + error("File not found - %s", tmpStr.c_str()); f.skip(6); f.read(_vm->_graphicsManager._palette, 800); @@ -228,21 +229,18 @@ void AnimationManager::playAnim2(const Common::String &filename, uint32 a2, uint while (!_vm->shouldQuit()) { memcpy(_vm->_graphicsManager._oldPalette, _vm->_graphicsManager._palette, 769); - _vm->_fileManager.constructLinuxFilename("TEMP.SCR"); - if (_vm->_graphicsManager._lineNbr == SCREEN_WIDTH) - _vm->_saveLoadManager.saveFile(_vm->_globals._curFilename, _vm->_graphicsManager._vesaScreen, 307200); + _vm->_saveLoadManager.saveFile("TEMP.SCR", _vm->_graphicsManager._vesaScreen, 307200); else if (_vm->_graphicsManager._lineNbr == (SCREEN_WIDTH * 2)) - _vm->_saveLoadManager.saveFile(_vm->_globals._curFilename, _vm->_graphicsManager._vesaScreen, 614400); + _vm->_saveLoadManager.saveFile("TEMP.SCR", _vm->_graphicsManager._vesaScreen, 614400); if (!_vm->_graphicsManager._lineNbr) _vm->_graphicsManager._scrollOffset = 0; screenP = _vm->_graphicsManager._vesaScreen; ptr = _vm->_globals.allocMemory(20); - _vm->_fileManager.constructFilename("ANM", filename); - if (!f.open(_vm->_globals._curFilename)) - error("Error opening file - %s", _vm->_globals._curFilename.c_str()); + if (!f.open(filename)) + error("Error opening file - %s", filename.c_str()); f.read(&buf, 6); f.read(_vm->_graphicsManager._palette, 800); @@ -476,11 +474,9 @@ void AnimationManager::loadAnim(const Common::String &animName) { clearAnim(); Common::String filename = animName + ".ANI"; - _vm->_fileManager.constructFilename("ANIM", filename); - Common::File f; - if (!f.open(_vm->_globals._curFilename)) - error("Failed to open %s", _vm->_globals._curFilename.c_str()); + if (!f.open(filename)) + error("Failed to open %s", filename.c_str()); int filesize = f.size(); int nbytes = filesize - 115; @@ -501,9 +497,7 @@ void AnimationManager::loadAnim(const Common::String &animName) { for (int idx = 0; idx <= 5; ++idx) { if (files[idx][0]) { - _vm->_fileManager.constructFilename("ANIM", files[idx]); - - if (!f.exists(_vm->_globals._curFilename)) + if (!f.exists(files[idx])) error("File not found"); if (loadSpriteBank(idx + 1, files[idx])) error("File not compatible with this soft."); @@ -545,12 +539,11 @@ int AnimationManager::loadSpriteBank(int idx, const Common::String &filename) { byte *v13; byte *v19; int result = 0; - _vm->_fileManager.constructFilename("ANIM", filename); - _vm->_globals.Bank[idx].field1C = _vm->_fileManager.fileSize(_vm->_globals._curFilename); + _vm->_globals.Bank[idx].field1C = _vm->_fileManager.fileSize(filename); _vm->_globals.Bank[idx]._loadedFl = true; _vm->_globals.Bank[idx]._filename = filename; - byte *fileDataPtr = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + byte *fileDataPtr = _vm->_fileManager.loadFile(filename); _vm->_globals.Bank[idx]._fileHeader = 0; if (fileDataPtr[1] == 'L' && fileDataPtr[2] == 'E') @@ -587,10 +580,9 @@ int AnimationManager::loadSpriteBank(int idx, const Common::String &filename) { } while (ch != '.'); ofsFilename += ".OFS"; - _vm->_fileManager.constructFilename("ANIM", ofsFilename); Common::File f; - if (f.exists(_vm->_globals._curFilename)) { - v19 = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + if (f.exists(ofsFilename)) { + v19 = _vm->_fileManager.loadFile(ofsFilename); v13 = v19; for (int objIdx = 0; objIdx < _vm->_globals.Bank[idx].field1A; ++objIdx, v13 += 8) { int x1 = (int16)READ_LE_UINT16(v13); @@ -723,19 +715,17 @@ void AnimationManager::playSequence(const Common::String &file, uint32 rate1, ui if (!NO_COUL) { _vm->_eventsManager.VBL(); - _vm->_fileManager.constructLinuxFilename("TEMP.SCR"); if (_vm->_graphicsManager._lineNbr == SCREEN_WIDTH) - _vm->_saveLoadManager.saveFile(_vm->_globals._curFilename, _vm->_graphicsManager._vesaScreen, 307200); + _vm->_saveLoadManager.saveFile("TEMP.SCR", _vm->_graphicsManager._vesaScreen, 307200); else if (_vm->_graphicsManager._lineNbr == (SCREEN_WIDTH * 2)) - _vm->_saveLoadManager.saveFile(_vm->_globals._curFilename, _vm->_graphicsManager._vesaScreen, 614400); + _vm->_saveLoadManager.saveFile("TEMP.SCR", _vm->_graphicsManager._vesaScreen, 614400); if (!_vm->_graphicsManager._lineNbr) _vm->_graphicsManager._scrollOffset = 0; } screenP = _vm->_graphicsManager._vesaScreen; v10 = _vm->_globals.allocMemory(22); - _vm->_fileManager.constructFilename("SEQ", file); - if (!f.open(_vm->_globals._curFilename)) - error("Error opening file - %s", _vm->_globals._curFilename.c_str()); + if (!f.open(file)) + error("Error opening file - %s", file.c_str()); f.skip(6); f.read(_vm->_graphicsManager._palette, 800); @@ -889,10 +879,9 @@ void AnimationManager::playSequence2(const Common::String &file, uint32 rate1, u _vm->_eventsManager._mouseFl = false; screenP = _vm->_graphicsManager._vesaScreen; v11 = _vm->_globals.allocMemory(22); - _vm->_fileManager.constructFilename("SEQ", file); - if (!f.open(_vm->_globals._curFilename)) - error("File not found - %s", _vm->_globals._curFilename.c_str()); + if (!f.open(file)) + error("File not found - %s", file.c_str()); f.skip(6); f.read(_vm->_graphicsManager._palette, 800); diff --git a/engines/hopkins/computer.cpp b/engines/hopkins/computer.cpp index bc67ccf23f..039dc563b3 100644 --- a/engines/hopkins/computer.cpp +++ b/engines/hopkins/computer.cpp @@ -78,9 +78,8 @@ void ComputerManager::setTextMode() { //SET_MODE(SCREEN_WIDTH, SCREEN_HEIGHT); _vm->_graphicsManager._lineNbr = SCREEN_WIDTH; - _vm->_fileManager.constructFilename("SYSTEM", "STFONT.SPR"); _vm->_globals.police = _vm->_globals.freeMemory(_vm->_globals.police); - _vm->_globals.police = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _vm->_globals.police = _vm->_fileManager.loadFile("STFONT.SPR"); _vm->_globals.police_l = 8; _vm->_globals.police_h = 8; _vm->_graphicsManager.loadImage("WINTEXT"); @@ -328,9 +327,8 @@ static char _frenchText[] = */ void ComputerManager::loadMenu() { char *ptr; - if (_vm->_fileManager.fileExists("LINK", "COMPUTAN.TXT")) { - _vm->_fileManager.constructFilename("LINK", "COMPUTAN.TXT"); - ptr = (char *)_vm->_fileManager.loadFile(_vm->_globals._curFilename); + if (_vm->_fileManager.fileExists("COMPUTAN.TXT")) { + ptr = (char *)_vm->_fileManager.loadFile("COMPUTAN.TXT"); } else if (_vm->_globals._language == LANG_FR) { ptr = (char *)_vm->_globals.allocMemory(sizeof(_frenchText)); strcpy(ptr, _frenchText); @@ -444,9 +442,8 @@ void ComputerManager::outText2(const Common::String &msg) { * Restores the scene for the FBI headquarters room */ void ComputerManager::restoreFBIRoom() { - _vm->_globals.police = _vm->_globals.freeMemory(_vm->_globals.police); - _vm->_fileManager.constructFilename("SYSTEM", "FONTE3.SPR"); - _vm->_globals.police = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _vm->_globals.freeMemory(_vm->_globals.police); + _vm->_globals.police = _vm->_fileManager.loadFile("FONTE3.SPR"); _vm->_globals.police_l = 12; _vm->_globals.police_h = 21; @@ -458,16 +455,18 @@ void ComputerManager::restoreFBIRoom() { */ void ComputerManager::readText(int idx) { _vm->_eventsManager._escKeyFl = false; + byte *ptr; + Common::String filename; if (_vm->_globals._language == LANG_EN) - _vm->_fileManager.constructFilename("LINK", "THOPKAN.TXT"); + filename = "THOPKAN.TXT"; else if (_vm->_globals._language == LANG_FR) - _vm->_fileManager.constructFilename("LINK", "THOPK.TXT"); + filename = "THOPK.TXT"; else if (_vm->_globals._language == LANG_SP) - _vm->_fileManager.constructFilename("LINK", "THOPKES.TXT"); + filename = "THOPKES.TXT"; - byte *ptr = _vm->_fileManager.loadFile(_vm->_globals._curFilename); - uint16 fileSize = _vm->_fileManager.fileSize(_vm->_globals._curFilename); + ptr = _vm->_fileManager.loadFile(filename); + uint16 fileSize = _vm->_fileManager.fileSize(filename); int pos; for (pos = 0; pos < fileSize; pos++) { if (ptr[pos] == '%') { @@ -528,8 +527,7 @@ void ComputerManager::displayGamesSubMenu() { _vm->_soundManager.loadSample(1, "SOUND37.WAV"); _vm->_soundManager.loadSample(2, "SOUND38.WAV"); _vm->_soundManager.loadSample(3, "SOUND39.WAV"); - _vm->_fileManager.constructFilename("SYSTEM", "CASSE.SPR"); - _breakoutSpr = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _breakoutSpr = _vm->_fileManager.loadFile("CASSE.SPR"); loadHiscore(); setModeVGA256(); newLevel(); @@ -560,9 +558,8 @@ void ComputerManager::loadHiscore() { char nextChar; byte *ptr; - _vm->_fileManager.constructLinuxFilename("HISCORE.DAT"); ptr = _vm->_globals.allocMemory(100); - _vm->_saveLoadManager.load(_vm->_globals._curFilename, ptr); + _vm->_saveLoadManager.load("HISCORE.DAT", ptr); for (int scoreIndex = 0; scoreIndex < 6; ++scoreIndex) { for (int i = 0; i < 5; ++i) { @@ -614,16 +611,14 @@ void ComputerManager::newLevel() { ++_breakoutLevelNbr; while (!_vm->shouldQuit()) { file = Common::String::format("TAB%d.TAB", _breakoutLevelNbr); - - _vm->_fileManager.constructFilename("SYSTEM", file); - if (f.open(_vm->_globals._curFilename)) + if (f.open(file)) break; _breakoutLevelNbr = 1; } f.close(); - _breakoutLevel = (int16 *)_vm->_fileManager.loadFile(_vm->_globals._curFilename); + _breakoutLevel = (int16 *)_vm->_fileManager.loadFile(file); displayBricks(); _vm->_objectsManager.SPRITE(_breakoutSpr, Common::Point(150, 192), 0, 13, 0, 0, 0, 0); _vm->_objectsManager.SPRITE(_breakoutSpr, Common::Point(164, 187), 1, 14, 0, 0, 0, 0); @@ -789,8 +784,7 @@ int ComputerManager::displayHiscores() { _vm->_graphicsManager.RESET_SEGMENT_VESA(); loadHiscore(); _vm->_graphicsManager.loadVgaImage("HISCORE.PCX"); - _vm->_fileManager.constructFilename("SYSTEM", "ALPHA.SPR"); - byte *ptr = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + byte *ptr = _vm->_fileManager.loadFile("ALPHA.SPR"); _vm->_graphicsManager.SETCOLOR3(252, 100, 100, 100); _vm->_graphicsManager.SETCOLOR3(253, 100, 100, 100); _vm->_graphicsManager.SETCOLOR3(251, 100, 100, 100); @@ -841,8 +835,7 @@ void ComputerManager::getScoreName() { _vm->_graphicsManager.SETCOLOR3(253, 100, 100, 100); _vm->_graphicsManager.SETCOLOR3(251, 100, 100, 100); _vm->_graphicsManager.SETCOLOR3(254, 0, 0, 0); - _vm->_fileManager.constructFilename("SYSTEM", "ALPHA.SPR"); - byte *ptr = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + byte *ptr = _vm->_fileManager.loadFile("ALPHA.SPR"); _vm->_graphicsManager.fadeInBreakout(); for (int strPos = 0; strPos <= 4; strPos++) { displayHiscoreLine(ptr, 9 * strPos + 140, 78, 1); @@ -885,7 +878,7 @@ void ComputerManager::displayScore() { Common::String scoreStr = Common::String::format("%d", _breakoutScore); int strSize = scoreStr.size(); int idx = 0; - for (int i = strSize; i > -1; i--) { + for (int i = strSize - 1; i > -1; i--) { displayScoreChar(idx++, scoreStr[i]); } } @@ -977,8 +970,7 @@ void ComputerManager::saveScore() { ptr[v9 + 9] = 0; } - _vm->_fileManager.constructLinuxFilename("HISCORE.DAT"); - _vm->_saveLoadManager.saveFile(_vm->_globals._curFilename, ptr, 100); + _vm->_saveLoadManager.saveFile("HISCORE.DAT", ptr, 100); _vm->_globals.freeMemory(ptr); } diff --git a/engines/hopkins/dialogs.cpp b/engines/hopkins/dialogs.cpp index 42abaa8ad9..b062bda538 100644 --- a/engines/hopkins/dialogs.cpp +++ b/engines/hopkins/dialogs.cpp @@ -59,14 +59,15 @@ void DialogsManager::showOptionsDialog() { doneFlag = false; _vm->_eventsManager.changeMouseCursor(0); _vm->_eventsManager.VBL(); + Common::String filename; if (_vm->_globals._language == LANG_FR) - _vm->_fileManager.constructFilename("SYSTEM", "OPTIFR.SPR"); + filename = "OPTIFR.SPR"; else if (_vm->_globals._language == LANG_EN) - _vm->_fileManager.constructFilename("SYSTEM", "OPTIAN.SPR"); + filename = "OPTIAN.SPR"; else if (_vm->_globals._language == LANG_SP) - _vm->_fileManager.constructFilename("SYSTEM", "OPTIES.SPR"); + filename = "OPTIES.SPR"; - _vm->_globals.OPTION_SPR = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _vm->_globals.OPTION_SPR = _vm->_fileManager.loadFile(filename); _vm->_globals._optionDialogFl = true; do { @@ -311,29 +312,29 @@ LABEL_7: _vm->_globals._disableInventFl = true; _vm->_graphicsManager.SETCOLOR4(251, 100, 100, 100); + Common::String filename; switch (_vm->_globals._language) { case LANG_EN: - _vm->_fileManager.constructFilename("SYSTEM", "INVENTAN.SPR"); + filename = "INVENTAN.SPR"; break; case LANG_FR: - _vm->_fileManager.constructFilename("SYSTEM", "INVENTFR.SPR"); + filename = "INVENTFR.SPR"; break; case LANG_SP: - _vm->_fileManager.constructFilename("SYSTEM", "INVENTES.SPR"); + filename = "INVENTES.SPR"; break; } Common::File f; - if (!f.open(_vm->_globals._curFilename)) - error("Error opening file - %s", _vm->_globals._curFilename.c_str()); + if (!f.open(filename)) + error("Error opening file - %s", filename.c_str()); size_t filesize = f.size(); _vm->_dialogsManager._inventWin1 = _vm->_globals.allocMemory(filesize); _vm->_fileManager.readStream(f, _vm->_dialogsManager._inventWin1, filesize); f.close(); - _vm->_fileManager.constructFilename("SYSTEM", "INVENT2.SPR"); - _inventBuf2 = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _inventBuf2 = _vm->_fileManager.loadFile("INVENT2.SPR"); int v19 = _inventX = _vm->_graphicsManager._scrollOffset + 152; _inventY = 114; @@ -609,21 +610,21 @@ void DialogsManager::showSaveLoad(int a1) { hopkinsSavegameHeader header; byte *thumb; + Common::String filename; switch (_vm->_globals._language) { case LANG_EN: - _vm->_fileManager.constructFilename("SYSTEM", "SAVEAN.SPR"); + filename = "SAVEAN.SPR"; break; case LANG_FR: - _vm->_fileManager.constructFilename("SYSTEM", "SAVEFR.SPR"); + filename = "SAVEFR.SPR"; break; case LANG_SP: - _vm->_fileManager.constructFilename("SYSTEM", "SAVEES.SPR"); + filename = "SAVEES.SPR"; break; } - _vm->_objectsManager.SL_SPR = _vm->_objectsManager.loadSprite(_vm->_globals._curFilename); - _vm->_fileManager.constructFilename("SYSTEM", "SAVE2.SPR"); - _vm->_objectsManager.SL_SPR2 = _vm->_objectsManager.loadSprite(_vm->_globals._curFilename); + _vm->_objectsManager.SL_SPR = _vm->_objectsManager.loadSprite(filename); + _vm->_objectsManager.SL_SPR2 = _vm->_objectsManager.loadSprite("SAVE2.SPR"); _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager._vesaBuffer, _vm->_objectsManager.SL_SPR, _vm->_eventsManager._startPos.x + 483, 360, 0); if (_vm->_globals._language == LANG_FR) { diff --git a/engines/hopkins/files.cpp b/engines/hopkins/files.cpp index 0ff2668d07..dbb33576bc 100644 --- a/engines/hopkins/files.cpp +++ b/engines/hopkins/files.cpp @@ -72,9 +72,8 @@ void FileManager::initCensorship() { _vm->_globals._censorshipFl = false; // If file doesn't exist, fallback to uncensored - if (fileExists("SYSTEM", "BLOOD.DAT")) { - constructFilename("SYSTEM", "BLOOD.DAT"); - char *data = (char *)loadFile(_vm->_globals._curFilename); + if (fileExists("BLOOD.DAT")) { + char *data = (char *)loadFile("BLOOD.DAT"); if ((data[6] == 'u' && data[7] == 'k') || (data[6] == 'U' && data[7] == 'K')) _vm->_globals._censorshipFl = true; @@ -84,40 +83,12 @@ void FileManager::initCensorship() { } /** - * Construct a filename based on a suggested folder and filename. - * @param folder Folder to use. May be overriden for animations. - * @param file Filename + * Check if a file is present */ -void FileManager::constructFilename(const Common::String &folder, const Common::String &file) { - Common::String folderToUse = folder; - - // A lot of the code in the original engine based on COPIE_SEQ was used to determine - // whether a file resided on the CD or hard disk. Since the ScummVM implementation - // requires all the files in the same location, we only need to do a somewhat simpler - // check for animations that don't exist in the ANM folder, but rather in special - // sub-folders depending on the physical screen resolution being used. - - if (folder == "ANM" && fileExists("SVGA", file)) - folderToUse = "SVGA"; - - _vm->_globals._curFilename = Common::String::format("%s/%s", folderToUse.c_str(), file.c_str()); -} - -/** - * Construct Linux filename - */ -void FileManager::constructLinuxFilename(const Common::String &file) { - _vm->_globals._curFilename = file; -} - -/** - * Check if a file is present in a given (optional) folder - */ -bool FileManager::fileExists(const Common::String &folder, const Common::String &file) { - Common::String filename = folder.empty() ? file : - Common::String::format("%s/%s", folder.c_str(), file.c_str()); +bool FileManager::fileExists(const Common::String &file) { + Common::File f; - return Common::File::exists(filename); + return f.exists(file); } /** @@ -128,101 +99,96 @@ byte *FileManager::searchCat(const Common::String &file, int a2) { Common::File f; Common::String filename = file; + Common::String secondaryFilename = ""; filename.toUppercase(); switch (a2) { case 1: - constructFilename("LINK", "RES_INI.CAT"); - if (!f.exists(_vm->_globals._curFilename)) + if (!f.exists("RES_INI.CAT")) return g_PTRNUL; - ptr = loadFile(_vm->_globals._curFilename); - constructFilename("LINK", "RES_INI.RES"); + ptr = loadFile("RES_INI.CAT"); + secondaryFilename = "RES_INI.RES"; break; case 2: - constructFilename("LINK", "RES_REP.CAT"); - if (!f.exists(_vm->_globals._curFilename)) + if (!f.exists("RES_REP.CAT")) return g_PTRNUL; - ptr = loadFile(_vm->_globals._curFilename); - constructFilename("LINK", "RES_REP.RES"); + ptr = loadFile("RES_REP.CAT"); + secondaryFilename = "RES_REP.RES"; break; case 3: - constructFilename("LINK", "RES_LIN.CAT"); - if (!f.exists(_vm->_globals._curFilename)) + if (!f.exists("RES_LIN.CAT")) return g_PTRNUL; - ptr = loadFile(_vm->_globals._curFilename); - constructFilename("LINK", "RES_LIN.RES"); + ptr = loadFile("RES_LIN.CAT"); + secondaryFilename = "RES_LIN.RES"; break; case 4: - constructFilename("ANIM", "RES_ANI.CAT"); - if (!f.exists(_vm->_globals._curFilename)) + if (!f.exists("RES_ANI.CAT")) return g_PTRNUL; - ptr = loadFile(_vm->_globals._curFilename); - constructFilename("ANIM", "RES_ANI.RES"); + ptr = loadFile("RES_ANI.CAT"); + secondaryFilename = "RES_ANI.RES"; break; case 5: - constructFilename("ANIM", "RES_PER.CAT"); - if (!f.exists(_vm->_globals._curFilename)) + if (!f.exists("RES_PER.CAT")) return g_PTRNUL; - ptr = loadFile(_vm->_globals._curFilename); - constructFilename("ANIM", "RES_PER.RES"); + ptr = loadFile("RES_PER.CAT"); + secondaryFilename = "RES_PER.RES"; break; case 6: - constructFilename("BUFFER", "PIC.CAT"); - if (!f.exists(_vm->_globals._curFilename)) + if (!f.exists("PIC.CAT")) return g_PTRNUL; - ptr = loadFile(_vm->_globals._curFilename); + ptr = loadFile("PIC.CAT"); break; case 7: - constructFilename("ANIM", "RES_SAN.CAT"); - if (!f.exists(_vm->_globals._curFilename)) + if (!f.exists("RES_SAN.CAT")) return g_PTRNUL; - ptr = loadFile(_vm->_globals._curFilename); + ptr = loadFile("RES_SAN.CAT"); break; case 8: - constructFilename("LINK", "RES_SLI.CAT"); - if (!f.exists(_vm->_globals._curFilename)) + if (!f.exists("RES_SLI.CAT")) return g_PTRNUL; - ptr = loadFile(_vm->_globals._curFilename); + ptr = loadFile("RES_SLI.CAT"); break; - case 9: + case 9: { + Common::String tmpFilename; if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - _vm->_fileManager.constructFilename("VOICE", "ENG_VOI.RES"); + tmpFilename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names else { switch (_vm->_globals._language) { case LANG_EN: - constructFilename("LINK", "RES_VAN.CAT"); + tmpFilename = "RES_VAN.CAT"; break; case LANG_FR: - constructFilename("LINK", "RES_VFR.CAT"); + tmpFilename = "RES_VFR.CAT"; break; case LANG_SP: - constructFilename("LINK", "RES_VES.CAT"); + tmpFilename = "RES_VES.CAT"; break; } } - if (!f.exists(_vm->_globals._curFilename)) + if (!f.exists(tmpFilename)) return g_PTRNUL; - ptr = loadFile(_vm->_globals._curFilename); + ptr = loadFile(tmpFilename); break; + } // Deliberate fall-through to default: break; @@ -254,9 +220,8 @@ byte *FileManager::searchCat(const Common::String &file, int a2) { _vm->_globals.freeMemory(ptr); - // TODO: Double check whether this really should be an unsigned int comparison - if ((uint16)(a2 - 6) > 1 && (uint16)(a2 - 8) > 1) { - if (!f.open(_vm->_globals._curFilename)) + if (secondaryFilename != "") { + if (!f.open(secondaryFilename)) error("CHARGE_FICHIER"); f.seek(_vm->_globals._catalogPos); diff --git a/engines/hopkins/files.h b/engines/hopkins/files.h index b2001e2a0c..55a57955b2 100644 --- a/engines/hopkins/files.h +++ b/engines/hopkins/files.h @@ -39,15 +39,11 @@ public: FileManager(); void setParent(HopkinsEngine *vm); - bool fileExists(const Common::String &folder, const Common::String &file); + bool fileExists(const Common::String &file); byte *loadFile(const Common::String &file); int readStream(Common::ReadStream &stream, void *buf, size_t nbytes); void initCensorship(); - void constructFilename(const Common::String &folder, const Common::String &file); - byte *searchCat(const Common::String &file, int a2); - void constructLinuxFilename(const Common::String &file); - uint32 fileSize(const Common::String &filename); }; diff --git a/engines/hopkins/font.cpp b/engines/hopkins/font.cpp index da81b7bf03..8b2bc51b90 100644 --- a/engines/hopkins/font.cpp +++ b/engines/hopkins/font.cpp @@ -165,9 +165,7 @@ void FontManager::box(int idx, int messageId, const Common::String &filename, in _textSortArray[v62] = 0; _text[idx]._textLoadedFl = true; - _vm->_fileManager.constructFilename("LINK", filename); - - file = _vm->_globals._curFilename; + file = filename; if (strncmp(file.c_str(), _oldName.c_str(), strlen(file.c_str())) != 0) { // Starting to access a new file, so read in the index file for the file _oldName = file; diff --git a/engines/hopkins/globals.cpp b/engines/hopkins/globals.cpp index 1fdcccfd6a..baafaeb975 100644 --- a/engines/hopkins/globals.cpp +++ b/engines/hopkins/globals.cpp @@ -433,8 +433,7 @@ void Globals::CLEAR_VBOB() { // Load Object void Globals::loadObjects() { - _vm->_fileManager.constructFilename("SYSTEM", "OBJET.DAT"); - byte *data = _vm->_fileManager.loadFile(_curFilename); + byte *data = _vm->_fileManager.loadFile("OBJET.DAT"); byte *srcP = data; for (int idx = 0; idx < 300; ++idx) { @@ -512,16 +511,13 @@ void Globals::loadCache(const Common::String &file) { Common::File f; resetCache(); - _vm->_fileManager.constructFilename("LINK", file); - ptr = _vm->_fileManager.loadFile(_curFilename); + ptr = _vm->_fileManager.loadFile(file); v16 = Common::String((const char *)ptr); - _vm->_fileManager.constructFilename("LINK", v16); - - if (!f.exists(_curFilename)) + if (!f.exists(v16)) return; - spriteData = _vm->_fileManager.loadFile(_curFilename); + spriteData = _vm->_fileManager.loadFile(v16); CACHE_BANQUE[1] = spriteData; int v15 = 60; for (int i = 0; i <= 21; i++) { diff --git a/engines/hopkins/globals.h b/engines/hopkins/globals.h index a4f60e1cfd..877683d850 100644 --- a/engines/hopkins/globals.h +++ b/engines/hopkins/globals.h @@ -335,7 +335,6 @@ public: uint _speed; Common::String FICH_ZONE; Common::String FICH_TEXTE; - Common::String _curFilename; bool _censorshipFl; int g_old_anim; int g_old_sens, g_old_sens2; diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 0021f3539e..aaf5962cac 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -163,8 +163,7 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { lockScreen(); clearScreen(); unlockScreen(); - _vm->_fileManager.constructFilename("BUFFER", file); - A_PCX320(_vesaScreen, _vm->_globals._curFilename, _palette); + A_PCX320(_vesaScreen, file, _palette); memcpy(_vesaBuffer, _vesaScreen, 64000); SCANLINE(320); max_x = 320; @@ -184,8 +183,7 @@ void GraphicsManager::loadScreen(const Common::String &file) { bool flag = true; if (_vm->_fileManager.searchCat(file, 6) == g_PTRNUL) { - _vm->_fileManager.constructFilename("BUFFER", file); - if (!f.open(_vm->_globals._curFilename)) + if (!f.open(file)) error("loadScreen - %s", file.c_str()); f.seek(0, SEEK_END); @@ -301,15 +299,12 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by if (typeFlag) { // Load PCX from within the PIC resource - _vm->_fileManager.constructFilename("BUFFER", "PIC.RES"); - if (!f.open(_vm->_globals._curFilename)) + if (!f.open("PIC.RES")) error("Error opening PIC.RES."); f.seek(_vm->_globals._catalogPos); - } else { // Load stand alone PCX file - _vm->_fileManager.constructFilename("BUFFER", file); - if (!f.open(_vm->_globals._curFilename)) + if (!f.open(file)) error("Error opening PCX %s.", file.c_str()); } @@ -1767,8 +1762,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode, bool initia byte *ptr = _vm->_fileManager.searchCat(filename, 1); if (ptr == g_PTRNUL) { - _vm->_fileManager.constructFilename("LINK", filename); - ptr = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + ptr = _vm->_fileManager.loadFile(filename); } if (!mode) { filename = file + ".spr"; @@ -1776,11 +1770,10 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode, bool initia if (initializeScreen) { _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.searchCat(filename, 8); if (_vm->_globals.SPRITE_ECRAN) { - _vm->_fileManager.constructFilename("LINK", filename); + _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.loadFile(filename); } else { - _vm->_fileManager.constructFilename("LINK", "RES_SLI.RES"); + _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.loadFile("RES_SLI.RES"); } - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.loadFile(_vm->_globals._curFilename); } } if (ptr[0] != 'I' || ptr[1] != 'N' || ptr[2] != 'I') { @@ -1814,8 +1807,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode, bool initia byte *dataP = _vm->_fileManager.searchCat(filename, 2); _vm->_globals.COUCOU = dataP; if (g_PTRNUL == dataP) { - _vm->_fileManager.constructFilename("LINK", filename); - dataP = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + dataP = _vm->_fileManager.loadFile(filename); _vm->_globals.COUCOU = dataP; } } diff --git a/engines/hopkins/hopkins.cpp b/engines/hopkins/hopkins.cpp index 85ffc6e2f6..94bfa239db 100644 --- a/engines/hopkins/hopkins.cpp +++ b/engines/hopkins/hopkins.cpp @@ -177,8 +177,7 @@ bool HopkinsEngine::runWin95Demo() { warning("TODO Init_Interrupt_();"); _graphicsManager.fadeOutLong(); _globals.iRegul = 1; - _fileManager.constructFilename("SYSTEM", "PERSO.SPR"); - _globals.PERSO = _fileManager.loadFile(_globals._curFilename); + _globals.PERSO = _fileManager.loadFile("PERSO.SPR"); _globals.PERSO_TYPE = 0; _globals.PLANX = _globals.PLANY = 0; memset(_globals._saveData, 0, 2000); @@ -477,8 +476,7 @@ bool HopkinsEngine::runLinuxDemo() { playIntro(); _globals.iRegul = 0; - _fileManager.constructFilename("SYSTEM", "PERSO.SPR"); - _globals.PERSO = _fileManager.loadFile(_globals._curFilename); + _globals.PERSO = _fileManager.loadFile("PERSO.SPR"); _globals.PERSO_TYPE = 0; _globals.PLANX = _globals.PLANY = 0; memset(_globals._saveData, 0, 2000); @@ -836,8 +834,7 @@ bool HopkinsEngine::runFull() { _graphicsManager.fadeOutLong(); } _globals.iRegul = 0; - _fileManager.constructFilename("SYSTEM", "PERSO.SPR"); - _globals.PERSO = _fileManager.loadFile(_globals._curFilename); + _globals.PERSO = _fileManager.loadFile("PERSO.SPR"); _globals.PERSO_TYPE = 0; _globals.PLANX = _globals.PLANY = 0; memset(_globals._saveData, 0, 2000); @@ -1193,8 +1190,7 @@ bool HopkinsEngine::runFull() { Common::String im = Common::String::format("IM%d", _globals._exitId); _soundManager.WSOUND(13); if (_globals._forestSprite == g_PTRNUL) { - _fileManager.constructFilename("SYSTEM", "HOPDEG.SPR"); - _globals._forestSprite = _objectsManager.loadSprite(_globals._curFilename); + _globals._forestSprite = _objectsManager.loadSprite("HOPDEG.SPR"); _soundManager.loadSample(1, "SOUND41.WAV"); } _objectsManager.PERSONAGE2(im, im, "BANDIT", im, 13, false); @@ -1605,8 +1601,7 @@ bool HopkinsEngine::runFull() { //_globals._exitId = WBASE(); // Handles the 3D Doom level (Windows) _soundManager.WSOUND_OFF(); //warning("TODO: heapshrink();"); // Windows - _fileManager.constructFilename("SYSTEM", "PERSO.SPR"); - _globals.PERSO = _fileManager.loadFile(_globals._curFilename); + _globals.PERSO = _fileManager.loadFile("PERSO.SPR"); _globals.PERSO_TYPE = 0; _globals.iRegul = 0; _graphicsManager._lineNbr = SCREEN_WIDTH; @@ -1638,61 +1633,69 @@ void HopkinsEngine::initializeSystem() { // Synchronise the sound settings from ScummVM _soundManager.syncSoundSettings(); + const Common::FSNode gameDataDir(ConfMan.get("path")); + SearchMan.addSubDirectoryMatching(gameDataDir, "SYSTEM"); + SearchMan.addSubDirectoryMatching(gameDataDir, "BUFFER"); + SearchMan.addSubDirectoryMatching(gameDataDir, "ANIM"); + SearchMan.addSubDirectoryMatching(gameDataDir, "ANM"); + SearchMan.addSubDirectoryMatching(gameDataDir, "BASE"); + SearchMan.addSubDirectoryMatching(gameDataDir, "LINK"); + SearchMan.addSubDirectoryMatching(gameDataDir, "MUSIC"); + SearchMan.addSubDirectoryMatching(gameDataDir, "SEQ"); + SearchMan.addSubDirectoryMatching(gameDataDir, "SAVE"); + SearchMan.addSubDirectoryMatching(gameDataDir, "SOUND"); + SearchMan.addSubDirectoryMatching(gameDataDir, "SVGA"); + SearchMan.addSubDirectoryMatching(gameDataDir, "VOICE"); + SearchMan.addSubDirectoryMatching(gameDataDir, "TSVGA"); + if (getPlatform() == Common::kPlatformLinux) _eventsManager._mouseLinuxFl = true; else _eventsManager._mouseLinuxFl = false; + if (_eventsManager._mouseLinuxFl) { + _eventsManager._mouseSizeX = 52; + _eventsManager._mouseSizeY = 32; + } else { + _eventsManager._mouseSizeX = 34; + _eventsManager._mouseSizeY = 20; + } + switch (_globals._language) { case LANG_EN: if (!_eventsManager._mouseLinuxFl) - _fileManager.constructFilename("SYSTEM", "SOUAN.SPR"); + _eventsManager._mouseCursor = _fileManager.loadFile("SOUAN.SPR"); else - _fileManager.constructFilename("SYSTEM", "LSOUAN.SPR"); + _eventsManager._mouseCursor = _fileManager.loadFile("LSOUAN.SPR"); break; case LANG_FR: if (!_eventsManager._mouseLinuxFl) - _fileManager.constructFilename("SYSTEM", "SOUFR.SPR"); + _eventsManager._mouseCursor = _fileManager.loadFile("SOUFR.SPR"); else - _fileManager.constructFilename("SYSTEM", "LSOUFR.SPR"); + _eventsManager._mouseCursor = _fileManager.loadFile("LSOUFR.SPR"); break; case LANG_SP: - _fileManager.constructFilename("SYSTEM", "SOUES.SPR"); + _eventsManager._mouseCursor = _fileManager.loadFile("SOUES.SPR"); break; } - if (_eventsManager._mouseLinuxFl) { - _eventsManager._mouseSizeX = 52; - _eventsManager._mouseSizeY = 32; - } else { - _eventsManager._mouseSizeX = 34; - _eventsManager._mouseSizeY = 20; - } - _eventsManager._mouseCursor = _fileManager.loadFile(_globals._curFilename); - _globals.clearAll(); - _fileManager.constructFilename("SYSTEM", "FONTE3.SPR"); - _globals.police = _fileManager.loadFile(_globals._curFilename); + _globals.police = _fileManager.loadFile("FONTE3.SPR"); _globals.police_l = 12; _globals.police_h = 21; - _fileManager.constructFilename("SYSTEM", "ICONE.SPR"); - _globals.ICONE = _fileManager.loadFile(_globals._curFilename); - _fileManager.constructFilename("SYSTEM", "TETE.SPR"); - _globals.TETE = _fileManager.loadFile(_globals._curFilename); + _globals.ICONE = _fileManager.loadFile("ICONE.SPR"); + _globals.TETE = _fileManager.loadFile("TETE.SPR"); switch (_globals._language) { case LANG_EN: - _fileManager.constructFilename("LINK", "ZONEAN.TXT"); - _globals.BUF_ZONE = _fileManager.loadFile(_globals._curFilename); + _globals.BUF_ZONE = _fileManager.loadFile("ZONEAN.TXT"); break; case LANG_FR: - _fileManager.constructFilename("LINK", "ZONE01.TXT"); - _globals.BUF_ZONE = _fileManager.loadFile(_globals._curFilename); + _globals.BUF_ZONE = _fileManager.loadFile("ZONE01.TXT"); break; case LANG_SP: - _fileManager.constructFilename("LINK", "ZONEES.TXT"); - _globals.BUF_ZONE = _fileManager.loadFile(_globals._curFilename); + _globals.BUF_ZONE = _fileManager.loadFile("ZONEES.TXT"); break; } @@ -2318,8 +2321,7 @@ void HopkinsEngine::playEnding() { _globals.iRegul = 0; _globals._exitId = 300; } - _fileManager.constructFilename("SYSTEM", "PERSO.SPR"); - _globals.PERSO = _fileManager.loadFile(_globals._curFilename); + _globals.PERSO = _fileManager.loadFile("PERSO.SPR"); _globals.PERSO_TYPE = 0; _globals.iRegul = 0; } @@ -2457,22 +2459,22 @@ void HopkinsEngine::loadCredits() { _globals.Credit_l = 10; _globals.Credit_h = 40; _globals.Credit_step = 45; + byte *bufPtr; switch (_globals._language) { case LANG_EN: - _fileManager.constructFilename("LINK", "CREAN.TXT"); + bufPtr = _fileManager.loadFile("CREAN.TXT"); break; case LANG_FR: - _fileManager.constructFilename("LINK", "CREFR.TXT"); + bufPtr = _fileManager.loadFile("CREFR.TXT"); break; case LANG_SP: - _fileManager.constructFilename("LINK", "CREES.TXT"); + bufPtr = _fileManager.loadFile("CREES.TXT"); break; default: error("Unhandled language"); break; } - byte *bufPtr = _fileManager.loadFile(_globals._curFilename); byte *curPtr = bufPtr; int idxLines = 0; bool loopCond = false; @@ -2823,8 +2825,7 @@ void HopkinsEngine::OCEAN(int16 curExitId, Common::String backgroundFilename, in _globals._exitId = 0; _globals._disableInventFl = true; _soundManager.WSOUND(soundId); - _fileManager.constructFilename("SYSTEM", "VAISSEAU.SPR"); - _globals.PERSO = _fileManager.loadFile(_globals._curFilename); + _globals.PERSO = _fileManager.loadFile("VAISSEAU.SPR"); if (backgroundFilename.size()) _graphicsManager.loadImage(backgroundFilename); @@ -2909,8 +2910,7 @@ void HopkinsEngine::OCEAN(int16 curExitId, Common::String backgroundFilename, in _graphicsManager.fadeOutLong(); _objectsManager.removeSprite(0); _objectsManager.CLEAR_ECRAN(); - _fileManager.constructFilename("SYSTEM", "PERSO.SPR"); - _globals.PERSO = _fileManager.loadFile(_globals._curFilename); + _globals.PERSO = _fileManager.loadFile("PERSO.SPR"); _globals.PERSO_TYPE = 0; } diff --git a/engines/hopkins/menu.cpp b/engines/hopkins/menu.cpp index 582b7a16f9..9598f60a94 100644 --- a/engines/hopkins/menu.cpp +++ b/engines/hopkins/menu.cpp @@ -85,15 +85,14 @@ int MenuManager::menu() { _vm->_graphicsManager.fadeInLong(); if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - _vm->_fileManager.constructFilename("SYSTEM", "MENU.SPR"); + spriteData = _vm->_objectsManager.loadSprite("MENU.SPR"); else if (_vm->_globals._language == LANG_EN) - _vm->_fileManager.constructFilename("SYSTEM", "MENUAN.SPR"); + spriteData = _vm->_objectsManager.loadSprite("MENUAN.SPR"); else if (_vm->_globals._language == LANG_FR) - _vm->_fileManager.constructFilename("SYSTEM", "MENUFR.SPR"); + spriteData = _vm->_objectsManager.loadSprite("MENUFR.SPR"); else if (_vm->_globals._language == LANG_SP) - _vm->_fileManager.constructFilename("SYSTEM", "MENUES.SPR"); + spriteData = _vm->_objectsManager.loadSprite("MENUES.SPR"); - spriteData = _vm->_objectsManager.loadSprite(_vm->_globals._curFilename); _vm->_eventsManager.mouseOn(); _vm->_eventsManager.changeMouseCursor(0); _vm->_eventsManager._mouseCursorId = 0; diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index ebc83520bd..42b13040df 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -116,8 +116,7 @@ byte *ObjectsManager::CAPTURE_OBJET(int objIndex, int mode) { if (_vm->_globals.ADR_FICHIER_OBJ != g_PTRNUL) ObjectsManager::DEL_FICHIER_OBJ(); if (val1 == 1) { - _vm->_fileManager.constructFilename("SYSTEM", "OBJET1.SPR"); - _vm->_globals.ADR_FICHIER_OBJ = ObjectsManager::loadSprite(_vm->_globals._curFilename); + _vm->_globals.ADR_FICHIER_OBJ = ObjectsManager::loadSprite("OBJET1.SPR"); } _vm->_globals.NUM_FICHIER_OBJ = val1; } @@ -2075,8 +2074,7 @@ void ObjectsManager::CHARGE_OBSTACLE(const Common::String &file) { _vm->_linesManager.RESET_OBSTACLE(); _vm->_linesManager._linesNumb = 0; _lastLine = 0; - _vm->_fileManager.constructFilename("LINK", file); - ptr = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + ptr = _vm->_fileManager.loadFile(file); v4 = 0; v5 = 0; do { @@ -2130,13 +2128,11 @@ void ObjectsManager::loadZone(const Common::String &file) { _vm->_globals.ZONEP[i].field10 = 0; } - _vm->_fileManager.constructFilename("LINK", file); - Common::File f; - if (!f.exists(_vm->_globals._curFilename)) - error("File not found : %s", _vm->_globals._curFilename.c_str()); + if (!f.exists(file)) + error("File not found : %s", file.c_str()); - ptr = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + ptr = _vm->_fileManager.loadFile(file); v4 = 0; v18 = 0; v17 = 0; @@ -2274,8 +2270,7 @@ void ObjectsManager::PLAN_BETA() { CHARGE_OBSTACLE("PLAN.OB2"); _vm->_globals.loadCache("PLAN.CA2"); loadZone("PLAN.ZO2"); - _vm->_fileManager.constructFilename("SYSTEM", "VOITURE.SPR"); - _spritePtr = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _spritePtr = _vm->_fileManager.loadFile("VOITURE.SPR"); _vm->_animationManager.loadAnim("PLAN"); _vm->_graphicsManager.VISU_ALL(); _vm->_graphicsManager.INI_ECRAN2("PLAN", false); @@ -2737,8 +2732,7 @@ void ObjectsManager::changeCharacterHead(PlayerCharacter oldCharacter, PlayerCha T_RECTIF = 0; loc = &_vm->_globals._saveData->_realHopkins; - _vm->_fileManager.constructFilename("SYSTEM", "PERSO.SPR"); - _vm->_globals.PERSO = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _vm->_globals.PERSO = _vm->_fileManager.loadFile("PERSO.SPR"); _vm->_globals.PERSO_TYPE = 0; SPRITE(_vm->_globals.PERSO, loc->_pos, 0, 64, loc->field4, 0, 34, 190); SPRITE_ON(0); @@ -2763,8 +2757,7 @@ void ObjectsManager::changeCharacterHead(PlayerCharacter oldCharacter, PlayerCha _vm->_globals._saveData->data[svField357] = 0; loc = &_vm->_globals._saveData->_samantha; - _vm->_fileManager.constructFilename("SYSTEM", "PSAMAN.SPR"); - _vm->_globals.PERSO = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _vm->_globals.PERSO = _vm->_fileManager.loadFile("PSAMAN.SPR"); _vm->_globals.PERSO_TYPE = 2; SPRITE(_vm->_globals.PERSO, loc->_pos, 0, 64, loc->field4, 0, 20, 127); SPRITE_ON(0); @@ -3742,8 +3735,7 @@ void ObjectsManager::OPTI_OBJET() { file = "OBJET1.ini"; data = _vm->_fileManager.searchCat(file, 1); if (data == g_PTRNUL) { - _vm->_fileManager.constructFilename("LINK", file); - data = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + data = _vm->_fileManager.loadFile(file); if (data == g_PTRNUL) error("INI file %s not found", file.c_str()); } @@ -3964,9 +3956,7 @@ void ObjectsManager::ACTION_DOS(int idx) { if (_vm->_globals.GESTE_FLAG != 1) { _vm->_globals.GESTE = _vm->_globals.freeMemory(_vm->_globals.GESTE); _vm->_globals.GESTE_FLAG = 1; - - _vm->_fileManager.constructFilename("SYSTEM", "DOS.SPR"); - _vm->_globals.GESTE = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _vm->_globals.GESTE = _vm->_fileManager.loadFile("DOS.SPR"); } if (idx == 1) ACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,8,8,8,8,8,8,7,6,5,4,3,2,1,0,-1,", 0, 0, 8, 0); @@ -3994,8 +3984,7 @@ void ObjectsManager::ACTION_DROITE(int idx) { if (_vm->_globals.GESTE_FLAG != 3) { _vm->_globals.GESTE = _vm->_globals.freeMemory(_vm->_globals.GESTE); _vm->_globals.GESTE_FLAG = 3; - _vm->_fileManager.constructFilename("SYSTEM", "PROFIL.SPR"); - _vm->_globals.GESTE = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _vm->_globals.GESTE = _vm->_fileManager.loadFile("PROFIL.SPR"); } if (idx == 1) ACTION(_vm->_globals.GESTE, "20,19,18,17,16,15,14,13,13,13,13,13,14,15,16,17,18,19,20,-1,", 0, 0, 8, 0); @@ -4023,8 +4012,7 @@ void ObjectsManager::Q_DROITE(int idx) { if (_vm->_globals.GESTE_FLAG != 4) { _vm->_globals.GESTE = _vm->_globals.freeMemory(_vm->_globals.GESTE); _vm->_globals.GESTE_FLAG = 4; - _vm->_fileManager.constructFilename("SYSTEM", "3Q.SPR"); - _vm->_globals.GESTE = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _vm->_globals.GESTE = _vm->_fileManager.loadFile("3Q.SPR"); } if (idx == 1) ACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,8,8,8,8,8,7,6,5,4,3,2,1,0,-1,", 0, 0, 8, 0); @@ -4052,8 +4040,7 @@ void ObjectsManager::ACTION_FACE(int idx) { if (_vm->_globals.GESTE_FLAG != 2) { _vm->_globals.GESTE = _vm->_globals.freeMemory(_vm->_globals.GESTE); _vm->_globals.GESTE_FLAG = 2; - _vm->_fileManager.constructFilename("SYSTEM", "FACE.SPR"); - _vm->_globals.GESTE = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _vm->_globals.GESTE = _vm->_fileManager.loadFile("FACE.SPR"); } if (idx == 1) ACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,9,9,9,9,9,9,7,6,5,4,3,2,1,0,-1,", 0, 0, 8, 0); @@ -4069,8 +4056,7 @@ void ObjectsManager::Q_GAUCHE(int idx) { if (_vm->_globals.GESTE_FLAG != 4) { _vm->_globals.GESTE = _vm->_globals.freeMemory(_vm->_globals.GESTE); _vm->_globals.GESTE_FLAG = 4; - _vm->_fileManager.constructFilename("SYSTEM", "3Q.SPR"); - _vm->_globals.GESTE = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _vm->_globals.GESTE = _vm->_fileManager.loadFile("3Q.SPR"); } if (idx == 1) ACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,8,8,8,8,8,7,6,5,4,3,2,1,0,-1,", 0, 0, 8, 1); @@ -4098,8 +4084,7 @@ void ObjectsManager::ACTION_GAUCHE(int idx) { if (_vm->_globals.GESTE_FLAG != 3) { _vm->_globals.GESTE = _vm->_globals.freeMemory(_vm->_globals.GESTE); _vm->_globals.GESTE_FLAG = 3; - _vm->_fileManager.constructFilename("SYSTEM", "PROFIL.SPR"); - _vm->_globals.GESTE = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _vm->_globals.GESTE = _vm->_fileManager.loadFile("PROFIL.SPR"); } if (idx == 1) ACTION(_vm->_globals.GESTE, "20,19,18,17,16,15,14,13,13,13,13,13,14,15,16,17,18,19,20,-1,", 0, 0, 8, 1); @@ -4246,10 +4231,8 @@ void ObjectsManager::INILINK(const Common::String &file) { ptr = _vm->_fileManager.searchCat(filename, 3); nbytes = _vm->_globals._catalogSize; if (ptr == g_PTRNUL) { - _vm->_fileManager.constructFilename("LINK", filename); - - if (!f.open(_vm->_globals._curFilename)) - error("Error opening file - %s", _vm->_globals._curFilename.c_str()); + if (!f.open(filename)) + error("Error opening file - %s", filename.c_str()); nbytes = f.size(); ptr = _vm->_globals.allocMemory(nbytes); @@ -4269,12 +4252,11 @@ void ObjectsManager::INILINK(const Common::String &file) { _vm->_globals.CACHE_BANQUE[1] = _vm->_fileManager.searchCat(filename2, 8); if (_vm->_globals.CACHE_BANQUE[1] || _vm->_globals.CACHE_BANQUE[1] == g_PTRNUL) { - _vm->_fileManager.constructFilename("LINK", filename2); + _vm->_globals.CACHE_BANQUE[1] = _vm->_fileManager.loadFile(filename2); } else { - _vm->_fileManager.constructFilename("LINK", "RES_SLI.RES"); + _vm->_globals.CACHE_BANQUE[1] = _vm->_fileManager.loadFile("RES_SLI.RES"); } - _vm->_globals.CACHE_BANQUE[1] = _vm->_fileManager.loadFile(_vm->_globals._curFilename); v36 = 60; v37 = ptr + 1000; for (int v40 = 0; v40 <= 21; v40++) { @@ -5095,21 +5077,18 @@ void ObjectsManager::PERSONAGE2(const Common::String &backgroundFile, const Comm _vm->_graphicsManager.SETCOLOR3(254, 0, 0, 0); if (_vm->_globals.PERSO_TYPE) { if (!_vm->_globals._saveData->data[svField122] && !_vm->_globals._saveData->data[svField356]) { - _vm->_fileManager.constructFilename("SYSTEM", "PERSO.SPR"); - _vm->_globals.PERSO = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _vm->_globals.PERSO = _vm->_fileManager.loadFile("PERSO.SPR"); _vm->_globals.PERSO_TYPE = 0; } } if (!_vm->_globals.PERSO_TYPE) { if (_vm->_globals._saveData->data[svField122] == 1) { - _vm->_fileManager.constructFilename("SYSTEM", "HOPFEM.SPR"); - _vm->_globals.PERSO = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _vm->_globals.PERSO = _vm->_fileManager.loadFile("HOPFEM.SPR"); _vm->_globals.PERSO_TYPE = 1; } } if (_vm->_globals.PERSO_TYPE != 2 && _vm->_globals._saveData->data[svField356] == 1) { - _vm->_fileManager.constructFilename("SYSTEM", "PSAMAN.SPR"); - _vm->_globals.PERSO = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _vm->_globals.PERSO = _vm->_fileManager.loadFile("PSAMAN.SPR"); _vm->_globals.PERSO_TYPE = 2; } _vm->_globals.loadCharacterData(); diff --git a/engines/hopkins/script.cpp b/engines/hopkins/script.cpp index dae57bd47d..f98ce3a5c0 100644 --- a/engines/hopkins/script.cpp +++ b/engines/hopkins/script.cpp @@ -918,8 +918,7 @@ int ScriptManager::handleOpcode(byte *dataP) { break; case 56: - _vm->_fileManager.constructFilename("SYSTEM", "HOPFEM.SPR"); - _vm->_globals.PERSO = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _vm->_globals.PERSO = _vm->_fileManager.loadFile("HOPFEM.SPR"); _vm->_globals.PERSO_TYPE = 1; _vm->_globals._saveData->data[svField122] = 1; _vm->_globals.loadCharacterData(); @@ -929,8 +928,7 @@ int ScriptManager::handleOpcode(byte *dataP) { break; case 57: - _vm->_fileManager.constructFilename("SYSTEM", "PERSO.SPR"); - _vm->_globals.PERSO = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + _vm->_globals.PERSO = _vm->_fileManager.loadFile("PERSO.SPR"); _vm->_globals.PERSO_TYPE = 0; _vm->_globals._saveData->data[svField122] = 0; _vm->_globals.loadCharacterData(); diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 1628268eca..9fb45fa9fe 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -380,14 +380,13 @@ void SoundManager::PLAY_MOD(const Common::String &file) { modFile += "2"; } } - _vm->_fileManager.constructFilename("MUSIC", modFile); if (MOD_FLAG) { stopMusic(); delMusic(); MOD_FLAG = false; } - loadMusic(_vm->_globals._curFilename); + loadMusic(modFile); playMusic(); MOD_FLAG = true; } @@ -520,43 +519,43 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { if (!_vm->_fileManager.searchCat(filename + ".WAV", 9)) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - _vm->_fileManager.constructFilename("VOICE", "ENG_VOI.RES"); + filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names else if (_vm->_globals._language == LANG_FR) - _vm->_fileManager.constructFilename("VOICE", "RES_VFR.RES"); + filename = "RES_VFR.RES"; else if (_vm->_globals._language == LANG_EN) - _vm->_fileManager.constructFilename("VOICE", "RES_VAN.RES"); + filename = "RES_VAN.RES"; else if (_vm->_globals._language == LANG_SP) - _vm->_fileManager.constructFilename("VOICE", "RES_VES.RES"); + filename = "RES_VES.RES"; catPos = _vm->_globals._catalogPos; catLen = _vm->_globals._catalogSize; } else if (!_vm->_fileManager.searchCat(filename + ".APC", 9)) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - _vm->_fileManager.constructFilename("VOICE", "ENG_VOI.RES"); + filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names else if (_vm->_globals._language == LANG_FR) - _vm->_fileManager.constructFilename("VOICE", "RES_VFR.RES"); + filename = "RES_VFR.RES"; else if (_vm->_globals._language == LANG_EN) - _vm->_fileManager.constructFilename("VOICE", "RES_VAN.RES"); + filename = "RES_VAN.RES"; else if (_vm->_globals._language == LANG_SP) - _vm->_fileManager.constructFilename("VOICE", "RES_VES.RES"); + filename = "RES_VES.RES"; catPos = _vm->_globals._catalogPos; catLen = _vm->_globals._catalogSize; } else { - _vm->_fileManager.constructFilename("VOICE", filename + ".WAV"); - if (!f.exists(_vm->_globals._curFilename)) { - _vm->_fileManager.constructFilename("VOICE", filename + ".APC"); - if (!f.exists(_vm->_globals._curFilename)) + if (!f.exists(filename + ".WAV")) { + if (!f.exists(filename + ".APC")) return false; - } + filename = filename + ".APC"; + } else + filename = filename + ".WAV"; catPos = 0; catLen = 0; } - SDL_LVOICE(catPos, catLen); + SDL_LVOICE(filename, catPos, catLen); oldMusicVol = _musicVolume; if (!_musicOffFl && _musicVolume > 2) _musicVolume = (signed int)((long double)_musicVolume - (long double)_musicVolume / 100.0 * 45.0); @@ -626,8 +625,7 @@ void SoundManager::MODSetMusicVolume(int volume) { } void SoundManager::loadSample(int wavIndex, const Common::String &file) { - _vm->_fileManager.constructFilename("SOUND", file); - LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals._curFilename, 0); + LOAD_SAMPLE2_SDL(wavIndex, file, 0); SOUND[wavIndex]._active = true; } @@ -700,9 +698,9 @@ void SoundManager::stopVoice(int voiceIndex) { Voice[voiceIndex].field14 = 0; } -void SoundManager::SDL_LVOICE(size_t filePosition, size_t entryLength) { - if (!SDL_LoadVoice(_vm->_globals._curFilename, filePosition, entryLength, Swav[20])) - error("Couldn't load the sample %s", _vm->_globals._curFilename.c_str()); +void SoundManager::SDL_LVOICE(Common::String filename, size_t filePosition, size_t entryLength) { + if (!SDL_LoadVoice(filename, filePosition, entryLength, Swav[20])) + error("Couldn't load the sample %s", filename.c_str()); Swav[20]._active = true; } @@ -758,8 +756,7 @@ void SoundManager::LOAD_SAMPLE2_SDL(int wavIndex, const Common::String &filename } void SoundManager::LOAD_NWAV(const Common::String &file, int wavIndex) { - _vm->_fileManager.constructFilename("SOUND", file); - LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals._curFilename, 1); + LOAD_SAMPLE2_SDL(wavIndex, file, 1); } void SoundManager::PLAY_NWAV(int wavIndex) { diff --git a/engines/hopkins/sound.h b/engines/hopkins/sound.h index 15efc85c4d..c6563209c9 100644 --- a/engines/hopkins/sound.h +++ b/engines/hopkins/sound.h @@ -69,7 +69,7 @@ private: int VOICE_STAT(int voiceIndex); void stopVoice(int voiceIndex); - void SDL_LVOICE(size_t filePosition, size_t entryLength); + void SDL_LVOICE(Common::String filename, size_t filePosition, size_t entryLength); void PLAY_VOICE_SDL(); bool DEL_SAMPLE_SDL(int wavIndex); bool SDL_LoadVoice(const Common::String &filename, size_t fileOffset, size_t entryLength, SwavItem &item); diff --git a/engines/hopkins/talk.cpp b/engines/hopkins/talk.cpp index 3d00c441fd..ff4642c18e 100644 --- a/engines/hopkins/talk.cpp +++ b/engines/hopkins/talk.cpp @@ -62,9 +62,8 @@ void TalkManager::PARLER_PERSO(const Common::String &filename) { _characterBuffer = _vm->_fileManager.searchCat(filename, 5); _characterSize = _vm->_globals._catalogSize; if (_characterBuffer == g_PTRNUL) { - _vm->_fileManager.constructFilename("ANIM", filename); - _characterBuffer = _vm->_fileManager.loadFile(_vm->_globals._curFilename); - _characterSize = _vm->_fileManager.fileSize(_vm->_globals._curFilename); + _characterBuffer = _vm->_fileManager.loadFile(filename); + _characterSize = _vm->_fileManager.fileSize(filename); } _vm->_globals._saveData->data[svField4] = 0; getStringFromBuffer(40, spriteFilename, (const char *)_characterBuffer); @@ -81,17 +80,15 @@ void TalkManager::PARLER_PERSO(const Common::String &filename) { _paletteBufferIdx = 20 * (int16)READ_LE_UINT16((uint16 *)_characterBuffer + 42) + 110; _characterSprite = _vm->_fileManager.searchCat(spriteFilename, 7); if (_characterSprite) { - _vm->_fileManager.constructFilename("ANIM", spriteFilename); + _characterSprite = _vm->_objectsManager.loadSprite(spriteFilename); } else { - _vm->_fileManager.constructFilename("ANIM", "RES_SAN.RES"); + _characterSprite = _vm->_objectsManager.loadSprite("RES_SAN.RES"); } - _characterSprite = _vm->_objectsManager.loadSprite(_vm->_globals._curFilename); - _vm->_fileManager.constructLinuxFilename("TEMP.SCR"); if (_vm->_graphicsManager._lineNbr == SCREEN_WIDTH) - _vm->_saveLoadManager.saveFile(_vm->_globals._curFilename, _vm->_graphicsManager._vesaScreen, 307200); + _vm->_saveLoadManager.saveFile("TEMP.SCR", _vm->_graphicsManager._vesaScreen, 307200); else if (_vm->_graphicsManager._lineNbr == (SCREEN_WIDTH * 2)) - _vm->_saveLoadManager.saveFile(_vm->_globals._curFilename, _vm->_graphicsManager._vesaScreen, 614400); + _vm->_saveLoadManager.saveFile("TEMP.SCR", _vm->_graphicsManager._vesaScreen, 614400); if (!_vm->_graphicsManager._lineNbr) _vm->_graphicsManager._scrollOffset = 0; @@ -163,9 +160,8 @@ void TalkManager::PARLER_PERSO2(const Common::String &filename) { _characterBuffer = _vm->_fileManager.searchCat(filename, 5); _characterSize = _vm->_globals._catalogSize; if (_characterBuffer == g_PTRNUL) { - _vm->_fileManager.constructFilename("ANIM", filename); - _characterBuffer = _vm->_fileManager.loadFile(_vm->_globals._curFilename); - _characterSize = _vm->_fileManager.fileSize(_vm->_globals._curFilename); + _characterBuffer = _vm->_fileManager.loadFile(filename); + _characterSize = _vm->_fileManager.fileSize(filename); } _vm->_globals._saveData->data[svField4] = 0; @@ -576,10 +572,9 @@ int TalkManager::VERIF_BOITE(int idx, const Common::String &file, int a3) { v18 = 0; _vm->_globals.police_l = 11; - _vm->_fileManager.constructFilename("LINK", file); // Build up the filename - filename = dest = _vm->_globals._curFilename; + filename = dest = file; while (filename.lastChar() != '.') filename.deleteLastChar(); filename += "IND"; @@ -1087,9 +1082,8 @@ void TalkManager::OBJET_VIVANT(const Common::String &a2) { _characterBuffer = _vm->_fileManager.searchCat(a2, 5); _characterSize = _vm->_globals._catalogSize; if (_characterBuffer == g_PTRNUL) { - _vm->_fileManager.constructFilename("ANIM", a2); - _characterBuffer = _vm->_fileManager.loadFile(_vm->_globals._curFilename); - _characterSize = _vm->_fileManager.fileSize(_vm->_globals._curFilename); + _characterBuffer = _vm->_fileManager.loadFile(a2); + _characterSize = _vm->_fileManager.fileSize(a2); } getStringFromBuffer(40, v23, (const char *)_characterBuffer); getStringFromBuffer(0, v22, (const char *)_characterBuffer); @@ -1100,17 +1094,14 @@ void TalkManager::OBJET_VIVANT(const Common::String &a2) { _characterSprite = _vm->_fileManager.searchCat(v23, 7); if (_characterSprite) - _vm->_fileManager.constructFilename("ANIM", v23); + _characterSprite = _vm->_objectsManager.loadSprite(v23); else - _vm->_fileManager.constructFilename("ANIM", "RES_SAN.RES"); + _characterSprite = _vm->_objectsManager.loadSprite("RES_SAN.RES"); - _characterSprite = _vm->_objectsManager.loadSprite(_vm->_globals._curFilename); - - _vm->_fileManager.constructLinuxFilename("TEMP.SCR"); if (_vm->_graphicsManager._lineNbr == SCREEN_WIDTH) - _vm->_saveLoadManager.saveFile(_vm->_globals._curFilename, _vm->_graphicsManager._vesaScreen, 307200); + _vm->_saveLoadManager.saveFile("TEMP.SCR", _vm->_graphicsManager._vesaScreen, 307200); else if (_vm->_graphicsManager._lineNbr == (SCREEN_WIDTH * 2)) - _vm->_saveLoadManager.saveFile(_vm->_globals._curFilename, _vm->_graphicsManager._vesaScreen, 614400); + _vm->_saveLoadManager.saveFile("TEMP.SCR", _vm->_graphicsManager._vesaScreen, 614400); if (!_vm->_graphicsManager._lineNbr) _vm->_graphicsManager._scrollOffset = 0; |