mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-17 16:10:49 +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.
This commit is contained in:
@@ -36,12 +36,14 @@
|
||||
#include "GitRevision.h"
|
||||
#include "Util.h"
|
||||
#include <iostream>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <openssl/opensslv.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
using boost::asio::ip::tcp;
|
||||
using namespace boost::program_options;
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
#ifndef _TRINITY_REALM_CONFIG
|
||||
# define _TRINITY_REALM_CONFIG "authserver.conf"
|
||||
@@ -69,7 +71,7 @@ void StopDB();
|
||||
void SignalHandler(const boost::system::error_code& error, int signalNumber);
|
||||
void KeepDatabaseAliveHandler(const boost::system::error_code& error);
|
||||
void BanExpiryHandler(boost::system::error_code const& error);
|
||||
variables_map GetConsoleArguments(int argc, char** argv, std::string& configFile, std::string& configService);
|
||||
variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile, std::string& configService);
|
||||
|
||||
boost::asio::io_service* _ioService;
|
||||
boost::asio::deadline_timer* _dbPingTimer;
|
||||
@@ -81,7 +83,7 @@ int main(int argc, char** argv)
|
||||
{
|
||||
signal(SIGABRT, &Trinity::AbortHandler);
|
||||
|
||||
std::string configFile = _TRINITY_REALM_CONFIG;
|
||||
auto configFile = fs::absolute(_TRINITY_REALM_CONFIG);
|
||||
std::string configService;
|
||||
auto vm = GetConsoleArguments(argc, argv, configFile, configService);
|
||||
// exit if help or version is enabled
|
||||
@@ -98,7 +100,9 @@ int main(int argc, char** argv)
|
||||
#endif
|
||||
|
||||
std::string configError;
|
||||
if (!sConfigMgr->LoadInitial(configFile, configError))
|
||||
if (!sConfigMgr->LoadInitial(configFile.generic_string(),
|
||||
std::vector<std::string>(argv, argv + argc),
|
||||
configError))
|
||||
{
|
||||
printf("Error in config file: %s\n", configError.c_str());
|
||||
return 1;
|
||||
@@ -109,7 +113,7 @@ int main(int argc, char** argv)
|
||||
|
||||
TC_LOG_INFO("server.authserver", "%s (authserver)", GitRevision::GetFullVersion());
|
||||
TC_LOG_INFO("server.authserver", "<Ctrl-C> to stop.\n");
|
||||
TC_LOG_INFO("server.authserver", "Using configuration file %s.", configFile.c_str());
|
||||
TC_LOG_INFO("server.authserver", "Using configuration file %s.", sConfigMgr->GetFilename().c_str());
|
||||
TC_LOG_INFO("server.authserver", "Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
|
||||
TC_LOG_INFO("server.authserver", "Using Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
|
||||
|
||||
@@ -286,13 +290,14 @@ void ServiceStatusWatcher(boost::system::error_code const& error)
|
||||
}
|
||||
#endif
|
||||
|
||||
variables_map GetConsoleArguments(int argc, char** argv, std::string& configFile, std::string& configService)
|
||||
variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile, std::string& configService)
|
||||
{
|
||||
options_description all("Allowed options");
|
||||
all.add_options()
|
||||
("help,h", "print usage message")
|
||||
("version,v", "print version build info")
|
||||
("config,c", value<std::string>(&configFile)->default_value(_TRINITY_REALM_CONFIG), "use <arg> as configuration file")
|
||||
("config,c", value<fs::path>(&configFile)->default_value(fs::absolute(_TRINITY_REALM_CONFIG)),
|
||||
"use <arg> as configuration file")
|
||||
;
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
options_description win("Windows platform specific options");
|
||||
|
||||
Reference in New Issue
Block a user