[Scummvm-git-logs] scummvm master -> 7775330954e1a2e292318549d3ba69d3af7bed5e

dreammaster paulfgilbert at gmail.com
Tue Nov 3 05:49:30 UTC 2020


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:
a5c6ea8f70 NUVIE: Fixes for using townsdir configuration entry
7775330954 COMMON: Ignore string erase calls when the passed length is zero


Commit: a5c6ea8f7087d83c047f5fb2e500cef9289029aa
    https://github.com/scummvm/scummvm/commit/a5c6ea8f7087d83c047f5fb2e500cef9289029aa
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-11-02T21:47:30-08:00

Commit Message:
NUVIE: Fixes for using townsdir configuration entry

Changed paths:
    engines/ultima/nuvie/conf/configuration.cpp
    engines/ultima/nuvie/core/converse.cpp
    engines/ultima/nuvie/core/converse_speech.cpp
    engines/ultima/nuvie/files/nuvie_io_file.cpp
    engines/ultima/nuvie/misc/u6_misc.cpp
    engines/ultima/nuvie/sound/towns_sfx_manager.cpp


diff --git a/engines/ultima/nuvie/conf/configuration.cpp b/engines/ultima/nuvie/conf/configuration.cpp
index 522088556b..f2ef7c010c 100644
--- a/engines/ultima/nuvie/conf/configuration.cpp
+++ b/engines/ultima/nuvie/conf/configuration.cpp
@@ -175,8 +175,6 @@ void Configuration::pathFromValue(const Std::string &key, Std::string file, Std:
 		full_path += U6PATH_DELIMITER + file;
 	else
 		full_path += file;
-
-	return;
 }
 
 bool Configuration::set(const Std::string &key, const Std::string &value) {
@@ -415,6 +413,8 @@ void Configuration::setCommonDefaults(GameId gameType) {
 	_settings["newscroll/border_color"] =
 		Common::String::format("%d", border_color[i]);
 
+	_settings["townsdir"] = "townsu6";
+
 	//	_settings["newgamedata/name"] = "Avatar";
 	//	_settings["newgamedata/gender"] = "0";
 	//	_settings["newgamedata/portrait"] = "0";
diff --git a/engines/ultima/nuvie/core/converse.cpp b/engines/ultima/nuvie/core/converse.cpp
index 5548f59a38..bc01a6e7f5 100644
--- a/engines/ultima/nuvie/core/converse.cpp
+++ b/engines/ultima/nuvie/core/converse.cpp
@@ -95,7 +95,7 @@ Converse::init(Configuration *cfg, nuvie_game_t t, MsgScroll *s, ActorManager *a
 	cfg->value("config/cheats/party_all_the_time", party_all_the_time);
 	cfg->value("config/audio/conversations_stop_music", conversations_stop_music, false);
 
-	cfg->value("config/ultima6/townsdir", townsdir, "");
+	cfg->value("config/townsdir", townsdir, "");
 	if (townsdir != "" && directory_exists(townsdir.c_str()))
 		using_fmtowns = true;
 
@@ -147,7 +147,7 @@ void Converse::reset() {
 void Converse::load_conv(const Std::string &convfilename) {
 	string conv_lib_str;
 	if (gametype == NUVIE_GAME_U6 && using_fmtowns) {
-		config->pathFromValue("config/ultima6/townsdir", convfilename, conv_lib_str); //FIXME handle case insensitive filename here.
+		config->pathFromValue("config/townsdir", convfilename, conv_lib_str); //FIXME handle case insensitive filename here.
 	} else {
 		config_get_path(config, convfilename, conv_lib_str);
 	}
diff --git a/engines/ultima/nuvie/core/converse_speech.cpp b/engines/ultima/nuvie/core/converse_speech.cpp
index 699049ebb8..c000ed3271 100644
--- a/engines/ultima/nuvie/core/converse_speech.cpp
+++ b/engines/ultima/nuvie/core/converse_speech.cpp
@@ -86,7 +86,7 @@ void ConverseSpeech::play_speech(uint16 actor_num, uint16 sample_num) {
 
 	sprintf(filename, "speech%cchar%u.sam", U6PATH_DELIMITER, actor_num);
 
-	config->pathFromValue("config/ultima6/townsdir", filename, sample_file);
+	config->pathFromValue("config/townsdir", filename, sample_file);
 
 	DEBUG(0, LEVEL_DEBUGGING, "Loading Speech Sample %s:%d\n", sample_file.c_str(), sample_num);
 
diff --git a/engines/ultima/nuvie/files/nuvie_io_file.cpp b/engines/ultima/nuvie/files/nuvie_io_file.cpp
index 5acfe4fa5b..ec814911f6 100644
--- a/engines/ultima/nuvie/files/nuvie_io_file.cpp
+++ b/engines/ultima/nuvie/files/nuvie_io_file.cpp
@@ -25,6 +25,7 @@
 #include "ultima/shared/engine/ultima.h"
 #include "engines/metaengine.h"
 #include "common/system.h"
+#include "common/config-manager.h"
 
 namespace Ultima {
 namespace Nuvie {
@@ -39,8 +40,21 @@ bool NuvieIOFileRead::open(const Common::String &filename) {
 		return false;
 
 	if (!_srcFile.open(filename)) {
-		DEBUG(0, LEVEL_ERROR, "Failed opening '%s'\n", filename.c_str());
-		return false;
+		Common::FSNode node(ConfMan.get("path"));
+		Common::String fname = filename;
+
+		for (size_t sepPos = fname.findFirstOf(U6PATH_DELIMITER);
+				sepPos != Common::String::npos; sepPos = fname.findFirstOf(U6PATH_DELIMITER)) {
+			node = node.getChild(fname.substr(0, sepPos));
+			fname = fname.substr(sepPos + 1);
+		}
+
+		node = node.getChild(fname);
+
+		if (!_srcFile.open(node)) {
+			DEBUG(0, LEVEL_ERROR, "Failed opening '%s'\n", filename.c_str());
+			return false;
+		}
 	}
 
 	_file = &_srcFile;
diff --git a/engines/ultima/nuvie/misc/u6_misc.cpp b/engines/ultima/nuvie/misc/u6_misc.cpp
index 6164d225b3..b4f63e2d60 100644
--- a/engines/ultima/nuvie/misc/u6_misc.cpp
+++ b/engines/ultima/nuvie/misc/u6_misc.cpp
@@ -25,6 +25,7 @@
 #include "ultima/nuvie/core/nuvie_defs.h"
 #include "ultima/nuvie/misc/u6_misc.h"
 #include "ultima/nuvie/conf/configuration.h"
+#include "common/config-manager.h"
 #include "common/file.h"
 #include "common/fs.h"
 #include "common/str.h"
@@ -229,7 +230,7 @@ void build_path(Std::string path, Std::string filename, Std::string &full_path)
 
 bool has_fmtowns_support(Configuration *config) {
 	Std::string townsdir;
-	config->value("config/ultima6/townsdir", townsdir, "");
+	config->value("config/townsdir", townsdir, "");
 	if (townsdir != "" && directory_exists(townsdir.c_str()))
 		return true;
 
@@ -237,8 +238,8 @@ bool has_fmtowns_support(Configuration *config) {
 }
 
 bool directory_exists(const char *directory) {
-	Common::FSNode dir(directory);
-	return dir.exists();
+	Common::FSNode gameDir(ConfMan.get("path"));
+	return Common::FSNode(directory).exists() || gameDir.getChild(directory).exists();
 }
 
 bool file_exists(const char *path) {
diff --git a/engines/ultima/nuvie/sound/towns_sfx_manager.cpp b/engines/ultima/nuvie/sound/towns_sfx_manager.cpp
index 0f6bed0d96..980eb0c340 100644
--- a/engines/ultima/nuvie/sound/towns_sfx_manager.cpp
+++ b/engines/ultima/nuvie/sound/towns_sfx_manager.cpp
@@ -60,8 +60,9 @@ static const TownsSfxLookup sfx_lookup_tbl[] = {
 	{NUVIE_SFX_ATTACK_SWING, 2}
 };
 
-TownsSfxManager::TownsSfxManager(Configuration *cfg, Audio::Mixer *m) : SfxManager(cfg, m) {
-	config->pathFromValue("config/ultima6/townsdir", "sounds2.dat", sounds2dat_filepath);
+TownsSfxManager::TownsSfxManager(Configuration *cfg, Audio::Mixer *m) : SfxManager(cfg, m),
+		fireStream(nullptr) {
+	config->pathFromValue("config/townsdir", "sounds2.dat", sounds2dat_filepath);
 	loadSound1Dat();
 }
 
@@ -78,7 +79,7 @@ void TownsSfxManager::loadSound1Dat() {
 	NuvieIOBuffer iobuf;
 	uint32 slib32_len = 0;
 
-	config->pathFromValue("config/ultima6/townsdir", "sounds1.dat", filename);
+	config->pathFromValue("config/townsdir", "sounds1.dat", filename);
 	unsigned char *slib32_data = decompressor.decompress_file(filename, slib32_len);
 
 	if (slib32_len == 0)


Commit: 7775330954e1a2e292318549d3ba69d3af7bed5e
    https://github.com/scummvm/scummvm/commit/7775330954e1a2e292318549d3ba69d3af7bed5e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-11-02T21:49:05-08:00

Commit Message:
COMMON: Ignore string erase calls when the passed length is zero

Changed paths:
    common/base-str.cpp


diff --git a/common/base-str.cpp b/common/base-str.cpp
index 09bed97409..0566821420 100644
--- a/common/base-str.cpp
+++ b/common/base-str.cpp
@@ -463,6 +463,9 @@ TEMPLATE void BASESTRING::deleteLastChar() {
 }
 
 TEMPLATE void BASESTRING::erase(uint32 p, uint32 len) {
+	if (len == 0)
+		return;
+
 	assert(p < _size);
 
 	makeUnique();




More information about the Scummvm-git-logs mailing list