From a1a5407c64c6d2736ddf3e4718d08967db9f68e6 Mon Sep 17 00:00:00 2001 From: Le Philousophe Date: Tue, 31 Oct 2023 22:44:17 +0100 Subject: [PATCH] HUGO: Migrate engine to Path --- engines/hugo/file.cpp | 6 +++--- engines/hugo/file_v1d.cpp | 13 +++++++------ engines/hugo/hugo.h | 2 +- engines/hugo/schedule.cpp | 8 ++++---- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/engines/hugo/file.cpp b/engines/hugo/file.cpp index 9c9040584c2..86d1cfdd2ce 100644 --- a/engines/hugo/file.cpp +++ b/engines/hugo/file.cpp @@ -165,12 +165,12 @@ void FileManager::readImage(const int objNum, Object *objPtr) { _objectsArchive.seek(objBlock.objOffset, SEEK_SET); } else { - Common::String buf; - buf = _vm->_picDir + Common::String(_vm->_text->getNoun(objPtr->_nounIndex, 0)) + ".PIX"; + Common::Path buf; + buf = _vm->_picDir.appendComponent(Common::String(_vm->_text->getNoun(objPtr->_nounIndex, 0)) + ".PIX"); if (!_objectsArchive.open(buf)) { buf = Common::String(_vm->_text->getNoun(objPtr->_nounIndex, 0)) + ".PIX"; if (!_objectsArchive.open(buf)) - error("File not found: %s", buf.c_str()); + error("File not found: %s", buf.toString().c_str()); } } diff --git a/engines/hugo/file_v1d.cpp b/engines/hugo/file_v1d.cpp index d63eb8553fe..3ba7874dfab 100644 --- a/engines/hugo/file_v1d.cpp +++ b/engines/hugo/file_v1d.cpp @@ -58,16 +58,17 @@ void FileManager_v1d::readOverlay(const int screenNum, ImagePtr image, const Ovl debugC(1, kDebugFile, "readOverlay(%d, ...)", screenNum); const char *ovlExt[] = {".b", ".o", ".ob"}; - Common::String buf = Common::String(_vm->_text->getScreenNames(screenNum)) + Common::String(ovlExt[overlayType]); + Common::Path buf(_vm->_text->getScreenNames(screenNum)); + buf.appendInPlace(ovlExt[overlayType]); if (!Common::File::exists(buf)) { memset(image, 0, kOvlSize); - warning("File not found: %s", buf.c_str()); + warning("File not found: %s", buf.toString().c_str()); return; } if (!_sceneryArchive1.open(buf)) - error("File not found: %s", buf.c_str()); + error("File not found: %s", buf.toString().c_str()); ImagePtr tmpImage = image; // temp ptr to overlay file @@ -81,10 +82,10 @@ void FileManager_v1d::readOverlay(const int screenNum, ImagePtr image, const Ovl void FileManager_v1d::readBackground(const int screenIndex) { debugC(1, kDebugFile, "readBackground(%d)", screenIndex); - Common::String buf; - buf = Common::String(_vm->_text->getScreenNames(screenIndex)) + ".ART"; + Common::Path buf(_vm->_text->getScreenNames(screenIndex)); + buf.appendInPlace(".ART"); if (!_sceneryArchive1.open(buf)) - error("File not found: %s", buf.c_str()); + error("File not found: %s", buf.toString().c_str()); // Read the image into dummy seq and static dib_a Seq *dummySeq; // Image sequence structure for Read_pcx dummySeq = readPCX(_sceneryArchive1, nullptr, _vm->_screen->getFrontBuffer(), true, _vm->_text->getScreenNames(screenIndex)); diff --git a/engines/hugo/hugo.h b/engines/hugo/hugo.h index d9863086c4d..86cfcc5bd57 100644 --- a/engines/hugo/hugo.h +++ b/engines/hugo/hugo.h @@ -219,7 +219,7 @@ public: Common::RandomSource *_rnd; const char *_episode; - Common::String _picDir; + Common::Path _picDir; Command _statusLine; Command _scoreLine; diff --git a/engines/hugo/schedule.cpp b/engines/hugo/schedule.cpp index 69257ef755d..0b5c5ec4fac 100644 --- a/engines/hugo/schedule.cpp +++ b/engines/hugo/schedule.cpp @@ -178,10 +178,10 @@ void Scheduler::newScreen(const int screenIndex) { // Make sure the background file exists! if (!_vm->isPacked()) { - Common::String filename = Common::String(_vm->_text->getScreenNames(screenIndex)); - if (!Common::File::exists(_vm->_picDir + filename + ".PCX") && - !Common::File::exists(filename + ".ART")) { - error("Unable to find background file for %s", filename.c_str()); + Common::Path filename = _vm->_picDir.appendComponent(Common::String(_vm->_text->getScreenNames(screenIndex))); + if (!Common::File::exists(filename.append(".PCX")) && + !Common::File::exists(filename.append(".ART"))) { + error("Unable to find background file for %s", filename.toString().c_str()); return; } }