[Code] PathManager Global to Singleton Cleanup (#4924)

This commit is contained in:
Chris Miles
2025-06-22 12:50:52 -05:00
committed by GitHub
parent e846bb86b6
commit df86ad371b
33 changed files with 83 additions and 89 deletions
+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);
}