mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
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 86b0fcf67a)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user