NUVIE: Fixes for using townsdir configuration entry

This commit is contained in:
Paul Gilbert 2020-11-02 21:47:30 -08:00
parent 2e5d5ba9ac
commit a5c6ea8f70
6 changed files with 29 additions and 13 deletions

View File

@ -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";

View File

@ -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);
}

View File

@ -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);

View File

@ -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;

View File

@ -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) {

View File

@ -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)