Allow servers to be run from directories other than build. Read/write files relative to binary instead of cwd (#834)

Allows the server to be run from a non-build directory.  Also only read or write files relative to the build directory, regardless of where the server is run from
This commit is contained in:
Jonathan Romano
2022-11-27 06:59:59 -05:00
committed by GitHub
parent e40a597f18
commit f8f5b731f1
16 changed files with 158 additions and 46 deletions

View File

@@ -13,6 +13,7 @@
#include "tinyxml2.h"
#include "Game.h"
#include "dLogger.h"
#include "BinaryPathFinder.h"
#include <fstream>
@@ -27,7 +28,7 @@ void VanityUtilities::SpawnVanity() {
const uint32_t zoneID = Game::server->GetZoneID();
ParseXML("./vanity/NPC.xml");
ParseXML((BinaryPathFinder::GetBinaryDir() / "vanity/NPC.xml").string());
// Loop through all parties
for (const auto& party : m_Parties) {
@@ -131,7 +132,7 @@ void VanityUtilities::SpawnVanity() {
info.spawnerID = EntityManager::Instance()->GetZoneControlEntity()->GetObjectID();
info.settings = { new LDFData<bool>(u"hasCustomText", true),
new LDFData<std::string>(u"customText", ParseMarkdown("./vanity/TESTAMENT.md")) };
new LDFData<std::string>(u"customText", ParseMarkdown((BinaryPathFinder::GetBinaryDir() / "vanity/TESTAMENT.md").string())) };
auto* entity = EntityManager::Instance()->CreateEntity(info);