[Scummvm-git-logs] scummvm master -> aa8325243abcc54ed50f36485edd1024197fd9d5

OMGPizzaGuy noreply at scummvm.org
Sat Jan 20 02:21:53 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
aa8325243a ULTIMA8: Migrate more code to Path


Commit: aa8325243abcc54ed50f36485edd1024197fd9d5
    https://github.com/scummvm/scummvm/commit/aa8325243abcc54ed50f36485edd1024197fd9d5
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2024-01-19T20:21:36-06:00

Commit Message:
ULTIMA8: Migrate more code to Path

Changed paths:
    engines/ultima/ultima8/audio/cru_music_process.cpp
    engines/ultima/ultima8/conf/config_file_manager.cpp
    engines/ultima/ultima8/conf/config_file_manager.h
    engines/ultima/ultima8/filesys/file_system.cpp
    engines/ultima/ultima8/filesys/file_system.h
    engines/ultima/ultima8/games/cru_game.cpp
    engines/ultima/ultima8/games/game_data.cpp
    engines/ultima/ultima8/games/u8_game.cpp
    engines/ultima/ultima8/graphics/fonts/font_manager.cpp
    engines/ultima/ultima8/graphics/fonts/font_manager.h
    engines/ultima/ultima8/gumps/movie_gump.cpp
    engines/ultima/ultima8/misc/debugger.cpp


