mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-19 04:28:22 +00:00
PathManager refactor, fixes "CheckinHandle"
This commit is contained in:
+19
-22
@@ -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
|
||||
}
|
||||
|
||||
+6
-6
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+24
-5
@@ -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<std::pair<std::string, bool *>> 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)) {
|
||||
|
||||
+1
-1
@@ -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());
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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.{}",
|
||||
|
||||
+1
-4
@@ -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) {
|
||||
|
||||
+1
-1
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user