File custom-paths-0.14.0.patch of Package OpenTESArena

--- OpenTESArena-opentesarena-0.14.0/OpenTESArena/CMakeLists.txt	2021-11-19 04:51:27.000000000 +0100
+++ patch/OpenTESArena/CMakeLists.txt	2021-12-01 19:17:17.141755126 +0100
@@ -2,6 +2,17 @@
 
 SET(OpenTESArena_VERSION "0.14.0")
 
+# Custom data path
+IF (NOT DEFINED OPENTESARENA_DATADIR)
+	SET(OPENTESARENA_DATADIR "data")
+ENDIF ()
+ADD_DEFINITIONS("-DTES_DATADIR=\"${OPENTESARENA_DATADIR}/\"")
+# Custom config / options path
+IF (DEFINED OPENTESARENA_OPTIONSDIR)
+	ADD_DEFINITIONS("-DTES_OPTIONSDIR=\"${OPENTESARENA_OPTIONSDIR}/\"")
+ENDIF()
+
+
 FIND_PACKAGE(SDL2 REQUIRED)
 FIND_PACKAGE(OpenAL REQUIRED)
 FIND_PACKAGE(WildMidi)
 --- OpenTESArena-opentesarena-0.14.0/OpenTESArena/src/Assets/ExeData.cpp	2021-11-19 04:51:27.000000000 +0100
+++ patch/OpenTESArena/src/Assets/ExeData.cpp	2021-12-01 19:20:29.983295004 +0100
@@ -7,6 +7,7 @@
 
 #include "components/debug/Debug.h"
 #include "components/utilities/Bytes.h"
+#include "components/utilities/File.h"
 #include "components/utilities/String.h"
 #include "components/utilities/StringView.h"
 
@@ -889,9 +890,9 @@
 }
 
 const std::string ExeData::FLOPPY_VERSION_EXE_FILENAME = "A.EXE";
-const std::string ExeData::FLOPPY_VERSION_MAP_FILENAME = "data/text/aExeStrings.txt";
+const std::string ExeData::FLOPPY_VERSION_MAP_FILENAME = TES_DATADIR "text/aExeStrings.txt";
 const std::string ExeData::CD_VERSION_EXE_FILENAME = "ACD.EXE";
-const std::string ExeData::CD_VERSION_MAP_FILENAME = "data/text/acdExeStrings.txt";
+const std::string ExeData::CD_VERSION_MAP_FILENAME = TES_DATADIR "text/acdExeStrings.txt";
 
 int ExeData::get(const KeyValueFile::Section &section, const std::string &key)
 {
@@ -997,7 +998,7 @@
 	const std::string &mapFilename = floppyVersion ?
 		ExeData::FLOPPY_VERSION_MAP_FILENAME : ExeData::CD_VERSION_MAP_FILENAME;
 	KeyValueFile keyValueFile;
-	if (!keyValueFile.init((Platform::getBasePath() + mapFilename).c_str()))
+	if (!keyValueFile.init(((File::pathIsRelative(mapFilename.c_str()) ? Platform::getBasePath() : std::string()) + mapFilename).c_str()))
 	{
 		DebugLogError("Couldn't init KeyValueFile for \"" + exeFilename + "\".");
 		return false;
 		--- OpenTESArena-opentesarena-0.14.0/OpenTESArena/src/Game/Game.cpp	2021-11-19 04:51:27.000000000 +0100
+++ patch/OpenTESArena/src/Game/Game.cpp	2021-12-01 19:23:22.352663635 +0100
@@ -67,8 +67,8 @@
 		this->options.getAudio_SoundResampling(), this->options.getAudio_Is3DAudio(), midiPath);
 
 	// Initialize music library from file.
-	const std::string musicLibraryPath = this->basePath + "data/audio/MusicDefinitions.txt";
-	if (!this->musicLibrary.init(musicLibraryPath.c_str()))
+	const std::string musicLibraryPath = TES_DATADIR "audio/MusicDefinitions.txt";
+	if (!this->musicLibrary.init(((File::pathIsRelative(TES_DATADIR) ? this->basePath : std::string()) + musicLibraryPath).c_str()))
 	{
 		DebugLogError("Couldn't init music library at \"" + musicLibraryPath + "\".");
 	}
@@ -175,7 +175,7 @@
 	// Load and set window icon.
 	const Surface icon = [this]()
 	{
-		const std::string iconPath = this->basePath + "data/icon.bmp";
+		const std::string iconPath = (File::pathIsRelative(TES_DATADIR) ? this->basePath : std::string())+ TES_DATADIR "icon.bmp";
 		Surface surface = Surface::loadBMP(iconPath.c_str(), Renderer::DEFAULT_PIXELFORMAT);
 
 		// Treat black as transparent.
@@ -187,7 +187,7 @@
 
 	// Load single-instance sounds file for the audio manager.
 	TextLinesFile singleInstanceSoundsFile;
-	const std::string singleInstanceSoundsPath = this->basePath + "data/audio/SingleInstanceSounds.txt";
+	const std::string singleInstanceSoundsPath = (File::pathIsRelative(TES_DATADIR) ? this->basePath : std::string()) + TES_DATADIR "audio/SingleInstanceSounds.txt";
 	if (singleInstanceSoundsFile.init(singleInstanceSoundsPath.c_str()))
 	{
 		for (int i = 0; i < singleInstanceSoundsFile.getLineCount(); i++)
@@ -409,7 +409,11 @@
 void Game::initOptions(const std::string &basePath, const std::string &optionsPath)
 {
 	// Load the default options first.
+#ifdef TES_OPTIONSDIR
+	const std::string defaultOptionsPath(TES_OPTIONSDIR + Options::DEFAULT_FILENAME);
+#else
 	const std::string defaultOptionsPath(basePath + "options/" + Options::DEFAULT_FILENAME);
+#endif
 	this->options.loadDefaults(defaultOptionsPath);
 
 	// Check if the changes options file exists.
openSUSE Build Service is sponsored by