mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +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:
parent
19791195e5
commit
f8e7576ae7
@ -15,7 +15,7 @@ volumes:
|
|||||||
steps:
|
steps:
|
||||||
- name: server-build
|
- name: server-build
|
||||||
# Source build script https://github.com/Akkadius/akk-stack/blob/master/containers/eqemu-server/Dockerfile#L20
|
# Source build script https://github.com/Akkadius/akk-stack/blob/master/containers/eqemu-server/Dockerfile#L20
|
||||||
image: akkadius/eqemu-server:latest
|
image: akkadius/eqemu-server:v11
|
||||||
commands:
|
commands:
|
||||||
- sudo chown eqemu:eqemu /drone/src/ * -R
|
- sudo chown eqemu:eqemu /drone/src/ * -R
|
||||||
- sudo chown eqemu:eqemu /home/eqemu/.ccache/ * -R
|
- sudo chown eqemu:eqemu /home/eqemu/.ccache/ * -R
|
||||||
|
|||||||
@ -28,10 +28,12 @@
|
|||||||
#include "../../common/strings.h"
|
#include "../../common/strings.h"
|
||||||
#include "../../common/content/world_content_service.h"
|
#include "../../common/content/world_content_service.h"
|
||||||
#include "../../common/zone_store.h"
|
#include "../../common/zone_store.h"
|
||||||
|
#include "../../common/path_manager.h"
|
||||||
|
|
||||||
EQEmuLogSys LogSys;
|
EQEmuLogSys LogSys;
|
||||||
WorldContentService content_service;
|
WorldContentService content_service;
|
||||||
ZoneStore zone_store;
|
ZoneStore zone_store;
|
||||||
|
PathManager path;
|
||||||
|
|
||||||
void ExportSpells(SharedDatabase *db);
|
void ExportSpells(SharedDatabase *db);
|
||||||
void ExportSkillCaps(SharedDatabase *db);
|
void ExportSkillCaps(SharedDatabase *db);
|
||||||
@ -44,6 +46,8 @@ int main(int argc, char **argv)
|
|||||||
LogSys.LoadLogSettingsDefaults();
|
LogSys.LoadLogSettingsDefaults();
|
||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
|
|
||||||
|
path.LoadPaths();
|
||||||
|
|
||||||
LogInfo("Client Files Export Utility");
|
LogInfo("Client Files Export Utility");
|
||||||
if (!EQEmuConfig::LoadConfig()) {
|
if (!EQEmuConfig::LoadConfig()) {
|
||||||
LogError("Unable to load configuration file");
|
LogError("Unable to load configuration file");
|
||||||
@ -86,6 +90,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LogSys.SetDatabase(&database)
|
LogSys.SetDatabase(&database)
|
||||||
|
->SetLogPath(path.GetLogPath())
|
||||||
->LoadLogDatabaseSettings()
|
->LoadLogDatabaseSettings()
|
||||||
->StartFileLogs();
|
->StartFileLogs();
|
||||||
|
|
||||||
@ -126,7 +131,8 @@ void ExportSpells(SharedDatabase *db)
|
|||||||
{
|
{
|
||||||
LogInfo("Exporting Spells");
|
LogInfo("Exporting Spells");
|
||||||
|
|
||||||
FILE *f = fopen("export/spells_us.txt", "w");
|
std::string file = fmt::format("{}/export/spells_us.txt", path.GetServerPath());
|
||||||
|
FILE *f = fopen(file.c_str(), "w");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
LogError("Unable to open export/spells_us.txt to write, skipping.");
|
LogError("Unable to open export/spells_us.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
@ -208,7 +214,8 @@ void ExportSkillCaps(SharedDatabase *db)
|
|||||||
{
|
{
|
||||||
LogInfo("Exporting Skill Caps");
|
LogInfo("Exporting Skill Caps");
|
||||||
|
|
||||||
FILE *f = fopen("export/SkillCaps.txt", "w");
|
std::string file = fmt::format("{}/export/SkillCaps.txt", path.GetServerPath());
|
||||||
|
FILE *f = fopen(file.c_str(), "w");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
LogError("Unable to open export/SkillCaps.txt to write, skipping.");
|
LogError("Unable to open export/SkillCaps.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
@ -238,7 +245,8 @@ void ExportBaseData(SharedDatabase *db)
|
|||||||
{
|
{
|
||||||
LogInfo("Exporting Base Data");
|
LogInfo("Exporting Base Data");
|
||||||
|
|
||||||
FILE *f = fopen("export/BaseData.txt", "w");
|
std::string file = fmt::format("{}/export/BaseData.txt", path.GetServerPath());
|
||||||
|
FILE *f = fopen(file.c_str(), "w");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
LogError("Unable to open export/BaseData.txt to write, skipping.");
|
LogError("Unable to open export/BaseData.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
@ -271,7 +279,8 @@ void ExportDBStrings(SharedDatabase *db)
|
|||||||
{
|
{
|
||||||
LogInfo("Exporting DB Strings");
|
LogInfo("Exporting DB Strings");
|
||||||
|
|
||||||
FILE *f = fopen("export/dbstr_us.txt", "w");
|
std::string file = fmt::format("{}/export/dbstr_us.txt", path.GetServerPath());
|
||||||
|
FILE *f = fopen(file.c_str(), "w");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
LogError("Unable to open export/dbstr_us.txt to write, skipping.");
|
LogError("Unable to open export/dbstr_us.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -26,10 +26,12 @@
|
|||||||
#include "../../common/strings.h"
|
#include "../../common/strings.h"
|
||||||
#include "../../common/content/world_content_service.h"
|
#include "../../common/content/world_content_service.h"
|
||||||
#include "../../common/zone_store.h"
|
#include "../../common/zone_store.h"
|
||||||
|
#include "../../common/path_manager.h"
|
||||||
|
|
||||||
EQEmuLogSys LogSys;
|
EQEmuLogSys LogSys;
|
||||||
WorldContentService content_service;
|
WorldContentService content_service;
|
||||||
ZoneStore zone_store;
|
ZoneStore zone_store;
|
||||||
|
PathManager path;
|
||||||
|
|
||||||
void ImportSpells(SharedDatabase *db);
|
void ImportSpells(SharedDatabase *db);
|
||||||
void ImportSkillCaps(SharedDatabase *db);
|
void ImportSkillCaps(SharedDatabase *db);
|
||||||
@ -41,6 +43,8 @@ int main(int argc, char **argv) {
|
|||||||
LogSys.LoadLogSettingsDefaults();
|
LogSys.LoadLogSettingsDefaults();
|
||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
|
|
||||||
|
path.LoadPaths();
|
||||||
|
|
||||||
LogInfo("Client Files Import Utility");
|
LogInfo("Client Files Import Utility");
|
||||||
if(!EQEmuConfig::LoadConfig()) {
|
if(!EQEmuConfig::LoadConfig()) {
|
||||||
LogError("Unable to load configuration file.");
|
LogError("Unable to load configuration file.");
|
||||||
@ -83,6 +87,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LogSys.SetDatabase(&database)
|
LogSys.SetDatabase(&database)
|
||||||
|
->SetLogPath(path.GetLogPath())
|
||||||
->LoadLogDatabaseSettings()
|
->LoadLogDatabaseSettings()
|
||||||
->StartFileLogs();
|
->StartFileLogs();
|
||||||
|
|
||||||
@ -127,9 +132,10 @@ bool IsStringField(int i) {
|
|||||||
|
|
||||||
void ImportSpells(SharedDatabase *db) {
|
void ImportSpells(SharedDatabase *db) {
|
||||||
LogInfo("Importing Spells");
|
LogInfo("Importing Spells");
|
||||||
FILE *f = fopen("import/spells_us.txt", "r");
|
std::string file = fmt::format("{}/import/spells_us.txt", path.GetServerPath());
|
||||||
|
FILE *f = fopen(file.c_str(), "r");
|
||||||
if(!f) {
|
if(!f) {
|
||||||
LogError("Unable to open import/spells_us.txt to read, skipping.");
|
LogError("Unable to open {} to read, skipping.", file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,9 +222,10 @@ void ImportSpells(SharedDatabase *db) {
|
|||||||
void ImportSkillCaps(SharedDatabase *db) {
|
void ImportSkillCaps(SharedDatabase *db) {
|
||||||
LogInfo("Importing Skill Caps");
|
LogInfo("Importing Skill Caps");
|
||||||
|
|
||||||
FILE *f = fopen("import/SkillCaps.txt", "r");
|
std::string file = fmt::format("{}/import/SkillCaps.txt", path.GetServerPath());
|
||||||
|
FILE *f = fopen(file.c_str(), "r");
|
||||||
if(!f) {
|
if(!f) {
|
||||||
LogError("Unable to open import/SkillCaps.txt to read, skipping.");
|
LogError("Unable to open {} to read, skipping.", file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,9 +258,10 @@ void ImportSkillCaps(SharedDatabase *db) {
|
|||||||
void ImportBaseData(SharedDatabase *db) {
|
void ImportBaseData(SharedDatabase *db) {
|
||||||
LogInfo("Importing Base Data");
|
LogInfo("Importing Base Data");
|
||||||
|
|
||||||
FILE *f = fopen("import/BaseData.txt", "r");
|
std::string file = fmt::format("{}/import/BaseData.txt", path.GetServerPath());
|
||||||
|
FILE *f = fopen(file.c_str(), "r");
|
||||||
if(!f) {
|
if(!f) {
|
||||||
LogError("Unable to open import/BaseData.txt to read, skipping.");
|
LogError("Unable to open {} to read, skipping.", file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,9 +304,10 @@ void ImportBaseData(SharedDatabase *db) {
|
|||||||
void ImportDBStrings(SharedDatabase *db) {
|
void ImportDBStrings(SharedDatabase *db) {
|
||||||
LogInfo("Importing DB Strings");
|
LogInfo("Importing DB Strings");
|
||||||
|
|
||||||
FILE *f = fopen("import/dbstr_us.txt", "r");
|
std::string file = fmt::format("{}/import/dbstr_us.txt", path.GetServerPath());
|
||||||
|
FILE *f = fopen(file.c_str(), "r");
|
||||||
if(!f) {
|
if(!f) {
|
||||||
LogError("Unable to open import/dbstr_us.txt to read, skipping.");
|
LogError("Unable to open {} to read, skipping.", file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ SET(common_sources
|
|||||||
extprofile.cpp
|
extprofile.cpp
|
||||||
discord_manager.cpp
|
discord_manager.cpp
|
||||||
faction.cpp
|
faction.cpp
|
||||||
file_util.cpp
|
file.cpp
|
||||||
guild_base.cpp
|
guild_base.cpp
|
||||||
guilds.cpp
|
guilds.cpp
|
||||||
inventory_profile.cpp
|
inventory_profile.cpp
|
||||||
@ -61,6 +61,7 @@ SET(common_sources
|
|||||||
packet_dump.cpp
|
packet_dump.cpp
|
||||||
packet_dump_file.cpp
|
packet_dump_file.cpp
|
||||||
packet_functions.cpp
|
packet_functions.cpp
|
||||||
|
path_manager.cpp
|
||||||
perl_eqdb.cpp
|
perl_eqdb.cpp
|
||||||
perl_eqdb_res.cpp
|
perl_eqdb_res.cpp
|
||||||
proc_launcher.cpp
|
proc_launcher.cpp
|
||||||
@ -529,7 +530,7 @@ SET(common_headers
|
|||||||
expedition_lockout_timer.h
|
expedition_lockout_timer.h
|
||||||
extprofile.h
|
extprofile.h
|
||||||
faction.h
|
faction.h
|
||||||
file_util.h
|
file.h
|
||||||
features.h
|
features.h
|
||||||
fixed_memory_hash_set.h
|
fixed_memory_hash_set.h
|
||||||
fixed_memory_variable_hash_set.h
|
fixed_memory_variable_hash_set.h
|
||||||
@ -565,6 +566,7 @@ SET(common_headers
|
|||||||
packet_dump.h
|
packet_dump.h
|
||||||
packet_dump_file.h
|
packet_dump_file.h
|
||||||
packet_functions.h
|
packet_functions.h
|
||||||
|
path_manager.cpp
|
||||||
platform.h
|
platform.h
|
||||||
proc_launcher.h
|
proc_launcher.h
|
||||||
profanity_manager.h
|
profanity_manager.h
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
#include "../strings.h"
|
#include "../strings.h"
|
||||||
#include "../eqemu_config.h"
|
#include "../eqemu_config.h"
|
||||||
#include "../database_schema.h"
|
#include "../database_schema.h"
|
||||||
#include "../file_util.h"
|
#include "../file.h"
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
@ -383,8 +383,8 @@ void DatabaseDumpService::Dump()
|
|||||||
pipe_file
|
pipe_file
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!FileUtil::exists(GetSetDumpPath()) && !IsDumpOutputToConsole()) {
|
if (!File::Exists(GetSetDumpPath()) && !IsDumpOutputToConsole()) {
|
||||||
FileUtil::mkdir(GetSetDumpPath());
|
File::Makedir(GetSetDumpPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsDumpDropTableSyntaxOnly()) {
|
if (IsDumpDropTableSyntaxOnly()) {
|
||||||
|
|||||||
@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
|
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "extprofile.h"
|
#include "extprofile.h"
|
||||||
|
#include "path_manager.h"
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -476,7 +477,9 @@ bool Database::CheckDatabaseConversions() {
|
|||||||
CheckDatabaseConvertCorpseDeblob();
|
CheckDatabaseConvertCorpseDeblob();
|
||||||
|
|
||||||
/* Run EQEmu Server script (Checks for database updates) */
|
/* Run EQEmu Server script (Checks for database updates) */
|
||||||
system("perl eqemu_server.pl ran_from_world");
|
|
||||||
|
const std::string file = fmt::format("{}/eqemu_server.pl", path.GetServerPath());
|
||||||
|
system(fmt::format("perl {} ran_from_world", file).c_str());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,9 @@
|
|||||||
|
|
||||||
#include "json/json.h"
|
#include "json/json.h"
|
||||||
#include "linked_list.h"
|
#include "linked_list.h"
|
||||||
|
#include "path_manager.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
struct LoginConfig {
|
struct LoginConfig {
|
||||||
std::string LoginHost;
|
std::string LoginHost;
|
||||||
@ -152,23 +154,31 @@ class EQEmuConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load the config
|
// Load the config
|
||||||
static bool LoadConfig()
|
static bool LoadConfig(const std::string& path = "")
|
||||||
{
|
{
|
||||||
if (_config != nullptr) {
|
if (_config != nullptr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
_config = new EQEmuConfig;
|
_config = new EQEmuConfig;
|
||||||
|
|
||||||
return parseFile();
|
return parseFile(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load config file and parse data
|
// Load config file and parse data
|
||||||
static bool parseFile() {
|
static bool parseFile(const std::string& file_path = ".")
|
||||||
|
{
|
||||||
if (_config == nullptr) {
|
if (_config == nullptr) {
|
||||||
return LoadConfig();
|
return LoadConfig(file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ifstream fconfig(EQEmuConfig::ConfigFile, std::ifstream::binary);
|
std::string file = fmt::format(
|
||||||
|
"{}/{}",
|
||||||
|
(file_path.empty() ? path.GetServerPath() : file_path),
|
||||||
|
EQEmuConfig::ConfigFile
|
||||||
|
);
|
||||||
|
|
||||||
|
std::ifstream fconfig(file, std::ifstream::binary);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fconfig >> _config->_root;
|
fconfig >> _config->_root;
|
||||||
_config->parse_config();
|
_config->parse_config();
|
||||||
|
|||||||
@ -521,37 +521,29 @@ void EQEmuLogSys::StartFileLogs(const std::string &log_name)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogInfo("Starting File Log [logs/{}_{}.log]", m_platform_file_name.c_str(), getpid());
|
LogInfo("Starting File Log [{}/zone/{}_{}.log]", GetLogPath(), m_platform_file_name.c_str(), getpid());
|
||||||
|
|
||||||
/**
|
// Make directory if not exists
|
||||||
* Make directory if not exists
|
EQEmuLogSys::MakeDirectory(fmt::format("{}/zone", GetLogPath()));
|
||||||
*/
|
|
||||||
EQEmuLogSys::MakeDirectory("logs/zone");
|
|
||||||
|
|
||||||
/**
|
// Open file pointer
|
||||||
* Open file pointer
|
|
||||||
*/
|
|
||||||
process_log.open(
|
process_log.open(
|
||||||
StringFormat("logs/zone/%s_%i.log", m_platform_file_name.c_str(), getpid()),
|
fmt::format("{}/zone/{}_{}.log", GetLogPath(), m_platform_file_name, getpid()),
|
||||||
std::ios_base::app | std::ios_base::out
|
std::ios_base::app | std::ios_base::out
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
/**
|
// All other processes
|
||||||
* All other processes
|
|
||||||
*/
|
|
||||||
if (m_platform_file_name.empty()) {
|
if (m_platform_file_name.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogInfo("Starting File Log [logs/{}_{}.log]", m_platform_file_name.c_str(), getpid());
|
LogInfo("Starting File Log [{}/{}_{}.log]", GetLogPath(), m_platform_file_name.c_str(), getpid());
|
||||||
|
|
||||||
/**
|
// Open file pointer
|
||||||
* Open file pointer
|
|
||||||
*/
|
|
||||||
process_log.open(
|
process_log.open(
|
||||||
StringFormat("logs/%s_%i.log", m_platform_file_name.c_str(), getpid()),
|
fmt::format("{}/{}_{}.log", GetLogPath(), m_platform_file_name.c_str(), getpid()),
|
||||||
std::ios_base::app | std::ios_base::out
|
std::ios_base::app | std::ios_base::out
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -756,3 +748,16 @@ bool EQEmuLogSys::IsLogEnabled(const Logs::DebugLevel &debug_level, const uint16
|
|||||||
{
|
{
|
||||||
return GetLogsEnabled(debug_level, log_category).log_enabled;
|
return GetLogsEnabled(debug_level, log_category).log_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string &EQEmuLogSys::GetLogPath() const
|
||||||
|
{
|
||||||
|
return m_log_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
EQEmuLogSys * EQEmuLogSys::SetLogPath(const std::string &log_path)
|
||||||
|
{
|
||||||
|
EQEmuLogSys::m_log_path = log_path;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -366,6 +366,9 @@ public:
|
|||||||
// database
|
// database
|
||||||
EQEmuLogSys *SetDatabase(Database *db);
|
EQEmuLogSys *SetDatabase(Database *db);
|
||||||
|
|
||||||
|
[[nodiscard]] const std::string &GetLogPath() const;
|
||||||
|
EQEmuLogSys * SetLogPath(const std::string &log_path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// reference to database
|
// reference to database
|
||||||
@ -377,6 +380,7 @@ private:
|
|||||||
bool m_file_logs_enabled = false;
|
bool m_file_logs_enabled = false;
|
||||||
int m_log_platform = 0;
|
int m_log_platform = 0;
|
||||||
std::string m_platform_file_name;
|
std::string m_platform_file_name;
|
||||||
|
std::string m_log_path;
|
||||||
|
|
||||||
std::string GetLinuxConsoleColorFromCategory(uint16 log_category);
|
std::string GetLinuxConsoleColorFromCategory(uint16 log_category);
|
||||||
uint16 GetWindowsConsoleColorFromCategory(uint16 log_category);
|
uint16 GetWindowsConsoleColorFromCategory(uint16 log_category);
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "file_util.h"
|
#include "file.h"
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
@ -35,38 +35,48 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <fmt/format.h>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool FileUtil::exists(const std::string &name)
|
bool File::Exists(const std::string &name)
|
||||||
{
|
{
|
||||||
std::ifstream f(name.c_str());
|
return fs::exists(fs::path{name});
|
||||||
|
|
||||||
return f.good();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param directory_name
|
* @param directory_name
|
||||||
*/
|
*/
|
||||||
void FileUtil::mkdir(const std::string& directory_name)
|
void File::Makedir(const std::string &directory_name)
|
||||||
{
|
{
|
||||||
|
fs::create_directory(directory_name);
|
||||||
|
fs::permissions(directory_name, fs::perms::owner_all);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
std::string File::FindEqemuConfigPath()
|
||||||
struct _stat st;
|
{
|
||||||
if (_stat(directory_name.c_str(), &st) == 0) // exists
|
if (File::Exists(fs::path{File::GetCwd() + "/eqemu_config.json"}.string())) {
|
||||||
return;
|
return File::GetCwd();
|
||||||
_mkdir(directory_name.c_str());
|
|
||||||
#else
|
|
||||||
struct stat st{};
|
|
||||||
if (stat(directory_name.c_str(), &st) == 0) { // exists
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
::mkdir(directory_name.c_str(), 0755);
|
else if (File::Exists(fs::path{File::GetCwd() + "/../eqemu_config.json"}.string())) {
|
||||||
#endif
|
return canonical(fs::path{File::GetCwd() + "/../"}).string();
|
||||||
|
}
|
||||||
|
else if (File::Exists(fs::path{File::GetCwd() + "/login.json"}.string())) {
|
||||||
|
return File::GetCwd();
|
||||||
|
}
|
||||||
|
else if (File::Exists(fs::path{File::GetCwd() + "/../login.json"}.string())) {
|
||||||
|
return canonical(fs::path{File::GetCwd() + "/../"}).string();
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool file_exists(const std::string& name) {
|
std::string File::GetCwd()
|
||||||
std::ifstream f(name.c_str());
|
{
|
||||||
return f.good();
|
return fs::current_path().string();
|
||||||
}
|
}
|
||||||
@ -18,16 +18,21 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef EQEMU_FILE_UTIL_H
|
#ifndef EQEMU_FILE_H
|
||||||
#define EQEMU_FILE_UTIL_H
|
#define EQEMU_FILE_H
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
class FileUtil {
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
class File {
|
||||||
public:
|
public:
|
||||||
static bool exists(const std::string &name);
|
static bool Exists(const std::string &name);
|
||||||
static void mkdir(const std::string& directory_name);
|
static void Makedir(const std::string& directory_name);
|
||||||
|
static std::string FindEqemuConfigPath();
|
||||||
|
static std::string GetCwd();
|
||||||
};
|
};
|
||||||
|
|
||||||
bool file_exists(const std::string& name);
|
bool Exists(const std::string& name);
|
||||||
|
|
||||||
#endif //EQEMU_FILE_UTIL_H
|
#endif //EQEMU_FILE_H
|
||||||
@ -30,6 +30,7 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "eqemu_exception.h"
|
#include "eqemu_exception.h"
|
||||||
#include "eqemu_config.h"
|
#include "eqemu_config.h"
|
||||||
|
#include "path_manager.h"
|
||||||
|
|
||||||
namespace EQ {
|
namespace EQ {
|
||||||
struct IPCMutex::Implementation {
|
struct IPCMutex::Implementation {
|
||||||
@ -40,12 +41,11 @@ namespace EQ {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
IPCMutex::IPCMutex(std::string name) : locked_(false) {
|
IPCMutex::IPCMutex(const std::string& name) : locked_(false) {
|
||||||
imp_ = new Implementation;
|
imp_ = new Implementation;
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
auto Config = EQEmuConfig::get();
|
auto Config = EQEmuConfig::get();
|
||||||
std::string final_name = Config->SharedMemDir + "EQEmuMutex_";
|
std::string final_name = fmt::format("{}/EQEmuMutex_{}", Config->SharedMemDir, name);
|
||||||
final_name += name;
|
|
||||||
|
|
||||||
imp_->mut_ = CreateMutex(nullptr,
|
imp_->mut_ = CreateMutex(nullptr,
|
||||||
FALSE,
|
FALSE,
|
||||||
@ -55,9 +55,7 @@ namespace EQ {
|
|||||||
EQ_EXCEPT("IPC Mutex", "Could not create mutex.");
|
EQ_EXCEPT("IPC Mutex", "Could not create mutex.");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
auto Config = EQEmuConfig::get();
|
std::string final_name = fmt::format("{}/{}.lock", path.GetSharedMemoryPath(), name);
|
||||||
std::string final_name = Config->SharedMemDir + name;
|
|
||||||
final_name += ".lock";
|
|
||||||
|
|
||||||
#ifdef __DARWIN
|
#ifdef __DARWIN
|
||||||
#if __DARWIN_C_LEVEL < 200809L
|
#if __DARWIN_C_LEVEL < 200809L
|
||||||
|
|||||||
@ -37,7 +37,7 @@ namespace EQ {
|
|||||||
Creates a named binary semaphore, basically a semaphore that is init S <- 1
|
Creates a named binary semaphore, basically a semaphore that is init S <- 1
|
||||||
\param name The name of this mutex.
|
\param name The name of this mutex.
|
||||||
*/
|
*/
|
||||||
IPCMutex(std::string name);
|
IPCMutex(const std::string& name);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~IPCMutex();
|
~IPCMutex();
|
||||||
|
|||||||
@ -33,6 +33,9 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
namespace EQ {
|
namespace EQ {
|
||||||
|
|
||||||
struct MemoryMappedFile::Implementation {
|
struct MemoryMappedFile::Implementation {
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
#include "../inventory_profile.h"
|
#include "../inventory_profile.h"
|
||||||
#include "rof_structs.h"
|
#include "rof_structs.h"
|
||||||
#include "../rulesys.h"
|
#include "../rulesys.h"
|
||||||
|
#include "../path_manager.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -75,12 +76,8 @@ namespace RoF
|
|||||||
{
|
{
|
||||||
//create our opcode manager if we havent already
|
//create our opcode manager if we havent already
|
||||||
if (opcodes == nullptr) {
|
if (opcodes == nullptr) {
|
||||||
//TODO: get this file name from the config file
|
std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name);
|
||||||
auto Config = EQEmuConfig::get();
|
|
||||||
std::string opfile = Config->PatchDir;
|
|
||||||
opfile += "patch_";
|
|
||||||
opfile += name;
|
|
||||||
opfile += ".conf";
|
|
||||||
//load up the opcode manager.
|
//load up the opcode manager.
|
||||||
//TODO: figure out how to support shared memory with multiple patches...
|
//TODO: figure out how to support shared memory with multiple patches...
|
||||||
opcodes = new RegularOpcodeManager();
|
opcodes = new RegularOpcodeManager();
|
||||||
@ -118,12 +115,7 @@ namespace RoF
|
|||||||
//we need to go to every stream and replace it's manager.
|
//we need to go to every stream and replace it's manager.
|
||||||
|
|
||||||
if (opcodes != nullptr) {
|
if (opcodes != nullptr) {
|
||||||
//TODO: get this file name from the config file
|
std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name);
|
||||||
auto Config = EQEmuConfig::get();
|
|
||||||
std::string opfile = Config->PatchDir;
|
|
||||||
opfile += "patch_";
|
|
||||||
opfile += name;
|
|
||||||
opfile += ".conf";
|
|
||||||
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||||
LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name);
|
LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
#include "../inventory_profile.h"
|
#include "../inventory_profile.h"
|
||||||
#include "rof2_structs.h"
|
#include "rof2_structs.h"
|
||||||
#include "../rulesys.h"
|
#include "../rulesys.h"
|
||||||
|
#include "../path_manager.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -76,12 +77,9 @@ namespace RoF2
|
|||||||
{
|
{
|
||||||
//create our opcode manager if we havent already
|
//create our opcode manager if we havent already
|
||||||
if (opcodes == nullptr) {
|
if (opcodes == nullptr) {
|
||||||
//TODO: get this file name from the config file
|
|
||||||
auto Config = EQEmuConfig::get();
|
std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name);
|
||||||
std::string opfile = Config->PatchDir;
|
|
||||||
opfile += "patch_";
|
|
||||||
opfile += name;
|
|
||||||
opfile += ".conf";
|
|
||||||
//load up the opcode manager.
|
//load up the opcode manager.
|
||||||
//TODO: figure out how to support shared memory with multiple patches...
|
//TODO: figure out how to support shared memory with multiple patches...
|
||||||
opcodes = new RegularOpcodeManager();
|
opcodes = new RegularOpcodeManager();
|
||||||
@ -122,12 +120,7 @@ namespace RoF2
|
|||||||
//we need to go to every stream and replace it's manager.
|
//we need to go to every stream and replace it's manager.
|
||||||
|
|
||||||
if (opcodes != nullptr) {
|
if (opcodes != nullptr) {
|
||||||
//TODO: get this file name from the config file
|
std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name);
|
||||||
auto Config = EQEmuConfig::get();
|
|
||||||
std::string opfile = Config->PatchDir;
|
|
||||||
opfile += "patch_";
|
|
||||||
opfile += name;
|
|
||||||
opfile += ".conf";
|
|
||||||
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||||
LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name);
|
LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
#include "../item_instance.h"
|
#include "../item_instance.h"
|
||||||
#include "sod_structs.h"
|
#include "sod_structs.h"
|
||||||
#include "../rulesys.h"
|
#include "../rulesys.h"
|
||||||
|
#include "../path_manager.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -69,12 +70,7 @@ namespace SoD
|
|||||||
{
|
{
|
||||||
//create our opcode manager if we havent already
|
//create our opcode manager if we havent already
|
||||||
if (opcodes == nullptr) {
|
if (opcodes == nullptr) {
|
||||||
//TODO: get this file name from the config file
|
std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name);
|
||||||
auto Config = EQEmuConfig::get();
|
|
||||||
std::string opfile = Config->PatchDir;
|
|
||||||
opfile += "patch_";
|
|
||||||
opfile += name;
|
|
||||||
opfile += ".conf";
|
|
||||||
//load up the opcode manager.
|
//load up the opcode manager.
|
||||||
//TODO: figure out how to support shared memory with multiple patches...
|
//TODO: figure out how to support shared memory with multiple patches...
|
||||||
opcodes = new RegularOpcodeManager();
|
opcodes = new RegularOpcodeManager();
|
||||||
@ -115,12 +111,7 @@ namespace SoD
|
|||||||
//we need to go to every stream and replace it's manager.
|
//we need to go to every stream and replace it's manager.
|
||||||
|
|
||||||
if (opcodes != nullptr) {
|
if (opcodes != nullptr) {
|
||||||
//TODO: get this file name from the config file
|
std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name);
|
||||||
auto Config = EQEmuConfig::get();
|
|
||||||
std::string opfile = Config->PatchDir;
|
|
||||||
opfile += "patch_";
|
|
||||||
opfile += name;
|
|
||||||
opfile += ".conf";
|
|
||||||
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||||
LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name);
|
LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
#include "../item_instance.h"
|
#include "../item_instance.h"
|
||||||
#include "sof_structs.h"
|
#include "sof_structs.h"
|
||||||
#include "../rulesys.h"
|
#include "../rulesys.h"
|
||||||
|
#include "../path_manager.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -69,12 +70,7 @@ namespace SoF
|
|||||||
{
|
{
|
||||||
//create our opcode manager if we havent already
|
//create our opcode manager if we havent already
|
||||||
if (opcodes == nullptr) {
|
if (opcodes == nullptr) {
|
||||||
//TODO: get this file name from the config file
|
std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name);
|
||||||
auto Config = EQEmuConfig::get();
|
|
||||||
std::string opfile = Config->PatchDir;
|
|
||||||
opfile += "patch_";
|
|
||||||
opfile += name;
|
|
||||||
opfile += ".conf";
|
|
||||||
//load up the opcode manager.
|
//load up the opcode manager.
|
||||||
//TODO: figure out how to support shared memory with multiple patches...
|
//TODO: figure out how to support shared memory with multiple patches...
|
||||||
opcodes = new RegularOpcodeManager();
|
opcodes = new RegularOpcodeManager();
|
||||||
@ -113,12 +109,7 @@ namespace SoF
|
|||||||
//we need to go to every stream and replace it's manager.
|
//we need to go to every stream and replace it's manager.
|
||||||
|
|
||||||
if (opcodes != nullptr) {
|
if (opcodes != nullptr) {
|
||||||
//TODO: get this file name from the config file
|
std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name);
|
||||||
auto Config = EQEmuConfig::get();
|
|
||||||
std::string opfile = Config->PatchDir;
|
|
||||||
opfile += "patch_";
|
|
||||||
opfile += name;
|
|
||||||
opfile += ".conf";
|
|
||||||
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||||
LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name);
|
LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
#include "../strings.h"
|
#include "../strings.h"
|
||||||
#include "../item_instance.h"
|
#include "../item_instance.h"
|
||||||
#include "titanium_structs.h"
|
#include "titanium_structs.h"
|
||||||
|
#include "../path_manager.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@ -69,11 +70,7 @@ namespace Titanium
|
|||||||
auto Config = EQEmuConfig::get();
|
auto Config = EQEmuConfig::get();
|
||||||
//create our opcode manager if we havent already
|
//create our opcode manager if we havent already
|
||||||
if (opcodes == nullptr) {
|
if (opcodes == nullptr) {
|
||||||
//TODO: get this file name from the config file
|
std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name);
|
||||||
std::string opfile = Config->PatchDir;
|
|
||||||
opfile += "patch_";
|
|
||||||
opfile += name;
|
|
||||||
opfile += ".conf";
|
|
||||||
//load up the opcode manager.
|
//load up the opcode manager.
|
||||||
//TODO: figure out how to support shared memory with multiple patches...
|
//TODO: figure out how to support shared memory with multiple patches...
|
||||||
opcodes = new RegularOpcodeManager();
|
opcodes = new RegularOpcodeManager();
|
||||||
@ -114,12 +111,7 @@ namespace Titanium
|
|||||||
//we need to go to every stream and replace it's manager.
|
//we need to go to every stream and replace it's manager.
|
||||||
|
|
||||||
if (opcodes != nullptr) {
|
if (opcodes != nullptr) {
|
||||||
//TODO: get this file name from the config file
|
std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name);
|
||||||
auto Config = EQEmuConfig::get();
|
|
||||||
std::string opfile = Config->PatchDir;
|
|
||||||
opfile += "patch_";
|
|
||||||
opfile += name;
|
|
||||||
opfile += ".conf";
|
|
||||||
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||||
LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name);
|
LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
#include "../item_instance.h"
|
#include "../item_instance.h"
|
||||||
#include "uf_structs.h"
|
#include "uf_structs.h"
|
||||||
#include "../rulesys.h"
|
#include "../rulesys.h"
|
||||||
|
#include "../path_manager.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -69,12 +70,7 @@ namespace UF
|
|||||||
{
|
{
|
||||||
//create our opcode manager if we havent already
|
//create our opcode manager if we havent already
|
||||||
if (opcodes == nullptr) {
|
if (opcodes == nullptr) {
|
||||||
//TODO: get this file name from the config file
|
std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name);
|
||||||
auto Config = EQEmuConfig::get();
|
|
||||||
std::string opfile = Config->PatchDir;
|
|
||||||
opfile += "patch_";
|
|
||||||
opfile += name;
|
|
||||||
opfile += ".conf";
|
|
||||||
//load up the opcode manager.
|
//load up the opcode manager.
|
||||||
//TODO: figure out how to support shared memory with multiple patches...
|
//TODO: figure out how to support shared memory with multiple patches...
|
||||||
opcodes = new RegularOpcodeManager();
|
opcodes = new RegularOpcodeManager();
|
||||||
@ -115,12 +111,7 @@ namespace UF
|
|||||||
//we need to go to every stream and replace it's manager.
|
//we need to go to every stream and replace it's manager.
|
||||||
|
|
||||||
if (opcodes != nullptr) {
|
if (opcodes != nullptr) {
|
||||||
//TODO: get this file name from the config file
|
std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name);
|
||||||
auto Config = EQEmuConfig::get();
|
|
||||||
std::string opfile = Config->PatchDir;
|
|
||||||
opfile += "patch_";
|
|
||||||
opfile += name;
|
|
||||||
opfile += ".conf";
|
|
||||||
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||||
LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name);
|
LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name);
|
||||||
return;
|
return;
|
||||||
|
|||||||
133
common/path_manager.cpp
Normal file
133
common/path_manager.cpp
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
#include "path_manager.h"
|
||||||
|
#include "file.h"
|
||||||
|
#include "eqemu_logsys.h"
|
||||||
|
#include "eqemu_config.h"
|
||||||
|
#include "strings.h"
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
inline std::string striptrailingslash(const std::string &file_path)
|
||||||
|
{
|
||||||
|
if (file_path.back() == '/' || file_path.back() == '\\') {
|
||||||
|
return file_path.substr(0, file_path.length() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return file_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathManager::LoadPaths()
|
||||||
|
{
|
||||||
|
m_server_path = File::FindEqemuConfigPath();
|
||||||
|
|
||||||
|
std::filesystem::current_path(m_server_path);
|
||||||
|
|
||||||
|
LogInfo("[PathManager] server [{}]", m_server_path);
|
||||||
|
|
||||||
|
if (!EQEmuConfig::LoadConfig()) {
|
||||||
|
LogError("[PathManager] Failed to load eqemu config");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto c = EQEmuConfig::get();
|
||||||
|
|
||||||
|
// maps
|
||||||
|
if (File::Exists(fs::path{m_server_path + "/" + c->MapDir}.string())) {
|
||||||
|
m_maps_path = fs::relative(fs::path{m_server_path + "/" + c->MapDir}).string();
|
||||||
|
}
|
||||||
|
else if (File::Exists(fs::path{m_server_path + "/maps"}.string())) {
|
||||||
|
m_maps_path = fs::relative(fs::path{m_server_path + "/maps"}).string();
|
||||||
|
}
|
||||||
|
else if (File::Exists(fs::path{m_server_path + "/Maps"}.string())) {
|
||||||
|
m_maps_path = fs::relative(fs::path{m_server_path + "/Maps"}).string();
|
||||||
|
}
|
||||||
|
|
||||||
|
// quests
|
||||||
|
if (File::Exists(fs::path{m_server_path + "/" + c->QuestDir}.string())) {
|
||||||
|
m_quests_path = fs::relative(fs::path{m_server_path + "/" + c->QuestDir}).string();
|
||||||
|
}
|
||||||
|
|
||||||
|
// plugins
|
||||||
|
if (File::Exists(fs::path{m_server_path + "/" + c->PluginDir}.string())) {
|
||||||
|
m_plugins_path = fs::relative(fs::path{m_server_path + "/" + c->PluginDir}).string();
|
||||||
|
}
|
||||||
|
|
||||||
|
// lua_modules
|
||||||
|
if (File::Exists(fs::path{m_server_path + "/" + c->LuaModuleDir}.string())) {
|
||||||
|
m_lua_modules_path = fs::relative(fs::path{m_server_path + "/" + c->LuaModuleDir}).string();
|
||||||
|
}
|
||||||
|
|
||||||
|
// lua mods
|
||||||
|
if (File::Exists(fs::path{ m_server_path + "/mods" }.string())) {
|
||||||
|
m_lua_mods_path = fs::relative(fs::path{ m_server_path + "/mods" }).string();
|
||||||
|
}
|
||||||
|
|
||||||
|
// patches
|
||||||
|
if (File::Exists(fs::path{m_server_path + "/" + c->PatchDir}.string())) {
|
||||||
|
m_patch_path = fs::relative(fs::path{m_server_path + "/" + c->PatchDir}).string();
|
||||||
|
}
|
||||||
|
|
||||||
|
// shared_memory_path
|
||||||
|
if (File::Exists(fs::path{m_server_path + "/" + c->SharedMemDir}.string())) {
|
||||||
|
m_shared_memory_path = fs::relative(fs::path{ m_server_path + "/" + c->SharedMemDir }).string();
|
||||||
|
}
|
||||||
|
|
||||||
|
// logging path
|
||||||
|
if (File::Exists(fs::path{m_server_path + "/" + c->LogDir}.string())) {
|
||||||
|
m_log_path = fs::relative(fs::path{m_server_path + "/" + c->LogDir}).string();
|
||||||
|
}
|
||||||
|
|
||||||
|
LogInfo("[PathManager] logs [{}]", m_log_path);
|
||||||
|
LogInfo("[PathManager] lua mods [{}]", m_lua_mods_path);
|
||||||
|
LogInfo("[PathManager] lua_modules [{}]", m_lua_modules_path);
|
||||||
|
LogInfo("[PathManager] maps [{}]", m_maps_path);
|
||||||
|
LogInfo("[PathManager] patches [{}]", m_patch_path);
|
||||||
|
LogInfo("[PathManager] plugins [{}]", m_plugins_path);
|
||||||
|
LogInfo("[PathManager] quests [{}]", m_quests_path);
|
||||||
|
LogInfo("[PathManager] shared_memory [{}]", m_shared_memory_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &PathManager::GetServerPath() const
|
||||||
|
{
|
||||||
|
return m_server_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &PathManager::GetMapsPath() const
|
||||||
|
{
|
||||||
|
return m_maps_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &PathManager::GetQuestsPath() const
|
||||||
|
{
|
||||||
|
return m_quests_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &PathManager::GetPluginsPath() const
|
||||||
|
{
|
||||||
|
return m_plugins_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &PathManager::GetSharedMemoryPath() const
|
||||||
|
{
|
||||||
|
return m_shared_memory_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &PathManager::GetLogPath() const
|
||||||
|
{
|
||||||
|
return m_log_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &PathManager::GetPatchPath() const
|
||||||
|
{
|
||||||
|
return m_patch_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &PathManager::GetLuaModulesPath() const
|
||||||
|
{
|
||||||
|
return m_lua_modules_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &PathManager::GetLuaModsPath() const
|
||||||
|
{
|
||||||
|
return m_lua_mods_path;
|
||||||
|
}
|
||||||
35
common/path_manager.h
Normal file
35
common/path_manager.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#ifndef EQEMU_PATH_MANAGER_H
|
||||||
|
#define EQEMU_PATH_MANAGER_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class PathManager {
|
||||||
|
public:
|
||||||
|
void LoadPaths();
|
||||||
|
|
||||||
|
[[nodiscard]] const std::string &GetLogPath() const;
|
||||||
|
[[nodiscard]] const std::string &GetLuaModsPath() const;
|
||||||
|
[[nodiscard]] const std::string &GetLuaModulesPath() const;
|
||||||
|
[[nodiscard]] const std::string &GetMapsPath() const;
|
||||||
|
[[nodiscard]] const std::string &GetPatchPath() const;
|
||||||
|
[[nodiscard]] const std::string &GetPluginsPath() const;
|
||||||
|
[[nodiscard]] const std::string &GetQuestsPath() const;
|
||||||
|
[[nodiscard]] const std::string &GetServerPath() const;
|
||||||
|
[[nodiscard]] const std::string &GetSharedMemoryPath() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_log_path;
|
||||||
|
std::string m_lua_mods_path;
|
||||||
|
std::string m_lua_modules_path;
|
||||||
|
std::string m_maps_path;
|
||||||
|
std::string m_patch_path;
|
||||||
|
std::string m_plugins_path;
|
||||||
|
std::string m_quests_path;
|
||||||
|
std::string m_server_path;
|
||||||
|
std::string m_shared_memory_path;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern PathManager path;
|
||||||
|
|
||||||
|
#endif //EQEMU_PATH_MANAGER_H
|
||||||
@ -67,6 +67,8 @@ std::string GetPlatformName()
|
|||||||
return "Launch";
|
return "Launch";
|
||||||
case EQEmuExePlatform::ExePlatformHC:
|
case EQEmuExePlatform::ExePlatformHC:
|
||||||
return "HC";
|
return "HC";
|
||||||
|
case EQEmuExePlatform::ExePlatformTests:
|
||||||
|
return "Tests";
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,8 @@ enum EQEmuExePlatform
|
|||||||
ExePlatformSharedMemory,
|
ExePlatformSharedMemory,
|
||||||
ExePlatformClientImport,
|
ExePlatformClientImport,
|
||||||
ExePlatformClientExport,
|
ExePlatformClientExport,
|
||||||
ExePlatformHC
|
ExePlatformHC,
|
||||||
|
ExePlatformTests
|
||||||
};
|
};
|
||||||
|
|
||||||
void RegisterExecutablePlatform(EQEmuExePlatform p);
|
void RegisterExecutablePlatform(EQEmuExePlatform p);
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "rulesys.h"
|
#include "rulesys.h"
|
||||||
|
#include "eqemu_logsys.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|||||||
@ -41,6 +41,7 @@
|
|||||||
#include "repositories/criteria/content_filter_criteria.h"
|
#include "repositories/criteria/content_filter_criteria.h"
|
||||||
#include "repositories/account_repository.h"
|
#include "repositories/account_repository.h"
|
||||||
#include "repositories/faction_association_repository.h"
|
#include "repositories/faction_association_repository.h"
|
||||||
|
#include "path_manager.h"
|
||||||
|
|
||||||
namespace ItemField
|
namespace ItemField
|
||||||
{
|
{
|
||||||
@ -940,7 +941,7 @@ bool SharedDatabase::LoadItems(const std::string &prefix) {
|
|||||||
const auto Config = EQEmuConfig::get();
|
const auto Config = EQEmuConfig::get();
|
||||||
EQ::IPCMutex mutex("items");
|
EQ::IPCMutex mutex("items");
|
||||||
mutex.Lock();
|
mutex.Lock();
|
||||||
std::string file_name = Config->SharedMemDir + prefix + std::string("items");
|
std::string file_name = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("items"));
|
||||||
LogInfo("[Shared Memory] Attempting to load file [{}]", file_name);
|
LogInfo("[Shared Memory] Attempting to load file [{}]", file_name);
|
||||||
items_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
|
items_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
|
||||||
items_hash = std::make_unique<EQ::FixedMemoryHashSet<EQ::ItemData>>(static_cast<uint8*>(items_mmf->Get()), items_mmf->Size());
|
items_hash = std::make_unique<EQ::FixedMemoryHashSet<EQ::ItemData>>(static_cast<uint8*>(items_mmf->Get()), items_mmf->Size());
|
||||||
@ -1436,7 +1437,7 @@ bool SharedDatabase::LoadNPCFactionLists(const std::string &prefix) {
|
|||||||
const auto Config = EQEmuConfig::get();
|
const auto Config = EQEmuConfig::get();
|
||||||
EQ::IPCMutex mutex("faction");
|
EQ::IPCMutex mutex("faction");
|
||||||
mutex.Lock();
|
mutex.Lock();
|
||||||
std::string file_name = Config->SharedMemDir + prefix + std::string("faction");
|
std::string file_name = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("faction"));
|
||||||
LogInfo("[Shared Memory] Attempting to load file [{}]", file_name);
|
LogInfo("[Shared Memory] Attempting to load file [{}]", file_name);
|
||||||
faction_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
|
faction_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
|
||||||
faction_hash = std::make_unique<EQ::FixedMemoryHashSet<NPCFactionList>>(static_cast<uint8*>(faction_mmf->Get()), faction_mmf->Size());
|
faction_hash = std::make_unique<EQ::FixedMemoryHashSet<NPCFactionList>>(static_cast<uint8*>(faction_mmf->Get()), faction_mmf->Size());
|
||||||
@ -1509,7 +1510,7 @@ bool SharedDatabase::LoadFactionAssociation(const std::string &prefix)
|
|||||||
auto Config = EQEmuConfig::get();
|
auto Config = EQEmuConfig::get();
|
||||||
EQ::IPCMutex mutex("factionassociations");
|
EQ::IPCMutex mutex("factionassociations");
|
||||||
mutex.Lock();
|
mutex.Lock();
|
||||||
std::string file_name = Config->SharedMemDir + prefix + std::string("factionassociations");
|
std::string file_name = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("factionassociations"));
|
||||||
faction_associations_mmf = std::unique_ptr<EQ::MemoryMappedFile>(new EQ::MemoryMappedFile(file_name));
|
faction_associations_mmf = std::unique_ptr<EQ::MemoryMappedFile>(new EQ::MemoryMappedFile(file_name));
|
||||||
faction_associations_hash = std::unique_ptr<EQ::FixedMemoryHashSet<FactionAssociations>>(
|
faction_associations_hash = std::unique_ptr<EQ::FixedMemoryHashSet<FactionAssociations>>(
|
||||||
new EQ::FixedMemoryHashSet<FactionAssociations>(reinterpret_cast<uint8 *>(faction_associations_mmf->Get()),
|
new EQ::FixedMemoryHashSet<FactionAssociations>(reinterpret_cast<uint8 *>(faction_associations_mmf->Get()),
|
||||||
@ -1704,7 +1705,7 @@ bool SharedDatabase::LoadSkillCaps(const std::string &prefix) {
|
|||||||
const auto Config = EQEmuConfig::get();
|
const auto Config = EQEmuConfig::get();
|
||||||
EQ::IPCMutex mutex("skill_caps");
|
EQ::IPCMutex mutex("skill_caps");
|
||||||
mutex.Lock();
|
mutex.Lock();
|
||||||
std::string file_name = Config->SharedMemDir + prefix + std::string("skill_caps");
|
std::string file_name = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("skill_caps"));
|
||||||
LogInfo("[Shared Memory] Attempting to load file [{}]", file_name);
|
LogInfo("[Shared Memory] Attempting to load file [{}]", file_name);
|
||||||
skill_caps_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
|
skill_caps_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
|
||||||
mutex.Unlock();
|
mutex.Unlock();
|
||||||
@ -1863,7 +1864,7 @@ bool SharedDatabase::LoadSpells(const std::string &prefix, int32 *records, const
|
|||||||
EQ::IPCMutex mutex("spells");
|
EQ::IPCMutex mutex("spells");
|
||||||
mutex.Lock();
|
mutex.Lock();
|
||||||
|
|
||||||
std::string file_name = Config->SharedMemDir + prefix + std::string("spells");
|
std::string file_name = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("spells"));
|
||||||
spells_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
|
spells_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
|
||||||
LogInfo("[Shared Memory] Attempting to load file [{}]", file_name);
|
LogInfo("[Shared Memory] Attempting to load file [{}]", file_name);
|
||||||
*records = *static_cast<uint32*>(spells_mmf->Get());
|
*records = *static_cast<uint32*>(spells_mmf->Get());
|
||||||
@ -2077,7 +2078,7 @@ bool SharedDatabase::LoadBaseData(const std::string &prefix) {
|
|||||||
EQ::IPCMutex mutex("base_data");
|
EQ::IPCMutex mutex("base_data");
|
||||||
mutex.Lock();
|
mutex.Lock();
|
||||||
|
|
||||||
std::string file_name = Config->SharedMemDir + prefix + std::string("base_data");
|
std::string file_name = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("base_data"));
|
||||||
base_data_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
|
base_data_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
|
||||||
mutex.Unlock();
|
mutex.Unlock();
|
||||||
} catch(std::exception& ex) {
|
} catch(std::exception& ex) {
|
||||||
@ -2398,12 +2399,13 @@ bool SharedDatabase::LoadLoot(const std::string &prefix) {
|
|||||||
const auto Config = EQEmuConfig::get();
|
const auto Config = EQEmuConfig::get();
|
||||||
EQ::IPCMutex mutex("loot");
|
EQ::IPCMutex mutex("loot");
|
||||||
mutex.Lock();
|
mutex.Lock();
|
||||||
std::string file_name_lt = Config->SharedMemDir + prefix + std::string("loot_table");
|
std::string file_name_lt = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("loot_table"));
|
||||||
|
|
||||||
loot_table_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name_lt);
|
loot_table_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name_lt);
|
||||||
loot_table_hash = std::make_unique<EQ::FixedMemoryVariableHashSet<LootTable_Struct>>(
|
loot_table_hash = std::make_unique<EQ::FixedMemoryVariableHashSet<LootTable_Struct>>(
|
||||||
static_cast<uint8*>(loot_table_mmf->Get()),
|
static_cast<uint8*>(loot_table_mmf->Get()),
|
||||||
loot_table_mmf->Size());
|
loot_table_mmf->Size());
|
||||||
std::string file_name_ld = Config->SharedMemDir + prefix + std::string("loot_drop");
|
std::string file_name_ld = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("loot_drop"));
|
||||||
loot_drop_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name_ld);
|
loot_drop_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name_ld);
|
||||||
loot_drop_hash = std::make_unique<EQ::FixedMemoryVariableHashSet<LootDrop_Struct>>(
|
loot_drop_hash = std::make_unique<EQ::FixedMemoryVariableHashSet<LootDrop_Struct>>(
|
||||||
static_cast<uint8*>(loot_drop_mmf->Get()),
|
static_cast<uint8*>(loot_drop_mmf->Get()),
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
#include "../common/proc_launcher.h"
|
#include "../common/proc_launcher.h"
|
||||||
#include "../common/eqemu_config.h"
|
#include "../common/eqemu_config.h"
|
||||||
#include "../common/servertalk.h"
|
#include "../common/servertalk.h"
|
||||||
|
#include "../common/path_manager.h"
|
||||||
#include "../common/platform.h"
|
#include "../common/platform.h"
|
||||||
#include "../common/crash.h"
|
#include "../common/crash.h"
|
||||||
#include "../common/unix.h"
|
#include "../common/unix.h"
|
||||||
@ -33,6 +34,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
EQEmuLogSys LogSys;
|
EQEmuLogSys LogSys;
|
||||||
|
PathManager path;
|
||||||
|
|
||||||
bool RunLoops = false;
|
bool RunLoops = false;
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ extern bool run_server;
|
|||||||
|
|
||||||
#include "../common/eqemu_logsys.h"
|
#include "../common/eqemu_logsys.h"
|
||||||
#include "../common/misc.h"
|
#include "../common/misc.h"
|
||||||
|
#include "../common/path_manager.h"
|
||||||
|
|
||||||
ClientManager::ClientManager()
|
ClientManager::ClientManager()
|
||||||
{
|
{
|
||||||
@ -15,13 +16,18 @@ ClientManager::ClientManager()
|
|||||||
|
|
||||||
titanium_stream = new EQ::Net::EQStreamManager(titanium_opts);
|
titanium_stream = new EQ::Net::EQStreamManager(titanium_opts);
|
||||||
titanium_ops = new RegularOpcodeManager;
|
titanium_ops = new RegularOpcodeManager;
|
||||||
if (!titanium_ops->LoadOpcodes(
|
|
||||||
|
std::string opcodes_path = fmt::format(
|
||||||
|
"{}/{}",
|
||||||
|
path.GetServerPath(),
|
||||||
server.config.GetVariableString(
|
server.config.GetVariableString(
|
||||||
"client_configuration",
|
"client_configuration",
|
||||||
"titanium_opcodes",
|
"titanium_opcodes",
|
||||||
"login_opcodes.conf"
|
"login_opcodes.conf"
|
||||||
).c_str())) {
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!titanium_ops->LoadOpcodes(opcodes_path.c_str())) {
|
||||||
LogError(
|
LogError(
|
||||||
"ClientManager fatal error: couldn't load opcodes for Titanium file [{0}]",
|
"ClientManager fatal error: couldn't load opcodes for Titanium file [{0}]",
|
||||||
server.config.GetVariableString("client_configuration", "titanium_opcodes", "login_opcodes.conf")
|
server.config.GetVariableString("client_configuration", "titanium_opcodes", "login_opcodes.conf")
|
||||||
@ -49,14 +55,18 @@ ClientManager::ClientManager()
|
|||||||
EQStreamManagerInterfaceOptions sod_opts(sod_port, false, false);
|
EQStreamManagerInterfaceOptions sod_opts(sod_port, false, false);
|
||||||
sod_stream = new EQ::Net::EQStreamManager(sod_opts);
|
sod_stream = new EQ::Net::EQStreamManager(sod_opts);
|
||||||
sod_ops = new RegularOpcodeManager;
|
sod_ops = new RegularOpcodeManager;
|
||||||
if (
|
|
||||||
!sod_ops->LoadOpcodes(
|
opcodes_path = fmt::format(
|
||||||
|
"{}/{}",
|
||||||
|
path.GetServerPath(),
|
||||||
server.config.GetVariableString(
|
server.config.GetVariableString(
|
||||||
"client_configuration",
|
"client_configuration",
|
||||||
"sod_opcodes",
|
"sod_opcodes",
|
||||||
"login_opcodes.conf"
|
"login_opcodes.conf"
|
||||||
).c_str()
|
)
|
||||||
)) {
|
);
|
||||||
|
|
||||||
|
if (!sod_ops->LoadOpcodes(opcodes_path.c_str())) {
|
||||||
LogError(
|
LogError(
|
||||||
"ClientManager fatal error: couldn't load opcodes for SoD file {0}",
|
"ClientManager fatal error: couldn't load opcodes for SoD file {0}",
|
||||||
server.config.GetVariableString("client_configuration", "sod_opcodes", "login_opcodes.conf").c_str()
|
server.config.GetVariableString("client_configuration", "sod_opcodes", "login_opcodes.conf").c_str()
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
#include "loginserver_webserver.h"
|
#include "loginserver_webserver.h"
|
||||||
#include "loginserver_command_handler.h"
|
#include "loginserver_command_handler.h"
|
||||||
#include "../common/strings.h"
|
#include "../common/strings.h"
|
||||||
|
#include "../common/path_manager.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -20,6 +21,7 @@
|
|||||||
LoginServer server;
|
LoginServer server;
|
||||||
EQEmuLogSys LogSys;
|
EQEmuLogSys LogSys;
|
||||||
bool run_server = true;
|
bool run_server = true;
|
||||||
|
PathManager path;
|
||||||
|
|
||||||
void ResolveAddresses();
|
void ResolveAddresses();
|
||||||
void CatchSignal(int sig_num)
|
void CatchSignal(int sig_num)
|
||||||
@ -42,7 +44,9 @@ void LoadDatabaseConnection()
|
|||||||
|
|
||||||
void LoadServerConfig()
|
void LoadServerConfig()
|
||||||
{
|
{
|
||||||
server.config = EQ::JsonConfigFile::Load("login.json");
|
server.config = EQ::JsonConfigFile::Load(
|
||||||
|
fmt::format("{}/login.json", path.GetServerPath())
|
||||||
|
);
|
||||||
LogInfo("Config System Init");
|
LogInfo("Config System Init");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -172,6 +176,8 @@ int main(int argc, char **argv)
|
|||||||
LogSys.LoadLogSettingsDefaults();
|
LogSys.LoadLogSettingsDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path.LoadPaths();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command handler
|
* Command handler
|
||||||
*/
|
*/
|
||||||
@ -197,6 +203,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
LogSys.SetDatabase(server.db)
|
LogSys.SetDatabase(server.db)
|
||||||
|
->SetLogPath("logs")
|
||||||
->LoadLogDatabaseSettings()
|
->LoadLogDatabaseSettings()
|
||||||
->StartFileLogs();
|
->StartFileLogs();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,6 +31,7 @@
|
|||||||
#include "queryservconfig.h"
|
#include "queryservconfig.h"
|
||||||
#include "lfguild.h"
|
#include "lfguild.h"
|
||||||
#include "worldserver.h"
|
#include "worldserver.h"
|
||||||
|
#include "../common/path_manager.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@ -43,6 +44,7 @@ std::string WorldShortName;
|
|||||||
const queryservconfig *Config;
|
const queryservconfig *Config;
|
||||||
WorldServer *worldserver = 0;
|
WorldServer *worldserver = 0;
|
||||||
EQEmuLogSys LogSys;
|
EQEmuLogSys LogSys;
|
||||||
|
PathManager path;
|
||||||
|
|
||||||
void CatchSignal(int sig_num)
|
void CatchSignal(int sig_num)
|
||||||
{
|
{
|
||||||
@ -56,6 +58,8 @@ int main()
|
|||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
Timer LFGuildExpireTimer(60000);
|
Timer LFGuildExpireTimer(60000);
|
||||||
|
|
||||||
|
path.LoadPaths();
|
||||||
|
|
||||||
LogInfo("Starting EQEmu QueryServ");
|
LogInfo("Starting EQEmu QueryServ");
|
||||||
if (!queryservconfig::LoadConfig()) {
|
if (!queryservconfig::LoadConfig()) {
|
||||||
LogInfo("Loading server configuration failed");
|
LogInfo("Loading server configuration failed");
|
||||||
@ -80,6 +84,7 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
LogSys.SetDatabase(&database)
|
LogSys.SetDatabase(&database)
|
||||||
|
->SetLogPath(path.GetLogPath())
|
||||||
->LoadLogDatabaseSettings()
|
->LoadLogDatabaseSettings()
|
||||||
->StartFileLogs();
|
->StartFileLogs();
|
||||||
|
|
||||||
|
|||||||
@ -40,13 +40,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load the config
|
// Load the config
|
||||||
static bool LoadConfig() {
|
static bool LoadConfig(const std::string& path = "") {
|
||||||
if (_chat_config != nullptr)
|
if (_chat_config != nullptr)
|
||||||
delete _chat_config;
|
delete _chat_config;
|
||||||
_chat_config=new queryservconfig;
|
_chat_config=new queryservconfig;
|
||||||
_config=_chat_config;
|
_config=_chat_config;
|
||||||
|
|
||||||
return _config->parseFile();
|
return _config->parseFile(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -36,10 +36,12 @@
|
|||||||
#include "base_data.h"
|
#include "base_data.h"
|
||||||
#include "../common/content/world_content_service.h"
|
#include "../common/content/world_content_service.h"
|
||||||
#include "../common/zone_store.h"
|
#include "../common/zone_store.h"
|
||||||
|
#include "../common/path_manager.h"
|
||||||
|
|
||||||
EQEmuLogSys LogSys;
|
EQEmuLogSys LogSys;
|
||||||
WorldContentService content_service;
|
WorldContentService content_service;
|
||||||
ZoneStore zone_store;
|
ZoneStore zone_store;
|
||||||
|
PathManager path;
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
@ -83,6 +85,8 @@ int main(int argc, char **argv)
|
|||||||
LogSys.LoadLogSettingsDefaults();
|
LogSys.LoadLogSettingsDefaults();
|
||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
|
|
||||||
|
path.LoadPaths();
|
||||||
|
|
||||||
LogInfo("Shared Memory Loader Program");
|
LogInfo("Shared Memory Loader Program");
|
||||||
if (!EQEmuConfig::LoadConfig()) {
|
if (!EQEmuConfig::LoadConfig()) {
|
||||||
LogError("Unable to load configuration file");
|
LogError("Unable to load configuration file");
|
||||||
@ -124,6 +128,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LogSys.SetDatabase(&database)
|
LogSys.SetDatabase(&database)
|
||||||
|
->SetLogPath(path.GetLogPath())
|
||||||
->LoadLogDatabaseSettings()
|
->LoadLogDatabaseSettings()
|
||||||
->StartFileLogs();
|
->StartFileLogs();
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ SET(tests_headers
|
|||||||
|
|
||||||
ADD_EXECUTABLE(tests ${tests_sources} ${tests_headers})
|
ADD_EXECUTABLE(tests ${tests_sources} ${tests_headers})
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(tests common cppunit fmt)
|
TARGET_LINK_LIBRARIES(tests common cppunit fmt ${SERVER_LIBS})
|
||||||
|
|
||||||
INSTALL(TARGETS tests RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
INSTALL(TARGETS tests RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include "../common/platform.h"
|
||||||
|
#include "../common/path_manager.h"
|
||||||
#include "memory_mapped_file_test.h"
|
#include "memory_mapped_file_test.h"
|
||||||
#include "ipc_mutex_test.h"
|
#include "ipc_mutex_test.h"
|
||||||
#include "fixed_memory_test.h"
|
#include "fixed_memory_test.h"
|
||||||
@ -30,11 +32,17 @@
|
|||||||
#include "data_verification_test.h"
|
#include "data_verification_test.h"
|
||||||
#include "skills_util_test.h"
|
#include "skills_util_test.h"
|
||||||
#include "task_state_test.h"
|
#include "task_state_test.h"
|
||||||
#include "../common/eqemu_config.h"
|
|
||||||
|
|
||||||
const EQEmuConfig *Config;
|
const EQEmuConfig *Config;
|
||||||
|
EQEmuLogSys LogSys;
|
||||||
|
PathManager path;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
RegisterExecutablePlatform(ExePlatformClientImport);
|
||||||
|
LogSys.LoadLogSettingsDefaults();
|
||||||
|
path.LoadPaths();
|
||||||
|
|
||||||
int main() {
|
|
||||||
auto ConfigLoadResult = EQEmuConfig::LoadConfig();
|
auto ConfigLoadResult = EQEmuConfig::LoadConfig();
|
||||||
Config = EQEmuConfig::get();
|
Config = EQEmuConfig::get();
|
||||||
try {
|
try {
|
||||||
@ -52,7 +60,7 @@ int main() {
|
|||||||
tests.add(new SkillsUtilsTest());
|
tests.add(new SkillsUtilsTest());
|
||||||
tests.add(new TaskStateTest());
|
tests.add(new TaskStateTest());
|
||||||
tests.run(*output, true);
|
tests.run(*output, true);
|
||||||
} catch(...) {
|
} catch (...) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
#include "clientlist.h"
|
#include "clientlist.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "chatchannel.h"
|
#include "chatchannel.h"
|
||||||
|
#include "../common/path_manager.h"
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -478,8 +479,11 @@ Clientlist::Clientlist(int ChatPort) {
|
|||||||
|
|
||||||
const ucsconfig *Config = ucsconfig::get();
|
const ucsconfig *Config = ucsconfig::get();
|
||||||
|
|
||||||
LogInfo("Loading [{}]", Config->MailOpCodesFile.c_str());
|
|
||||||
if (!ChatOpMgr->LoadOpcodes(Config->MailOpCodesFile.c_str()))
|
std::string opcodes_file = fmt::format("{}/{}", path.GetServerPath(), Config->MailOpCodesFile);
|
||||||
|
|
||||||
|
LogInfo("Loading [{}]", opcodes_file);
|
||||||
|
if (!ChatOpMgr->LoadOpcodes(opcodes_file.c_str()))
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
chatsf->OnNewConnection([this](std::shared_ptr<EQ::Net::EQStream> stream) {
|
chatsf->OnNewConnection([this](std::shared_ptr<EQ::Net::EQStream> stream) {
|
||||||
|
|||||||
@ -38,6 +38,7 @@
|
|||||||
#include "../common/net/tcp_server.h"
|
#include "../common/net/tcp_server.h"
|
||||||
#include "../common/net/servertalk_client_connection.h"
|
#include "../common/net/servertalk_client_connection.h"
|
||||||
#include "../common/discord_manager.h"
|
#include "../common/discord_manager.h"
|
||||||
|
#include "../common/path_manager.h"
|
||||||
|
|
||||||
ChatChannelList *ChannelList;
|
ChatChannelList *ChannelList;
|
||||||
Clientlist *g_Clientlist;
|
Clientlist *g_Clientlist;
|
||||||
@ -45,6 +46,7 @@ EQEmuLogSys LogSys;
|
|||||||
Database database;
|
Database database;
|
||||||
WorldServer *worldserver = nullptr;
|
WorldServer *worldserver = nullptr;
|
||||||
DiscordManager discord_manager;
|
DiscordManager discord_manager;
|
||||||
|
PathManager path;
|
||||||
|
|
||||||
const ucsconfig *Config;
|
const ucsconfig *Config;
|
||||||
|
|
||||||
@ -101,6 +103,8 @@ int main() {
|
|||||||
LogSys.LoadLogSettingsDefaults();
|
LogSys.LoadLogSettingsDefaults();
|
||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
|
|
||||||
|
path.LoadPaths();
|
||||||
|
|
||||||
// Check every minute for unused channels we can delete
|
// Check every minute for unused channels we can delete
|
||||||
//
|
//
|
||||||
Timer ChannelListProcessTimer(60000);
|
Timer ChannelListProcessTimer(60000);
|
||||||
@ -132,6 +136,7 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LogSys.SetDatabase(&database)
|
LogSys.SetDatabase(&database)
|
||||||
|
->SetLogPath(path.GetLogPath())
|
||||||
->LoadLogDatabaseSettings()
|
->LoadLogDatabaseSettings()
|
||||||
->StartFileLogs();
|
->StartFileLogs();
|
||||||
|
|
||||||
|
|||||||
@ -40,13 +40,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load the config
|
// Load the config
|
||||||
static bool LoadConfig() {
|
static bool LoadConfig(const std::string& path = "") {
|
||||||
if (_chat_config != nullptr)
|
if (_chat_config != nullptr)
|
||||||
delete _chat_config;
|
delete _chat_config;
|
||||||
_chat_config=new ucsconfig;
|
_chat_config=new ucsconfig;
|
||||||
_config=_chat_config;
|
_config=_chat_config;
|
||||||
|
|
||||||
return _config->parseFile();
|
return _config->parseFile(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -50,6 +50,11 @@ if ($Config{osname} =~ /Win|MS/i) {
|
|||||||
$OS = "Windows";
|
$OS = "Windows";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (-e "../eqemu_config.json") {
|
||||||
|
print "[Info] Config is up one level, let's set current directory up one level...\n";
|
||||||
|
chdir("../");
|
||||||
|
}
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# internet check
|
# internet check
|
||||||
#############################################
|
#############################################
|
||||||
@ -83,6 +88,8 @@ if (-d "bin") {
|
|||||||
$bin_dir = "bin/";
|
$bin_dir = "bin/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $world_path = get_world_path();
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
# run routines
|
# run routines
|
||||||
#############################################
|
#############################################
|
||||||
@ -540,14 +547,6 @@ sub do_installer_routines
|
|||||||
print `"$path" --host $host --user $root_user --password="$root_password" -N -B -e "FLUSH PRIVILEGES"`;
|
print `"$path" --host $host --user $root_user --password="$root_password" -N -B -e "FLUSH PRIVILEGES"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $world_path = "world";
|
|
||||||
if (-e "bin/world") {
|
|
||||||
$world_path = "bin/world";
|
|
||||||
}
|
|
||||||
elsif (-e "bin/world.exe") {
|
|
||||||
$world_path = "bin/world.exe";
|
|
||||||
}
|
|
||||||
|
|
||||||
#::: Get Binary DB version
|
#::: Get Binary DB version
|
||||||
if ($OS eq "Windows") {
|
if ($OS eq "Windows") {
|
||||||
@db_version = split(': ', `"$world_path" db_version`);
|
@db_version = split(': ', `"$world_path" db_version`);
|
||||||
@ -592,15 +591,6 @@ sub check_for_input
|
|||||||
|
|
||||||
sub check_for_world_bootup_database_update
|
sub check_for_world_bootup_database_update
|
||||||
{
|
{
|
||||||
|
|
||||||
my $world_path = "world";
|
|
||||||
if (-e "bin/world") {
|
|
||||||
$world_path = "bin/world";
|
|
||||||
}
|
|
||||||
elsif (-e "bin/world.exe") {
|
|
||||||
$world_path = "bin/world.exe";
|
|
||||||
}
|
|
||||||
|
|
||||||
$binary_database_version = 0;
|
$binary_database_version = 0;
|
||||||
$local_database_version = 0;
|
$local_database_version = 0;
|
||||||
|
|
||||||
|
|||||||
@ -490,7 +490,7 @@ bool LoginServer::Connect()
|
|||||||
[this](EQ::Net::ServertalkClient *client) {
|
[this](EQ::Net::ServertalkClient *client) {
|
||||||
if (client) {
|
if (client) {
|
||||||
LogInfo(
|
LogInfo(
|
||||||
"Connected to Loginserver: [{0}:{1}]",
|
"Connected to Loginserver [{0}:{1}]",
|
||||||
m_loginserver_address,
|
m_loginserver_address,
|
||||||
m_loginserver_port
|
m_loginserver_port
|
||||||
);
|
);
|
||||||
@ -499,7 +499,6 @@ bool LoginServer::Connect()
|
|||||||
zoneserver_list.SendLSZones();
|
zoneserver_list.SendLSZones();
|
||||||
|
|
||||||
m_statusupdate_timer = std::make_unique<EQ::Timer>(
|
m_statusupdate_timer = std::make_unique<EQ::Timer>(
|
||||||
|
|
||||||
LoginServer_StatusUpdateInterval, true, [this](EQ::Timer *t) {
|
LoginServer_StatusUpdateInterval, true, [this](EQ::Timer *t) {
|
||||||
SendStatus();
|
SendStatus();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,6 +95,8 @@ union semun {
|
|||||||
#include "world_event_scheduler.h"
|
#include "world_event_scheduler.h"
|
||||||
#include "shared_task_manager.h"
|
#include "shared_task_manager.h"
|
||||||
#include "world_boot.h"
|
#include "world_boot.h"
|
||||||
|
#include "../common/path_manager.h"
|
||||||
|
|
||||||
|
|
||||||
ZoneStore zone_store;
|
ZoneStore zone_store;
|
||||||
ClientList client_list;
|
ClientList client_list;
|
||||||
@ -115,6 +117,7 @@ const WorldConfig *Config;
|
|||||||
EQEmuLogSys LogSys;
|
EQEmuLogSys LogSys;
|
||||||
WorldContentService content_service;
|
WorldContentService content_service;
|
||||||
WebInterfaceList web_interface;
|
WebInterfaceList web_interface;
|
||||||
|
PathManager path;
|
||||||
|
|
||||||
void CatchSignal(int sig_num);
|
void CatchSignal(int sig_num);
|
||||||
|
|
||||||
@ -138,6 +141,8 @@ int main(int argc, char **argv)
|
|||||||
LogSys.LoadLogSettingsDefaults();
|
LogSys.LoadLogSettingsDefaults();
|
||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
|
|
||||||
|
path.LoadPaths();
|
||||||
|
|
||||||
if (WorldBoot::HandleCommandInput(argc, argv)) {
|
if (WorldBoot::HandleCommandInput(argc, argv)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
#include "zoneserver.h"
|
#include "zoneserver.h"
|
||||||
#include "../common/ip_util.h"
|
#include "../common/ip_util.h"
|
||||||
#include "../common/zone_store.h"
|
#include "../common/zone_store.h"
|
||||||
|
#include "../common/path_manager.h"
|
||||||
|
|
||||||
extern ZSList zoneserver_list;
|
extern ZSList zoneserver_list;
|
||||||
extern WorldConfig Config;
|
extern WorldConfig Config;
|
||||||
@ -169,14 +170,14 @@ int get_file_size(const std::string &filename) // path to file
|
|||||||
|
|
||||||
void WorldBoot::CheckForServerScript(bool force_download)
|
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);
|
std::ifstream f(file);
|
||||||
|
|
||||||
/* Fetch EQEmu Server script */
|
/* Fetch EQEmu Server script */
|
||||||
if (!f || get_file_size(file) < 100 || force_download) {
|
if (!f || get_file_size(file) < 100 || force_download) {
|
||||||
|
|
||||||
if (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 */
|
} /* Delete local before fetch */
|
||||||
|
|
||||||
std::cout << "Pulling down EQEmu Server Maintenance Script (eqemu_server.pl)..." << std::endl;
|
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 (auto res = r.Get(u.get_path().c_str())) {
|
||||||
if (res->status == 200) {
|
if (res->status == 200) {
|
||||||
// write file
|
// 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 << res->body;
|
||||||
out.close();
|
out.close();
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#else
|
#else
|
||||||
system("chmod 755 eqemu_server.pl");
|
system(fmt::format("chmod 755 {}", script).c_str());
|
||||||
system("chmod +x eqemu_server.pl");
|
system(fmt::format("chmod +x {}", script).c_str());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,7 +219,8 @@ void WorldBoot::CheckForXMLConfigUpgrade()
|
|||||||
{
|
{
|
||||||
if (!std::ifstream("eqemu_config.json") && std::ifstream("eqemu_config.xml")) {
|
if (!std::ifstream("eqemu_config.json") && std::ifstream("eqemu_config.xml")) {
|
||||||
CheckForServerScript(true);
|
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 {
|
else {
|
||||||
CheckForServerScript();
|
CheckForServerScript();
|
||||||
@ -291,6 +295,7 @@ bool WorldBoot::DatabaseLoadRoutines(int argc, char **argv)
|
|||||||
|
|
||||||
// logging system init
|
// logging system init
|
||||||
auto logging = LogSys.SetDatabase(&database)
|
auto logging = LogSys.SetDatabase(&database)
|
||||||
|
->SetLogPath(path.GetLogPath())
|
||||||
->LoadLogDatabaseSettings();
|
->LoadLogDatabaseSettings();
|
||||||
|
|
||||||
if (RuleB(Logging, WorldGMSayLogging)) {
|
if (RuleB(Logging, WorldGMSayLogging)) {
|
||||||
|
|||||||
@ -46,13 +46,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load the config
|
// Load the config
|
||||||
static bool LoadConfig() {
|
static bool LoadConfig(const std::string& path = "") {
|
||||||
if (_world_config != nullptr)
|
if (_world_config != nullptr)
|
||||||
delete _world_config;
|
delete _world_config;
|
||||||
_world_config=new WorldConfig;
|
_world_config=new WorldConfig;
|
||||||
_config=_world_config;
|
_config=_world_config;
|
||||||
|
|
||||||
return _config->parseFile();
|
return _config->parseFile(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accessors for the static private object
|
// Accessors for the static private object
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#include "../common/strings.h"
|
#include "../common/strings.h"
|
||||||
#include "../common/say_link.h"
|
#include "../common/say_link.h"
|
||||||
#include "../common/net/eqstream.h"
|
#include "../common/net/eqstream.h"
|
||||||
#include "../common/file_util.h"
|
#include "../common/file.h"
|
||||||
#include "../common/repositories/dynamic_zones_repository.h"
|
#include "../common/repositories/dynamic_zones_repository.h"
|
||||||
|
|
||||||
#include "data_bucket.h"
|
#include "data_bucket.h"
|
||||||
@ -811,7 +811,7 @@ void command_hotfix(Client *c, const Seperator *sep)
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
shared_memory_path = "shared_memory";
|
shared_memory_path = "shared_memory";
|
||||||
if (file_exists("bin/shared_memory.exe")) {
|
if (File::Exists("bin/shared_memory.exe")) {
|
||||||
shared_memory_path = "bin\\shared_memory.exe";
|
shared_memory_path = "bin\\shared_memory.exe";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,7 +827,7 @@ void command_hotfix(Client *c, const Seperator *sep)
|
|||||||
if (system(hotfix_command.c_str())) {}
|
if (system(hotfix_command.c_str())) {}
|
||||||
#else
|
#else
|
||||||
shared_memory_path = "./shared_memory";
|
shared_memory_path = "./shared_memory";
|
||||||
if (file_exists("./bin/shared_memory")) {
|
if (File::Exists("./bin/shared_memory")) {
|
||||||
shared_memory_path = "./bin/shared_memory";
|
shared_memory_path = "./bin/shared_memory";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,8 @@ Eglin
|
|||||||
#include "embperl.h"
|
#include "embperl.h"
|
||||||
#include "embxs.h"
|
#include "embxs.h"
|
||||||
#include "../common/features.h"
|
#include "../common/features.h"
|
||||||
|
#include "../common/path_manager.h"
|
||||||
|
|
||||||
#ifndef GvCV_set
|
#ifndef GvCV_set
|
||||||
#define GvCV_set(gv,cv) (GvCV(gv) = (cv))
|
#define GvCV_set(gv,cv) (GvCV(gv) = (cv))
|
||||||
#endif
|
#endif
|
||||||
@ -146,11 +148,11 @@ void Embperl::DoInit() {
|
|||||||
//should probably read the directory in c, instead, so that
|
//should probably read the directory in c, instead, so that
|
||||||
//I can echo filenames as I do it, but c'mon... I'm lazy and this 1 line reads in all the plugins
|
//I can echo filenames as I do it, but c'mon... I'm lazy and this 1 line reads in all the plugins
|
||||||
std::string perl_command =
|
std::string perl_command =
|
||||||
"if(opendir(D,'" + Config->PluginDir +"')) { "
|
"if(opendir(D,'" + path.GetPluginsPath() +"')) { "
|
||||||
" my @d = readdir(D);"
|
" my @d = readdir(D);"
|
||||||
" closedir(D);"
|
" closedir(D);"
|
||||||
" foreach(@d){ "
|
" foreach(@d){ "
|
||||||
" main::eval_file('plugin','" + Config->PluginDir + "/'.$_)if/\\.pl$/;"
|
" main::eval_file('plugin','" + path.GetPluginsPath() + "/'.$_)if/\\.pl$/;"
|
||||||
" }"
|
" }"
|
||||||
"}";
|
"}";
|
||||||
eval_pv(perl_command.c_str(),FALSE);
|
eval_pv(perl_command.c_str(),FALSE);
|
||||||
|
|||||||
@ -39,6 +39,7 @@
|
|||||||
#include "lua_general.h"
|
#include "lua_general.h"
|
||||||
#include "lua_encounter.h"
|
#include "lua_encounter.h"
|
||||||
#include "lua_stat_bonuses.h"
|
#include "lua_stat_bonuses.h"
|
||||||
|
#include "../common/path_manager.h"
|
||||||
|
|
||||||
#ifdef BOTS
|
#ifdef BOTS
|
||||||
#include "lua_bot.h"
|
#include "lua_bot.h"
|
||||||
@ -927,11 +928,11 @@ void LuaParser::ReloadQuests() {
|
|||||||
lua_getglobal(L, "package");
|
lua_getglobal(L, "package");
|
||||||
lua_getfield(L, -1, "path");
|
lua_getfield(L, -1, "path");
|
||||||
std::string module_path = lua_tostring(L,-1);
|
std::string module_path = lua_tostring(L,-1);
|
||||||
module_path += ";./" + Config->LuaModuleDir + "?.lua;./" + Config->LuaModuleDir + "?/init.lua";
|
module_path += ";" + path.GetLuaModulesPath() + "/?.lua;" + path.GetLuaModulesPath() + "/?/init.lua";
|
||||||
// luarock paths using lua_modules as tree
|
// luarock paths using lua_modules as tree
|
||||||
// to path it adds foo/share/lua/5.1/?.lua and foo/share/lua/5.1/?/init.lua
|
// to path it adds foo/share/lua/5.1/?.lua and foo/share/lua/5.1/?/init.lua
|
||||||
module_path += ";./" + Config->LuaModuleDir + "share/lua/" + lua_version + "/?.lua";
|
module_path += ";" + path.GetLuaModulesPath() + "/share/lua/" + lua_version + "/?.lua";
|
||||||
module_path += ";./" + Config->LuaModuleDir + "share/lua/" + lua_version + "/?/init.lua";
|
module_path += ";" + path.GetLuaModulesPath() + "/share/lua/" + lua_version + "/?/init.lua";
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
lua_pushstring(L, module_path.c_str());
|
lua_pushstring(L, module_path.c_str());
|
||||||
lua_setfield(L, -2, "path");
|
lua_setfield(L, -2, "path");
|
||||||
@ -940,10 +941,10 @@ void LuaParser::ReloadQuests() {
|
|||||||
lua_getglobal(L, "package");
|
lua_getglobal(L, "package");
|
||||||
lua_getfield(L, -1, "cpath");
|
lua_getfield(L, -1, "cpath");
|
||||||
module_path = lua_tostring(L, -1);
|
module_path = lua_tostring(L, -1);
|
||||||
module_path += ";./" + Config->LuaModuleDir + "?" + libext;
|
module_path += ";" + path.GetLuaModulesPath() + "/?" + libext;
|
||||||
// luarock paths using lua_modules as tree
|
// luarock paths using lua_modules as tree
|
||||||
// luarocks adds foo/lib/lua/5.1/?.so for cpath
|
// luarocks adds foo/lib/lua/5.1/?.so for cpath
|
||||||
module_path += ";./" + Config->LuaModuleDir + "lib/lua/" + lua_version + "/?" + libext;
|
module_path += ";" + path.GetLuaModulesPath() + "/lib/lua/" + lua_version + "/?" + libext;
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
lua_pushstring(L, module_path.c_str());
|
lua_pushstring(L, module_path.c_str());
|
||||||
lua_setfield(L, -2, "cpath");
|
lua_setfield(L, -2, "cpath");
|
||||||
@ -951,17 +952,14 @@ void LuaParser::ReloadQuests() {
|
|||||||
|
|
||||||
MapFunctions(L);
|
MapFunctions(L);
|
||||||
|
|
||||||
//load init
|
// load init
|
||||||
std::string path = Config->QuestDir;
|
std::string filename = fmt::format("{}/{}/script_init.lua", path.GetQuestsPath(), QUEST_GLOBAL_DIRECTORY);
|
||||||
path += "/";
|
|
||||||
path += QUEST_GLOBAL_DIRECTORY;
|
|
||||||
path += "/script_init.lua";
|
|
||||||
|
|
||||||
FILE *f = fopen(path.c_str(), "r");
|
FILE *f = fopen(filename.c_str(), "r");
|
||||||
if(f) {
|
if(f) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
if(luaL_dofile(L, path.c_str())) {
|
if(luaL_dofile(L, filename.c_str())) {
|
||||||
std::string error = lua_tostring(L, -1);
|
std::string error = lua_tostring(L, -1);
|
||||||
AddError(error);
|
AddError(error);
|
||||||
}
|
}
|
||||||
@ -969,12 +967,13 @@ void LuaParser::ReloadQuests() {
|
|||||||
|
|
||||||
//zone init - always loads after global
|
//zone init - always loads after global
|
||||||
if(zone) {
|
if(zone) {
|
||||||
std::string zone_script = Config->QuestDir;
|
std::string zone_script = fmt::format(
|
||||||
zone_script += "/";
|
"{}/{}/script_init_v{}.lua",
|
||||||
zone_script += zone->GetShortName();
|
path.GetQuestsPath(),
|
||||||
zone_script += "/script_init_v";
|
zone->GetShortName(),
|
||||||
zone_script += std::to_string(zone->GetInstanceVersion());
|
zone->GetInstanceVersion()
|
||||||
zone_script += ".lua";
|
);
|
||||||
|
|
||||||
f = fopen(zone_script.c_str(), "r");
|
f = fopen(zone_script.c_str(), "r");
|
||||||
if(f) {
|
if(f) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
@ -985,10 +984,8 @@ void LuaParser::ReloadQuests() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
zone_script = Config->QuestDir;
|
zone_script = fmt::format("{}/{}/script_init.lua", path.GetQuestsPath(), zone->GetShortName());
|
||||||
zone_script += "/";
|
|
||||||
zone_script += zone->GetShortName();
|
|
||||||
zone_script += "/script_init.lua";
|
|
||||||
f = fopen(zone_script.c_str(), "r");
|
f = fopen(zone_script.c_str(), "r");
|
||||||
if (f) {
|
if (f) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
@ -1001,20 +998,20 @@ void LuaParser::ReloadQuests() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *load_order = fopen("mods/load_order.txt", "r");
|
FILE *load_order = fopen(fmt::format("{}/load_order.txt", path.GetLuaModsPath()).c_str(), "r");
|
||||||
if (load_order) {
|
if (load_order) {
|
||||||
char file_name[256] = { 0 };
|
char file_name[256] = { 0 };
|
||||||
while (fgets(file_name, 256, load_order) != nullptr) {
|
while (fgets(file_name, 256, load_order) != nullptr) {
|
||||||
for (int i = 0; i < 256; ++i) {
|
for (char & i : file_name) {
|
||||||
auto c = file_name[i];
|
auto c = i;
|
||||||
if (c == '\n' || c == '\r' || c == ' ') {
|
if (c == '\n' || c == '\r' || c == ' ') {
|
||||||
file_name[i] = 0;
|
i = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadScript("mods/" + std::string(file_name), file_name);
|
LoadScript(fmt::format("{}{}", path.GetLuaModsPath(), std::string(file_name)), file_name);
|
||||||
mods_.push_back(LuaMod(L, this, file_name));
|
mods_.emplace_back(L, this, file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(load_order);
|
fclose(load_order);
|
||||||
@ -1107,8 +1104,8 @@ bool LuaParser::HasEncounterSub(const std::string& package_name, QuestEventID ev
|
|||||||
{
|
{
|
||||||
auto it = lua_encounter_events_registered.find(package_name);
|
auto it = lua_encounter_events_registered.find(package_name);
|
||||||
if (it != lua_encounter_events_registered.end()) {
|
if (it != lua_encounter_events_registered.end()) {
|
||||||
for (auto riter = it->second.begin(); riter != it->second.end(); ++riter) {
|
for (auto & riter : it->second) {
|
||||||
if (riter->event_id == evt) {
|
if (riter.event_id == evt) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,7 +78,6 @@
|
|||||||
#else
|
#else
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "../common/unix.h"
|
#include "../common/unix.h"
|
||||||
#include "zone_event_scheduler.h"
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -89,12 +88,17 @@ volatile bool RunLoops = true;
|
|||||||
|
|
||||||
extern volatile bool is_zone_loaded;
|
extern volatile bool is_zone_loaded;
|
||||||
|
|
||||||
|
#include "zone_event_scheduler.h"
|
||||||
|
#include "../common/file.h"
|
||||||
|
#include "../common/path_manager.h"
|
||||||
|
|
||||||
EntityList entity_list;
|
EntityList entity_list;
|
||||||
WorldServer worldserver;
|
WorldServer worldserver;
|
||||||
ZoneStore zone_store;
|
ZoneStore zone_store;
|
||||||
uint32 numclients = 0;
|
uint32 numclients = 0;
|
||||||
char errorname[32];
|
char errorname[32];
|
||||||
extern Zone* zone;
|
extern Zone *zone;
|
||||||
|
|
||||||
npcDecayTimes_Struct npcCorpseDecayTimes[100];
|
npcDecayTimes_Struct npcCorpseDecayTimes[100];
|
||||||
TitleManager title_manager;
|
TitleManager title_manager;
|
||||||
QueryServ *QServ = 0;
|
QueryServ *QServ = 0;
|
||||||
@ -104,6 +108,8 @@ QuestParserCollection *parse = 0;
|
|||||||
EQEmuLogSys LogSys;
|
EQEmuLogSys LogSys;
|
||||||
ZoneEventScheduler event_scheduler;
|
ZoneEventScheduler event_scheduler;
|
||||||
WorldContentService content_service;
|
WorldContentService content_service;
|
||||||
|
PathManager path;
|
||||||
|
|
||||||
const SPDat_Spell_Struct* spells;
|
const SPDat_Spell_Struct* spells;
|
||||||
int32 SPDAT_RECORDS = -1;
|
int32 SPDAT_RECORDS = -1;
|
||||||
const ZoneConfig *Config;
|
const ZoneConfig *Config;
|
||||||
@ -121,6 +127,8 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
|
|
||||||
|
path.LoadPaths();
|
||||||
|
|
||||||
#ifdef USE_MAP_MMFS
|
#ifdef USE_MAP_MMFS
|
||||||
if (argc == 3 && strcasecmp(argv[1], "convert_map") == 0) {
|
if (argc == 3 && strcasecmp(argv[1], "convert_map") == 0) {
|
||||||
if (!ZoneConfig::LoadConfig())
|
if (!ZoneConfig::LoadConfig())
|
||||||
@ -255,6 +263,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
/* Register Log System and Settings */
|
/* Register Log System and Settings */
|
||||||
LogSys.SetDatabase(&database)
|
LogSys.SetDatabase(&database)
|
||||||
|
->SetLogPath(path.GetLogPath())
|
||||||
->LoadLogDatabaseSettings()
|
->LoadLogDatabaseSettings()
|
||||||
->SetGMSayHandler(&Zone::GMSayHookCallBackProcess)
|
->SetGMSayHandler(&Zone::GMSayHookCallBackProcess)
|
||||||
->StartFileLogs();
|
->StartFileLogs();
|
||||||
|
|||||||
23
zone/map.cpp
23
zone/map.cpp
@ -5,6 +5,8 @@
|
|||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "raycast_mesh.h"
|
#include "raycast_mesh.h"
|
||||||
#include "zone.h"
|
#include "zone.h"
|
||||||
|
#include "../common/file.h"
|
||||||
|
#include "../common/path_manager.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -200,28 +202,9 @@ bool Map::DoCollisionCheck(glm::vec3 myloc, glm::vec3 oloc, glm::vec3 &outnorm,
|
|||||||
return imp->rm->raycast((const RmReal*)&myloc, (const RmReal*)&oloc, nullptr, (RmReal *)&outnorm, (RmReal *)&distance);
|
return imp->rm->raycast((const RmReal*)&myloc, (const RmReal*)&oloc, nullptr, (RmReal *)&outnorm, (RmReal *)&distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool file_exists(const std::string& name) {
|
|
||||||
std::ifstream f(name.c_str());
|
|
||||||
return f.good();
|
|
||||||
}
|
|
||||||
|
|
||||||
Map *Map::LoadMapFile(std::string file) {
|
Map *Map::LoadMapFile(std::string file) {
|
||||||
|
|
||||||
std::string filename = "";
|
|
||||||
if (file_exists("maps")) {
|
|
||||||
filename = "maps";
|
|
||||||
}
|
|
||||||
else if (file_exists("Maps")) {
|
|
||||||
filename = "Maps";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
filename = Config->MapDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::transform(file.begin(), file.end(), file.begin(), ::tolower);
|
std::transform(file.begin(), file.end(), file.begin(), ::tolower);
|
||||||
filename += "/base/";
|
std::string filename = fmt::format("{}/base/{}.map", path.GetMapsPath(), file);
|
||||||
filename += file;
|
|
||||||
filename += ".map";
|
|
||||||
|
|
||||||
LogInfo("Attempting to load Map File [{}]", filename.c_str());
|
LogInfo("Attempting to load Map File [{}]", filename.c_str());
|
||||||
|
|
||||||
|
|||||||
@ -3,12 +3,13 @@
|
|||||||
#include "pathfinder_null.h"
|
#include "pathfinder_null.h"
|
||||||
#include "pathfinder_nav_mesh.h"
|
#include "pathfinder_nav_mesh.h"
|
||||||
#include "pathfinder_waypoint.h"
|
#include "pathfinder_waypoint.h"
|
||||||
|
#include "../common/path_manager.h"
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
IPathfinder *IPathfinder::Load(const std::string &zone) {
|
IPathfinder *IPathfinder::Load(const std::string &zone) {
|
||||||
struct stat statbuffer;
|
struct stat statbuffer;
|
||||||
std::string navmesh_path = fmt::format("maps/nav/{0}.nav", zone);
|
std::string navmesh_path = fmt::format("{}/maps/nav/{}.nav", path.GetServerPath(), zone);
|
||||||
if (stat(navmesh_path.c_str(), &statbuffer) == 0) {
|
if (stat(navmesh_path.c_str(), &statbuffer) == 0) {
|
||||||
return new PathfinderNavmesh(navmesh_path);
|
return new PathfinderNavmesh(navmesh_path);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
#include "quest_interface.h"
|
#include "quest_interface.h"
|
||||||
#include "zone.h"
|
#include "zone.h"
|
||||||
#include "questmgr.h"
|
#include "questmgr.h"
|
||||||
#include "zone_config.h"
|
#include "../common/path_manager.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@ -513,11 +513,9 @@ int QuestParserCollection::EventEncounter(QuestEventID evt, std::string encounte
|
|||||||
}
|
}
|
||||||
|
|
||||||
QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string &filename) {
|
QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string &filename) {
|
||||||
//first look for /quests/zone/npcid.ext (precedence)
|
// first look for /quests/zone/npcid.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/{}", path.GetQuestsPath(), zone->GetShortName(), npcid);
|
||||||
filename += zone->GetShortName();
|
|
||||||
filename += "/";
|
|
||||||
filename += itoa(npcid);
|
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
FILE *f = nullptr;
|
FILE *f = nullptr;
|
||||||
|
|
||||||
@ -557,10 +555,7 @@ QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/{}", path.GetQuestsPath(), zone->GetShortName(), npc_name);
|
||||||
filename += zone->GetShortName();
|
|
||||||
filename += "/";
|
|
||||||
filename += npc_name;
|
|
||||||
|
|
||||||
iter = _load_precedence.begin();
|
iter = _load_precedence.begin();
|
||||||
while(iter != _load_precedence.end()) {
|
while(iter != _load_precedence.end()) {
|
||||||
@ -578,11 +573,8 @@ QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string
|
|||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//third look for /quests/global/npcid.ext (precedence)
|
// third look for /quests/global/npcid.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/{}", path.GetQuestsPath(), QUEST_GLOBAL_DIRECTORY, npcid);
|
||||||
filename += QUEST_GLOBAL_DIRECTORY;
|
|
||||||
filename += "/";
|
|
||||||
filename += itoa(npcid);
|
|
||||||
iter = _load_precedence.begin();
|
iter = _load_precedence.begin();
|
||||||
while(iter != _load_precedence.end()) {
|
while(iter != _load_precedence.end()) {
|
||||||
tmp = filename;
|
tmp = filename;
|
||||||
@ -599,11 +591,8 @@ QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string
|
|||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//fourth look for /quests/global/npcname.ext (precedence)
|
// fourth look for /quests/global/npcname.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/{}", path.GetQuestsPath(), QUEST_GLOBAL_DIRECTORY, npc_name);
|
||||||
filename += QUEST_GLOBAL_DIRECTORY;
|
|
||||||
filename += "/";
|
|
||||||
filename += npc_name;
|
|
||||||
iter = _load_precedence.begin();
|
iter = _load_precedence.begin();
|
||||||
while(iter != _load_precedence.end()) {
|
while(iter != _load_precedence.end()) {
|
||||||
tmp = filename;
|
tmp = filename;
|
||||||
@ -620,11 +609,8 @@ QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string
|
|||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//fifth look for /quests/zone/default.ext (precedence)
|
// fifth look for /quests/zone/default.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/default", path.GetQuestsPath(), zone->GetShortName());
|
||||||
filename += zone->GetShortName();
|
|
||||||
filename += "/";
|
|
||||||
filename += "default";
|
|
||||||
iter = _load_precedence.begin();
|
iter = _load_precedence.begin();
|
||||||
while(iter != _load_precedence.end()) {
|
while(iter != _load_precedence.end()) {
|
||||||
tmp = filename;
|
tmp = filename;
|
||||||
@ -641,11 +627,8 @@ QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string
|
|||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//last look for /quests/global/default.ext (precedence)
|
// last look for /quests/global/default.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/default", path.GetQuestsPath(), QUEST_GLOBAL_DIRECTORY);
|
||||||
filename += QUEST_GLOBAL_DIRECTORY;
|
|
||||||
filename += "/";
|
|
||||||
filename += "default";
|
|
||||||
iter = _load_precedence.begin();
|
iter = _load_precedence.begin();
|
||||||
while(iter != _load_precedence.end()) {
|
while(iter != _load_precedence.end()) {
|
||||||
tmp = filename;
|
tmp = filename;
|
||||||
@ -669,12 +652,8 @@ QuestInterface *QuestParserCollection::GetQIByPlayerQuest(std::string &filename)
|
|||||||
if(!zone || !zone->IsLoaded())
|
if(!zone || !zone->IsLoaded())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
//first look for /quests/zone/player_v[instance_version].ext (precedence)
|
// first look for /quests/zone/player_v[instance_version].ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/player_v{}", path.GetQuestsPath(), zone->GetShortName(), zone->GetInstanceVersion());
|
||||||
filename += zone->GetShortName();
|
|
||||||
filename += "/";
|
|
||||||
filename += "player_v";
|
|
||||||
filename += itoa(zone->GetInstanceVersion());
|
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
FILE *f = nullptr;
|
FILE *f = nullptr;
|
||||||
|
|
||||||
@ -694,11 +673,8 @@ QuestInterface *QuestParserCollection::GetQIByPlayerQuest(std::string &filename)
|
|||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//second look for /quests/zone/player.ext (precedence)
|
// second look for /quests/zone/player.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/player", path.GetQuestsPath(), zone->GetShortName());
|
||||||
filename += zone->GetShortName();
|
|
||||||
filename += "/";
|
|
||||||
filename += "player";
|
|
||||||
|
|
||||||
iter = _load_precedence.begin();
|
iter = _load_precedence.begin();
|
||||||
while(iter != _load_precedence.end()) {
|
while(iter != _load_precedence.end()) {
|
||||||
@ -716,11 +692,8 @@ QuestInterface *QuestParserCollection::GetQIByPlayerQuest(std::string &filename)
|
|||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//third look for /quests/global/player.ext (precedence)
|
// third look for /quests/global/player.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/player", path.GetQuestsPath(), QUEST_GLOBAL_DIRECTORY);
|
||||||
filename += QUEST_GLOBAL_DIRECTORY;
|
|
||||||
filename += "/";
|
|
||||||
filename += "player";
|
|
||||||
iter = _load_precedence.begin();
|
iter = _load_precedence.begin();
|
||||||
while(iter != _load_precedence.end()) {
|
while(iter != _load_precedence.end()) {
|
||||||
tmp = filename;
|
tmp = filename;
|
||||||
@ -742,15 +715,11 @@ QuestInterface *QuestParserCollection::GetQIByPlayerQuest(std::string &filename)
|
|||||||
|
|
||||||
QuestInterface *QuestParserCollection::GetQIByGlobalNPCQuest(std::string &filename) {
|
QuestInterface *QuestParserCollection::GetQIByGlobalNPCQuest(std::string &filename) {
|
||||||
// simply look for /quests/global/global_npc.ext
|
// simply look for /quests/global/global_npc.ext
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/global_npc", path.GetQuestsPath(), QUEST_GLOBAL_DIRECTORY);
|
||||||
filename += QUEST_GLOBAL_DIRECTORY;
|
|
||||||
filename += "/";
|
|
||||||
filename += "global_npc";
|
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
FILE *f = nullptr;
|
FILE *f = nullptr;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
auto iter = _load_precedence.begin();
|
auto iter = _load_precedence.begin();
|
||||||
while(iter != _load_precedence.end()) {
|
while(iter != _load_precedence.end()) {
|
||||||
tmp = filename;
|
tmp = filename;
|
||||||
@ -772,11 +741,8 @@ QuestInterface *QuestParserCollection::GetQIByGlobalNPCQuest(std::string &filena
|
|||||||
}
|
}
|
||||||
|
|
||||||
QuestInterface *QuestParserCollection::GetQIByGlobalPlayerQuest(std::string &filename) {
|
QuestInterface *QuestParserCollection::GetQIByGlobalPlayerQuest(std::string &filename) {
|
||||||
//first look for /quests/global/player.ext (precedence)
|
// first look for /quests/global/player.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/global_player", path.GetQuestsPath(), QUEST_GLOBAL_DIRECTORY);
|
||||||
filename += QUEST_GLOBAL_DIRECTORY;
|
|
||||||
filename += "/";
|
|
||||||
filename += "global_player";
|
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
FILE *f = nullptr;
|
FILE *f = nullptr;
|
||||||
|
|
||||||
@ -801,10 +767,7 @@ QuestInterface *QuestParserCollection::GetQIByGlobalPlayerQuest(std::string &fil
|
|||||||
|
|
||||||
QuestInterface *QuestParserCollection::GetQIBySpellQuest(uint32 spell_id, std::string &filename) {
|
QuestInterface *QuestParserCollection::GetQIBySpellQuest(uint32 spell_id, std::string &filename) {
|
||||||
//first look for /quests/zone/spells/spell_id.ext (precedence)
|
//first look for /quests/zone/spells/spell_id.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/spells/{}", path.GetQuestsPath(), zone->GetShortName(), spell_id);
|
||||||
filename += zone->GetShortName();
|
|
||||||
filename += "/spells/";
|
|
||||||
filename += itoa(spell_id);
|
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
FILE *f = nullptr;
|
FILE *f = nullptr;
|
||||||
|
|
||||||
@ -824,11 +787,8 @@ QuestInterface *QuestParserCollection::GetQIBySpellQuest(uint32 spell_id, std::s
|
|||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//second look for /quests/global/spells/spell_id.ext (precedence)
|
// second look for /quests/global/spells/spell_id.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/spells/{}", path.GetQuestsPath(), QUEST_GLOBAL_DIRECTORY, spell_id);
|
||||||
filename += QUEST_GLOBAL_DIRECTORY;
|
|
||||||
filename += "/spells/";
|
|
||||||
filename += itoa(spell_id);
|
|
||||||
|
|
||||||
iter = _load_precedence.begin();
|
iter = _load_precedence.begin();
|
||||||
while(iter != _load_precedence.end()) {
|
while(iter != _load_precedence.end()) {
|
||||||
@ -846,10 +806,8 @@ QuestInterface *QuestParserCollection::GetQIBySpellQuest(uint32 spell_id, std::s
|
|||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//third look for /quests/zone/spells/default.ext (precedence)
|
// third look for /quests/zone/spells/default.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/spells/default", path.GetQuestsPath(), zone->GetShortName());
|
||||||
filename += zone->GetShortName();
|
|
||||||
filename += "/spells/default";
|
|
||||||
|
|
||||||
iter = _load_precedence.begin();
|
iter = _load_precedence.begin();
|
||||||
while(iter != _load_precedence.end()) {
|
while(iter != _load_precedence.end()) {
|
||||||
@ -867,10 +825,8 @@ QuestInterface *QuestParserCollection::GetQIBySpellQuest(uint32 spell_id, std::s
|
|||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//last look for /quests/global/spells/default.ext (precedence)
|
// last look for /quests/global/spells/default.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/spells/default", path.GetQuestsPath(), QUEST_GLOBAL_DIRECTORY);
|
||||||
filename += QUEST_GLOBAL_DIRECTORY;
|
|
||||||
filename += "/spells/default";
|
|
||||||
|
|
||||||
iter = _load_precedence.begin();
|
iter = _load_precedence.begin();
|
||||||
while(iter != _load_precedence.end()) {
|
while(iter != _load_precedence.end()) {
|
||||||
@ -892,11 +848,8 @@ QuestInterface *QuestParserCollection::GetQIBySpellQuest(uint32 spell_id, std::s
|
|||||||
}
|
}
|
||||||
|
|
||||||
QuestInterface *QuestParserCollection::GetQIByItemQuest(std::string item_script, std::string &filename) {
|
QuestInterface *QuestParserCollection::GetQIByItemQuest(std::string item_script, std::string &filename) {
|
||||||
//first look for /quests/zone/items/item_script.ext (precedence)
|
// first look for /quests/zone/items/item_script.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/items/{}", path.GetQuestsPath(), zone->GetShortName(), item_script);
|
||||||
filename += zone->GetShortName();
|
|
||||||
filename += "/items/";
|
|
||||||
filename += item_script;
|
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
FILE *f = nullptr;
|
FILE *f = nullptr;
|
||||||
|
|
||||||
@ -916,11 +869,8 @@ QuestInterface *QuestParserCollection::GetQIByItemQuest(std::string item_script,
|
|||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//second look for /quests/global/items/item_script.ext (precedence)
|
// second look for /quests/global/items/item_script.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/items/{}", path.GetQuestsPath(), QUEST_GLOBAL_DIRECTORY, item_script);
|
||||||
filename += QUEST_GLOBAL_DIRECTORY;
|
|
||||||
filename += "/items/";
|
|
||||||
filename += item_script;
|
|
||||||
|
|
||||||
iter = _load_precedence.begin();
|
iter = _load_precedence.begin();
|
||||||
while(iter != _load_precedence.end()) {
|
while(iter != _load_precedence.end()) {
|
||||||
@ -938,11 +888,8 @@ QuestInterface *QuestParserCollection::GetQIByItemQuest(std::string item_script,
|
|||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//third look for /quests/zone/items/default.ext (precedence)
|
// third look for /quests/zone/items/default.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/items/default", path.GetQuestsPath(), zone->GetShortName());
|
||||||
filename += zone->GetShortName();
|
|
||||||
filename += "/items/default";
|
|
||||||
|
|
||||||
iter = _load_precedence.begin();
|
iter = _load_precedence.begin();
|
||||||
while(iter != _load_precedence.end()) {
|
while(iter != _load_precedence.end()) {
|
||||||
tmp = filename;
|
tmp = filename;
|
||||||
@ -959,11 +906,8 @@ QuestInterface *QuestParserCollection::GetQIByItemQuest(std::string item_script,
|
|||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//last look for /quests/global/items/default.ext (precedence)
|
// last look for /quests/global/items/default.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/items/default", path.GetQuestsPath(), QUEST_GLOBAL_DIRECTORY);
|
||||||
filename += QUEST_GLOBAL_DIRECTORY;
|
|
||||||
filename += "/items/default";
|
|
||||||
|
|
||||||
iter = _load_precedence.begin();
|
iter = _load_precedence.begin();
|
||||||
while(iter != _load_precedence.end()) {
|
while(iter != _load_precedence.end()) {
|
||||||
tmp = filename;
|
tmp = filename;
|
||||||
@ -984,11 +928,8 @@ QuestInterface *QuestParserCollection::GetQIByItemQuest(std::string item_script,
|
|||||||
}
|
}
|
||||||
|
|
||||||
QuestInterface *QuestParserCollection::GetQIByEncounterQuest(std::string encounter_name, std::string &filename) {
|
QuestInterface *QuestParserCollection::GetQIByEncounterQuest(std::string encounter_name, std::string &filename) {
|
||||||
//first look for /quests/zone/encounters/encounter_name.ext (precedence)
|
// first look for /quests/zone/encounters/encounter_name.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/encounters/{}", path.GetQuestsPath(), zone->GetShortName(), encounter_name);
|
||||||
filename += zone->GetShortName();
|
|
||||||
filename += "/encounters/";
|
|
||||||
filename += encounter_name;
|
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
FILE *f = nullptr;
|
FILE *f = nullptr;
|
||||||
|
|
||||||
@ -1008,11 +949,8 @@ QuestInterface *QuestParserCollection::GetQIByEncounterQuest(std::string encount
|
|||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//second look for /quests/global/encounters/encounter_name.ext (precedence)
|
// second look for /quests/global/encounters/encounter_name.ext (precedence)
|
||||||
filename = Config->QuestDir;
|
filename = fmt::format("{}/{}/encounters/{}", path.GetQuestsPath(), QUEST_GLOBAL_DIRECTORY, encounter_name);
|
||||||
filename += QUEST_GLOBAL_DIRECTORY;
|
|
||||||
filename += "/encounters/";
|
|
||||||
filename += encounter_name;
|
|
||||||
|
|
||||||
iter = _load_precedence.begin();
|
iter = _load_precedence.begin();
|
||||||
while(iter != _load_precedence.end()) {
|
while(iter != _load_precedence.end()) {
|
||||||
|
|||||||
@ -192,7 +192,7 @@ void QuestManager::summonitem(uint32 itemid, int16 charges) {
|
|||||||
|
|
||||||
void QuestManager::write(const char *file, const char *str) {
|
void QuestManager::write(const char *file, const char *str) {
|
||||||
FILE * pFile;
|
FILE * pFile;
|
||||||
pFile = fopen (file, "a");
|
pFile = fopen (fmt::format("{}/{}", path.GetServerPath(), file).c_str(), "a");
|
||||||
if(!pFile)
|
if(!pFile)
|
||||||
return;
|
return;
|
||||||
fprintf(pFile, "%s\n", str);
|
fprintf(pFile, "%s\n", str);
|
||||||
|
|||||||
@ -4,21 +4,14 @@
|
|||||||
#include "water_map_v1.h"
|
#include "water_map_v1.h"
|
||||||
#include "water_map_v2.h"
|
#include "water_map_v2.h"
|
||||||
#include "../common/eqemu_logsys.h"
|
#include "../common/eqemu_logsys.h"
|
||||||
|
#include "../common/file.h"
|
||||||
|
#include "../common/path_manager.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
inline bool file_exists(const std::string& name) {
|
|
||||||
std::ifstream f(name.c_str());
|
|
||||||
return f.good();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param zone_name
|
* @param zone_name
|
||||||
* @return
|
* @return
|
||||||
@ -26,18 +19,7 @@ inline bool file_exists(const std::string& name) {
|
|||||||
WaterMap* WaterMap::LoadWaterMapfile(std::string zone_name) {
|
WaterMap* WaterMap::LoadWaterMapfile(std::string zone_name) {
|
||||||
std::transform(zone_name.begin(), zone_name.end(), zone_name.begin(), ::tolower);
|
std::transform(zone_name.begin(), zone_name.end(), zone_name.begin(), ::tolower);
|
||||||
|
|
||||||
std::string filename;
|
std::string file_path = fmt::format("{}/water/{}.wtr", path.GetMapsPath(), zone_name);
|
||||||
if (file_exists("maps")) {
|
|
||||||
filename = "maps";
|
|
||||||
}
|
|
||||||
else if (file_exists("Maps")) {
|
|
||||||
filename = "Maps";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
filename = Config->MapDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string file_path = filename + "/water/" + zone_name + std::string(".wtr");
|
|
||||||
LogDebug("Attempting to load water map with path [{}]", file_path.c_str());
|
LogDebug("Attempting to load water map with path [{}]", file_path.c_str());
|
||||||
FILE *f = fopen(file_path.c_str(), "rb");
|
FILE *f = fopen(file_path.c_str(), "rb");
|
||||||
if(f) {
|
if(f) {
|
||||||
|
|||||||
@ -43,13 +43,13 @@ class ZoneConfig : public EQEmuConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load the config
|
// Load the config
|
||||||
static bool LoadConfig() {
|
static bool LoadConfig(const std::string& path = "") {
|
||||||
if (_zone_config != nullptr)
|
if (_zone_config != nullptr)
|
||||||
delete _zone_config;
|
delete _zone_config;
|
||||||
_zone_config=new ZoneConfig;
|
_zone_config=new ZoneConfig;
|
||||||
_config=_zone_config;
|
_config=_zone_config;
|
||||||
|
|
||||||
return _config->parseFile();
|
return _config->parseFile(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accessors for the static private object
|
// Accessors for the static private object
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user