mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +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:
@@ -24,6 +24,7 @@
|
||||
#include <openssl/crypto.h>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
#include "Common.h"
|
||||
@@ -53,6 +54,7 @@
|
||||
#include "AppenderDB.h"
|
||||
|
||||
using namespace boost::program_options;
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
#ifndef _TRINITY_CORE_CONFIG
|
||||
#define _TRINITY_CORE_CONFIG "worldserver.conf"
|
||||
@@ -90,14 +92,14 @@ void ClearOnlineAccounts();
|
||||
void ShutdownCLIThread(std::thread* cliThread);
|
||||
void ShutdownThreadPool(std::vector<std::thread>& threadPool);
|
||||
bool LoadRealmInfo();
|
||||
variables_map GetConsoleArguments(int argc, char** argv, std::string& cfg_file, std::string& cfg_service);
|
||||
variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile, std::string& cfg_service);
|
||||
|
||||
/// Launch the Trinity server
|
||||
extern int main(int argc, char** argv)
|
||||
{
|
||||
signal(SIGABRT, &Trinity::AbortHandler);
|
||||
|
||||
std::string configFile = _TRINITY_CORE_CONFIG;
|
||||
auto configFile = fs::absolute(_TRINITY_CORE_CONFIG);
|
||||
std::string configService;
|
||||
|
||||
auto vm = GetConsoleArguments(argc, argv, configFile, configService);
|
||||
@@ -115,7 +117,9 @@ extern 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;
|
||||
@@ -136,7 +140,7 @@ extern int main(int argc, char** argv)
|
||||
TC_LOG_INFO("server.worldserver", " \\/_/\\/_/ \\/_/\\/_/\\/_/\\/_/\\/__/ `/___/> \\");
|
||||
TC_LOG_INFO("server.worldserver", " C O R E /\\___/");
|
||||
TC_LOG_INFO("server.worldserver", "http://TrinityCore.org \\/__/\n");
|
||||
TC_LOG_INFO("server.worldserver", "Using configuration file %s.", configFile.c_str());
|
||||
TC_LOG_INFO("server.worldserver", "Using configuration file %s.", sConfigMgr->GetFilename().c_str());
|
||||
TC_LOG_INFO("server.worldserver", "Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
|
||||
TC_LOG_INFO("server.worldserver", "Using Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
|
||||
|
||||
@@ -571,7 +575,7 @@ void ClearOnlineAccounts()
|
||||
|
||||
/// @}
|
||||
|
||||
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)
|
||||
{
|
||||
// Silences warning about configService not be used if the OS is not Windows
|
||||
(void)configService;
|
||||
@@ -580,7 +584,8 @@ variables_map GetConsoleArguments(int argc, char** argv, std::string& configFile
|
||||
all.add_options()
|
||||
("help,h", "print usage message")
|
||||
("version,v", "print version build info")
|
||||
("config,c", value<std::string>(&configFile)->default_value(_TRINITY_CORE_CONFIG), "use <arg> as configuration file")
|
||||
("config,c", value<fs::path>(&configFile)->default_value(fs::absolute(_TRINITY_CORE_CONFIG)),
|
||||
"use <arg> as configuration file")
|
||||
;
|
||||
#ifdef _WIN32
|
||||
options_description win("Windows platform specific options");
|
||||
|
||||
Reference in New Issue
Block a user