mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-04 10:26:37 +00:00
[File Paths] Implement Path Manager (#2440)
* Push up branch for testing * Path manager * Tweaks * Changes * More path work * Update paths for eqemu_server.pl * More path work * Import and export client files * Path remove * More path work * Update eqemu_config.h * Fix tests * Tests disable temp * Update eqemu_config.h * Update .drone.yml * Hook tests back up * Update main.cpp * Platform tests * Fix include * Use std::filesystem on windows * Fix IPCMutex name on windows * std::filesystem changes * Update path_manager.cpp * Explicit string cast * Explicit string cast * Update path_manager.cpp * Windows fixes * Mapped files * Relative fixes * Use relative paths off of cwd * Update Debian image to Debian 11 (updates GCC) Co-authored-by: hg <4683435+hgtw@users.noreply.github.com>
This commit is contained in:
@@ -490,7 +490,7 @@ bool LoginServer::Connect()
|
||||
[this](EQ::Net::ServertalkClient *client) {
|
||||
if (client) {
|
||||
LogInfo(
|
||||
"Connected to Loginserver: [{0}:{1}]",
|
||||
"Connected to Loginserver [{0}:{1}]",
|
||||
m_loginserver_address,
|
||||
m_loginserver_port
|
||||
);
|
||||
@@ -499,7 +499,6 @@ bool LoginServer::Connect()
|
||||
zoneserver_list.SendLSZones();
|
||||
|
||||
m_statusupdate_timer = std::make_unique<EQ::Timer>(
|
||||
|
||||
LoginServer_StatusUpdateInterval, true, [this](EQ::Timer *t) {
|
||||
SendStatus();
|
||||
}
|
||||
|
||||
@@ -95,6 +95,8 @@ union semun {
|
||||
#include "world_event_scheduler.h"
|
||||
#include "shared_task_manager.h"
|
||||
#include "world_boot.h"
|
||||
#include "../common/path_manager.h"
|
||||
|
||||
|
||||
ZoneStore zone_store;
|
||||
ClientList client_list;
|
||||
@@ -115,6 +117,7 @@ const WorldConfig *Config;
|
||||
EQEmuLogSys LogSys;
|
||||
WorldContentService content_service;
|
||||
WebInterfaceList web_interface;
|
||||
PathManager path;
|
||||
|
||||
void CatchSignal(int sig_num);
|
||||
|
||||
@@ -138,6 +141,8 @@ int main(int argc, char **argv)
|
||||
LogSys.LoadLogSettingsDefaults();
|
||||
set_exception_handler();
|
||||
|
||||
path.LoadPaths();
|
||||
|
||||
if (WorldBoot::HandleCommandInput(argc, argv)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
+11
-6
@@ -25,6 +25,7 @@
|
||||
#include "zoneserver.h"
|
||||
#include "../common/ip_util.h"
|
||||
#include "../common/zone_store.h"
|
||||
#include "../common/path_manager.h"
|
||||
|
||||
extern ZSList zoneserver_list;
|
||||
extern WorldConfig Config;
|
||||
@@ -169,14 +170,14 @@ int get_file_size(const std::string &filename) // path to file
|
||||
|
||||
void WorldBoot::CheckForServerScript(bool force_download)
|
||||
{
|
||||
const std::string file = "eqemu_server.pl";
|
||||
const std::string file = fmt::format("{}/eqemu_server.pl", path.GetServerPath());
|
||||
std::ifstream f(file);
|
||||
|
||||
/* Fetch EQEmu Server script */
|
||||
if (!f || get_file_size(file) < 100 || force_download) {
|
||||
|
||||
if (force_download) {
|
||||
std::remove("eqemu_server.pl");
|
||||
std::remove(fmt::format("{}/eqemu_server.pl", path.GetServerPath()).c_str());
|
||||
} /* Delete local before fetch */
|
||||
|
||||
std::cout << "Pulling down EQEmu Server Maintenance Script (eqemu_server.pl)..." << std::endl;
|
||||
@@ -199,13 +200,15 @@ void WorldBoot::CheckForServerScript(bool force_download)
|
||||
if (auto res = r.Get(u.get_path().c_str())) {
|
||||
if (res->status == 200) {
|
||||
// write file
|
||||
std::ofstream out("eqemu_server.pl");
|
||||
|
||||
std::string script = fmt::format("{}/eqemu_server.pl", path.GetServerPath());
|
||||
std::ofstream out(script);
|
||||
out << res->body;
|
||||
out.close();
|
||||
#ifdef _WIN32
|
||||
#else
|
||||
system("chmod 755 eqemu_server.pl");
|
||||
system("chmod +x eqemu_server.pl");
|
||||
system(fmt::format("chmod 755 {}", script).c_str());
|
||||
system(fmt::format("chmod +x {}", script).c_str());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -216,7 +219,8 @@ void WorldBoot::CheckForXMLConfigUpgrade()
|
||||
{
|
||||
if (!std::ifstream("eqemu_config.json") && std::ifstream("eqemu_config.xml")) {
|
||||
CheckForServerScript(true);
|
||||
if (system("perl eqemu_server.pl convert_xml")) {}
|
||||
std::string command = fmt::format("perl {}/eqemu_server.pl convert_xml", path.GetServerPath());
|
||||
if (system(command.c_str())) {}
|
||||
}
|
||||
else {
|
||||
CheckForServerScript();
|
||||
@@ -291,6 +295,7 @@ bool WorldBoot::DatabaseLoadRoutines(int argc, char **argv)
|
||||
|
||||
// logging system init
|
||||
auto logging = LogSys.SetDatabase(&database)
|
||||
->SetLogPath(path.GetLogPath())
|
||||
->LoadLogDatabaseSettings();
|
||||
|
||||
if (RuleB(Logging, WorldGMSayLogging)) {
|
||||
|
||||
@@ -46,13 +46,13 @@ public:
|
||||
}
|
||||
|
||||
// Load the config
|
||||
static bool LoadConfig() {
|
||||
static bool LoadConfig(const std::string& path = "") {
|
||||
if (_world_config != nullptr)
|
||||
delete _world_config;
|
||||
_world_config=new WorldConfig;
|
||||
_config=_world_config;
|
||||
|
||||
return _config->parseFile();
|
||||
return _config->parseFile(path);
|
||||
}
|
||||
|
||||
// Accessors for the static private object
|
||||
|
||||
Reference in New Issue
Block a user