[Code] PathManager Global to Singleton Cleanup

This commit is contained in:
Chris Miles
2025-06-20 19:38:11 -05:00
parent 1be7e56b86
commit 4e721237c4
33 changed files with 83 additions and 89 deletions
+1 -1
View File
@@ -138,7 +138,7 @@ void Embperl::DoInit()
LogQuests("Warning [{}]: [{}]", Config->PluginPlFile, e);
}
for (auto & dir : path.GetPluginPaths()) {
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
+6 -6
View File
@@ -1070,7 +1070,7 @@ void LuaParser::ReloadQuests() {
std::string module_path = lua_tostring(L, -1);
lua_pop(L, 1);
for (const auto& dir : path.GetLuaModulePaths()) {
for (const auto& dir : PathManager::Instance()->GetLuaModulePaths()) {
module_path += fmt::format(";{}/?.lua", dir);
module_path += fmt::format(";{}/?/init.lua", dir);
module_path += fmt::format(";{}/share/lua/{}/?.lua", dir, lua_version);
@@ -1086,7 +1086,7 @@ void LuaParser::ReloadQuests() {
module_path = lua_tostring(L, -1);
lua_pop(L, 1);
for (const auto& dir : path.GetLuaModulePaths()) {
for (const auto& dir : PathManager::Instance()->GetLuaModulePaths()) {
module_path += fmt::format(";{}/?{}", dir, libext);
module_path += fmt::format(";{}/lib/lua/{}/?{}", dir, lua_version, libext);
}
@@ -1098,7 +1098,7 @@ void LuaParser::ReloadQuests() {
MapFunctions(L);
// load init
for (auto& dir : path.GetQuestPaths()) {
for (auto& dir : PathManager::Instance()->GetQuestPaths()) {
std::string filename = fmt::format("{}/{}/script_init.lua", dir, QUEST_GLOBAL_DIRECTORY);
FILE* f = fopen(filename.c_str(), "r");
@@ -1114,7 +1114,7 @@ void LuaParser::ReloadQuests() {
//zone init - always loads after global
if (zone) {
for (auto& dir : path.GetQuestPaths()) {
for (auto& dir : PathManager::Instance()->GetQuestPaths()) {
std::string zone_script = fmt::format(
"{}/{}/script_init_v{}.lua",
dir,
@@ -1147,7 +1147,7 @@ void LuaParser::ReloadQuests() {
}
}
FILE *load_order = fopen(fmt::format("{}/load_order.txt", path.GetLuaModsPath()).c_str(), "r");
FILE *load_order = fopen(fmt::format("{}/load_order.txt", PathManager::Instance()->GetLuaModsPath()).c_str(), "r");
if (load_order) {
char file_name[256] = { 0 };
while (fgets(file_name, 256, load_order) != nullptr) {
@@ -1159,7 +1159,7 @@ void LuaParser::ReloadQuests() {
}
}
LoadScript(fmt::format("{}/{}", path.GetLuaModsPath(), std::string(file_name)), file_name);
LoadScript(fmt::format("{}/{}", PathManager::Instance()->GetLuaModsPath(), std::string(file_name)), file_name);
mods_.emplace_back(L, this, file_name);
}
+3 -4
View File
@@ -107,7 +107,6 @@ QuestParserCollection *parse = 0;
EQEmuLogSys LogSys;
ZoneEventScheduler event_scheduler;
WorldContentService content_service;
PathManager path;
PlayerEventLogs player_event_logs;
DatabaseUpdate database_update;
SkillCaps skill_caps;
@@ -137,7 +136,7 @@ int main(int argc, char **argv)
LogSys.SilenceConsoleLogging();
}
path.LoadPaths();
PathManager::Instance()->Init();
#ifdef USE_MAP_MMFS
if (argc == 3 && strcasecmp(argv[1], "convert_map") == 0) {
@@ -305,7 +304,7 @@ int main(int argc, char **argv)
}
LogSys.SetDatabase(&database)
->SetLogPath(path.GetLogPath())
->SetLogPath(PathManager::Instance()->GetLogPath())
->LoadLogDatabaseSettings(ZoneCLI::RanTestCommand(argc, argv))
->SetGMSayHandler(&Zone::GMSayHookCallBackProcess)
->StartFileLogs();
@@ -752,7 +751,7 @@ bool CheckForCompatibleQuestPlugins()
try {
for (const auto &[directory, flag]: directories) {
std::string dir_path = path.GetServerPath() + "/" + directory;
std::string dir_path = PathManager::Instance()->GetServerPath() + "/" + directory;
if (!File::Exists(dir_path)) { continue; }
for (const auto &file: fs::directory_iterator(dir_path)) {
+1 -1
View File
@@ -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", path.GetMapsPath(), file);
std::string filename = fmt::format("{}/base/{}.map", PathManager::Instance()->GetMapsPath(), file);
LogInfo("Attempting to load Map File [{}]", filename.c_str());
+1 -1
View File
@@ -7,7 +7,7 @@
IPathfinder *IPathfinder::Load(const std::string &zone) {
struct stat statbuffer;
std::string navmesh_path = fmt::format("{}/maps/nav/{}.nav", path.GetServerPath(), zone);
std::string navmesh_path = fmt::format("{}/maps/nav/{}.nav", PathManager::Instance()->GetServerPath(), zone);
if (stat(navmesh_path.c_str(), &statbuffer) == 0) {
return new PathfinderNavmesh(navmesh_path);
}
+11 -11
View File
@@ -939,7 +939,7 @@ QuestInterface* QuestParserCollection::GetQIByNPCQuest(uint32 npc_id, std::strin
Strings::FindReplace(npc_name, "`", "-");
for (auto & dir : path.GetQuestPaths()) {
for (auto & dir : PathManager::Instance()->GetQuestPaths()) {
const std::string& npc_id_and_name = fmt::format(
"{}_{}",
npc_name,
@@ -1007,7 +1007,7 @@ QuestInterface* QuestParserCollection::GetQIByPlayerQuest(std::string& filename)
return nullptr;
}
for (auto & dir : path.GetQuestPaths()) {
for (auto & dir : PathManager::Instance()->GetQuestPaths()) {
const std::string& global_path = fmt::format(
"{}/{}",
dir,
@@ -1062,7 +1062,7 @@ QuestInterface* QuestParserCollection::GetQIByGlobalNPCQuest(std::string& filena
std::string file_name;
for (auto & dir : path.GetQuestPaths()) {
for (auto & dir : PathManager::Instance()->GetQuestPaths()) {
for (auto* e: _load_precedence) {
file_name = fmt::format(
"{}/{}/global_npc.{}",
@@ -1088,7 +1088,7 @@ QuestInterface* QuestParserCollection::GetQIByGlobalPlayerQuest(std::string& fil
}
std::string file_name;
for (auto & dir : path.GetQuestPaths()) {
for (auto & dir : PathManager::Instance()->GetQuestPaths()) {
for (auto* e: _load_precedence) {
file_name = fmt::format(
"{}/{}/global_player.{}",
@@ -1113,7 +1113,7 @@ QuestInterface* QuestParserCollection::GetQIBySpellQuest(uint32 spell_id, std::s
return nullptr;
}
for (auto & dir : path.GetQuestPaths()) {
for (auto & dir : PathManager::Instance()->GetQuestPaths()) {
const std::string& global_path = fmt::format(
"{}/{}/spells",
dir,
@@ -1167,7 +1167,7 @@ QuestInterface* QuestParserCollection::GetQIByItemQuest(std::string item_script,
return nullptr;
}
for (auto & dir : path.GetQuestPaths()) {
for (auto & dir : PathManager::Instance()->GetQuestPaths()) {
const std::string& global_path = fmt::format(
"{}/{}/items",
dir,
@@ -1221,7 +1221,7 @@ QuestInterface* QuestParserCollection::GetQIByEncounterQuest(std::string encount
return nullptr;
}
for (auto & dir : path.GetQuestPaths()) {
for (auto & dir : PathManager::Instance()->GetQuestPaths()) {
const std::string& global_path = fmt::format(
"{}/{}/encounters",
dir,
@@ -1273,7 +1273,7 @@ QuestInterface* QuestParserCollection::GetQIByBotQuest(std::string& filename)
return nullptr;
}
for (auto & dir : path.GetQuestPaths()) {
for (auto & dir : PathManager::Instance()->GetQuestPaths()) {
const std::string& global_path = fmt::format(
"{}/{}",
dir,
@@ -1327,7 +1327,7 @@ QuestInterface* QuestParserCollection::GetQIByGlobalBotQuest(std::string& filena
}
std::string file_name;
for (auto & dir : path.GetQuestPaths()) {
for (auto & dir : PathManager::Instance()->GetQuestPaths()) {
for (auto* e: _load_precedence) {
file_name = fmt::format(
"{}/{}/global_bot.{}",
@@ -1352,7 +1352,7 @@ QuestInterface* QuestParserCollection::GetQIByMercQuest(std::string& filename)
return nullptr;
}
for (auto & dir : path.GetQuestPaths()) {
for (auto & dir : PathManager::Instance()->GetQuestPaths()) {
const std::string& global_path = fmt::format(
"{}/{}",
dir,
@@ -1406,7 +1406,7 @@ QuestInterface* QuestParserCollection::GetQIByGlobalMercQuest(std::string& filen
}
std::string file_name;
for (auto & dir : path.GetQuestPaths()) {
for (auto & dir : PathManager::Instance()->GetQuestPaths()) {
for (auto* e: _load_precedence) {
file_name = fmt::format(
"{}/{}/global_merc.{}",
+1 -1
View File
@@ -200,7 +200,7 @@ void QuestManager::summonitem(uint32 itemid, int16 charges) {
void QuestManager::write(const char *file, const char *str) {
FILE * pFile;
pFile = fopen (fmt::format("{}/{}", path.GetServerPath(), file).c_str(), "a");
pFile = fopen (fmt::format("{}/{}", PathManager::Instance()->GetServerPath(), file).c_str(), "a");
if(!pFile)
return;
fprintf(pFile, "%s\n", str);
+1 -1
View File
@@ -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", path.GetMapsPath(), zone_name);
std::string file_path = fmt::format("{}/water/{}.wtr", PathManager::Instance()->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) {