From 34ffb5b90827cf907c90e4a84b0c158a3f9ff847 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Thu, 10 Nov 2016 12:00:44 -0600 Subject: [PATCH] Create shared_memory directory from the config file if it doesn't exist on launch of shared_memory.exe --- common/emu_legacy.h | 1 + shared_memory/main.cpp | 38 ++++++++++++++++++++++++++++++++++++++ zone/map.cpp | 6 +++--- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/common/emu_legacy.h b/common/emu_legacy.h index b70d7143c..a624be883 100644 --- a/common/emu_legacy.h +++ b/common/emu_legacy.h @@ -176,6 +176,7 @@ namespace EQEmu static const size_t TEXT_LINK_BODY_LENGTH = 56; } + } #endif /* COMMON_EMU_LEGACY_H */ diff --git a/shared_memory/main.cpp b/shared_memory/main.cpp index 79824251f..8f9ad4255 100644 --- a/shared_memory/main.cpp +++ b/shared_memory/main.cpp @@ -36,6 +36,39 @@ EQEmuLogSys Log; +#ifdef _WINDOWS +#include +#else +#include +#include +#endif + +inline bool MakeDirectory(const std::string &directory_name) +{ +#ifdef _WINDOWS + struct _stat st; + if (_stat(directory_name.c_str(), &st) == 0) { + return false; + } + else { + _mkdir(directory_name.c_str()); + return true; + } + +#else + struct stat st; + if (stat(directory_name.c_str(), &st) == 0) { + return false; + } + else { + mkdir(directory_name.c_str(), 0755); + return true; + } + +#endif + return false; +} + int main(int argc, char **argv) { RegisterExecutablePlatform(ExePlatformSharedMemory); Log.LoadLogSettingsDefaults(); @@ -62,6 +95,11 @@ int main(int argc, char **argv) { database.LoadLogSettings(Log.log_settings); Log.StartFileLogs(); + std::string shared_mem_directory = Config->SharedMemDir; + if (MakeDirectory(shared_mem_directory)) { + Log.Out(Logs::General, Logs::Status, "Shared Memory folder doesn't exist, so we created it... '%s'", shared_mem_directory.c_str()); + } + database.LoadVariables(); /* If we're running shared memory and hotfix has no custom name, we probably want to start from scratch... */ diff --git a/zone/map.cpp b/zone/map.cpp index 9a5ab8e10..b4daca584 100644 --- a/zone/map.cpp +++ b/zone/map.cpp @@ -302,7 +302,7 @@ Map *Map::LoadMapFile(std::string file) { bool Map::Load(std::string filename, bool force_mmf_overwrite) { if (LoadMMF(filename, force_mmf_overwrite)) { - Log.Out(Logs::General, Logs::Zone_Server, "Loaded .MMF Map File in place of '%s'", filename.c_str()); + Log.Out(Logs::General, Logs::Status, "Loaded .MMF Map File in place of '%s'", filename.c_str()); return true; } #else @@ -319,7 +319,7 @@ bool Map::Load(std::string filename) } if(version == 0x01000000) { - Log.Out(Logs::General, Logs::Zone_Server, "Loaded V1 Map File :: '%s'", filename.c_str()); + Log.Out(Logs::General, Logs::Status, "Loaded V1 Map File :: '%s'", filename.c_str()); bool v = LoadV1(f); fclose(f); @@ -330,7 +330,7 @@ bool Map::Load(std::string filename) return v; } else if(version == 0x02000000) { - Log.Out(Logs::General, Logs::Zone_Server, "Loaded V2 Map File :: '%s'", filename.c_str()); + Log.Out(Logs::General, Logs::Status, "Loaded V2 Map File :: '%s'", filename.c_str()); bool v = LoadV2(f); fclose(f);