[Scummvm-git-logs] scummvm master -> 9a7d3b58ea1c23c169df4ab4952fc6cc59652d6a

OMGPizzaGuy 48367439+OMGPizzaGuy at users.noreply.github.com
Wed Feb 3 02:32:28 UTC 2021


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

Summary:
f77102639d ULTIMA8: Remove SettingManager and thus finally eliminate pentagram.ini
c257a1b957 ULTIMA8: Remove now dead code around ConfigFIleManager
9a7d3b58ea ULTIMA8: Remove ConfigManager usage in ConfigFileManagers


Commit: f77102639dbe5a55eba17a9042033b20af1bce07
    https://github.com/scummvm/scummvm/commit/f77102639dbe5a55eba17a9042033b20af1bce07
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2021-02-02T20:32:06-06:00

Commit Message:
ULTIMA8: Remove SettingManager and thus finally eliminate pentagram.ini

Changed paths:
  R engines/ultima/ultima8/conf/setting_manager.cpp
  R engines/ultima/ultima8/conf/setting_manager.h
    engines/ultima/module.mk
    engines/ultima/ultima8/games/game_data.cpp
    engines/ultima/ultima8/kernel/core_app.cpp
    engines/ultima/ultima8/kernel/core_app.h
    engines/ultima/ultima8/world/container.cpp


diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index 0df1299d32..5a95e8e609 100644
--- a/engines/ultima/module.mk
+++ b/engines/ultima/module.mk
@@ -394,7 +394,6 @@ MODULE_OBJS := \
 	ultima8/audio/u8_music_process.o \
 	ultima8/conf/config_file_manager.o \
 	ultima8/conf/ini_file.o \
-	ultima8/conf/setting_manager.o \
 	ultima8/convert/convert_shape.o \
 	ultima8/convert/u8/convert_shape_u8.o \
 	ultima8/convert/crusader/convert_shape_crusader.o \
