[Scummvm-git-logs] scummvm master -> 66d0229272d9f2d38e79a7da08e1079372342c3c

OMGPizzaGuy noreply at scummvm.org
Wed Jun 5 03:44:38 UTC 2024


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

Summary:
0512544750 ULTIMA8: Remove DebugLevel enum values.
66d0229272 ULTIMA8: Replace string utility functions


Commit: 0512544750eabf5e22df22c73e3c0342fa7cbef7
    https://github.com/scummvm/scummvm/commit/0512544750eabf5e22df22c73e3c0342fa7cbef7
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2024-06-04T22:44:09-05:00

Commit Message:
ULTIMA8: Remove DebugLevel enum values.
Only one DebugLevel was used, and it was orginally intended to be used similar to channels (MsgMask)

Changed paths:
    engines/ultima/ultima8/audio/audio_mixer.cpp
    engines/ultima/ultima8/audio/audio_process.cpp
    engines/ultima/ultima8/audio/speech_flex.cpp
    engines/ultima/ultima8/conf/config_file_manager.cpp
    engines/ultima/ultima8/games/cru_game.cpp
    engines/ultima/ultima8/games/game_data.cpp
    engines/ultima/ultima8/games/u8_game.cpp
    engines/ultima/ultima8/gfx/fonts/font_manager.cpp
    engines/ultima/ultima8/gfx/palette_manager.cpp
    engines/ultima/ultima8/gumps/credits_gump.cpp
    engines/ultima/ultima8/kernel/kernel.cpp
    engines/ultima/ultima8/kernel/object_manager.cpp
    engines/ultima/ultima8/misc/common_types.h
    engines/ultima/ultima8/misc/id_man.cpp
    engines/ultima/ultima8/ultima8.cpp
    engines/ultima/ultima8/usecode/uc_machine.cpp
    engines/ultima/ultima8/world/camera_process.cpp
    engines/ultima/ultima8/world/world.cpp