diff --git a/engines/ultima/ultima8/audio/cru_music_process.cpp b/engines/ultima/ultima8/audio/cru_music_process.cpp
index e76f50e9b13..a25c295f439 100644
--- a/engines/ultima/ultima8/audio/cru_music_process.cpp
+++ b/engines/ultima/ultima8/audio/cru_music_process.cpp
@@ -186,7 +186,7 @@ void CruMusicProcess::playMusic_internal(int track) {
 		const Std::string fname = Std::string::format("sound/%s.amf", _trackNames[track]);
 		FileSystem *filesystem = FileSystem::get_instance();
 		assert(filesystem);
-		Common::SeekableReadStream *rs = filesystem->ReadFile(fname);
+		Common::SeekableReadStream *rs = filesystem->ReadFile(fname.c_str());
 		if (!rs) {
 			// This happens in No Regret demo.
 			warning("Couldn't load AMF file: %s", fname.c_str());
diff --git a/engines/ultima/ultima8/conf/config_file_manager.cpp b/engines/ultima/ultima8/conf/config_file_manager.cpp
index 66107c1bf43..5153fcfdb6f 100644
--- a/engines/ultima/ultima8/conf/config_file_manager.cpp
+++ b/engines/ultima/ultima8/conf/config_file_manager.cpp
@@ -43,7 +43,7 @@ ConfigFileManager::~ConfigFileManager() {
 	_configFileManager = nullptr;
 }
 
-bool ConfigFileManager::readConfigFile(string fname, const Std::string &category) {
+bool ConfigFileManager::readConfigFile(const Common::Path &fname, const Std::string &category) {
 	Common::SeekableReadStream *f = FileSystem::get_instance()->ReadFile(fname);
 	if (!f) return false;
 
diff --git a/engines/ultima/ultima8/conf/config_file_manager.h b/engines/ultima/ultima8/conf/config_file_manager.h
index 8ca3347fb97..513154a445b 100644
--- a/engines/ultima/ultima8/conf/config_file_manager.h
+++ b/engines/ultima/ultima8/conf/config_file_manager.h
@@ -50,7 +50,7 @@ public:
 	//! \param root The name of the root node in the file
 	//! \param readonly If true, don't write to this file's tree (or the file)
 	//! \return true if successful
-	bool readConfigFile(Std::string fname, const Std::string &category);
+	bool readConfigFile(const Common::Path &fname, const Std::string &category);
 
 	//! clear everything
 	void clear();
diff --git a/engines/ultima/ultima8/filesys/file_system.cpp b/engines/ultima/ultima8/filesys/file_system.cpp
index b59e2f53d00..c47c834fef5 100644
--- a/engines/ultima/ultima8/filesys/file_system.cpp
+++ b/engines/ultima/ultima8/filesys/file_system.cpp
@@ -40,9 +40,8 @@ FileSystem::~FileSystem() {
 
 
 // Open a streaming file as readable. Streamed (0 on failure)
-Common::SeekableReadStream *FileSystem::ReadFile(const string &vfn) {
+Common::SeekableReadStream *FileSystem::ReadFile(const Common::Path &path) {
 	Common::File *f = new Common::File();
-	Common::Path path(vfn);
 	if (f->open(path))
 		return f;
 
diff --git a/engines/ultima/ultima8/filesys/file_system.h b/engines/ultima/ultima8/filesys/file_system.h
index b2b7d12f6ad..1ec318f182b 100644
--- a/engines/ultima/ultima8/filesys/file_system.h
+++ b/engines/ultima/ultima8/filesys/file_system.h
@@ -22,7 +22,6 @@
 #ifndef ULTIMA8_FILESYS_FILESYSTEM_H
 #define ULTIMA8_FILESYS_FILESYSTEM_H
 
-#include "ultima/shared/std/string.h"
 #include "common/file.h"
 
 namespace Ultima {
@@ -37,10 +36,7 @@ public:
 		return _fileSystem;
 	}
 
-	//! Open a file as readable. Streamed.
-	//! \param vfn the (virtual) filename
-	//! \return nullptr on failure
-	Common::SeekableReadStream *ReadFile(const Std::string &vfn);
+	Common::SeekableReadStream *ReadFile(const Common::Path &path);
 
 private:
 	static FileSystem *_fileSystem;
diff --git a/engines/ultima/ultima8/games/cru_game.cpp b/engines/ultima/ultima8/games/cru_game.cpp
index e6b59bcb219..edc3e71efd4 100644
--- a/engines/ultima/ultima8/games/cru_game.cpp
+++ b/engines/ultima/ultima8/games/cru_game.cpp
@@ -183,10 +183,10 @@ void CruGame::playDemoScreen() {
 	Process *menuproc = new MainMenuProcess();
 	Kernel::get_instance()->addProcess(menuproc);
 
-	static const Std::string bmp_filename = "static/buyme.dat";
+	static const Common::Path bmp_filename = "static/buyme.dat";
 	Common::SeekableReadStream *bmprs = FileSystem::get_instance()->ReadFile(bmp_filename);
 	if (!bmprs) {
-		warning("RemorseGame::playDemoScreen: error opening demo background: %s", bmp_filename.c_str());
+		warning("RemorseGame::playDemoScreen: error opening demo background: %s", bmp_filename.toString().c_str());
 		return;
 	}
 	Gump *gump = new CruDemoGump(bmprs);
@@ -200,17 +200,17 @@ void CruGame::playDemoScreen() {
 }
 
 ProcId CruGame::playCreditsNoMenu() {
-	static const Std::string txt_filename = "static/credits.dat";
-	static const Std::string bmp_filename = "static/cred.dat";
+	static const Common::Path txt_filename = "static/credits.dat";
+	static const Common::Path bmp_filename = "static/cred.dat";
 	Common::SeekableReadStream *txtrs = FileSystem::get_instance()->ReadFile(txt_filename);
 	Common::SeekableReadStream *bmprs = FileSystem::get_instance()->ReadFile(bmp_filename);
 
 	if (!txtrs) {
-		warning("RemorseGame::playCredits: error opening credits text: %s", txt_filename.c_str());
+		warning("RemorseGame::playCredits: error opening credits text: %s", txt_filename.toString().c_str());
 		return 0;
 	}
 	if (!bmprs) {
-		warning("RemorseGame::playCredits: error opening credits background: %s", bmp_filename.c_str());
+		warning("RemorseGame::playCredits: error opening credits background: %s", bmp_filename.toString().c_str());
 		return 0;
 	}
 	Gump *creditsgump = new CruCreditsGump(txtrs, bmprs);
diff --git a/engines/ultima/ultima8/games/game_data.cpp b/engines/ultima/ultima8/games/game_data.cpp
index 3babd038bd2..d8583fdf01f 100644
--- a/engines/ultima/ultima8/games/game_data.cpp
+++ b/engines/ultima/ultima8/games/game_data.cpp
@@ -144,7 +144,7 @@ const ShapeFrame *GameData::getFrame(FrameID f) const {
 
 void GameData::loadTranslation() {
 	ConfigFileManager *config = ConfigFileManager::get_instance();
-	Std::string translationfile;
+	Common::Path translationfile;
 
 	if (_gameInfo->_type == GameInfo::GAME_U8) {
 		switch (_gameInfo->_language) {
@@ -171,7 +171,7 @@ void GameData::loadTranslation() {
 	}
 
 	if (!translationfile.empty()) {
-		debug(MM_INFO, "Loading translation: %s", translationfile.c_str());
+		debug(MM_INFO, "Loading translation: %s", translationfile.toString().c_str());
 
 		config->readConfigFile(translationfile, "language");
 	}
@@ -242,7 +242,7 @@ void GameData::loadU8Data() {
 	filename += "usecode.flx";
 
 
-	Common::SeekableReadStream *uds = filesystem->ReadFile(filename);
+	Common::SeekableReadStream *uds = filesystem->ReadFile(filename.c_str());
 	if (!uds)
 		error("Unable to load %s", filename.c_str());
 
@@ -419,7 +419,7 @@ void GameData::setupTTFOverrides(const char *category, bool SJIS) {
 			continue;
 		}
 
-		const Std::string &filename = vals[0];
+		const Common::Path filename(vals[0]);
 		int pointsize = atoi(vals[1].c_str());
 		uint32 col32 = strtol(vals[2].c_str(), 0, 0);
 		int border = atoi(vals[3].c_str());
@@ -441,12 +441,6 @@ SpeechFlex *GameData::getSpeechFlex(uint32 shapeNum) {
 	s = new SpeechFlex*;
 	*s = nullptr;
 
-	FileSystem *filesystem = FileSystem::get_instance();
-
-	static const Std::string u8_sound_ = "sound/";
-	char num_flx [32];
-	snprintf(num_flx , 32, "%i.flx", shapeNum);
-
 	char langletter = _gameInfo->getLanguageFileLetter();
 	if (!langletter) {
 		warning("GameData::getSpeechFlex: Unknown language.");
@@ -454,7 +448,10 @@ SpeechFlex *GameData::getSpeechFlex(uint32 shapeNum) {
 		return nullptr;
 	}
 
-	Common::SeekableReadStream *sflx = filesystem->ReadFile(u8_sound_ + langletter + num_flx);
+	Common::Path path(Common::String::format("sound/%c%i.flx", langletter, shapeNum));
+
+	FileSystem *filesystem = FileSystem::get_instance();
+	Common::SeekableReadStream *sflx = filesystem->ReadFile(path);
 	if (sflx) {
 		*s = new SpeechFlex(sflx);
 	}
@@ -517,8 +514,7 @@ void GameData::loadRemorseData() {
 	filename += langletter;
 	filename += "usecode.flx";
 
-
-	Common::SeekableReadStream *uds = filesystem->ReadFile(filename);
+	Common::SeekableReadStream *uds = filesystem->ReadFile(filename.c_str());
 	if (!uds)
 		error("Unable to load %s", filename.c_str());
 
diff --git a/engines/ultima/ultima8/games/u8_game.cpp b/engines/ultima/ultima8/games/u8_game.cpp
index 4640ff3356e..2f62fa549fe 100644
--- a/engines/ultima/ultima8/games/u8_game.cpp
+++ b/engines/ultima/ultima8/games/u8_game.cpp
@@ -161,12 +161,12 @@ ProcId U8Game::playIntroMovie(bool fade) {
 		return 0;
 	}
 
-	Std::string filename = "static/";
+	Common::String filename = "static/";
 	filename += langletter;
 	filename += "intro.skf";
 
 	FileSystem *filesys = FileSystem::get_instance();
-	Common::SeekableReadStream *skf = filesys->ReadFile(filename);
+	Common::SeekableReadStream *skf = filesys->ReadFile(filename.c_str());
 	if (!skf) {
 		debug(MM_INFO, "U8Game::playIntro: movie not found.");
 		return 0;
@@ -176,7 +176,7 @@ ProcId U8Game::playIntroMovie(bool fade) {
 }
 
 ProcId U8Game::playEndgameMovie(bool fade) {
-	static const Std::string filename = "static/endgame.skf";
+	static const Common::Path filename = "static/endgame.skf";
 	FileSystem *filesys = FileSystem::get_instance();
 	Common::SeekableReadStream *skf = filesys->ReadFile(filename);
 	if (!skf) {
@@ -194,11 +194,12 @@ void U8Game::playCredits() {
 		warning("U8Game::playCredits: Unknown language.");
 		return;
 	}
-	Std::string filename = "static/";
+
+	Common::String filename = "static/";
 	filename += langletter;
 	filename += "credits.dat";
 
-	Common::SeekableReadStream *rs = FileSystem::get_instance()->ReadFile(filename);
+	Common::SeekableReadStream *rs = FileSystem::get_instance()->ReadFile(filename.c_str());
 	if (!rs) {
 		warning("U8Game::playCredits: error opening credits file: %s", filename.c_str());
 		return;
@@ -216,11 +217,11 @@ void U8Game::playCredits() {
 }
 
 void U8Game::playQuotes() {
-	static const Std::string filename = "static/quotes.dat";
+	static const Common::Path filename = "static/quotes.dat";
 
 	Common::SeekableReadStream *rs = FileSystem::get_instance()->ReadFile(filename);
 	if (!rs) {
-		warning("U8Game::playQuotes: error opening quotes file: %s", filename.c_str());
+		warning("U8Game::playQuotes: error opening quotes file: %s", filename.toString().c_str());
 		return;
 	}
 	const Std::string text = getCreditText(rs);
diff --git a/engines/ultima/ultima8/graphics/fonts/font_manager.cpp b/engines/ultima/ultima8/graphics/fonts/font_manager.cpp
index 8335b48864b..7b2de346eb0 100644
--- a/engines/ultima/ultima8/graphics/fonts/font_manager.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/font_manager.cpp
@@ -87,7 +87,7 @@ Font *FontManager::getTTFont(unsigned int fontnum) {
 }
 
 
-Graphics::Font *FontManager::getTTF_Font(const Std::string &filename, int pointsize, bool antialiasing) {
+Graphics::Font *FontManager::getTTF_Font(const Common::Path &filename, int pointsize, bool antialiasing) {
 	TTFId id;
 	id._filename = filename;
 	id._pointSize = pointsize;
@@ -101,7 +101,7 @@ Graphics::Font *FontManager::getTTF_Font(const Std::string &filename, int points
 	Common::SeekableReadStream *fontids;
 	fontids = FileSystem::get_instance()->ReadFile(filename);
 	if (!fontids) {
-		warning("Failed to open TTF: %s", filename.c_str());
+		warning("Failed to open TTF: %s", filename.toString().c_str());
 		return nullptr;
 	}
 
@@ -112,13 +112,13 @@ Graphics::Font *FontManager::getTTF_Font(const Std::string &filename, int points
 	Graphics::Font *font = Graphics::loadTTFFont(*fontids, pointsize, Graphics::kTTFSizeModeCharacter, 0, 0, mode, 0, false);
 
 	if (!font) {
-		warning("Failed to open TTF: %s", filename.c_str());
+		warning("Failed to open TTF: %s", filename.toString().c_str());
 		return nullptr;
 	}
 
 	_ttfFonts[id] = font;
 
-	debugC(kDebugGraphics, "Opened TTF: %s.", filename.c_str());
+	debugC(kDebugGraphics, "Opened TTF: %s.", filename.toString().c_str());
 	return font;
 #else // !USE_FREETYPE2
 	return nullptr;
@@ -136,7 +136,7 @@ void FontManager::setOverride(unsigned int fontnum, Font *newFont) {
 }
 
 
-bool FontManager::addTTFOverride(unsigned int fontnum, const Std::string &filename,
+bool FontManager::addTTFOverride(unsigned int fontnum, const Common::Path &filename,
 								 int pointsize, uint32 rgb, int bordersize,
 								 bool SJIS) {
 	bool antialiasing = ConfMan.getBool("font_antialiasing");
@@ -184,7 +184,7 @@ bool FontManager::addJPOverride(unsigned int fontnum,
 }
 
 
-bool FontManager::loadTTFont(unsigned int fontnum, const Std::string &filename,
+bool FontManager::loadTTFont(unsigned int fontnum, const Common::Path &filename,
 							 int pointsize, uint32 rgb, int bordersize) {
 	bool antialiasing = ConfMan.getBool("font_antialiasing");
 	Graphics::Font *f = getTTF_Font(filename, pointsize, antialiasing);
diff --git a/engines/ultima/ultima8/graphics/fonts/font_manager.h b/engines/ultima/ultima8/graphics/fonts/font_manager.h
index 9104425831e..67a343c92fa 100644
--- a/engines/ultima/ultima8/graphics/fonts/font_manager.h
+++ b/engines/ultima/ultima8/graphics/fonts/font_manager.h
@@ -40,7 +40,7 @@ class TTFont;
 class FontManager {
 private:
 	struct TTFId {
-		Std::string _filename;
+		Common::Path _filename;
 		int _pointSize;
 		bool operator<(const TTFId &other) const {
 			return (_pointSize < other._pointSize ||
@@ -67,7 +67,7 @@ private:
 
 	//! Get a (possibly cached) TTF_Font structure for filename/pointsize,
 	//! loading it if necessary.
-	Graphics::Font *getTTF_Font(const Std::string &filename, int pointsize, bool antialiasing);
+	Graphics::Font *getTTF_Font(const Common::Path &filename, int pointsize, bool antialiasing);
 
 	//! Override fontnum with specified font
 	void setOverride(unsigned int fontnum, Font *newFont);
@@ -101,7 +101,7 @@ public:
 	//! \param rgb the color to use for the font
 	//! \param bordersize the size of the black border to add
 	//! \param SJIS true for a Japanese game font
-	bool addTTFOverride(unsigned int fontnum, const Std::string &filename,
+	bool addTTFOverride(unsigned int fontnum, const Common::Path &filename,
 	                    int pointsize, uint32 rgb, int bordersize,
 	                    bool SJIS = false);
 
@@ -112,7 +112,7 @@ public:
 	bool addJPOverride(unsigned int fontnum, unsigned int jpfont, uint32 rgb);
 
 	//! load a TTF (for non-game fonts)
-	bool loadTTFont(unsigned int ttfnum, const Std::string &filename,
+	bool loadTTFont(unsigned int ttfnum, const Common::Path &filename,
 	                int pointsize, uint32 rgb, int bordersize);
 
 	// Reset the game fonts
diff --git a/engines/ultima/ultima8/gumps/movie_gump.cpp b/engines/ultima/ultima8/gumps/movie_gump.cpp
index 001bf583a23..56e32378f20 100644
--- a/engines/ultima/ultima8/gumps/movie_gump.cpp
+++ b/engines/ultima/ultima8/gumps/movie_gump.cpp
@@ -79,11 +79,11 @@ static Std::string _fixCrusaderMovieName(const Std::string &s) {
 static Common::SeekableReadStream *_tryLoadCruMovieFile(const Std::string &filename, const char *extn) {
 	const Std::string path = Std::string::format("flics/%s.%s", filename.c_str(), extn);
 	FileSystem *filesys = FileSystem::get_instance();
-	Common::SeekableReadStream *rs = filesys->ReadFile(path);
+	Common::SeekableReadStream *rs = filesys->ReadFile(path.c_str());
 	if (!rs) {
 		// Try with a "0" in the name
 		const Std::string adjustedfn = Std::string::format("flics/0%s.%s", filename.c_str(), extn);
-		rs = filesys->ReadFile(adjustedfn);
+		rs = filesys->ReadFile(adjustedfn.c_str());
 		if (!rs)
 			return nullptr;
 	}
diff --git a/engines/ultima/ultima8/misc/debugger.cpp b/engines/ultima/ultima8/misc/debugger.cpp
index 3a39af0323b..fda82e736f1 100644
--- a/engines/ultima/ultima8/misc/debugger.cpp
+++ b/engines/ultima/ultima8/misc/debugger.cpp
@@ -1748,9 +1748,9 @@ bool Debugger::cmdPlayMovie(int argc, const char **argv) {
 		return true;
 	}
 
-	Std::string filename = Common::String::format("static/%s.skf", argv[1]);
+	Common::String filename = Common::String::format("static/%s.skf", argv[1]);
 	FileSystem *filesys = FileSystem::get_instance();
-	Common::SeekableReadStream *skf = filesys->ReadFile(filename);
+	Common::SeekableReadStream *skf = filesys->ReadFile(filename.c_str());
 	if (!skf) {
 		debugPrintf("movie not found.\n");
 		return true;




More information about the Scummvm-git-logs mailing list