diff options
author | Naios <naios-dev@live.de> | 2016-04-18 20:29:42 +0200 |
---|---|---|
committer | Naios <naios-dev@live.de> | 2016-04-18 23:03:24 +0200 |
commit | 51ec8d3b8cc6d2691b4a9c0d4502fd1936d82c79 (patch) | |
tree | 61667f6e4bc15ad98e171bc224721d3f859bd0e1 /src/server/game/Scripting/ScriptReloadMgr.cpp | |
parent | 2809f11839ff0fd4eec45b2e116811b0698dd05b (diff) |
Core/Scripting: Use the path of the worldserver executable to search for the scripts dir
* Fixes issues when starting the worldserver not in the bin directory
or the CMAKE_INSTALL_PREFIX directory using the -c option.
(cherry picked from commit 86b0fcf67aadc0d313253befb0590d00efd085bc)
Diffstat (limited to 'src/server/game/Scripting/ScriptReloadMgr.cpp')
-rw-r--r-- | src/server/game/Scripting/ScriptReloadMgr.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/server/game/Scripting/ScriptReloadMgr.cpp b/src/server/game/Scripting/ScriptReloadMgr.cpp index 6862125369b..d13fa9c30f0 100644 --- a/src/server/game/Scripting/ScriptReloadMgr.cpp +++ b/src/server/game/Scripting/ScriptReloadMgr.cpp @@ -102,6 +102,18 @@ typedef HMODULE HandleType; typedef void* HandleType; #endif +static fs::path GetDirectoryOfExecutable() +{ + ASSERT((!sConfigMgr->GetArguments().empty()), + "Expected the arguments to contain at least 1 element!"); + + fs::path path(sConfigMgr->GetArguments()[0]); + if (path.is_absolute()) + return path.parent_path(); + else + return fs::absolute(path).parent_path(); +} + class SharedLibraryUnloader { public: @@ -537,7 +549,13 @@ public: /// Returns the absolute path to the script module directory static fs::path GetLibraryDirectory() { - return fs::absolute(sConfigMgr->GetStringDefault("HotSwap.ScriptDir", "scripts")); + // When an absolute path is given in the config use it, + // otherwise interpret paths relative to the executable. + fs::path path(sConfigMgr->GetStringDefault("HotSwap.ScriptDir", "scripts")); + if (path.is_absolute()) + return path; + else + return fs::absolute(path, GetDirectoryOfExecutable()); } /// Returns the absolute path to the scripts directory in the source tree. @@ -734,7 +752,6 @@ private: static fs::path CalculateTemporaryCachePath() { auto path = fs::temp_directory_path(); - path /= Trinity::StringFormat("tc_script_cache_%s_%s", GitRevision::GetBranch(), CalculateSHA1Hash(sConfigMgr->GetFilename()).c_str()); @@ -1316,7 +1333,7 @@ private: #ifndef _WIN32 // The worldserver location is ${CMAKE_INSTALL_PREFIX}/bin // on all other platforms then windows - current_path = current_path.remove_leaf(); + current_path = current_path.parent_path(); #endif if (value != current_path) @@ -1332,7 +1349,7 @@ private: if (base == branch) return true; - branch = branch.remove_leaf(); + branch = branch.parent_path(); } return false; |