diff --git a/engines/ultima/ultima8/audio/audio_mixer.cpp b/engines/ultima/ultima8/audio/audio_mixer.cpp
index 8e4b33953db..f7373c3ca98 100644
--- a/engines/ultima/ultima8/audio/audio_mixer.cpp
+++ b/engines/ultima/ultima8/audio/audio_mixer.cpp
@@ -45,7 +45,7 @@ AudioMixer::AudioMixer(Audio::Mixer *mixer) : _mixer(mixer), _midiPlayer(nullptr
 	for (int idx = 0; idx < TOTAL_CHANNEL_COUNT; ++idx)
 		_channels[idx] = new AudioChannel(_mixer, SAMPLE_RATE, true);
 
-	debugN(MM_INFO, "Creating AudioMixer...\n");
+	debug(1, "Creating AudioMixer...");
 }
 
 void AudioMixer::createProcesses() {
@@ -65,7 +65,7 @@ void AudioMixer::createProcesses() {
 AudioMixer::~AudioMixer(void) {
 	_audioMixer = nullptr;
 
-	debugN(MM_INFO, "Destroying AudioMixer...\n");
+	debug(1, "Destroying AudioMixer...");
 
 	closeMidiOutput();
 
diff --git a/engines/ultima/ultima8/audio/audio_process.cpp b/engines/ultima/ultima8/audio/audio_process.cpp
index 95bbdab4738..557e4306a9e 100644
--- a/engines/ultima/ultima8/audio/audio_process.cpp
+++ b/engines/ultima/ultima8/audio/audio_process.cpp
@@ -245,7 +245,7 @@ void AudioProcess::playSFX(int sfxNum, int priority, ObjId objId, int loops,
 				// Exactly the same (and playing) so just return
 				//if (it->priority == priority)
 				if (mixer->isPlaying(it->_channel)) {
-					debug(MM_INFO, "Sound %d already playing on obj %u", sfxNum, objId);
+					debug(1, "Sound %d already playing on obj %u", sfxNum, objId);
 					return;
 				} else {
 					it = _sampleInfo.erase(it);
@@ -355,7 +355,7 @@ bool AudioProcess::playSpeech(const Std::string &barked, int shapeNum, ObjId obj
 		        it->_priority == shapeNum && it->_objId == objId) {
 
 			if (mixer->isPlaying(it->_channel)) {
-				debug(MM_INFO, "Speech already playing");
+				debug(1, "Speech already playing");
 				return true;
 			} else {
 				it = _sampleInfo.erase(it);
diff --git a/engines/ultima/ultima8/audio/speech_flex.cpp b/engines/ultima/ultima8/audio/speech_flex.cpp
index f5827d95df6..6d0b1981ba5 100644
--- a/engines/ultima/ultima8/audio/speech_flex.cpp
+++ b/engines/ultima/ultima8/audio/speech_flex.cpp
@@ -47,7 +47,7 @@ SpeechFlex::SpeechFlex(Common::SeekableReadStream *rs) : SoundFlex(rs) {
 		TabsToSpaces(str, 1);
 		TrimSpaces(str);
 
-		//debug(MM_INFO, "Found string: \"%s\"", str.c_str());
+		debug(6, "Found string: \"%s\"", str.c_str());
 
 		_phrases.push_back(str);
 	}
@@ -73,11 +73,11 @@ int SpeechFlex::getIndexForPhrase(const Std::string &phrase,
 	Std::string::size_type pos2 = text.findLastNotOf(' ');
 	text = text.substr(pos1, pos2 - pos1 + 1);
 
-	//debug(MM_INFO, "Looking for string: \"%s\"", text.c_str());
+	debug(6, "Looking for string: \"%s\"", text.c_str());
 
 	for (it = _phrases.begin(); it != _phrases.end(); ++it) {
 		if (text.hasPrefixIgnoreCase(*it)) {
-			//debug(MM_INFO, "Found: %d", i);
+			debug(6, "Found: %d", i);
 			end = (*it).size() + start + pos1;
 			if (end >= start + pos2)
 				end = phrase.size();
@@ -86,7 +86,7 @@ int SpeechFlex::getIndexForPhrase(const Std::string &phrase,
 		i++;
 	}
 
-	//debug(MM_INFO, "Not found");
+	debug(6, "Not found");
 
 	return 0;
 }
diff --git a/engines/ultima/ultima8/conf/config_file_manager.cpp b/engines/ultima/ultima8/conf/config_file_manager.cpp
index 7c6451dc180..a375c65d3e6 100644
--- a/engines/ultima/ultima8/conf/config_file_manager.cpp
+++ b/engines/ultima/ultima8/conf/config_file_manager.cpp
@@ -32,13 +32,13 @@ using Std::string;
 ConfigFileManager *ConfigFileManager::_configFileManager = nullptr;
 
 ConfigFileManager::ConfigFileManager() {
-	debugN(MM_INFO, "Creating ConfigFileManager...\n");
+	debug(1, "Creating ConfigFileManager...");
 
 	_configFileManager = this;
 }
 
 ConfigFileManager::~ConfigFileManager() {
-	debugN(MM_INFO, "Destroying ConfigFileManager...\n");
+	debug(1, "Destroying ConfigFileManager...");
 
 	clear();
 	_configFileManager = nullptr;
diff --git a/engines/ultima/ultima8/games/cru_game.cpp b/engines/ultima/ultima8/games/cru_game.cpp
index e57e78b48ba..dd865126a77 100644
--- a/engines/ultima/ultima8/games/cru_game.cpp
+++ b/engines/ultima/ultima8/games/cru_game.cpp
@@ -70,7 +70,7 @@ static bool loadPalette(const char *path, PaletteManager::PalIndex index) {
 
 bool CruGame::loadFiles() {
 	// Load palette
-	debug(MM_INFO, "Load Palettes");
+	debug(1, "Load Palettes");
 
 	if (!loadPalette("static/gamepal.pal", PaletteManager::Pal_Game))
 		return false;
@@ -86,7 +86,7 @@ bool CruGame::loadFiles() {
 	// We don't use his one at the moment, ok to fail.
 	loadPalette("static/star.pal", PaletteManager::Pal_Star);
 
-	debug(MM_INFO, "Load GameData");
+	debug(1, "Load GameData");
 	GameData::get_instance()->loadRemorseData();
 
 	return true;
@@ -94,7 +94,7 @@ bool CruGame::loadFiles() {
 
 bool CruGame::startGame() {
 	// NOTE: assumes the entire engine has been reset!
-	debug(MM_INFO, "Starting new Crusader: No Remorse game.");
+	debug(1, "Starting new Crusader: No Remorse game.");
 
 	ObjectManager *objman = ObjectManager::get_instance();
 
@@ -148,7 +148,7 @@ bool CruGame::startInitialUsecode(int saveSlot) {
 static ProcId playMovie(const char *movieID, bool fade, bool noScale) {
 	MovieGump *gump = MovieGump::CruMovieViewer(movieID, 640, 480, nullptr, nullptr, 0);
 	if (!gump) {
-		debug(MM_INFO, "RemorseGame::playIntro: movie %s not found.", movieID);
+		debug(1, "RemorseGame::playIntro: movie %s not found.", movieID);
 		return 0;
 	}
 	gump->CreateNotifier();
diff --git a/engines/ultima/ultima8/games/game_data.cpp b/engines/ultima/ultima8/games/game_data.cpp
index 4f4ebebe2b5..6b65d8bc8c2 100644
--- a/engines/ultima/ultima8/games/game_data.cpp
+++ b/engines/ultima/ultima8/games/game_data.cpp
@@ -53,14 +53,14 @@ GameData::GameData(GameInfo *gameInfo)
 	: _fixed(nullptr), _mainShapes(nullptr), _mainUsecode(nullptr), _globs(),
 	  _fonts(nullptr), _gumps(nullptr), _mouse(nullptr), _music(nullptr),
 	  _weaponOverlay(nullptr), _soundFlex(nullptr), _gameInfo(gameInfo) {
-	debugN(MM_INFO, "Creating GameData...\n");
+	debug(1, "Creating GameData...");
 
 	_gameData = this;
 	_speech.resize(1024);
 }
 
 GameData::~GameData() {
-	debugN(MM_INFO, "Destroying GameData...\n");
+	debug(1, "Destroying GameData...");
 
 	delete _fixed;
 	_fixed = nullptr;
@@ -171,7 +171,7 @@ void GameData::loadTranslation() {
 	}
 
 	if (!translationfile.empty()) {
-		debug(MM_INFO, "Loading translation: %s", translationfile.toString().c_str());
+		debug(1, "Loading translation: %s", translationfile.toString().c_str());
 
 		config->readConfigFile(translationfile, "language");
 	}
@@ -247,7 +247,7 @@ void GameData::loadU8Data() {
 	_mainUsecode = new UsecodeFlex(uds);
 
 	// Load main shapes
-	debug(MM_INFO, "Load Shapes");
+	debug(1, "Load Shapes");
 	auto *sf = new Common::File();
 	if (!(sf->open("static/u8shapes.flx") || sf->open("static/u8shapes.cmp")))
 		error("Unable to load static/u8shapes.flx or static/u8shapes.cmp");
@@ -514,7 +514,7 @@ void GameData::loadRemorseData() {
 	_mainUsecode = new UsecodeFlex(uds);
 
 	// Load main shapes
-	debug(MM_INFO, "Load Shapes");
+	debug(1, "Load Shapes");
 	auto *sf = new Common::File();
 	if (!sf->open("static/shapes.flx"))
 		error("Unable to load static/shapes.flx");
diff --git a/engines/ultima/ultima8/games/u8_game.cpp b/engines/ultima/ultima8/games/u8_game.cpp
index 9c2db5fe30d..cefdb4a8a19 100644
--- a/engines/ultima/ultima8/games/u8_game.cpp
+++ b/engines/ultima/ultima8/games/u8_game.cpp
@@ -69,7 +69,7 @@ U8Game::~U8Game() {
 
 bool U8Game::loadFiles() {
 	// Load palette
-	debug(MM_INFO, "Load Palette");
+	debug(1, "Load Palette");
 	Common::File pf;
 	if (!pf.open("static/u8pal.pal")) {
 		warning("Unable to load static/u8pal.pal.");
@@ -80,7 +80,7 @@ bool U8Game::loadFiles() {
 	Common::MemoryReadStream xfds(U8XFormPal, 1024);
 	PaletteManager::get_instance()->load(PaletteManager::Pal_Game, pf, xfds);
 
-	debug(MM_INFO, "Load GameData");
+	debug(1, "Load GameData");
 	GameData::get_instance()->loadU8Data();
 
 	return true;
@@ -88,7 +88,7 @@ bool U8Game::loadFiles() {
 
 bool U8Game::startGame() {
 	// NOTE: assumes the entire engine has been reset!
-	debug(MM_INFO, "Starting new Ultima 8 game.");
+	debug(1, "Starting new Ultima 8 game.");
 
 	ObjectManager *objman = ObjectManager::get_instance();
 
@@ -167,7 +167,7 @@ ProcId U8Game::playIntroMovie(bool fade) {
 
 	auto *skf = new Common::File();
 	if (!skf->open(filename.c_str())) {
-		debug(MM_INFO, "U8Game::playIntro: movie not found.");
+		debug(1, "U8Game::playIntro: movie not found.");
 		delete skf;
 		return 0;
 	}
@@ -179,7 +179,7 @@ ProcId U8Game::playEndgameMovie(bool fade) {
 	static const Common::Path filename = "static/endgame.skf";
 	auto *skf = new Common::File();
 	if (!skf->open(filename)) {
-		debug(MM_INFO, "U8Game::playEndgame: movie not found.");
+		debug(1, "U8Game::playEndgame: movie not found.");
 		delete skf;
 		return 0;
 	}
diff --git a/engines/ultima/ultima8/gfx/fonts/font_manager.cpp b/engines/ultima/ultima8/gfx/fonts/font_manager.cpp
index a9d2d161f46..bd277d4cd3a 100644
--- a/engines/ultima/ultima8/gfx/fonts/font_manager.cpp
+++ b/engines/ultima/ultima8/gfx/fonts/font_manager.cpp
@@ -43,7 +43,7 @@ namespace Ultima8 {
 FontManager *FontManager::_fontManager = nullptr;
 
 FontManager::FontManager() {
-	debugN(MM_INFO, "Creating Font Manager...\n");
+	debug(1, "Creating Font Manager...");
 
 	_fontManager = this;
 
@@ -51,7 +51,7 @@ FontManager::FontManager() {
 }
 
 FontManager::~FontManager() {
-	debugN(MM_INFO, "Destroying Font Manager...\n");
+	debug(1, "Destroying Font Manager...");
 
 	resetGameFonts();
 
diff --git a/engines/ultima/ultima8/gfx/palette_manager.cpp b/engines/ultima/ultima8/gfx/palette_manager.cpp
index 269b698a676..ba526eb1fd1 100644
--- a/engines/ultima/ultima8/gfx/palette_manager.cpp
+++ b/engines/ultima/ultima8/gfx/palette_manager.cpp
@@ -31,20 +31,20 @@ namespace Ultima8 {
 PaletteManager *PaletteManager::_paletteManager = nullptr;
 
 PaletteManager::PaletteManager(const Graphics::PixelFormat &format) : _format(format) {
-	debugN(MM_INFO, "Creating PaletteManager...\n");
+	debug(1, "Creating PaletteManager...");
 
 	_paletteManager = this;
 }
 
 PaletteManager::~PaletteManager() {
 	reset();
-	debugN(MM_INFO, "Destroying PaletteManager...\n");
+	debug(1, "Destroying PaletteManager...");
 	_paletteManager = nullptr;
 }
 
 // Reset the Palette Manager
 void PaletteManager::reset() {
-	debugN(MM_INFO, "Resetting PaletteManager...\n");
+	debug(1, "Resetting PaletteManager...");
 
 	for (unsigned int i = 0; i < _palettes.size(); ++i)
 		delete _palettes[i];
@@ -59,7 +59,7 @@ void PaletteManager::updatedPalette(PalIndex index, int maxindex) {
 
 // Reset all the transforms back to default
 void PaletteManager::resetTransforms() {
-	debugN(MM_INFO, "Resetting Palette Transforms...\n");
+	debug(1, "Resetting Palette Transforms...");
 
 	int16 matrix[12];
 	getTransformMatrix(matrix, Transform_None);
diff --git a/engines/ultima/ultima8/gumps/credits_gump.cpp b/engines/ultima/ultima8/gumps/credits_gump.cpp
index 15ed566f5d9..5f233224a02 100644
--- a/engines/ultima/ultima8/gumps/credits_gump.cpp
+++ b/engines/ultima/ultima8/gumps/credits_gump.cpp
@@ -147,7 +147,6 @@ void CreditsGump::run() {
 	}
 
 	if (_state == CS_CLOSING) {
-		//debug(MM_INFO, "CreditsGump: closing");
 		Close();
 		return;
 	}
@@ -164,7 +163,7 @@ void CreditsGump::run() {
 	if (available == 0) nextblock = 0;
 
 	if (_state == CS_FINISHING && available <= 156) {
-		//debug(MM_INFO, "CreditsGump: waiting before closing");
+		debug(6, "CreditsGump: waiting before closing");
 		_timer = 120;
 		_state = CS_CLOSING;
 
@@ -207,7 +206,7 @@ void CreditsGump::run() {
 				continue;
 			}
 
-			//debug(MM_INFO, "Rendering paragraph: %s", line.c_str());
+			debug(6, "Rendering paragraph: %s", line.c_str());
 
 			if (line[0] == '+') {
 				// set _title
@@ -249,7 +248,7 @@ void CreditsGump::run() {
 					unsigned int remaining;
 					extractLine(line, modifier, outline);
 
-					//debug(MM_INFO, "Rendering line: %s", outline.c.str());
+					debug(6, "Rendering line: %s", outline.c_str());
 
 					switch (modifier) {
 					case '&':
@@ -266,7 +265,7 @@ void CreditsGump::run() {
 						indent = 32;
 						break;
 					case '@':
-						//debug(MM_INFO, "CreditsGump: done, finishing");
+						debug(6, "CreditsGump: done, finishing");
 						_state = CS_FINISHING;
 						break;
 					default:
diff --git a/engines/ultima/ultima8/kernel/kernel.cpp b/engines/ultima/ultima8/kernel/kernel.cpp
index a2080e507aa..749802dd880 100644
--- a/engines/ultima/ultima8/kernel/kernel.cpp
+++ b/engines/ultima/ultima8/kernel/kernel.cpp
@@ -43,7 +43,7 @@ static const uint16 CRU_PROC_TYPE_ALL = 0xc;
 
 Kernel::Kernel() : _loading(false), _tickNum(0), _paused(0),
 		_runningProcess(nullptr), _frameByFrame(false) {
-	debugN(MM_INFO, "Creating Kernel...\n");
+	debug(1, "Creating Kernel...");
 
 	_kernel = this;
 	_pIDs = new idMan(1, 32766, 128);
@@ -52,7 +52,7 @@ Kernel::Kernel() : _loading(false), _tickNum(0), _paused(0),
 
 Kernel::~Kernel() {
 	reset();
-	debugN(MM_INFO, "Destroying Kernel...\n");
+	debug(1, "Destroying Kernel...");
 
 	_kernel = nullptr;
 
@@ -60,7 +60,7 @@ Kernel::~Kernel() {
 }
 
 void Kernel::reset() {
-	debugN(MM_INFO, "Resetting Kernel...\n");
+	debug(1, "Resetting Kernel...");
 
 	for (ProcessIterator it = _processes.begin(); it != _processes.end(); ++it) {
 		Process *p = *it;
@@ -103,7 +103,7 @@ ProcId Kernel::addProcess(Process *proc, bool dispose) {
 	assert(proc->_pid != 0 && proc->_pid != 0xFFFF);
 
 #if 0
-	debug(MM_INFO, "[Kernel] Adding process %p, pid = %u type %s",
+	debug(1, "[Kernel] Adding process %p, pid = %u type %s",
 		proc, proc->_pid, proc->GetClassType()._className);
 #endif
 
@@ -125,7 +125,7 @@ ProcId Kernel::addProcessExec(Process *proc, bool dispose) {
 	assert(proc->_pid != 0 && proc->_pid != 0xFFFF);
 
 #if 0
-	debug(MM_INFO, "[Kernel] Adding process %p, pid = %u type %s",
+	debug(1, "[Kernel] Adding process %p, pid = %u type %s",
 		proc, proc->_pid, proc->GetClassType()._className);
 #endif
 
diff --git a/engines/ultima/ultima8/kernel/object_manager.cpp b/engines/ultima/ultima8/kernel/object_manager.cpp
index 7fd068e36d0..7493ed21577 100644
--- a/engines/ultima/ultima8/kernel/object_manager.cpp
+++ b/engines/ultima/ultima8/kernel/object_manager.cpp
@@ -62,7 +62,7 @@ struct ObjectLoader {
 };
 
 ObjectManager::ObjectManager() {
-	debugN(MM_INFO, "Creating ObjectManager...\n");
+	debug(1, "Creating ObjectManager...");
 
 	_objectManager = this;
 
@@ -77,7 +77,7 @@ ObjectManager::ObjectManager() {
 
 ObjectManager::~ObjectManager() {
 	reset();
-	debugN(MM_INFO, "Destroying ObjectManager...\n");
+	debug(1, "Destroying ObjectManager...");
 
 	_objectManager = nullptr;
 
@@ -86,7 +86,7 @@ ObjectManager::~ObjectManager() {
 }
 
 void ObjectManager::reset() {
-	debugN(MM_INFO, "Resetting ObjectManager...\n");
+	debug(1, "Resetting ObjectManager...");
 
 	unsigned int i;
 
@@ -276,7 +276,7 @@ bool ObjectManager::load(Common::ReadStream *rs, uint32 version) {
 			count++;
 		}
 	}
-	debug(MM_INFO, "Reclaimed %u _objIDs on load.", count);
+	debug(1, "Reclaimed %u _objIDs on load.", count);
 
 	// Integrity check items - their ids should match, and if they have
 	// parents, those should be valid.
diff --git a/engines/ultima/ultima8/misc/common_types.h b/engines/ultima/ultima8/misc/common_types.h
index 18ac16788d3..acf0bac761d 100644
--- a/engines/ultima/ultima8/misc/common_types.h
+++ b/engines/ultima/ultima8/misc/common_types.h
@@ -27,15 +27,6 @@
 namespace Ultima {
 namespace Ultima8 {
 
-
-enum DebugLevel {
-	// General info debug information
-	MM_INFO = 1,
-
-	// Minor warnings not important enough to show to the user normally
-	MM_MINOR_WARN = 1
-};
-
 // ObjId and ProcId
 
 //! 16-Bit ID of an Object
diff --git a/engines/ultima/ultima8/misc/id_man.cpp b/engines/ultima/ultima8/misc/id_man.cpp
index ec7ead7acb8..14ea88ba29c 100644
--- a/engines/ultima/ultima8/misc/id_man.cpp
+++ b/engines/ultima/ultima8/misc/id_man.cpp
@@ -102,7 +102,7 @@ void idMan::expand() {
 	_ids.resize(_end + 1);
 
 #if 0
-	debug(MM_INFO, "Expanding idMan from (%u-%u) to (%u-%u)",
+	debug(1, "Expanding idMan from (%u-%u) to (%u-%u)",
 		_begin, old_end, _begin, _end);
 #endif
 
diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index b5f1d226b10..c0e1b54517b 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -176,7 +176,7 @@ void Ultima8Engine::initializePath(const Common::FSNode& gamePath) {
 }
 
 Common::Error Ultima8Engine::initialize() {
-	debug(MM_INFO, "-- Initializing Pentagram --");
+	debug(1, "-- Initializing Pentagram --");
 
 	// Call syncSoundSettings to get default volumes set
 	syncSoundSettings();
@@ -310,7 +310,7 @@ Common::Error Ultima8Engine::initialize() {
 	// Audio Mixer
 	_audioMixer = new AudioMixer(_mixer);
 
-	debug(MM_INFO, "-- Pentagram Initialized -- ");
+	debug(1, "-- Pentagram Initialized -- ");
 
 	if (setupGame()) {
 		Common::Error result = startupGame();
@@ -325,7 +325,7 @@ Common::Error Ultima8Engine::initialize() {
 }
 
 void Ultima8Engine::deinitialize() {
-	debug(MM_INFO, "-- Shutting down Game -- ");
+	debug(1, "-- Shutting down Game -- ");
 
 	// Save config here....
 
@@ -374,7 +374,7 @@ void Ultima8Engine::deinitialize() {
 	_configFileMan->clearRoot("game");
 	_gameInfo = nullptr;
 
-	debug(MM_INFO, "-- Game Shutdown -- ");
+	debug(1, "-- Game Shutdown -- ");
 }
 
 void Ultima8Engine::pauseEngineIntern(bool pause) {
@@ -481,14 +481,14 @@ bool Ultima8Engine::setupGame() {
 
 	// output detected game info
 	Std::string details = info->getPrintDetails();
-	debug(MM_INFO, "%s: %s", info->_name.c_str(), details.c_str());
+	debug(1, "%s: %s", info->_name.c_str(), details.c_str());
 
 	_gameInfo = info;
 	return true;
 }
 
 Common::Error Ultima8Engine::startupGame() {
-	debug(MM_INFO, "-- Initializing Game: %s --", _gameInfo->_name.c_str());
+	debug(1, "-- Initializing Game: %s --", _gameInfo->_name.c_str());
 
 	if (ConfMan.hasKey("usehighres")) {
 		_highRes = ConfMan.getBool("usehighres");
@@ -587,7 +587,7 @@ Common::Error Ultima8Engine::startupGame() {
 
 	newGame(saveSlot);
 
-	debug(MM_INFO, "-- Game Initialized --");
+	debug(1, "-- Game Initialized --");
 	return Common::kNoError;
 }
 
@@ -626,7 +626,7 @@ Common::Error Ultima8Engine::runGame() {
 					_desktopGump->run();
 				}
 #if 0
-				debug(MM_INFO, "--- NEW FRAME ---");
+				debug(1, "--- NEW FRAME ---");
 #endif
 				_inBetweenFrame = false;
 
@@ -642,7 +642,6 @@ Common::Error Ultima8Engine::runGame() {
 
 			// Calculate the lerp_factor
 			_lerpFactor = ((_animationRate - diff) * 256) / _animationRate;
-			//debug(MM_INFO, "_lerpFactor: %d framenum: %d", _lerpFactor, framenum);
 			if (!_interpolate || _kernel->isPaused() || _lerpFactor > 256)
 				_lerpFactor = 256;
 		}
@@ -732,7 +731,7 @@ void Ultima8Engine::changeVideoMode(int width, int height) {
 	}
 
 	// Set Screen Resolution
-	debugN(MM_INFO, "Setting Video Mode %dx%d...\n", width, height);
+	debug(1, "Setting Video Mode %dx%d...", width, height);
 
 	Common::List<Graphics::PixelFormat> tryModes = g_system->getSupportedFormats();
 	for (Common::List<Graphics::PixelFormat>::iterator g = tryModes.begin(); g != tryModes.end(); ++g) {
@@ -1017,7 +1016,7 @@ Common::Error Ultima8Engine::saveGameStream(Common::WriteStream *stream, bool is
 	// Restore mouse over
 	if (gump) gump->onMouseOver();
 
-	debug(MM_INFO, "Done");
+	debug(1, "Done");
 
 	_mouse->popMouseCursor();
 
@@ -1025,7 +1024,7 @@ Common::Error Ultima8Engine::saveGameStream(Common::WriteStream *stream, bool is
 }
 
 void Ultima8Engine::resetEngine() {
-	debugN(MM_INFO, "-- Resetting Engine --\n");
+	debug(1, "-- Resetting Engine --");
 
 	// kill music
 	if (_audioMixer) _audioMixer->reset();
@@ -1053,16 +1052,16 @@ void Ultima8Engine::resetEngine() {
 	_saveCount = 0;
 	_hasCheated = false;
 
-	debugN(MM_INFO, "-- Engine Reset --\n");
+	debug(1, "-- Engine Reset --");
 }
 
 void Ultima8Engine::setupCoreGumps() {
-	debugN(MM_INFO, "Setting up core game gumps...\n");
+	debug(1, "Setting up core game gumps...");
 
 	Rect dims;
 	_screen->GetSurfaceDims(dims);
 
-	debugN(MM_INFO, "Creating Desktop...\n");
+	debug(1, "Creating Desktop...");
 	_desktopGump = new DesktopGump(0, 0, dims.width(), dims.height());
 	_desktopGump->InitGump(0);
 	_desktopGump->MakeFocus();
@@ -1072,11 +1071,11 @@ void Ultima8Engine::setupCoreGumps() {
 	DesktopGump::SetFadedModal(faded_modal);
 
 	if (GAME_IS_U8) {
-		debugN(MM_INFO, "Creating Inverter...\n");
+		debug(1, "Creating Inverter...");
 		_inverterGump = new InverterGump(0, 0, dims.width(), dims.height());
 		_inverterGump->InitGump(0);
 	}
-	debugN(MM_INFO, "Creating GameMapGump...\n");
+	debug(1, "Creating GameMapGump...");
 	_gameMapGump = new GameMapGump(0, 0, dims.width(), dims.height());
 	_gameMapGump->InitGump(0);
 
@@ -1092,7 +1091,7 @@ void Ultima8Engine::setupCoreGumps() {
 }
 
 bool Ultima8Engine::newGame(int saveSlot) {
-	debugN(MM_INFO, "Starting New Game (slot %d)... \n", saveSlot);
+	debug(1, "Starting New Game (slot %d)... ", saveSlot);
 
 	resetEngine();
 
@@ -1100,10 +1099,10 @@ bool Ultima8Engine::newGame(int saveSlot) {
 
 	_game->startGame();
 
-	debugN(MM_INFO, "Create Camera...\n");
+	debug(1, "Create Camera...");
 	CameraProcess::SetCameraProcess(new CameraProcess(kMainActorId));
 
-	debugN(MM_INFO, "Create persistent Processes...\n");
+	debug(1, "Create persistent Processes...");
 	if (GAME_IS_U8)
 		_avatarMoverProcess = new U8AvatarMoverProcess();
 	else
@@ -1229,7 +1228,7 @@ Common::Error Ultima8Engine::loadGameStream(Common::SeekableReadStream *stream)
 		if (!ignore) {
 			error("%s", message.c_str());
 		}
-		debug(MM_INFO, "%s", message.c_str());
+		debug(1, "%s", message.c_str());
 #else
 		delete sg;
 		return Common::Error(Common::kReadingFailed, message);
@@ -1253,7 +1252,7 @@ Common::Error Ultima8Engine::loadGameStream(Common::SeekableReadStream *stream)
 	ok = _ucMachine->loadStrings(ds, version);
 	ok &= (ds->pos() == ds->size() && !ds->eos());
 	totalok &= ok;
-	debug(MM_INFO, "UCSTRINGS: %s", (ok ? "ok" : "failed"));
+	debug(1, "UCSTRINGS: %s", (ok ? "ok" : "failed"));
 	if (!ok) message += "UCSTRINGS: failed\n";
 	delete ds;
 
@@ -1261,7 +1260,7 @@ Common::Error Ultima8Engine::loadGameStream(Common::SeekableReadStream *stream)
 	ok = _ucMachine->loadGlobals(ds, version);
 	ok &= (ds->pos() == ds->size() && !ds->eos());
 	totalok &= ok;
-	debug(MM_INFO, "UCGLOBALS: %s", (ok ? "ok" : "failed"));
+	debug(1, "UCGLOBALS: %s", (ok ? "ok" : "failed"));
 	if (!ok) message += "UCGLOBALS: failed\n";
 	delete ds;
 
@@ -1269,7 +1268,7 @@ Common::Error Ultima8Engine::loadGameStream(Common::SeekableReadStream *stream)
 	ok = _ucMachine->loadLists(ds, version);
 	ok &= (ds->pos() == ds->size() && !ds->eos());
 	totalok &= ok;
-	debug(MM_INFO, "UCLISTS: %s", (ok ? "ok" : "failed"));
+	debug(1, "UCLISTS: %s", (ok ? "ok" : "failed"));
 	if (!ok) message += "UCLISTS: failed\n";
 	delete ds;
 
@@ -1279,7 +1278,7 @@ Common::Error Ultima8Engine::loadGameStream(Common::SeekableReadStream *stream)
 	ok = _kernel->load(ds, version);
 	ok &= (ds->pos() == ds->size() && !ds->eos());
 	totalok &= ok;
-	debug(MM_INFO, "KERNEL: %s", (ok ? "ok" : "failed"));
+	debug(1, "KERNEL: %s", (ok ? "ok" : "failed"));
 	if (!ok) message += "KERNEL: failed\n";
 	delete ds;
 
@@ -1287,7 +1286,7 @@ Common::Error Ultima8Engine::loadGameStream(Common::SeekableReadStream *stream)
 	ok = load(ds, version);
 	ok &= (ds->pos() == ds->size() && !ds->eos());
 	totalok &= ok;
-	debug(MM_INFO, "APP: %s", (ok ? "ok" : "failed"));
+	debug(1, "APP: %s", (ok ? "ok" : "failed"));
 	if (!ok) message += "APP: failed\n";
 	delete ds;
 
@@ -1296,7 +1295,7 @@ Common::Error Ultima8Engine::loadGameStream(Common::SeekableReadStream *stream)
 	ok = _world->load(ds, version);
 	ok &= (ds->pos() == ds->size() && !ds->eos());
 	totalok &= ok;
-	debug(MM_INFO, "WORLD: %s", (ok ? "ok" : "failed"));
+	debug(1, "WORLD: %s", (ok ? "ok" : "failed"));
 	if (!ok) message += "WORLD: failed\n";
 	delete ds;
 
@@ -1304,7 +1303,7 @@ Common::Error Ultima8Engine::loadGameStream(Common::SeekableReadStream *stream)
 	ok = _world->getCurrentMap()->load(ds, version);
 	ok &= (ds->pos() == ds->size() && !ds->eos());
 	totalok &= ok;
-	debug(MM_INFO, "CURRENTMAP: %s", (ok ? "ok" : "failed"));
+	debug(1, "CURRENTMAP: %s", (ok ? "ok" : "failed"));
 	if (!ok) message += "CURRENTMAP: failed\n";
 	delete ds;
 
@@ -1312,7 +1311,7 @@ Common::Error Ultima8Engine::loadGameStream(Common::SeekableReadStream *stream)
 	ok = _objectManager->load(ds, version);
 	ok &= (ds->pos() == ds->size() && !ds->eos());
 	totalok &= ok;
-	debug(MM_INFO, "OBJECTS: %s", (ok ? "ok" : "failed"));
+	debug(1, "OBJECTS: %s", (ok ? "ok" : "failed"));
 	if (!ok) message += "OBJECTS: failed\n";
 	delete ds;
 
@@ -1320,7 +1319,7 @@ Common::Error Ultima8Engine::loadGameStream(Common::SeekableReadStream *stream)
 	ok = _world->loadMaps(ds, version);
 	ok &= (ds->pos() == ds->size() && !ds->eos());
 	totalok &= ok;
-	debug(MM_INFO, "MAPS: %s", (ok ? "ok" : "failed"));
+	debug(1, "MAPS: %s", (ok ? "ok" : "failed"));
 	if (!ok) message += "MAPS: failed\n";
 	delete ds;
 
@@ -1347,7 +1346,7 @@ Common::Error Ultima8Engine::loadGameStream(Common::SeekableReadStream *stream)
 		return Common::Error(Common::kReadingFailed, message);
 	}
 
-	debug(MM_INFO, "Done");
+	debug(1, "Done");
 
 	delete sg;
 	return Common::kNoError;
diff --git a/engines/ultima/ultima8/usecode/uc_machine.cpp b/engines/ultima/ultima8/usecode/uc_machine.cpp
index 2457cc07560..f6a5514d8d7 100644
--- a/engines/ultima/ultima8/usecode/uc_machine.cpp
+++ b/engines/ultima/ultima8/usecode/uc_machine.cpp
@@ -82,7 +82,7 @@ enum UCSegments {
 UCMachine *UCMachine::_ucMachine = nullptr;
 
 UCMachine::UCMachine(Intrinsic *iset, unsigned int icount) {
-	debug(MM_INFO, "Creating UCMachine...");
+	debug(1, "Creating UCMachine...");
 
 	_ucMachine = this;
 
@@ -114,7 +114,7 @@ UCMachine::UCMachine(Intrinsic *iset, unsigned int icount) {
 
 
 UCMachine::~UCMachine() {
-	debug(MM_INFO, "Destroying UCMachine...");
+	debug(1, "Destroying UCMachine...");
 	_ucMachine = nullptr;
 
 	delete _globals;
@@ -124,7 +124,7 @@ UCMachine::~UCMachine() {
 }
 
 void UCMachine::reset() {
-	debug(MM_INFO, "Resetting UCMachine");
+	debug(1, "Resetting UCMachine");
 
 	// clear _globals
 	_globals->setSize(0x1000);
diff --git a/engines/ultima/ultima8/world/camera_process.cpp b/engines/ultima/ultima8/world/camera_process.cpp
index d4b8ffeaa1b..f2402f1d829 100644
--- a/engines/ultima/ultima8/world/camera_process.cpp
+++ b/engines/ultima/ultima8/world/camera_process.cpp
@@ -143,8 +143,8 @@ CameraProcess::CameraProcess(int32 x, int32 y, int32 z) :
 CameraProcess::CameraProcess(int32 x, int32 y, int32 z, int32 time) :
 	_ex(x), _ey(y), _ez(z), _time(time), _elapsed(0), _itemNum(0), _lastFrameNum(0) {
 	GetCameraLocation(_sx, _sy, _sz);
-	//debug(MM_INFO, "Scrolling from (%d, %d,%d) to (%d, %d, %d) in %d frames",
-	//  sx, sy, sz, ex, ey, ez,  _time);
+	debug(10, "Scrolling from (%d, %d,%d) to (%d, %d, %d) in %d frames",
+		_sx, _sy, _sz, _ex, _ey, _ez,  _time);
 }
 
 void CameraProcess::terminate() {
diff --git a/engines/ultima/ultima8/world/world.cpp b/engines/ultima/ultima8/world/world.cpp
index e1085be12f0..1827c8e5385 100644
--- a/engines/ultima/ultima8/world/world.cpp
+++ b/engines/ultima/ultima8/world/world.cpp
@@ -51,14 +51,14 @@ World *World::_world = nullptr;
 
 World::World() : _currentMap(nullptr), _alertActive(false), _difficulty(3),
 				 _controlledNPCNum(1), _vargasShield(5000) {
-	debugN(MM_INFO, "Creating World...\n");
+	debug(1, "Creating World...");
 
 	_world = this;
 }
 
 
 World::~World() {
-	debugN(MM_INFO, "Destroying World...\n");
+	debug(1, "Destroying World...");
 	clear();
 
 	_world = nullptr;
@@ -85,7 +85,7 @@ void World::clear() {
 }
 
 void World::reset() {
-	debugN(MM_INFO, "Resetting World...\n");
+	debug(1, "Resetting World...");
 
 	clear();
 
@@ -157,13 +157,13 @@ bool World::switchMap(uint32 newmap) {
 
 	uint32 oldmap = _currentMap->getNum();
 	if (oldmap != 0) {
-		debug(MM_INFO, "Unloading map %u", oldmap);
+		debug(1, "Unloading map %u", oldmap);
 
 		assert(oldmap < _maps.size() && _maps[oldmap] != nullptr);
 
 		_currentMap->writeback();
 
-		debug(MM_INFO, "Unloading Fixed items from map %u", oldmap);
+		debug(1, "Unloading Fixed items from map %u", oldmap);
 
 		_maps[oldmap]->unloadFixed();
 	}
@@ -180,7 +180,7 @@ bool World::switchMap(uint32 newmap) {
 		Kernel::get_instance()->addProcess(new SchedulerProcess());
 	}
 
-	debug(MM_INFO, "Loading Fixed items in map %u", newmap);
+	debug(1, "Loading Fixed items in map %u", newmap);
 	Common::SeekableReadStream *items = GameData::get_instance()->getFixed()
 	                     ->get_datasource(newmap);
 	_maps[newmap]->loadFixed(items);
@@ -209,7 +209,7 @@ bool World::switchMap(uint32 newmap) {
 void World::loadNonFixed(Common::SeekableReadStream *rs) {
 	FlexFile *f = new FlexFile(rs);
 
-	debug(MM_INFO, "Loading NonFixed items");
+	debug(1, "Loading NonFixed items");
 
 	for (unsigned int i = 0; i < f->getCount(); ++i) {
 
@@ -240,7 +240,7 @@ void World::loadItemCachNPCData(Common::SeekableReadStream *itemcach, Common::Se
 	delete itemcachflex;
 	delete npcdataflex;
 
-	debug(MM_INFO, "Loading NPCs");
+	debug(1, "Loading NPCs");
 
 	for (uint32 i = 1; i < 256; ++i) { // Get rid of constants?
 		// These are ALL unsigned on disk


Commit: 66d0229272d9f2d38e79a7da08e1079372342c3c
    https://github.com/scummvm/scummvm/commit/66d0229272d9f2d38e79a7da08e1079372342c3c
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2024-06-04T22:44:09-05:00

Commit Message:
ULTIMA8: Replace string utility functions

Changed paths:
    engines/ultima/ultima8/audio/speech_flex.cpp
    engines/ultima/ultima8/games/game_info.cpp
    engines/ultima/ultima8/misc/util.cpp
    engines/ultima/ultima8/misc/util.h


diff --git a/engines/ultima/ultima8/audio/speech_flex.cpp b/engines/ultima/ultima8/audio/speech_flex.cpp
index 6d0b1981ba5..54096fa87d6 100644
--- a/engines/ultima/ultima8/audio/speech_flex.cpp
+++ b/engines/ultima/ultima8/audio/speech_flex.cpp
@@ -44,8 +44,8 @@ SpeechFlex::SpeechFlex(Common::SeekableReadStream *rs) : SoundFlex(rs) {
 		Std::string str(cbuf + off, slen);
 		off += slen + 1;
 
-		TabsToSpaces(str, 1);
-		TrimSpaces(str);
+		str.replace('\t', ' ');
+		str.trim();
 
 		debug(6, "Found string: \"%s\"", str.c_str());
 
@@ -65,7 +65,7 @@ int SpeechFlex::getIndexForPhrase(const Std::string &phrase,
 	int i = 1;
 
 	Std::string text = phrase.substr(start);
-	TabsToSpaces(text, 1);
+	text.replace('\t', ' ');
 
 	Std::string::size_type pos1 = text.findFirstNotOf(' ');
 	if (pos1 == Std::string::npos) return 0;
diff --git a/engines/ultima/ultima8/games/game_info.cpp b/engines/ultima/ultima8/games/game_info.cpp
index e4f571a96be..041231c7391 100644
--- a/engines/ultima/ultima8/games/game_info.cpp
+++ b/engines/ultima/ultima8/games/game_info.cpp
@@ -19,6 +19,8 @@
  *
  */
 
+#include "common/tokenizer.h"
+
 #include "ultima/ultima8/misc/debugger.h"
 
 #include "ultima/ultima8/games/game_info.h"
@@ -184,6 +186,8 @@ bool GameInfo::load(Common::SeekableReadStream *rs, uint32 ver) {
 	Std::vector<Std::string> parts;
 
 	s = rs->readLine();
+	Common::StringTokenizer tokenizer(s, ",");
+
 	SplitString(s, ',', parts);
 	if (parts.size() != 4) return false;
 
diff --git a/engines/ultima/ultima8/misc/util.cpp b/engines/ultima/ultima8/misc/util.cpp
index 64432010351..7a8166c03fc 100644
--- a/engines/ultima/ultima8/misc/util.cpp
+++ b/engines/ultima/ultima8/misc/util.cpp
@@ -88,30 +88,6 @@ template<class T> void StringToArgv(const T &args, Common::Array<T> &argv) {
 
 template void StringToArgv<Common::String>(const Common::String &args, Common::Array<Common::String> &argv);
 
-template<class T> void TrimSpaces(T &str) {
-	if (str.empty()) return;
-
-	typename T::size_type pos1 = str.findFirstNotOf(' ');
-	if (pos1 == T::npos) {
-		str = "";
-		return;
-	}
-
-	typename T::size_type pos2 = str.findLastNotOf(' ');
-	str = str.substr(pos1, pos2 - pos1 + 1);
-}
-
-template void TrimSpaces<Std::string>(Std::string &str);
-
-template<class T> void TabsToSpaces(T &str, unsigned int n) {
-	T repl(n, ' ');
-	typename T::size_type p;
-	while ((p = str.find('\t')) != T::npos)
-		str.replace(p, 1, repl);
-}
-
-template void TabsToSpaces<Std::string>(Std::string &str, unsigned int n);
-
 template<class T> void SplitString(const T &args, char sep,
 								   Std::vector<T> &argv) {
 	// Clear the vector
@@ -151,12 +127,12 @@ template<class T> void SplitStringKV(const T &args, char sep,
 		typename T::size_type pos;
 		pos = keyvals[i].find('=');
 		keyval.first = keyvals[i].substr(0, pos);
-		TrimSpaces(keyval.first);
+		keyval.first.trim();
 		if (pos == T::npos) {
 			keyval.second = "";
 		} else {
 			keyval.second = keyvals[i].substr(pos + 1);
-			TrimSpaces(keyval.second);
+			keyval.second.trim();
 		}
 		if (!(keyval.first.empty() && keyval.second.empty()))
 			argv.push_back(keyval);
diff --git a/engines/ultima/ultima8/misc/util.h b/engines/ultima/ultima8/misc/util.h
index 3a5da2d1b12..268f49d8ced 100644
--- a/engines/ultima/ultima8/misc/util.h
+++ b/engines/ultima/ultima8/misc/util.h
@@ -29,10 +29,6 @@ namespace Ultima8 {
 
 template<class T> void StringToArgv(const T &args, Common::Array<T> &argv);
 
-template<class T> void TrimSpaces(T &str);
-
-template<class T> void TabsToSpaces(T &str, unsigned int nspaces);
-
 template<class T> void SplitString(const T &args, char sep, Std::vector<T> &argv);
 
 template<class T> void SplitStringKV(const T &args, char sep,




More information about the Scummvm-git-logs mailing list