From f3c5ad1aea634c45ed78bac20ad96a6691faa005 Mon Sep 17 00:00:00 2001 From: m0th <43860202+m0th@users.noreply.github.com> Date: Wed, 8 Oct 2025 16:21:11 +0000 Subject: [PATCH] PathManager refactor, fixes "CheckinHandle" --- .devcontainer/Makefile | 4 +- .devcontainer/devcontainer.json | 11 ++--- .vscode/settings.json | 5 ++- client_files/export/main.cpp | 19 ++++++--- client_files/import/main.cpp | 19 ++++++--- common/eqemu_config.cpp | 21 ++-------- common/eqemu_config.h | 25 +----------- common/eqemu_logsys.cpp | 45 ++++++--------------- common/ipc_mutex.cpp | 2 +- common/patches/rof.cpp | 4 +- common/patches/rof2.cpp | 6 +-- common/patches/sod.cpp | 4 +- common/patches/sof.cpp | 4 +- common/patches/titanium.cpp | 4 +- common/patches/uf.cpp | 4 +- common/path_manager.cpp | 69 +++++++++++--------------------- common/path_manager.h | 42 ++++++++----------- common/shareddb.cpp | 23 +++++++++-- eqlaunch/eqlaunch.cpp | 5 ++- loginserver/client_manager.cpp | 8 ++-- loginserver/main.cpp | 4 +- queryserv/queryserv.cpp | 12 +++++- shared_memory/main.cpp | 11 ++++- tests/main.cpp | 6 ++- ucs/clientlist.cpp | 4 +- ucs/ucs.cpp | 4 +- world/main.cpp | 19 ++++++++- world/world_boot.cpp | 4 +- zone/embperl.cpp | 41 +++++++++---------- zone/lua_parser.cpp | 12 +++--- zone/main.cpp | 29 +++++++++++--- zone/map.cpp | 2 +- zone/pathfinder_interface.cpp | 2 +- zone/quest_parser_collection.cpp | 26 ++++++------ zone/questmgr.cpp | 5 +-- zone/water_map.cpp | 2 +- 36 files changed, 251 insertions(+), 256 deletions(-) diff --git a/.devcontainer/Makefile b/.devcontainer/Makefile index 18356dc11..95589d0b1 100644 --- a/.devcontainer/Makefile +++ b/.devcontainer/Makefile @@ -117,7 +117,7 @@ ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer) @make -C ../ -f .devcontainer/Makefile quests --no-print-directory exit endif - @cd build/bin && git clone https://gitlab.com/TheGrandLibrary/projecteq/projecteqquests.git quests + @cd build/bin && git clone https://github.com/ProjectEQ/projecteqquests.git quests # Runs tests .PHONY: test @@ -207,7 +207,7 @@ inject-mariadb: -sudo mariadb -e "CREATE USER IF NOT EXISTS 'peq'@'127.0.0.1' IDENTIFIED BY 'peqpass';" -sudo mariadb -e "GRANT ALL PRIVILEGES ON *.* TO 'peq'@'127.0.0.1';" ifeq (,$(wildcard .devcontainer/base/db/db.sql.zip)) - @echo ".devcontainer/base/db.sql.zip not found. Downloading latest database from https://db.eqemu.dev/latest ..." + @echo ".devcontainer/base/db.sql.zip not found. Downloading latest database from https://db.eqemu.dev/" wget -nc https://db.eqemu.dev/latest -O .devcontainer/base/db/db.sql.zip -cd .devcontainer/base/db && unzip db.sql.zip endif diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d6ccc7265..e0c9c9254 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -6,14 +6,9 @@ "dockerfile": "Dockerfile.debian.dev" }, "appPort": [ - "5998:5998/udp", - "7000:7000/udp", - "7001:7001/udp", - "7002:7002/udp", - "7003:7003/udp", - "7004:7004/udp", - "7005:7005/udp", - "9000:9000/udp", + "5998-5999:5998-5999/udp", // loginserver + "7000-7374:7000-7374/udp", //zone + "9000:9000/udp", // world "9001:9001/udp" ], "forwardPorts": [ diff --git a/.vscode/settings.json b/.vscode/settings.json index bf5c79fae..0367041da 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -114,7 +114,10 @@ "charconv": "cpp", "format": "cpp", "ranges": "cpp", - "span": "cpp" + "span": "cpp", + "shared_mutex": "cpp", + "stdfloat": "cpp", + "text_encoding": "cpp" }, "cmake.statusbar.advanced": { "kit": { diff --git a/client_files/export/main.cpp b/client_files/export/main.cpp index 8d0a27a3c..6ff9f008d 100644 --- a/client_files/export/main.cpp +++ b/client_files/export/main.cpp @@ -38,6 +38,13 @@ #include "../../common/skill_caps.h" #include "../../common/evolving_items.h" +EQEmuLogSys LogSys; +WorldContentService content_service; +ZoneStore zone_store; +PathManager path; +PlayerEventLogs player_event_logs; +EvolvingItemsManager evolving_items_manager; + void ExportSpells(SharedDatabase *db); void ExportSkillCaps(SharedDatabase *db); void ExportBaseData(SharedDatabase *db); @@ -49,7 +56,7 @@ int main(int argc, char **argv) EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); set_exception_handler(); - PathManager::Instance()->Init(); + path.LoadPaths(); LogInfo("Client Files Export Utility"); if (!EQEmuConfig::LoadConfig()) { @@ -93,7 +100,7 @@ int main(int argc, char **argv) } EQEmuLogSys::Instance()->SetDatabase(&database) - ->SetLogPath(PathManager::Instance()->GetLogPath()) + ->SetLogPath(path.GetLogPath()) ->LoadLogDatabaseSettings() ->StartFileLogs(); @@ -129,7 +136,7 @@ int main(int argc, char **argv) void ExportSpells(SharedDatabase* db) { - std::ofstream file(fmt::format("{}/export/spells_us.txt", PathManager::Instance()->GetServerPath())); + std::ofstream file(fmt::format("{}/export/spells_us.txt", path.GetServerPath())); if (!file || !file.is_open()) { LogError("Unable to open export/spells_us.txt to write, skipping."); return; @@ -148,7 +155,7 @@ void ExportSpells(SharedDatabase* db) void ExportSkillCaps(SharedDatabase* db) { - std::ofstream file(fmt::format("{}/export/SkillCaps.txt", PathManager::Instance()->GetServerPath())); + std::ofstream file(fmt::format("{}/export/SkillCaps.txt", path.GetServerPath())); if (!file || !file.is_open()) { LogError("Unable to open export/SkillCaps.txt to write, skipping."); return; @@ -167,7 +174,7 @@ void ExportSkillCaps(SharedDatabase* db) void ExportBaseData(SharedDatabase *db) { - std::ofstream file(fmt::format("{}/export/BaseData.txt", PathManager::Instance()->GetServerPath())); + std::ofstream file(fmt::format("{}/export/BaseData.txt", path.GetServerPath())); if (!file || !file.is_open()) { LogError("Unable to open export/BaseData.txt to write, skipping."); return; @@ -186,7 +193,7 @@ void ExportBaseData(SharedDatabase *db) void ExportDBStrings(SharedDatabase *db) { - std::ofstream file(fmt::format("{}/export/dbstr_us.txt", PathManager::Instance()->GetServerPath())); + std::ofstream file(fmt::format("{}/export/dbstr_us.txt", path.GetServerPath())); if (!file || !file.is_open()) { LogError("Unable to open export/dbstr_us.txt to write, skipping."); return; diff --git a/client_files/import/main.cpp b/client_files/import/main.cpp index b7be706d7..e698d141f 100644 --- a/client_files/import/main.cpp +++ b/client_files/import/main.cpp @@ -32,6 +32,13 @@ #include "../../common/events/player_event_logs.h" #include "../../common/evolving_items.h" +EQEmuLogSys LogSys; +WorldContentService content_service; +ZoneStore zone_store; +PathManager path; +PlayerEventLogs player_event_logs; +EvolvingItemsManager evolving_items_manager; + void ImportSpells(SharedDatabase *db); void ImportSkillCaps(SharedDatabase *db); void ImportBaseData(SharedDatabase *db); @@ -42,7 +49,7 @@ int main(int argc, char **argv) { EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); set_exception_handler(); - PathManager::Instance()->Init(); + path.LoadPaths(); LogInfo("Client Files Import Utility"); if(!EQEmuConfig::LoadConfig()) { @@ -86,7 +93,7 @@ int main(int argc, char **argv) { } EQEmuLogSys::Instance()->SetDatabase(&database) - ->SetLogPath(PathManager::Instance()->GetLogPath()) + ->SetLogPath(path.GetLogPath()) ->LoadLogDatabaseSettings() ->StartFileLogs(); @@ -131,7 +138,7 @@ bool IsStringField(int i) { void ImportSpells(SharedDatabase *db) { LogInfo("Importing Spells"); - std::string file = fmt::format("{}/import/spells_us.txt", PathManager::Instance()->GetServerPath()); + std::string file = fmt::format("{}/import/spells_us.txt", path.GetServerPath()); FILE *f = fopen(file.c_str(), "r"); if(!f) { LogError("Unable to open {} to read, skipping.", file); @@ -221,7 +228,7 @@ void ImportSpells(SharedDatabase *db) { void ImportSkillCaps(SharedDatabase *db) { LogInfo("Importing Skill Caps"); - std::string file = fmt::format("{}/import/SkillCaps.txt", PathManager::Instance()->GetServerPath()); + std::string file = fmt::format("{}/import/SkillCaps.txt", path.GetServerPath()); FILE *f = fopen(file.c_str(), "r"); if(!f) { LogError("Unable to open {} to read, skipping.", file); @@ -258,7 +265,7 @@ void ImportBaseData(SharedDatabase *db) { LogInfo("Importing Base Data"); - const std::string& file_name = fmt::format("{}/import/BaseData.txt", PathManager::Instance()->GetServerPath()); + const std::string& file_name = fmt::format("{}/import/BaseData.txt", path.GetServerPath()); const auto& file_contents = File::GetContents(file_name); if (!file_contents.error.empty()) { @@ -298,7 +305,7 @@ void ImportBaseData(SharedDatabase *db) void ImportDBStrings(SharedDatabase *db) { LogInfo("Importing DB Strings"); - std::string file = fmt::format("{}/import/dbstr_us.txt", PathManager::Instance()->GetServerPath()); + std::string file = fmt::format("{}/import/dbstr_us.txt", path.GetServerPath()); FILE *f = fopen(file.c_str(), "r"); if(!f) { LogError("Unable to open {} to read, skipping.", file); diff --git a/common/eqemu_config.cpp b/common/eqemu_config.cpp index e2f35106c..a02b4b036 100644 --- a/common/eqemu_config.cpp +++ b/common/eqemu_config.cpp @@ -177,21 +177,6 @@ void EQEmuConfig::parse_config() SharedMemDir = _root["server"]["directories"].get("shared_memory", "shared/").asString(); LogDir = _root["server"]["directories"].get("logs", "logs/").asString(); - auto load_paths = [&](const std::string& key, std::vector& target) { - const auto& paths = _root["server"]["directories"][key]; - if (paths.isArray()) { - for (const auto& dir : paths) { - if (dir.isString()) { - target.push_back(dir.asString()); - } - } - } - }; - - load_paths("quest_paths", m_quest_directories); - load_paths("plugin_paths", m_plugin_directories); - load_paths("lua_module_paths", m_lua_module_directories); - /** * Logs */ @@ -436,11 +421,11 @@ void EQEmuConfig::CheckUcsConfigConversion() LogInfo("Migrating old [eqemu_config] UCS configuration to new configuration"); std::string config_file_path = std::filesystem::path{ - PathManager::Instance()->GetServerPath() + "/eqemu_config.json" + path.GetServerPath() + "/eqemu_config.json" }.string(); std::string config_file_bak_path = std::filesystem::path{ - PathManager::Instance()->GetServerPath() + "/eqemu_config.ucs-migrate-json.bak" + path.GetServerPath() + "/eqemu_config.ucs-migrate-json.bak" }.string(); // copy eqemu_config.json to eqemu_config.json.bak @@ -504,4 +489,4 @@ void EQEmuConfig::CheckUcsConfigConversion() return; } } -} +} \ No newline at end of file diff --git a/common/eqemu_config.h b/common/eqemu_config.h index 57a0543c8..2356f7e71 100644 --- a/common/eqemu_config.h +++ b/common/eqemu_config.h @@ -120,22 +120,6 @@ class EQEmuConfig const std::string &GetUCSHost() const; uint16 GetUCSPort() const; - std::vector GetQuestDirectories() const - { - return m_quest_directories; - } - - std::vector GetPluginsDirectories() const - { - return m_plugin_directories; - } - - std::vector GetLuaModuleDirectories() const - { - return m_lua_module_directories; - } - - // uint16 DynamicCount; // map StaticZones; @@ -149,11 +133,6 @@ class EQEmuConfig Json::Value _root; static std::string ConfigFile; - std::vector m_quest_directories = {}; - std::vector m_plugin_directories = {}; - std::vector m_lua_module_directories = {}; - - protected: void parse_config(); EQEmuConfig() @@ -191,7 +170,7 @@ class EQEmuConfig std::string file = fmt::format( "{}/{}", - (file_path.empty() ? PathManager::Instance()->GetServerPath() : file_path), + (file_path.empty() ? path.GetServerPath() : file_path), EQEmuConfig::ConfigFile ); @@ -211,4 +190,4 @@ class EQEmuConfig void CheckUcsConfigConversion(); }; -#endif +#endif \ No newline at end of file diff --git a/common/eqemu_logsys.cpp b/common/eqemu_logsys.cpp index 0d735b407..7a25276f4 100644 --- a/common/eqemu_logsys.cpp +++ b/common/eqemu_logsys.cpp @@ -537,9 +537,9 @@ void EQEmuLogSys::StartFileLogs(const std::string &log_name) { EQEmuLogSys::CloseFileLogs(); - if (!File::Exists(PathManager::Instance()->GetLogPath())) { - LogInfo("Logs directory not found, creating [{}]", PathManager::Instance()->GetLogPath()); - File::Makedir(PathManager::Instance()->GetLogPath()); + if (!File::Exists(path.GetLogPath())) { + LogInfo("Logs directory not found, creating [{}]", path.GetLogPath()); + File::Makedir(path.GetLogPath()); } /** @@ -656,7 +656,7 @@ EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings(bool silent_load) // If we go through this whole loop and nothing is set to any debug level, there // is no point to create a file or keep anything open if (log_settings[c.log_category_id].log_to_file > 0) { - m_file_logs_enabled = true; + EQEmuLogSys::Instance()->m_file_logs_enabled = true; } db_categories.emplace_back(c.log_category_id); @@ -682,33 +682,14 @@ EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings(bool silent_load) if (is_missing_in_database && !is_deprecated_category) { LogInfo("Automatically adding new log category [{}] ({})", Logs::LogCategoryName[i], i); - auto e = LogsysCategoriesRepository::NewEntity(); - e.log_category_id = i; - e.log_category_description = Strings::Escape(Logs::LogCategoryName[i]); - e.log_to_console = log_settings[i].log_to_console; - e.log_to_gmsay = log_settings[i].log_to_gmsay; - e.log_to_file = log_settings[i].log_to_file; - e.log_to_discord = log_settings[i].log_to_discord; - db_categories_to_add.emplace_back(e); - } - - // look to see if the category name is different in the database - auto it = std::find_if( - categories.begin(), - categories.end(), - [i](const auto &c) { return c.log_category_id == i; } - ); - if (it != categories.end()) { - if (it->log_category_description != Logs::LogCategoryName[i]) { - LogInfo( - "Updating log category [{}] ({}) to new name [{}]", - it->log_category_description, - i, - Logs::LogCategoryName[i] - ); - it->log_category_description = Logs::LogCategoryName[i]; - LogsysCategoriesRepository::ReplaceOne(*m_database, *it); - } + auto new_category = LogsysCategoriesRepository::NewEntity(); + new_category.log_category_id = i; + new_category.log_category_description = Strings::Escape(Logs::LogCategoryName[i]); + new_category.log_to_console = log_settings[i].log_to_console; + new_category.log_to_gmsay = log_settings[i].log_to_gmsay; + new_category.log_to_file = log_settings[i].log_to_file; + new_category.log_to_discord = log_settings[i].log_to_discord; + db_categories_to_add.emplace_back(new_category); } } @@ -858,4 +839,4 @@ void EQEmuLogSys::EnableMySQLErrorLogs() log_settings[Logs::MySQLError].log_to_file = 1; log_settings[Logs::MySQLError].log_to_console = 1; log_settings[Logs::MySQLError].log_to_gmsay = 1; -} +} \ No newline at end of file diff --git a/common/ipc_mutex.cpp b/common/ipc_mutex.cpp index ebd13a693..e2c123f22 100644 --- a/common/ipc_mutex.cpp +++ b/common/ipc_mutex.cpp @@ -55,7 +55,7 @@ namespace EQ { EQ_EXCEPT("IPC Mutex", "Could not create mutex."); } #else - std::string final_name = fmt::format("{}/{}.lock", PathManager::Instance()->GetSharedMemoryPath(), name); + std::string final_name = fmt::format("{}/{}.lock", path.GetSharedMemoryPath(), name); #ifdef __DARWIN #if __DARWIN_C_LEVEL < 200809L diff --git a/common/patches/rof.cpp b/common/patches/rof.cpp index 15b745b16..0e23bb429 100644 --- a/common/patches/rof.cpp +++ b/common/patches/rof.cpp @@ -78,7 +78,7 @@ namespace RoF { //create our opcode manager if we havent already if (opcodes == nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); //load up the opcode manager. //TODO: figure out how to support shared memory with multiple patches... @@ -117,7 +117,7 @@ namespace RoF //we need to go to every stream and replace it's manager. if (opcodes != nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); if (!opcodes->ReloadOpcodes(opfile.c_str())) { LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name); return; diff --git a/common/patches/rof2.cpp b/common/patches/rof2.cpp index b250a5de6..d94f1f912 100644 --- a/common/patches/rof2.cpp +++ b/common/patches/rof2.cpp @@ -81,7 +81,7 @@ namespace RoF2 //create our opcode manager if we havent already if (opcodes == nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); //load up the opcode manager. //TODO: figure out how to support shared memory with multiple patches... @@ -123,7 +123,7 @@ namespace RoF2 //we need to go to every stream and replace it's manager. if (opcodes != nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); if (!opcodes->ReloadOpcodes(opfile.c_str())) { LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name); return; @@ -180,7 +180,7 @@ namespace RoF2 } eq->class_entry_count = emu->class_entry_count; - for (uint32 i = 0; i < emu->class_entry_count; ++i) // 15 + for (uint32 i = 0; i < emu->class_entry_count; ++i) // 16 { OUT(membership_classes[i].purchase_id); OUT(membership_classes[i].bitwise_entry); diff --git a/common/patches/sod.cpp b/common/patches/sod.cpp index 72a3a3c48..931931dff 100644 --- a/common/patches/sod.cpp +++ b/common/patches/sod.cpp @@ -72,7 +72,7 @@ namespace SoD { //create our opcode manager if we havent already if (opcodes == nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); //load up the opcode manager. //TODO: figure out how to support shared memory with multiple patches... opcodes = new RegularOpcodeManager(); @@ -113,7 +113,7 @@ namespace SoD //we need to go to every stream and replace it's manager. if (opcodes != nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); if (!opcodes->ReloadOpcodes(opfile.c_str())) { LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name); return; diff --git a/common/patches/sof.cpp b/common/patches/sof.cpp index 444b33b35..13dbc81a1 100644 --- a/common/patches/sof.cpp +++ b/common/patches/sof.cpp @@ -71,7 +71,7 @@ namespace SoF { //create our opcode manager if we havent already if (opcodes == nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); //load up the opcode manager. //TODO: figure out how to support shared memory with multiple patches... opcodes = new RegularOpcodeManager(); @@ -110,7 +110,7 @@ namespace SoF //we need to go to every stream and replace it's manager. if (opcodes != nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); if (!opcodes->ReloadOpcodes(opfile.c_str())) { LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name); return; diff --git a/common/patches/titanium.cpp b/common/patches/titanium.cpp index c93b92581..4e7992089 100644 --- a/common/patches/titanium.cpp +++ b/common/patches/titanium.cpp @@ -73,7 +73,7 @@ namespace Titanium auto Config = EQEmuConfig::get(); //create our opcode manager if we havent already if (opcodes == nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); //load up the opcode manager. //TODO: figure out how to support shared memory with multiple patches... opcodes = new RegularOpcodeManager(); @@ -114,7 +114,7 @@ namespace Titanium //we need to go to every stream and replace it's manager. if (opcodes != nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); if (!opcodes->ReloadOpcodes(opfile.c_str())) { LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name); return; diff --git a/common/patches/uf.cpp b/common/patches/uf.cpp index 6433621f5..35452727b 100644 --- a/common/patches/uf.cpp +++ b/common/patches/uf.cpp @@ -76,7 +76,7 @@ namespace UF { //create our opcode manager if we havent already if (opcodes == nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); //load up the opcode manager. //TODO: figure out how to support shared memory with multiple patches... opcodes = new RegularOpcodeManager(); @@ -117,7 +117,7 @@ namespace UF //we need to go to every stream and replace it's manager. if (opcodes != nullptr) { - std::string opfile = fmt::format("{}/patch_{}.conf", PathManager::Instance()->GetPatchPath(), name); + std::string opfile = fmt::format("{}/patch_{}.conf", path.GetPatchPath(), name); if (!opcodes->ReloadOpcodes(opfile.c_str())) { LogNetcode("[OPCODES] Error reloading opcodes file [{}] for patch [{}]", opfile.c_str(), name); return; diff --git a/common/path_manager.cpp b/common/path_manager.cpp index c63835854..274d957c3 100644 --- a/common/path_manager.cpp +++ b/common/path_manager.cpp @@ -8,7 +8,7 @@ namespace fs = std::filesystem; -void PathManager::Init() +void PathManager::LoadPaths() { m_server_path = File::FindEqemuConfigPath(); @@ -48,23 +48,10 @@ void PathManager::Init() return dir; }; - auto load_many_paths_fallback = [&](const std::vector& dirs, const std::string& fallback, std::vector& target) { - target.clear(); - if (!dirs.empty()) { - for (const auto& path : dirs) { - target.push_back(resolve_path(path)); - } - } else { - target.push_back(resolve_path(fallback)); - } - }; - - load_many_paths_fallback(c->GetQuestDirectories(), c->QuestDir, m_quests_paths); - load_many_paths_fallback(c->GetPluginsDirectories(), c->PluginDir, m_plugin_paths); - load_many_paths_fallback(c->GetLuaModuleDirectories(), c->LuaModuleDir, m_lua_module_paths); - - // resolve all paths m_maps_path = resolve_path(c->MapDir, {"maps", "Maps"}); + m_quests_path = resolve_path(c->QuestDir); + m_plugins_path = resolve_path(c->PluginDir); + m_lua_modules_path = resolve_path(c->LuaModuleDir); m_lua_mods_path = resolve_path("mods"); m_patch_path = resolve_path(c->PatchDir); m_opcode_path = resolve_path(c->OpcodeDir); @@ -75,10 +62,13 @@ void PathManager::Init() std::vector> paths = { {"server", m_server_path}, {"logs", m_log_path}, - {"maps", m_maps_path}, {"lua mods", m_lua_mods_path}, + {"lua_modules", m_lua_modules_path}, + {"maps", m_maps_path}, {"patches", m_patch_path}, {"opcode", m_opcode_path}, + {"plugins", m_plugins_path}, + {"quests", m_quests_path}, {"shared_memory", m_shared_memory_path} }; @@ -93,17 +83,6 @@ void PathManager::Init() LogInfo("{:>{}} > [{:<{}}]", name, name_width, in_path, path_width); } } - - auto log_paths = [&](const std::string& label, const std::vector& paths) { - if (!paths.empty()) { - LogInfo("{:>{}} > [{:<{}}]", label, name_width - 1, Strings::Join(paths, ";"), path_width); - } - }; - - log_paths("quests", m_quests_paths); - log_paths("plugins", m_plugin_paths); - log_paths("lua_modules", m_lua_module_paths); - LogInfo("{}", Strings::Repeat("-", break_length)); } @@ -117,26 +96,21 @@ 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; } -std::vector PathManager::GetQuestPaths() const -{ - return m_quests_paths; -} - -std::vector PathManager::GetPluginPaths() const -{ - return m_plugin_paths; -} - -std::vector PathManager::GetLuaModulePaths() const -{ - return m_lua_module_paths; -} - const std::string &PathManager::GetLogPath() const { return m_log_path; @@ -152,7 +126,12 @@ const std::string &PathManager::GetOpcodePath() const return m_opcode_path; } +const std::string &PathManager::GetLuaModulesPath() const +{ + return m_lua_modules_path; +} + const std::string &PathManager::GetLuaModsPath() const { return m_lua_mods_path; -} +} \ No newline at end of file diff --git a/common/path_manager.h b/common/path_manager.h index 67919511e..431f3f202 100644 --- a/common/path_manager.h +++ b/common/path_manager.h @@ -3,17 +3,10 @@ #include -#include class PathManager { public: - void Init(); - - static PathManager *Instance() - { - static PathManager instance; - return &instance; - } + void LoadPaths(); [[nodiscard]] const std::string &GetLogPath() const; [[nodiscard]] const std::string &GetLuaModsPath() const; @@ -21,27 +14,24 @@ public: [[nodiscard]] const std::string &GetMapsPath() const; [[nodiscard]] const std::string &GetPatchPath() const; [[nodiscard]] const std::string &GetOpcodePath() 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; - [[nodiscard]] std::vector GetQuestPaths() const; - [[nodiscard]] std::vector GetPluginPaths() const; - [[nodiscard]] std::vector GetLuaModulePaths() const; private: - std::string m_log_path; - std::string m_lua_mods_path; - std::string m_maps_path; - std::string m_patch_path; - std::string m_opcode_path; - std::string m_quests_path; - std::vector m_quests_paths; - std::vector m_plugin_paths; - std::vector m_lua_module_paths; - - -private: - std::string m_server_path; - std::string m_shared_memory_path; + 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_opcode_path; + std::string m_plugins_path; + std::string m_quests_path; + std::string m_server_path; + std::string m_shared_memory_path; }; -#endif //EQEMU_PATH_MANAGER_H +extern PathManager path; + +#endif //EQEMU_PATH_MANAGER_H \ No newline at end of file diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 0ef0cbe4e..ba1175433 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -916,7 +916,7 @@ bool SharedDatabase::LoadItems(const std::string &prefix) { const auto Config = EQEmuConfig::get(); EQ::IPCMutex mutex("items"); mutex.Lock(); - std::string file_name = fmt::format("{}/{}{}", PathManager::Instance()->GetSharedMemoryPath(), prefix, std::string("items")); + std::string file_name = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("items")); items_mmf = std::make_unique(file_name); items_hash = std::make_unique>(static_cast(items_mmf->Get()), items_mmf->Size()); mutex.Unlock(); @@ -1650,7 +1650,7 @@ bool SharedDatabase::LoadSpells(const std::string &prefix, int32 *records, const EQ::IPCMutex mutex("spells"); mutex.Lock(); - std::string file_name = fmt::format("{}/{}{}", PathManager::Instance()->GetSharedMemoryPath(), prefix, std::string("spells")); + std::string file_name = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("spells")); spells_mmf = std::make_unique(file_name); LogInfo("Loading [{}]", file_name); *records = *static_cast(spells_mmf->Get()); @@ -1757,8 +1757,22 @@ void SharedDatabase::LoadSpells(void *data, int max_spells) { sp[tempid].environment_type=Strings::ToInt(row[102]); sp[tempid].time_of_day=Strings::ToInt(row[103]); - for(y=0; y < Class::PLAYER_CLASS_COUNT;y++) - sp[tempid].classes[y]=Strings::ToInt(row[104+y]); + sp[tempid].classes[1] = Strings::ToInt(row[104]); + sp[tempid].classes[2] = Strings::ToInt(row[105]); + sp[tempid].classes[3] = Strings::ToInt(row[106]); + sp[tempid].classes[4] = Strings::ToInt(row[107]); + sp[tempid].classes[5] = Strings::ToInt(row[108]); + sp[tempid].classes[6] = Strings::ToInt(row[109]); + sp[tempid].classes[7] = Strings::ToInt(row[110]); + sp[tempid].classes[8] = Strings::ToInt(row[111]); + sp[tempid].classes[9] = Strings::ToInt(row[112]); + sp[tempid].classes[10] = Strings::ToInt(row[113]); + sp[tempid].classes[11] = Strings::ToInt(row[114]); + sp[tempid].classes[12] = Strings::ToInt(row[115]); + sp[tempid].classes[13] = Strings::ToInt(row[116]); + sp[tempid].classes[14] = Strings::ToInt(row[117]); + sp[tempid].classes[15] = Strings::ToInt(row[118]); + sp[tempid].classes[16] = Strings::ToInt(row[119]); sp[tempid].casting_animation=Strings::ToInt(row[120]); sp[tempid].spell_affect_index=Strings::ToInt(row[123]); @@ -1838,6 +1852,7 @@ void SharedDatabase::LoadSpells(void *data, int max_spells) { sp[tempid].min_range = Strings::ToFloat(row[231]); sp[tempid].no_remove = Strings::ToBool(row[232]); sp[tempid].damage_shield_type = 0; + sp[tempid].class17 = Strings::ToInt(row[237]); } LoadDamageShieldTypes(sp); diff --git a/eqlaunch/eqlaunch.cpp b/eqlaunch/eqlaunch.cpp index edc50aea7..59fbe6071 100644 --- a/eqlaunch/eqlaunch.cpp +++ b/eqlaunch/eqlaunch.cpp @@ -33,6 +33,9 @@ #include #include +EQEmuLogSys LogSys; +PathManager path; + bool RunLoops = false; void CatchSignal(int sig_num); @@ -42,7 +45,7 @@ int main(int argc, char *argv[]) { EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); set_exception_handler(); - PathManager::Instance()->Init(); + path.LoadPaths(); std::string launcher_name; if(argc == 2) { diff --git a/loginserver/client_manager.cpp b/loginserver/client_manager.cpp index 5767f538b..19828488d 100644 --- a/loginserver/client_manager.cpp +++ b/loginserver/client_manager.cpp @@ -8,6 +8,8 @@ extern bool run_server; #include "../common/path_manager.h" #include "../common/file.h" +PathManager path; + void CheckTitaniumOpcodeFile(const std::string &path) { if (File::Exists(path)) { @@ -94,7 +96,7 @@ ClientManager::ClientManager() std::string opcodes_path = fmt::format( "{}/{}", - PathManager::Instance()->GetOpcodePath(), + path.GetOpcodePath(), "login_opcodes.conf" ); @@ -131,7 +133,7 @@ ClientManager::ClientManager() opcodes_path = fmt::format( "{}/{}", - PathManager::Instance()->GetOpcodePath(), + path.GetOpcodePath(), "login_opcodes_sod.conf" ); @@ -169,7 +171,7 @@ ClientManager::ClientManager() opcodes_path = fmt::format( "{}/{}", - PathManager::Instance()->GetOpcodePath(), + path.GetOpcodePath(), "login_opcodes_larion.conf" ); diff --git a/loginserver/main.cpp b/loginserver/main.cpp index 9047db8c8..2fff600c5 100644 --- a/loginserver/main.cpp +++ b/loginserver/main.cpp @@ -48,7 +48,7 @@ void LoadDatabaseConnection() void LoadServerConfig() { server.config = EQ::JsonConfigFile::Load( - fmt::format("{}/login.json", PathManager::Instance()->GetServerPath()) + fmt::format("{}/login.json", path.GetServerPath()) ); LogInfo("Config System Init"); @@ -158,7 +158,7 @@ int main(int argc, char **argv) EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); } - PathManager::Instance()->Init(); + path.LoadPaths(); // command handler if (argc > 1) { diff --git a/queryserv/queryserv.cpp b/queryserv/queryserv.cpp index b6bf21a71..4264612ab 100644 --- a/queryserv/queryserv.cpp +++ b/queryserv/queryserv.cpp @@ -20,15 +20,23 @@ #include "../common/net/console_server.h" #include "../queryserv/zonelist.h" #include "../queryserv/zoneserver.h" +#include "../common/discord/discord_manager.h" volatile bool RunLoops = true; QSDatabase qs_database; Database database; +LFGuildManager lfguildmanager; std::string WorldShortName; const queryservconfig *Config; WorldServer *worldserver = 0; +EQEmuLogSys LogSys; +PathManager path; +ZoneStore zone_store; +PlayerEventLogs player_event_logs; +ZSList zs_list; uint32 numzones = 0; +DiscordManager discord_manager; void CatchSignal(int sig_num) { @@ -42,7 +50,7 @@ int main() set_exception_handler(); Timer LFGuildExpireTimer(60000); - PathManager::Instance()->Init(); + path.LoadPaths(); LogInfo("Starting EQEmu QueryServ"); if (!queryservconfig::LoadConfig()) { @@ -78,7 +86,7 @@ int main() } EQEmuLogSys::Instance()->SetDatabase(&database) - ->SetLogPath(PathManager::Instance()->GetLogPath()) + ->SetLogPath(path.GetLogPath()) ->LoadLogDatabaseSettings() ->StartFileLogs(); diff --git a/shared_memory/main.cpp b/shared_memory/main.cpp index d29bd31e4..e36cf0fd9 100644 --- a/shared_memory/main.cpp +++ b/shared_memory/main.cpp @@ -35,6 +35,13 @@ #include "../common/events/player_event_logs.h" #include "../common/evolving_items.h" +EQEmuLogSys LogSys; +WorldContentService content_service; +ZoneStore zone_store; +PathManager path; +PlayerEventLogs player_event_logs; +EvolvingItemsManager evolving_items_manager; + #ifdef _WINDOWS #include #else @@ -77,7 +84,7 @@ int main(int argc, char **argv) EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); set_exception_handler(); - PathManager::Instance()->Init(); + path.LoadPaths(); LogInfo("Shared Memory Loader Program"); if (!EQEmuConfig::LoadConfig()) { @@ -120,7 +127,7 @@ int main(int argc, char **argv) } EQEmuLogSys::Instance()->SetDatabase(&database) - ->SetLogPath(PathManager::Instance()->GetLogPath()) + ->SetLogPath(path.GetLogPath()) ->LoadLogDatabaseSettings() ->StartFileLogs(); diff --git a/tests/main.cpp b/tests/main.cpp index 9c9af40c9..892dcdae3 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -34,12 +34,14 @@ #include "task_state_test.h" const EQEmuConfig *Config; +EQEmuLogSys LogSys; +PathManager path; int main() { RegisterExecutablePlatform(ExePlatformClientImport); EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); - PathManager::Instance()->Init(); + path.LoadPaths(); auto ConfigLoadResult = EQEmuConfig::LoadConfig(); Config = EQEmuConfig::get(); @@ -63,4 +65,4 @@ int main() return -1; } return 0; -} +} \ No newline at end of file diff --git a/ucs/clientlist.cpp b/ucs/clientlist.cpp index 749b9276f..8865d0184 100644 --- a/ucs/clientlist.cpp +++ b/ucs/clientlist.cpp @@ -42,6 +42,8 @@ extern Clientlist *g_Clientlist; extern uint32 ChatMessagesSent; extern uint32 MailMessagesSent; +PathManager path; + int LookupCommand(const char *ChatCommand) { if (!ChatCommand) return -1; @@ -482,7 +484,7 @@ Clientlist::Clientlist(int ChatPort) { const ucsconfig *Config = ucsconfig::get(); - std::string opcodes_file = fmt::format("{}/{}", PathManager::Instance()->GetServerPath(), Config->MailOpCodesFile); + std::string opcodes_file = fmt::format("{}/{}", path.GetServerPath(), Config->MailOpCodesFile); LogInfo("Loading [{}]", opcodes_file); if (!ChatOpMgr->LoadOpcodes(opcodes_file.c_str())) diff --git a/ucs/ucs.cpp b/ucs/ucs.cpp index f74bb79c1..7f1b14071 100644 --- a/ucs/ucs.cpp +++ b/ucs/ucs.cpp @@ -102,7 +102,7 @@ int main() { EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); set_exception_handler(); - PathManager::Instance()->Init(); + path.LoadPaths(); // Check every minute for unused channels we can delete // @@ -136,7 +136,7 @@ int main() { EQEmuLogSys::Instance() ->SetDatabase(&database) - ->SetLogPath(PathManager::Instance()->GetLogPath()) + ->SetLogPath(path.GetLogPath()) ->LoadLogDatabaseSettings() ->StartFileLogs(); diff --git a/world/main.cpp b/world/main.cpp index c9386128e..bdb5c67ba 100644 --- a/world/main.cpp +++ b/world/main.cpp @@ -91,12 +91,29 @@ #include "../common/repositories/character_parcels_repository.h" #include "../common/ip_util.h" +SkillCaps skill_caps; +ZoneStore zone_store; +ClientList client_list; GroupLFPList LFPGroupList; +ZSList zoneserver_list; +LoginServerList loginserverlist; +UCSConnection UCSLink; +QueryServConnection QSLink; LauncherList launcher_list; +AdventureManager adventure_manager; +WorldEventScheduler event_scheduler; +SharedTaskManager shared_task_manager; +EQ::Random emu_random; volatile bool RunLoops = true; uint32 numclients = 0; uint32 numzones = 0; const WorldConfig *Config; +EQEmuLogSys LogSys; +WorldContentService content_service; +WebInterfaceList web_interface; +PathManager path; +PlayerEventLogs player_event_logs; +EvolvingItemsManager evolving_items_manager; void CatchSignal(int sig_num); @@ -125,7 +142,7 @@ int main(int argc, char **argv) return 0; } - PathManager::Instance()->Init(); + path.LoadPaths(); if (!WorldBoot::LoadServerConfig()) { return 0; diff --git a/world/world_boot.cpp b/world/world_boot.cpp index 19667927c..dbf40bddc 100644 --- a/world/world_boot.cpp +++ b/world/world_boot.cpp @@ -83,7 +83,7 @@ bool WorldBoot::HandleCommandInput(int argc, char **argv) // command handler if (argc > 1) { EQEmuLogSys::Instance()->SilenceConsoleLogging(); - PathManager::Instance()->Init(); + path.LoadPaths(); WorldConfig::LoadConfig(); LoadDatabaseConnections(); RuleManager::Instance()->LoadRules(&database, "default", false); @@ -227,7 +227,7 @@ bool WorldBoot::DatabaseLoadRoutines(int argc, char **argv) { // logging system init auto logging = EQEmuLogSys::Instance()->SetDatabase(&database) - ->SetLogPath(PathManager::Instance()->GetLogPath()) + ->SetLogPath(path.GetLogPath()) ->LoadLogDatabaseSettings(); EQEmuLogSys::Instance()->SetDiscordHandler(&WorldBoot::DiscordWebhookMessageHandler); diff --git a/zone/embperl.cpp b/zone/embperl.cpp index b48c714e3..21a82f111 100644 --- a/zone/embperl.cpp +++ b/zone/embperl.cpp @@ -137,28 +137,25 @@ void Embperl::DoInit() catch (std::string& e) { LogQuests("Warning [{}]: [{}]", Config->PluginPlFile, e); } - - for (auto & dir : PathManager::Instance()->GetPluginPaths()) { - try { - //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 - const std::string& perl_command = ( - "if(opendir(D,'" + - dir + - "')) { " - " my @d = readdir(D);" - " closedir(D);" - " foreach(@d){ " - " main::eval_file('plugin','" + - dir + - "/'.$_)if/\\.pl$/;" - " }" - "}"); - eval_pv(perl_command.c_str(), FALSE); - } - catch (std::string& e) { - LogQuests("Warning [{}]", e); - } + try { + //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 + const std::string& perl_command = ( + "if(opendir(D,'" + + path.GetPluginsPath() + + "')) { " + " my @d = readdir(D);" + " closedir(D);" + " foreach(@d){ " + " main::eval_file('plugin','" + + path.GetPluginsPath() + + "/'.$_)if/\\.pl$/;" + " }" + "}"); + eval_pv(perl_command.c_str(), FALSE); + } + catch (std::string& e) { + LogQuests("Warning [{}]", e); } #endif //EMBPERL_PLUGIN } diff --git a/zone/lua_parser.cpp b/zone/lua_parser.cpp index 3e3a5257f..1fca39fe2 100644 --- a/zone/lua_parser.cpp +++ b/zone/lua_parser.cpp @@ -1127,7 +1127,7 @@ void LuaParser::ReloadQuests() { std::string module_path = lua_tostring(L, -1); lua_pop(L, 1); - for (const auto& dir : PathManager::Instance()->GetLuaModulePaths()) { + for (const auto& dir : path.GetLuaModulesPath()) { module_path += fmt::format(";{}/?.lua", dir); module_path += fmt::format(";{}/?/init.lua", dir); module_path += fmt::format(";{}/share/lua/{}/?.lua", dir, lua_version); @@ -1143,7 +1143,7 @@ void LuaParser::ReloadQuests() { module_path = lua_tostring(L, -1); lua_pop(L, 1); - for (const auto& dir : PathManager::Instance()->GetLuaModulePaths()) { + for (const auto& dir : path.GetLuaModulesPath()) { module_path += fmt::format(";{}/?{}", dir, libext); module_path += fmt::format(";{}/lib/lua/{}/?{}", dir, lua_version, libext); } @@ -1155,7 +1155,7 @@ void LuaParser::ReloadQuests() { MapFunctions(L); // load init - for (auto& dir : PathManager::Instance()->GetQuestPaths()) { + for (auto& dir : path.GetQuestsPath()) { std::string filename = fmt::format("{}/{}/script_init.lua", dir, QUEST_GLOBAL_DIRECTORY); FILE* f = fopen(filename.c_str(), "r"); @@ -1171,7 +1171,7 @@ void LuaParser::ReloadQuests() { //zone init - always loads after global if (zone) { - for (auto& dir : PathManager::Instance()->GetQuestPaths()) { + for (auto& dir : path.GetQuestsPath()) { std::string zone_script = fmt::format( "{}/{}/script_init_v{}.lua", dir, @@ -1204,7 +1204,7 @@ void LuaParser::ReloadQuests() { } } - FILE *load_order = fopen(fmt::format("{}/load_order.txt", PathManager::Instance()->GetLuaModsPath()).c_str(), "r"); + FILE *load_order = fopen(fmt::format("{}/load_order.txt", path.GetLuaModsPath()).c_str(), "r"); if (load_order) { char file_name[256] = { 0 }; while (fgets(file_name, 256, load_order) != nullptr) { @@ -1216,7 +1216,7 @@ void LuaParser::ReloadQuests() { } } - LoadScript(fmt::format("{}/{}", PathManager::Instance()->GetLuaModsPath(), std::string(file_name)), file_name); + LoadScript(fmt::format("{}/{}", path.GetLuaModsPath(), std::string(file_name)), file_name); mods_.emplace_back(L, this, file_name); } diff --git a/zone/main.cpp b/zone/main.cpp index 4f5916078..5f4328a06 100644 --- a/zone/main.cpp +++ b/zone/main.cpp @@ -88,10 +88,12 @@ extern volatile bool is_zone_loaded; #include "../common/path_manager.h" #include "../common/database/database_update.h" #include "../common/skill_caps.h" +#include "zone_event_scheduler.h" #include "zone_cli.h" EntityList entity_list; WorldServer worldserver; +ZoneStore zone_store; uint32 numclients = 0; char errorname[32]; extern Zone *zone; @@ -99,8 +101,17 @@ extern Zone *zone; npcDecayTimes_Struct npcCorpseDecayTimes[100]; TitleManager title_manager; QueryServ *QServ = 0; +TaskManager *taskmanager = 0; NpcScaleManager *npc_scale_manager; QuestParserCollection *parse = 0; +EQEmuLogSys LogSys; +ZoneEventScheduler event_scheduler; +WorldContentService content_service; +PathManager path; +PlayerEventLogs player_event_logs; +DatabaseUpdate database_update; +SkillCaps skill_caps; +EvolvingItemsManager evolving_items_manager; const SPDat_Spell_Struct* spells; int32 SPDAT_RECORDS = -1; @@ -126,7 +137,7 @@ int main(int argc, char **argv) EQEmuLogSys::Instance()->SilenceConsoleLogging(); } - PathManager::Instance()->Init(); + path.LoadPaths(); #ifdef USE_MAP_MMFS if (argc == 3 && strcasecmp(argv[1], "convert_map") == 0) { @@ -293,8 +304,8 @@ int main(int argc, char **argv) ZoneCLI::CommandHandler(argc, argv); } - EQEmuLogSys::Instance()->SetDatabase(&database) - ->SetLogPath(PathManager::Instance()->GetLogPath()) + LogSys.SetDatabase(&database) + ->SetLogPath(path.GetLogPath()) ->LoadLogDatabaseSettings(ZoneCLI::RanTestCommand(argc, argv)) ->SetGMSayHandler(&Zone::GMSayHookCallBackProcess) ->StartFileLogs(); @@ -732,7 +743,7 @@ bool CheckForCompatibleQuestPlugins() { const std::vector> directories = { {"lua_modules", nullptr}, - {"plugins", nullptr} + {"plugins", nullptr} }; bool lua_found = false; @@ -740,7 +751,15 @@ bool CheckForCompatibleQuestPlugins() try { for (const auto &[directory, flag]: directories) { - std::string dir_path = PathManager::Instance()->GetServerPath() + "/" + directory; + + auto dir_path = path.GetLuaModulesPath(); + if (directory == "plugins") { + dir_path = path.GetPluginsPath(); + } + if (dir_path == "") { + dir_path = path.GetServerPath() + "/" + directory; + } + if (!File::Exists(dir_path)) { continue; } for (const auto &file: fs::directory_iterator(dir_path)) { diff --git a/zone/map.cpp b/zone/map.cpp index bf6ff68ec..7e3d8822c 100644 --- a/zone/map.cpp +++ b/zone/map.cpp @@ -271,7 +271,7 @@ bool Map::DoCollisionCheck(glm::vec3 myloc, glm::vec3 oloc, glm::vec3 &outnorm, Map *Map::LoadMapFile(std::string file) { std::transform(file.begin(), file.end(), file.begin(), ::tolower); - std::string filename = fmt::format("{}/base/{}.map", PathManager::Instance()->GetMapsPath(), file); + std::string filename = fmt::format("{}/base/{}.map", path.GetMapsPath(), file); LogInfo("Attempting to load Map File [{}]", filename.c_str()); diff --git a/zone/pathfinder_interface.cpp b/zone/pathfinder_interface.cpp index e6aef0cd9..74209703c 100644 --- a/zone/pathfinder_interface.cpp +++ b/zone/pathfinder_interface.cpp @@ -7,7 +7,7 @@ IPathfinder *IPathfinder::Load(const std::string &zone) { struct stat statbuffer; - std::string navmesh_path = fmt::format("{}/maps/nav/{}.nav", PathManager::Instance()->GetServerPath(), zone); + std::string navmesh_path = fmt::format("{}/maps/nav/{}.nav", path.GetServerPath(), zone); if (stat(navmesh_path.c_str(), &statbuffer) == 0) { return new PathfinderNavmesh(navmesh_path); } diff --git a/zone/quest_parser_collection.cpp b/zone/quest_parser_collection.cpp index 9535cb89a..b453a3efc 100644 --- a/zone/quest_parser_collection.cpp +++ b/zone/quest_parser_collection.cpp @@ -1064,7 +1064,7 @@ QuestInterface* QuestParserCollection::GetQIByNPCQuest(uint32 npc_id, std::strin Strings::FindReplace(npc_name, "`", "-"); - for (auto & dir : PathManager::Instance()->GetQuestPaths()) { + for (auto & dir : path.GetQuestsPath()) { const std::string& npc_id_and_name = fmt::format( "{}_{}", npc_name, @@ -1132,7 +1132,7 @@ QuestInterface* QuestParserCollection::GetQIByPlayerQuest(std::string& filename) return nullptr; } - for (auto & dir : PathManager::Instance()->GetQuestPaths()) { + for (auto & dir : path.GetQuestsPath()) { const std::string& global_path = fmt::format( "{}/{}", dir, @@ -1187,7 +1187,7 @@ QuestInterface* QuestParserCollection::GetQIByGlobalNPCQuest(std::string& filena std::string file_name; - for (auto & dir : PathManager::Instance()->GetQuestPaths()) { + for (auto & dir : path.GetQuestsPath()) { for (auto* e: _load_precedence) { file_name = fmt::format( "{}/{}/global_npc.{}", @@ -1213,7 +1213,7 @@ QuestInterface* QuestParserCollection::GetQIByGlobalPlayerQuest(std::string& fil } std::string file_name; - for (auto & dir : PathManager::Instance()->GetQuestPaths()) { + for (auto & dir : path.GetQuestsPath()) { for (auto* e: _load_precedence) { file_name = fmt::format( "{}/{}/global_player.{}", @@ -1238,7 +1238,7 @@ QuestInterface* QuestParserCollection::GetQIBySpellQuest(uint32 spell_id, std::s return nullptr; } - for (auto & dir : PathManager::Instance()->GetQuestPaths()) { + for (auto & dir : path.GetQuestsPath()) { const std::string& global_path = fmt::format( "{}/{}/spells", dir, @@ -1292,7 +1292,7 @@ QuestInterface* QuestParserCollection::GetQIByItemQuest(std::string item_script, return nullptr; } - for (auto & dir : PathManager::Instance()->GetQuestPaths()) { + for (auto & dir : path.GetQuestsPath()) { const std::string& global_path = fmt::format( "{}/{}/items", dir, @@ -1346,7 +1346,7 @@ QuestInterface* QuestParserCollection::GetQIByEncounterQuest(std::string encount return nullptr; } - for (auto & dir : PathManager::Instance()->GetQuestPaths()) { + for (auto & dir : path.GetQuestsPath()) { const std::string& global_path = fmt::format( "{}/{}/encounters", dir, @@ -1398,7 +1398,7 @@ QuestInterface* QuestParserCollection::GetQIByBotQuest(std::string& filename) return nullptr; } - for (auto & dir : PathManager::Instance()->GetQuestPaths()) { + for (auto & dir : path.GetQuestsPath()) { const std::string& global_path = fmt::format( "{}/{}", dir, @@ -1452,7 +1452,7 @@ QuestInterface* QuestParserCollection::GetQIByGlobalBotQuest(std::string& filena } std::string file_name; - for (auto & dir : PathManager::Instance()->GetQuestPaths()) { + for (auto & dir : path.GetQuestsPath()) { for (auto* e: _load_precedence) { file_name = fmt::format( "{}/{}/global_bot.{}", @@ -1477,7 +1477,7 @@ QuestInterface* QuestParserCollection::GetQIByMercQuest(std::string& filename) return nullptr; } - for (auto & dir : PathManager::Instance()->GetQuestPaths()) { + for (auto & dir : path.GetQuestsPath()) { const std::string& global_path = fmt::format( "{}/{}", dir, @@ -1531,7 +1531,7 @@ QuestInterface* QuestParserCollection::GetQIByGlobalMercQuest(std::string& filen } std::string file_name; - for (auto & dir : PathManager::Instance()->GetQuestPaths()) { + for (auto & dir : path.GetQuestsPath()) { for (auto* e: _load_precedence) { file_name = fmt::format( "{}/{}/global_merc.{}", @@ -1557,7 +1557,7 @@ QuestInterface* QuestParserCollection::GetQIByZoneQuest(std::string& filename) } std::string file_name; - for (auto& dir: PathManager::Instance()->GetQuestPaths()) { + for (auto& dir: path.GetQuestsPath()) { const std::string& global_path = fmt::format( "{}/{}", dir, @@ -1611,7 +1611,7 @@ QuestInterface* QuestParserCollection::GetQIByGlobalZoneQuest(std::string& filen std::string file_name; - for (auto& dir: PathManager::Instance()->GetQuestPaths()) { + for (auto& dir: path.GetQuestsPath()) { for (auto* e: _load_precedence) { file_name = fmt::format( "{}/{}/global_zone.{}", diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 342955fff..b64d31bb4 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -198,7 +198,7 @@ void QuestManager::summonitem(uint32 itemid, int16 charges) { void QuestManager::write(const char *file, const char *str) { FILE * pFile; - pFile = fopen (fmt::format("{}/{}", PathManager::Instance()->GetServerPath(), file).c_str(), "a"); + pFile = fopen (fmt::format("{}/{}", path.GetServerPath(), file).c_str(), "a"); if(!pFile) return; fprintf(pFile, "%s\n", str); @@ -1352,7 +1352,6 @@ void QuestManager::permaclass(int class_id) { initiator->SetBaseClass(class_id); initiator->Save(2); - initiator->Kick("Base class change by QuestManager"); } void QuestManager::permarace(int race_id) { @@ -1364,7 +1363,6 @@ void QuestManager::permarace(int race_id) { initiator->SetBaseRace(race_id); initiator->Save(2); - initiator->Kick("Base race change by QuestManager"); } void QuestManager::permagender(int gender_id) { @@ -1376,7 +1374,6 @@ void QuestManager::permagender(int gender_id) { initiator->SetBaseGender(gender_id); initiator->Save(2); - initiator->Kick("Base gender change by QuestManager"); } uint16 QuestManager::scribespells(uint8 max_level, uint8 min_level) { diff --git a/zone/water_map.cpp b/zone/water_map.cpp index e31bb0c75..27289abd6 100644 --- a/zone/water_map.cpp +++ b/zone/water_map.cpp @@ -17,7 +17,7 @@ WaterMap* WaterMap::LoadWaterMapfile(std::string zone_name) { std::transform(zone_name.begin(), zone_name.end(), zone_name.begin(), ::tolower); - std::string file_path = fmt::format("{}/water/{}.wtr", PathManager::Instance()->GetMapsPath(), zone_name); + std::string file_path = fmt::format("{}/water/{}.wtr", path.GetMapsPath(), zone_name); LogDebug("Attempting to load water map with path [{}]", file_path.c_str()); FILE *f = fopen(file_path.c_str(), "rb"); if(f) {