Load instance data from XDT

This commit is contained in:
Gent S 2020-11-28 09:16:14 -05:00
parent 45b8f8f581
commit b81a3761b6
3 changed files with 23 additions and 2 deletions

View File

@ -2,7 +2,11 @@
#include "CNStructs.hpp"
#include "RacingManager.hpp"
std::map<int32_t, EPInfo> RacingManager::EPData;
void RacingManager::init() {
//REGISTER_SHARD_PACKET(P_CL2FE_REQ_EP_RACE_START, racingStart);
}

View File

@ -2,8 +2,13 @@
#include "CNShardServer.hpp"
struct EPInfo {
int zoneX, zoneY, EPID, maxScore;
};
namespace RacingManager {
void init();
extern std::map<int32_t, EPInfo> EPData;
void init();
}

View File

@ -7,6 +7,7 @@
#include "MobManager.hpp"
#include "ChunkManager.hpp"
#include "NanoManager.hpp"
#include "RacingManager.hpp"
#include "contrib/JSON.hpp"
@ -228,6 +229,17 @@ void TableData::init() {
std::cout << "[INFO] Loaded " << NanoManager::SkillTable.size() << " nano skills" << std::endl;
// load EP data
nlohmann::json instances = xdtData["m_pInstanceTable"]["m_pInstanceData"];
for (nlohmann::json::iterator _instance = instances.begin(); _instance != instances.end(); _instance++) {
auto instance = _instance.value();
EPInfo epInfo = {instance["m_iZoneX"], instance["m_iZoneY"], instance["m_iIsEP"], (int)instance["m_ScoreMax"]};
RacingManager::EPData[instance["m_iInstanceNameID"]] = epInfo;
}
std::cout << "[INFO] Loaded " << RacingManager::EPData.size() << " instances" << std::endl;
}
catch (const std::exception& err) {
std::cerr << "[FATAL] Malformed xdt.json file! Reason:" << err.what() << std::endl;