diff --git a/engines/ultima/ultima8/conf/setting_manager.cpp b/engines/ultima/ultima8/conf/setting_manager.cpp
deleted file mode 100644
index cf220fd55c..0000000000
--- a/engines/ultima/ultima8/conf/setting_manager.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "ultima/ultima8/misc/pent_include.h"
-#include "ultima/ultima8/conf/setting_manager.h"
-#include "common/config-manager.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-SettingManager *SettingManager::_settingManager = nullptr;
-
-SettingManager::SettingManager() {
-	debugN(MM_INFO, "Creating SettingManager...\n");
-
-	_settingManager = this;
-
-	_domains.resize(DOM_GAME + 1);
-
-	_confFileMan = ConfigFileManager::get_instance();
-
-	_confFileMan->readConfigString("", "defaultsettings", false);
-}
-
-SettingManager::~SettingManager() {
-	debugN(MM_INFO, "Destroying SettingManager...\n");
-
-	_settingManager = nullptr;
-}
-
-bool SettingManager::readConfigFile(Std::string fname, bool readonly) {
-	return _confFileMan->readConfigFile(fname, "settings", readonly);
-}
-
-void SettingManager::write() {
-	_confFileMan->write("settings");
-}
-
-bool SettingManager::exists(istring key, Domain dom) {
-	Domain temp;
-
-	return findKeyDomain(key, dom, temp);
-}
-
-bool SettingManager::get(istring key, Std::string &ret, Domain dom) {
-	Domain keydom;
-	bool found = findKeyDomain(key, dom, keydom);
-	if (!found)
-		return false;
-
-	_confFileMan->get(getConfigKey(key, keydom), ret);
-
-	return true;
-}
-
-bool SettingManager::get(istring key, int &ret, Domain dom) {
-	Domain keydom;
-	bool found = findKeyDomain(key, dom, keydom);
-	if (!found)
-		return false;
-
-	_confFileMan->get(getConfigKey(key, keydom), ret);
-
-	return true;
-}
-
-bool SettingManager::get(istring key, bool &ret, Domain dom) {
-	Domain keydom;
-	bool found = findKeyDomain(key, dom, keydom);
-	if (!found)
-		return false;
-
-	_confFileMan->get(getConfigKey(key, keydom), ret);
-
-	return true;
-}
-
-
-void SettingManager::set(istring key, Std::string value, Domain dom) {
-	_confFileMan->set(getConfigKey(key, dom), value);
-
-	callCallbacks(key);
-}
-
-void SettingManager::set(istring key, const char *value, Domain dom) {
-	_confFileMan->set(getConfigKey(key, dom), value);
-
-	callCallbacks(key);
-}
-
-void SettingManager::set(istring key, int value, Domain dom) {
-	_confFileMan->set(getConfigKey(key, dom), value);
-
-	callCallbacks(key);
-}
-
-void SettingManager::set(istring key, bool value, Domain dom) {
-	_confFileMan->set(getConfigKey(key, dom), value);
-
-	callCallbacks(key);
-}
-
-void SettingManager::unset(istring key, Domain dom) {
-	_confFileMan->unset(getConfigKey(key, dom));
-
-	callCallbacks(key);
-}
-
-
-
-
-void SettingManager::setDefault(istring key, Std::string value) {
-	set(key, value, DOM_DEFAULTS);
-}
-
-void SettingManager::setDefault(istring key, const char *value) {
-	set(key, value, DOM_DEFAULTS);
-}
-
-void SettingManager::setDefault(istring key, int value) {
-	set(key, value, DOM_DEFAULTS);
-}
-
-void SettingManager::setDefault(istring key, bool value) {
-	set(key, value, DOM_DEFAULTS);
-}
-
-
-
-void SettingManager::setCurrentDomain(Domain dom) {
-	_currentDomain = dom;
-}
-
-void SettingManager::setDomainName(Domain dom, istring section) {
-	unsigned int d = static_cast<unsigned int>(dom);
-
-	if (_domains.size() <= d)
-		_domains.resize(d + 1);
-	_domains[d] = section;
-}
-
-void SettingManager::registerCallback(istring key, ConfigCallback callback) {
-	_callbacks[key].push_back(callback);
-}
-
-void SettingManager::unregisterCallback(istring key, ConfigCallback callback) {
-	Callbacks::iterator i = _callbacks.find(key);
-	if (i == _callbacks.end())
-		return;
-
-	Std::vector<ConfigCallback> &cb = (*i)._value;
-	Std::vector<ConfigCallback>::iterator iter;
-	for (iter = cb.begin(); iter != cb.end(); ++iter) {
-		if (*iter == callback) {
-			cb.erase(iter);
-			return;
-		}
-	}
-}
-
-Std::vector<istring> SettingManager::listDataKeys(istring section) {
-	istring csection = "settings/" + _domains[DOM_GAME] + ":" + section;
-
-	return _confFileMan->listKeys(csection, false);
-}
-
-KeyMap SettingManager::listDataValues(istring section) {
-	istring csection = "settings/" + _domains[DOM_GAME] + ":" + section;
-
-	return _confFileMan->listKeyValues(csection, false);
-}
-
-bool SettingManager::findKeyDomain(istring key, Domain dom, Domain &keydom) {
-	// if domain is DOM_CURRENT we search through all _domains below the
-	//    current domain.
-	// otherwise, we search only the domain passed
-
-	if (dom == DOM_CURRENT) {
-		int d = static_cast<int>(_currentDomain);
-		for (; d >= 0; --d) {
-			if (_confFileMan->exists(getConfigKey(key, static_cast<Domain>(d)))) {
-				keydom = static_cast<Domain>(d);
-				return true;
-			}
-		}
-		return false;
-	} else {
-		keydom = dom;
-		return _confFileMan->exists(getConfigKey(key, dom));
-	}
-}
-
-istring SettingManager::getConfigKey(istring key, Domain dom) {
-	istring ckey;
-
-	if (dom == DOM_CURRENT)
-		dom = _currentDomain;
-
-	if (dom == DOM_GLOBAL && ConfMan.hasKey(key))
-		// Key exists in scummvm.ini, so can be used as is
-		return key;
-
-	if (dom == DOM_DEFAULTS) {
-		ckey = "defaultsettings/";
-	} else {
-		ckey = "settings/" + _domains[dom];
-	}
-
-	istring::size_type pos = key.find('/');
-
-	if (pos != istring::npos) {
-		ckey += ":" + key;
-	} else {
-		ckey += "/" + key;
-	}
-
-	return ckey;
-}
-
-void SettingManager::callCallbacks(istring key) {
-	Callbacks::iterator i;
-	i = _callbacks.find(key);
-
-	if (i == _callbacks.end()) return;
-
-	Std::vector<ConfigCallback> &cb = (*i)._value;
-	Std::vector<ConfigCallback>::iterator iter;
-	for (iter = cb.begin(); iter != cb.end(); ++iter) {
-		(*iter)(key);
-	}
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/conf/setting_manager.h b/engines/ultima/ultima8/conf/setting_manager.h
deleted file mode 100644
index c11930d583..0000000000
--- a/engines/ultima/ultima8/conf/setting_manager.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ULTIMA8_CONF_SETTINGMANAGER_H
-#define ULTIMA8_CONF_SETTINGMANAGER_H
-
-#include "ultima/ultima8/conf/config_file_manager.h"
-#include "ultima/ultima8/misc/istring.h"
-#include "ultima/shared/std/string.h"
-#include "ultima/shared/std/containers.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-class ConfigFileManager;
-
-class SettingManager {
-public:
-	SettingManager();
-	~SettingManager();
-
-	static SettingManager *get_instance() {
-		return _settingManager;
-	}
-
-	enum Domain {
-		DOM_DEFAULTS = 0,
-		DOM_GLOBAL   = 1,
-		DOM_GAME     = 2,
-		DOM_CURRENT  = 100
-	};
-
-	typedef void (*ConfigCallback)(istring key);
-	typedef Std::map<Common::String, Std::vector<ConfigCallback>, Common::IgnoreCase_Hash > Callbacks;
-
-	//! read a config file. Multiple files may be read. Order is important.
-	//! \param fname The file to read
-	//! \param readonly If true, don't write to this file's tree (or the file)
-	//! \return true if succesful
-	bool readConfigFile(Std::string fname, bool readonly = false);
-
-	//! write all (writable) config files
-	void write();
-
-	//! does the key exist?
-	bool exists(istring key, Domain dom = DOM_CURRENT);
-
-	//! get value
-	bool get(istring key, Std::string &ret, Domain dom = DOM_CURRENT);
-	//! get value
-	bool get(istring key, int &ret, Domain dom = DOM_CURRENT);
-	//! get value
-	bool get(istring key, bool &ret, Domain dom = DOM_CURRENT);
-
-	//! set value
-	void set(istring key, Std::string value, Domain dom = DOM_CURRENT);
-	//! set value
-	void set(istring key, const char *value, Domain dom = DOM_CURRENT);
-	//! set value
-	void set(istring key, int value, Domain dom = DOM_CURRENT);
-	//! set value
-	void set(istring key, bool value, Domain dom = DOM_CURRENT);
-
-	//! remove key
-	void unset(istring key, Domain dom = DOM_CURRENT);
-
-	//! set default value
-	void setDefault(istring key, Std::string value);
-	//! set default value
-	void setDefault(istring key, const char *value);
-	//! set default value
-	void setDefault(istring key, int value);
-	//! set default value
-	void setDefault(istring key, bool value);
-
-	//! set the current domain
-	void setCurrentDomain(Domain dom);
-	//! set the configuration section for a domain
-	void setDomainName(Domain dom, istring section);
-
-	//! register a function to be called when the key changes
-	void registerCallback(istring key, ConfigCallback callback);
-	//! unregister a callback
-	void unregisterCallback(istring key, ConfigCallback callback);
-
-	//! list all keys in a game data section
-	//! \param section The section to return setkeys of
-	//! \return the keys. They have no guaranteed order.
-	Std::vector<istring> listDataKeys(istring section);
-
-	//! list all key-value pairs in the given section.
-	//! \param section The section to list
-	//! \return the key-value pairs. They have no guaranteed order.
-	KeyMap listDataValues(istring section);
-
-private:
-
-	bool findKeyDomain(istring key, Domain dom, Domain &keydom);
-	istring getConfigKey(istring key, Domain dom);
-	void callCallbacks(istring key);
-
-	Callbacks _callbacks;
-	Std::vector<istring> _domains;
-
-	Domain _currentDomain;
-
-	ConfigFileManager *_confFileMan;
-
-	static SettingManager *_settingManager;
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/games/game_data.cpp b/engines/ultima/ultima8/games/game_data.cpp
index ddd0af37b6..5178fe434d 100644
--- a/engines/ultima/ultima8/games/game_data.cpp
+++ b/engines/ultima/ultima8/games/game_data.cpp
@@ -40,7 +40,7 @@
 #include "ultima/ultima8/graphics/fonts/font_manager.h"
 #include "ultima/ultima8/games/game_info.h"
 #include "ultima/ultima8/gumps/weasel_dat.h"
-#include "ultima/ultima8/conf/setting_manager.h"
+#include "ultima/ultima8/conf/config_file_manager.h"
 #include "ultima/ultima8/convert/crusader/convert_shape_crusader.h"
 #include "ultima/ultima8/audio/music_flex.h"
 #include "ultima/ultima8/audio/speech_flex.h"
diff --git a/engines/ultima/ultima8/kernel/core_app.cpp b/engines/ultima/ultima8/kernel/core_app.cpp
index d3455518b8..7f6e1cd15e 100644
--- a/engines/ultima/ultima8/kernel/core_app.cpp
+++ b/engines/ultima/ultima8/kernel/core_app.cpp
@@ -20,10 +20,11 @@
  *
  */
 
+#include "common/config-manager.h"
 #include "ultima/ultima8/misc/pent_include.h"
 #include "ultima/ultima8/kernel/core_app.h"
 #include "ultima/ultima8/filesys/file_system.h"
-#include "ultima/ultima8/conf/setting_manager.h"
+#include "ultima/ultima8/conf/config_file_manager.h"
 
 namespace Ultima {
 namespace Ultima8 {
@@ -34,13 +35,12 @@ CoreApp *CoreApp::_application = nullptr;
 
 CoreApp::CoreApp(const Ultima::UltimaGameDescription *gameDesc)
 		: _gameDesc(gameDesc), _isRunning(false), _gameInfo(nullptr), _fileSystem(nullptr),
-		_configFileMan(nullptr), _settingMan(nullptr) {
+		_configFileMan(nullptr){
 	_application = this;
 }
 
 CoreApp::~CoreApp() {
 	FORGET_OBJECT(_fileSystem);
-	FORGET_OBJECT(_settingMan);
 	FORGET_OBJECT(_configFileMan);
 	FORGET_OBJECT(_gameInfo);
 
@@ -48,52 +48,12 @@ CoreApp::~CoreApp() {
 }
 
 void CoreApp::startup() {
-	sysInit();
-	loadConfig(); // load config files
-}
-
-void CoreApp::sysInit() {
 	_gameInfo = nullptr;
 
 	_fileSystem = new FileSystem;
 
 	_configFileMan = new ConfigFileManager();
-	_settingMan = new SettingManager();
-	_settingMan->setDomainName(SettingManager::DOM_GLOBAL, "pentagram");
-	_settingMan->setCurrentDomain(SettingManager::DOM_GLOBAL);
-}
-
-// load configuration files
-void CoreApp::loadConfig() {
-	pout << "Loading configuration files:" << Std::endl;
-
-	bool dataconf, homeconf;
 
-	// system-wide config, read-only
-	dataconf = _settingMan->readConfigFile("@data/pentagram.ini", true);
-
-	// user config
-	homeconf = _settingMan->readConfigFile("@home/pentagram.ini");
-
-	if (!homeconf && !dataconf) {
-		pout << "No configuration files found." << Std::endl;
-	} else {
-
-		if (dataconf)
-			pout << "@data/pentagram.ini" << Std::endl;
-		if (homeconf)
-			pout << "@home/pentagram.ini" << Std::endl;
-	}
-
-	//  load pentagram specific data path
-	Std::string data;
-	if (_settingMan->get("data", data, SettingManager::DOM_GLOBAL)) {
-		pout << "Setting custom data path: " << data << Std::endl;
-		bool ok = _fileSystem->AddVirtualPath("@data", data);
-		if (!ok) {
-			perr << "Error opening data directory." << Std::endl;
-		}
-	}
 }
 
 bool CoreApp::setupGame() {
@@ -117,16 +77,14 @@ bool CoreApp::setupGame() {
 	pout << "Selected game: " << info->_name << Std::endl;
 	pout << info->getPrintDetails() << Std::endl;
 
-	setupGamePaths(info);
+	// load main game data path - it needs to be empty
+	//Std::string gpath = ConfMan.get("path");
+	_fileSystem->AddVirtualPath("@game", "");
 
 	return true;
 }
 
 void CoreApp::killGame() {
-	// Save the settings!
-	pout << "Saving settings" << Std::endl;
-	_settingMan->write();
-
 	_fileSystem->RemoveVirtualPath("@game");
 
 	_configFileMan->clearRoot("bindings");
@@ -135,8 +93,6 @@ void CoreApp::killGame() {
 	_configFileMan->clearRoot("armour");
 	_configFileMan->clearRoot("monsters");
 	_configFileMan->clearRoot("game");
-	_settingMan->setCurrentDomain(SettingManager::DOM_GLOBAL);
-
 	_gameInfo = nullptr;
 }
 
@@ -183,22 +139,6 @@ bool CoreApp::getGameInfo(const istring &game, GameInfo *ginfo) {
 	return ginfo->_type != GameInfo::GAME_UNKNOWN;
 }
 
-void CoreApp::setupGamePaths(GameInfo *ginfo) {
-	if (!ginfo) {
-		_settingMan->setCurrentDomain(SettingManager::DOM_GLOBAL);
-		return;
-	}
-
-	istring game = ginfo->_name;
-
-	_settingMan->setDomainName(SettingManager::DOM_GAME, game);
-	_settingMan->setCurrentDomain(SettingManager::DOM_GAME);
-
-	// load main game data path
-	Std::string gpath;
-	_settingMan->get("path", gpath, SettingManager::DOM_GAME);
-	_fileSystem->AddVirtualPath("@game", gpath);
-}
 
 void CoreApp::ParseArgs(const int argc, const char *const *const argv) {
 	_parameters.process(argc, argv);
diff --git a/engines/ultima/ultima8/kernel/core_app.h b/engines/ultima/ultima8/kernel/core_app.h
index c06b9632e8..8cf00414b9 100644
--- a/engines/ultima/ultima8/kernel/core_app.h
+++ b/engines/ultima/ultima8/kernel/core_app.h
@@ -33,7 +33,6 @@ namespace Ultima8 {
 class Console;
 class FileSystem;
 class ConfigFileManager;
-class SettingManager;
 struct GameInfo;
 
 
@@ -74,7 +73,6 @@ protected:
 	// minimal system
 	FileSystem *_fileSystem;
 	ConfigFileManager *_configFileMan;
-	SettingManager *_settingMan;
 
 	Args _parameters;
 
@@ -83,9 +81,6 @@ protected:
 private:
 	const Ultima::UltimaGameDescription *_gameDesc;
 
-	//! start filesystem, kernel, config
-	virtual void sysInit();
-
 	//! parse commandline arguments
 	void ParseArgs(int argc, const char *const  *argv);
 
@@ -95,9 +90,6 @@ private:
 	//! \return true if detected all the fields, false if detection failed
 	bool getGameInfo(const istring &game, GameInfo *gameinfo);
 
-	//! load configuration files
-	void loadConfig();
-
 protected:
 	//! Setup up a game
 	//! \return false if failed
@@ -105,10 +97,6 @@ protected:
 
 	//! kill current gameinfo
 	void killGame();
-
-	//! Setup the virtual game paths for the current game (set in gameinfo)
-	//! Specifically, @game
-	void setupGamePaths(GameInfo *gameinfo);
 };
 
 } // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/world/container.cpp b/engines/ultima/ultima8/world/container.cpp
index 85aeaafaad..99095363a6 100644
--- a/engines/ultima/ultima8/world/container.cpp
+++ b/engines/ultima/ultima8/world/container.cpp
@@ -109,8 +109,7 @@ bool Container::CanAddItem(Item *item, bool checkwghtvol) {
 		uint32 shapeid = item->getShape();
 		if (GAME_IS_U8 && (shapeid == 115 /*Barrel*/
 		                   || shapeid == 78 || shapeid == 117 /*Chests*/)) {
-			// TODO: make this off by default, but can enable it through
-			// pentagram.ini
+			// TODO: make this off by default, but can enable it through config
 			MainActor *avatar = getMainActor();
 			ObjId bp = avatar->getEquip(7); // !! constant
 			Container *avatarbackpack = getContainer(bp);


Commit: c257a1b957b17780491c9c4b59f1a5b0d67192dd
    https://github.com/scummvm/scummvm/commit/c257a1b957b17780491c9c4b59f1a5b0d67192dd
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2021-02-02T20:32:06-06:00

Commit Message:
ULTIMA8: Remove now dead code around ConfigFIleManager

Changed paths:
    engines/ultima/ultima8/conf/config_file_manager.cpp
    engines/ultima/ultima8/conf/config_file_manager.h
    engines/ultima/ultima8/games/game_data.cpp


diff --git a/engines/ultima/ultima8/conf/config_file_manager.cpp b/engines/ultima/ultima8/conf/config_file_manager.cpp
index 084ed74326..1c4848865d 100644
--- a/engines/ultima/ultima8/conf/config_file_manager.cpp
+++ b/engines/ultima/ultima8/conf/config_file_manager.cpp
@@ -45,44 +45,18 @@ ConfigFileManager::~ConfigFileManager() {
 	_configFileManager = nullptr;
 }
 
-bool ConfigFileManager::readConfigFile(string fname, istring root,
-                                       bool readonly) {
+bool ConfigFileManager::readConfigFile(string fname, istring root) {
 	INIFile *inifile = new INIFile();
 	inifile->clear(root);
 	if (!inifile->readConfigFile(fname)) {
 		delete inifile;
 		return false;
 	}
-	if (readonly)
-		inifile->setReadonly();
 
 	_iniFiles.push_back(inifile);
 	return true;
 }
 
-bool ConfigFileManager::readConfigString(string config, istring root,
-        bool readonly) {
-	INIFile *inifile = new INIFile();
-	inifile->clear(root);
-	if (!inifile->readConfigString(config)) {
-		delete inifile;
-		return false;
-	}
-	if (readonly)
-		inifile->setReadonly();
-
-	_iniFiles.push_back(inifile);
-	return true;
-}
-
-void ConfigFileManager::write(istring root) {
-	for (Std::vector<INIFile *>::iterator i = _iniFiles.begin();
-	        i != _iniFiles.end(); ++i) {
-		if (!(*i)->isReadonly() && (root == "" || (*i)->checkRoot(root)))
-			(*i)->write();
-	}
-}
-
 void ConfigFileManager::clear() {
 	for (Std::vector<INIFile *>::iterator i = _iniFiles.begin();
 	        i != _iniFiles.end(); ++i) {
@@ -148,89 +122,6 @@ bool ConfigFileManager::get(istring key, bool &ret) {
 	return true;
 }
 
-void ConfigFileManager::set(istring key, string val) {
-	if (key.hasPrefix("settings/")) {
-		Common::String subKey(key.c_str() + key.findLastOf('/') + 1);
-		ConfMan.set(subKey, val);
-	} else {
-		INIFile *ini = findWriteINI(key);
-		if (!ini) return;
-
-		ini->set(key, val);
-	}
-}
-
-void ConfigFileManager::set(istring key, const char *val) {
-	if (key.hasPrefix("settings/")) {
-		Common::String subKey(key.c_str() + key.findLastOf('/') + 1);
-		ConfMan.set(subKey, val);
-	} else {
-		INIFile *ini = findWriteINI(key);
-		if (!ini) return;
-
-		ini->set(key, val);
-	}
-}
-
-void ConfigFileManager::set(istring key, int val) {
-	if (key.hasPrefix("settings/")) {
-		Common::String subKey(key.c_str() + key.findLastOf('/') + 1);
-		ConfMan.setInt(subKey, val);
-	} else {
-		INIFile *ini = findWriteINI(key);
-		if (!ini) return;
-
-		ini->set(key, val);
-	}
-}
-
-void ConfigFileManager::set(istring key, bool val) {
-	if (key.hasPrefix("settings/")) {
-		Common::String subKey(key.c_str() + key.findLastOf('/') + 1);
-		ConfMan.setBool(subKey, val);
-	} else {
-		INIFile *ini = findWriteINI(key);
-		if (!ini) return;
-
-		ini->set(key, val);
-	}
-}
-
-void ConfigFileManager::unset(istring key) {
-	if (key.hasPrefix("settings/")) {
-		Common::String subKey(key.c_str() + key.findLastOf('/') + 1);
-		ConfMan.set(subKey, "");
-	} else {
-		INIFile *ini = findWriteINI(key);
-		if (!ini) return;
-
-		ini->unset(key);
-	}
-}
-
-
-
-Std::vector<istring> ConfigFileManager::listKeys(istring section,
-        bool longformat) {
-	Std::vector<istring> keys;
-
-	Std::set<istring> keyset;
-	Std::set<istring>::iterator iter;
-
-	for (Std::vector<INIFile *>::iterator i = _iniFiles.begin();
-	        i != _iniFiles.end(); ++i) {
-		if ((*i)->checkRoot(section)) {
-			(*i)->listKeys(keyset, section, longformat);
-		}
-	}
-
-	for (iter = keyset.begin(); iter != keyset.end(); ++iter) {
-		keys.push_back(*iter);
-	}
-
-	return keys;
-}
-
 Std::vector<istring> ConfigFileManager::listSections(istring root,
         bool longformat) {
 	Std::vector<istring> sections;
@@ -277,15 +168,5 @@ INIFile *ConfigFileManager::findKeyINI(istring key) {
 	return nullptr;
 }
 
-INIFile *ConfigFileManager::findWriteINI(istring key) {
-	for (Std::vector<INIFile *>::reverse_iterator i = _iniFiles.rbegin();
-	        i != _iniFiles.rend(); ++i) {
-		if (!(*i)->isReadonly() && (*i)->checkRoot(key))
-			return (*i);
-	}
-
-	return nullptr;
-}
-
 } // End of namespace Ultima8
 } // End of namespace Ultima
diff --git a/engines/ultima/ultima8/conf/config_file_manager.h b/engines/ultima/ultima8/conf/config_file_manager.h
index b9fb6d9204..503f18f8f4 100644
--- a/engines/ultima/ultima8/conf/config_file_manager.h
+++ b/engines/ultima/ultima8/conf/config_file_manager.h
@@ -45,14 +45,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 succesful
-	bool readConfigFile(Std::string fname, istring root,
-	                    bool readonly = false);
-	bool readConfigString(Std::string config, istring root,
-	                      bool readonly = false);
-
-	//! write all (writable) config files in the given root
-	//! \param root The root to write, or empty string to write everything
-	void write(istring root = "");
+	bool readConfigFile(Std::string fname, istring root);
 
 	//! clear everything
 	void clear();
@@ -70,26 +63,6 @@ public:
 	//! get value
 	bool get(istring, bool &ret);
 
-	//! set value
-	void set(istring key, Std::string value);
-	//! set value
-	void set(istring key, const char *value);
-	//! set value
-	void set(istring key, int value);
-	//! set value
-	void set(istring key, bool value);
-
-	//! remove key
-	void unset(istring key);
-
-	//! list all keys in a section
-	//! \param section The section to return setkeys of
-	//! \param longformat If true, return the full key name, instead of
-	//!                   just the last part
-	//! \return the keys. They have no guaranteed order.
-	Std::vector<istring> listKeys(istring section,
-	        bool longformat = false);
-
 	//! list all sections
 	//! \param root The config root to list all sections in
 	//! \param longformat If true, return the full key name (including section)
@@ -106,7 +79,6 @@ public:
 private:
 
 	INIFile *findKeyINI(istring key);
-	INIFile *findWriteINI(istring key);
 
 	Std::vector<INIFile *> _iniFiles;
 
diff --git a/engines/ultima/ultima8/games/game_data.cpp b/engines/ultima/ultima8/games/game_data.cpp
index 5178fe434d..ba1d197bd8 100644
--- a/engines/ultima/ultima8/games/game_data.cpp
+++ b/engines/ultima/ultima8/games/game_data.cpp
@@ -175,7 +175,7 @@ void GameData::loadTranslation() {
 
 		pout << "Loading translation: " << translationfile << Std::endl;
 
-		config->readConfigFile(translationfile, "language", true);
+		config->readConfigFile(translationfile, "language");
 	}
 }
 
@@ -266,10 +266,10 @@ void GameData::loadU8Data() {
 
 	// Load weapon, armour info
 	ConfigFileManager *config = ConfigFileManager::get_instance();
-	config->readConfigFile("@data/u8weapons.ini", "weapons", true);
-	config->readConfigFile("@data/u8armour.ini", "armour", true);
-	config->readConfigFile("@data/u8monsters.ini", "monsters", true);
-	config->readConfigFile("@data/u8.ini", "game", true);
+	config->readConfigFile("@data/u8weapons.ini", "weapons");
+	config->readConfigFile("@data/u8armour.ini", "armour");
+	config->readConfigFile("@data/u8monsters.ini", "monsters");
+	config->readConfigFile("@data/u8.ini", "game");
 
 	// Load typeflags
 	Common::SeekableReadStream *tfs = filesystem->ReadFile("@game/static/typeflag.dat");
@@ -546,12 +546,12 @@ void GameData::loadRemorseData() {
 
 	ConfigFileManager *config = ConfigFileManager::get_instance();
 	// Load weapon, armour info
-	config->readConfigFile("@data/remorseweapons.ini", "weapons", true);
+	config->readConfigFile("@data/remorseweapons.ini", "weapons");
 #if 0
-	config->readConfigFile("@data/u8armour.ini", "armour", true);
-	config->readConfigFile("@data/u8monsters.ini", "monsters", true);
+	config->readConfigFile("@data/u8armour.ini", "armour");
+	config->readConfigFile("@data/u8monsters.ini", "monsters");
 #endif
-	config->readConfigFile("@data/remorse.ini", "game", true);
+	config->readConfigFile("@data/remorse.ini", "game");
 
 	// Load typeflags
 	Common::SeekableReadStream *tfs = filesystem->ReadFile("@game/static/typeflag.dat");


Commit: 9a7d3b58ea1c23c169df4ab4952fc6cc59652d6a
    https://github.com/scummvm/scummvm/commit/9a7d3b58ea1c23c169df4ab4952fc6cc59652d6a
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2021-02-02T20:32:06-06:00

Commit Message:
ULTIMA8: Remove ConfigManager usage in ConfigFileManagers

The keys in ConfigFileManager are paths in the form of "root/section/key" and are used for the files in ultima.dat.

Changed paths:
    engines/ultima/ultima8/conf/config_file_manager.cpp


diff --git a/engines/ultima/ultima8/conf/config_file_manager.cpp b/engines/ultima/ultima8/conf/config_file_manager.cpp
index 1c4848865d..468ade7cbd 100644
--- a/engines/ultima/ultima8/conf/config_file_manager.cpp
+++ b/engines/ultima/ultima8/conf/config_file_manager.cpp
@@ -22,7 +22,6 @@
 
 #include "ultima/ultima8/misc/pent_include.h"
 #include "ultima/ultima8/conf/config_file_manager.h"
-#include "common/config-manager.h"
 
 namespace Ultima {
 namespace Ultima8 {
@@ -40,7 +39,6 @@ ConfigFileManager::ConfigFileManager() {
 ConfigFileManager::~ConfigFileManager() {
 	debugN(MM_INFO, "Destroying ConfigFileManager...\n");
 
-	ConfMan.flushToDisk();
 	clear();
 	_configFileManager = nullptr;
 }
@@ -79,15 +77,10 @@ void ConfigFileManager::clearRoot(istring root) {
 }
 
 bool ConfigFileManager::exists(istring key) {
-	return ConfMan.hasKey(key) || (findKeyINI(key) != nullptr);
+	return (findKeyINI(key) != nullptr);
 }
 
 bool ConfigFileManager::get(istring key, string &ret) {
-	if (ConfMan.hasKey(key)) {
-		ret = ConfMan.get(key);
-		return true;
-	}
-
 	INIFile *ini = findKeyINI(key);
 	if (!ini) return false;
 
@@ -97,11 +90,6 @@ bool ConfigFileManager::get(istring key, string &ret) {
 
 
 bool ConfigFileManager::get(istring key, int &ret) {
-	if (ConfMan.hasKey(key)) {
-		ret = ConfMan.getInt(key);
-		return true;
-	}
-
 	INIFile *ini = findKeyINI(key);
 	if (!ini) return false;
 
@@ -110,11 +98,6 @@ bool ConfigFileManager::get(istring key, int &ret) {
 }
 
 bool ConfigFileManager::get(istring key, bool &ret) {
-	if (ConfMan.hasKey(key)) {
-		ret = ConfMan.getBool(key);
-		return true;
-	}
-
 	INIFile *ini = findKeyINI(key);
 	if (!ini) return false;
 




More information about the Scummvm-git-logs mailing list