From 113ce0af075ae6be9f3b8d1594c287b04f928a5e Mon Sep 17 00:00:00 2001 From: dongresource Date: Tue, 25 Aug 2020 03:45:04 +0200 Subject: [PATCH] Load the NPC and warp JSON files according to the config file. NPC data was being read from the config, but ignored. --- config.ini | 2 ++ src/NPCManager.cpp | 4 ++-- src/settings.cpp | 2 ++ src/settings.hpp | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/config.ini b/config.ini index 7ab905e..65173ca 100644 --- a/config.ini +++ b/config.ini @@ -23,6 +23,8 @@ view=20000 motd=Welcome to OpenFusion! # NPC json data npcdata=NPCs.json +# warp target json data +warpdata=warps.json # spawn coordinates (Z is height) # the supplied defaults are at City Hall diff --git a/src/NPCManager.cpp b/src/NPCManager.cpp index 22ce2ff..1cbf973 100644 --- a/src/NPCManager.cpp +++ b/src/NPCManager.cpp @@ -17,7 +17,7 @@ void NPCManager::init() { // load NPCs from NPCs.json into our NPC manager try { - std::ifstream inFile("NPCs.json"); + std::ifstream inFile(settings::NPCJSON); nlohmann::json npcData; // read file into json @@ -37,7 +37,7 @@ void NPCManager::init() { } try { - std::ifstream infile("warps.json"); + std::ifstream infile(settings::WARPJSON); nlohmann::json warpData; // read file into json diff --git a/src/settings.cpp b/src/settings.cpp index efa5c09..7564ab5 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -18,6 +18,7 @@ int settings::SPAWN_Y = 268451; int settings::SPAWN_Z = -4210; std::string settings::GMPASS = "pass"; std::string settings::NPCJSON = "NPCs.json"; +std::string settings::WARPJSON = "warps.json"; std::string settings::MOTDSTRING = "Welcome to OpenFusion!"; void settings::init() { @@ -43,6 +44,7 @@ void settings::init() { SPAWN_Z = reader.GetInteger("shard", "spawnz", SPAWN_Z); GMPASS = reader.Get("login", "pass", GMPASS); NPCJSON = reader.Get("shard", "npcdata", NPCJSON); + WARPJSON = reader.Get("shard", "warpdata", WARPJSON); MOTDSTRING = reader.Get("shard", "motd", MOTDSTRING); } diff --git a/src/settings.hpp b/src/settings.hpp index ef9e54c..ac0186e 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -12,6 +12,7 @@ namespace settings { extern int SPAWN_Z; extern std::string MOTDSTRING; extern std::string NPCJSON; + extern std::string WARPJSON; extern std::string GMPASS; void init();