mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2025-10-04 05:30:06 +00:00
switched to dumped XDT & moved to a submodule
This commit is contained in:
@@ -14,80 +14,6 @@ std::map<int32_t, WarpLocation> NPCManager::Warps;
|
||||
std::vector<WarpLocation> NPCManager::RespawnPoints;
|
||||
|
||||
void NPCManager::init() {
|
||||
// load NPCs from NPCs.json into our NPC manager
|
||||
// Temporary fix, IDs will be pulled from json later
|
||||
int i = 0;
|
||||
|
||||
try {
|
||||
std::ifstream inFile(settings::NPCJSON);
|
||||
nlohmann::json npcData;
|
||||
|
||||
// read file into json
|
||||
inFile >> npcData;
|
||||
|
||||
for (nlohmann::json::iterator npc = npcData.begin(); npc != npcData.end(); npc++) {
|
||||
BaseNPC tmp(npc.value()["x"], npc.value()["y"], npc.value()["z"], npc.value()["id"]);
|
||||
|
||||
// Temporary fix, IDs will be pulled from json later
|
||||
tmp.appearanceData.iNPC_ID = i;
|
||||
i++;
|
||||
|
||||
NPCs[tmp.appearanceData.iNPC_ID] = tmp;
|
||||
|
||||
if (npc.value()["id"] == 641 || npc.value()["id"] == 642)
|
||||
RespawnPoints.push_back({ npc.value()["x"], npc.value()["y"], ((int)npc.value()["z"]) + RESURRECT_HEIGHT });
|
||||
}
|
||||
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
std::cerr << "[WARN] Malformed NPCs.json file! Reason:" << err.what() << std::endl;
|
||||
}
|
||||
|
||||
// load temporary mob dump
|
||||
try {
|
||||
std::ifstream inFile(settings::MOBJSON); // not in settings, since it's temp
|
||||
nlohmann::json npcData;
|
||||
|
||||
// read file into json
|
||||
inFile >> npcData;
|
||||
|
||||
for (nlohmann::json::iterator npc = npcData.begin(); npc != npcData.end(); npc++) {
|
||||
BaseNPC tmp(npc.value()["iX"], npc.value()["iY"], npc.value()["iZ"], npc.value()["iNPCType"],
|
||||
npc.value()["iHP"], npc.value()["iConditionBitFlag"], npc.value()["iAngle"], npc.value()["iBarkerType"]);
|
||||
|
||||
// Temporary fix, IDs will be pulled from json later
|
||||
tmp.appearanceData.iNPC_ID = i;
|
||||
i++;
|
||||
|
||||
NPCs[tmp.appearanceData.iNPC_ID] = tmp;
|
||||
}
|
||||
|
||||
std::cout << "[INFO] populated " << NPCs.size() << " NPCs" << std::endl;
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
std::cerr << "[WARN] Malformed mobs.json file! Reason:" << err.what() << std::endl;
|
||||
}
|
||||
|
||||
try {
|
||||
std::ifstream infile(settings::WARPJSON);
|
||||
nlohmann::json warpData;
|
||||
|
||||
// read file into json
|
||||
infile >> warpData;
|
||||
|
||||
for (nlohmann::json::iterator warp = warpData.begin(); warp != warpData.end(); warp++) {
|
||||
WarpLocation warpLoc = { warp.value()["m_iToX"], warp.value()["m_iToY"], warp.value()["m_iToZ"] };
|
||||
int warpID = atoi(warp.key().c_str());
|
||||
Warps[warpID] = warpLoc;
|
||||
}
|
||||
|
||||
std::cout << "[INFO] populated " << Warps.size() << " Warps" << std::endl;
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
std::cerr << "[WARN] Malformed warps.json file! Reason:" << err.what() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_WARP_USE_NPC, npcWarpHandler);
|
||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NPC_SUMMON, npcSummonHandler);
|
||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_BARKER, npcBarkHandler);
|
||||
|
87
src/TableData.cpp
Normal file
87
src/TableData.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
#include "TableData.hpp"
|
||||
#include "NPCManager.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "contrib/JSON.hpp"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
void TabledataManager::init() {
|
||||
int i = 0;
|
||||
|
||||
// load NPCs from NPC.json
|
||||
try {
|
||||
|
||||
std::ifstream inFile(settings::NPCJSON);
|
||||
nlohmann::json npcData;
|
||||
|
||||
// read file into json
|
||||
inFile >> npcData;
|
||||
|
||||
for (nlohmann::json::iterator npc = npcData.begin(); npc != npcData.end(); npc++) {
|
||||
BaseNPC tmp(npc.value()["x"], npc.value()["y"], npc.value()["z"], npc.value()["id"]);
|
||||
|
||||
// Temporary fix, IDs will be pulled from json later
|
||||
tmp.appearanceData.iNPC_ID = i;
|
||||
i++;
|
||||
|
||||
NPCManager::NPCs[tmp.appearanceData.iNPC_ID] = tmp;
|
||||
|
||||
if (npc.value()["id"] == 641 || npc.value()["id"] == 642)
|
||||
NPCManager::RespawnPoints.push_back({ npc.value()["x"], npc.value()["y"], ((int)npc.value()["z"]) + RESURRECT_HEIGHT });
|
||||
}
|
||||
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
std::cerr << "[WARN] Malformed NPCs.json file! Reason:" << err.what() << std::endl;
|
||||
}
|
||||
|
||||
// load temporary mob dump
|
||||
try {
|
||||
std::ifstream inFile(settings::MOBJSON); // not in settings, since it's temp
|
||||
nlohmann::json npcData;
|
||||
|
||||
// read file into json
|
||||
inFile >> npcData;
|
||||
|
||||
for (nlohmann::json::iterator npc = npcData.begin(); npc != npcData.end(); npc++) {
|
||||
BaseNPC tmp(npc.value()["iX"], npc.value()["iY"], npc.value()["iZ"], npc.value()["iNPCType"],
|
||||
npc.value()["iHP"], npc.value()["iConditionBitFlag"], npc.value()["iAngle"], npc.value()["iBarkerType"]);
|
||||
|
||||
// Temporary fix, IDs will be pulled from json later
|
||||
tmp.appearanceData.iNPC_ID = i;
|
||||
i++;
|
||||
|
||||
NPCManager::NPCs[tmp.appearanceData.iNPC_ID] = tmp;
|
||||
}
|
||||
|
||||
std::cout << "[INFO] populated " << NPCManager::NPCs.size() << " NPCs" << std::endl;
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
std::cerr << "[WARN] Malformed mobs.json file! Reason:" << err.what() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
// load everything else from xdttable
|
||||
try {
|
||||
std::ifstream infile(settings::XDTJSON);
|
||||
nlohmann::json xdtData;
|
||||
|
||||
// read file into json
|
||||
infile >> xdtData;
|
||||
|
||||
// load warps from m_pInstanceTable.m_pWarpData
|
||||
nlohmann::json warpData = xdtData["m_pInstanceTable"]["m_pWarpData"];
|
||||
|
||||
for (nlohmann::json::iterator warp = warpData.begin(); warp != warpData.end(); warp++) {
|
||||
WarpLocation warpLoc = { warp.value()["m_iToX"], warp.value()["m_iToY"], warp.value()["m_iToZ"] };
|
||||
int warpID = warp.value()["m_iWarpNumber"];
|
||||
NPCManager::Warps[warpID] = warpLoc;
|
||||
}
|
||||
|
||||
std::cout << "[INFO] populated " << NPCManager::Warps.size() << " Warps" << std::endl;
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
std::cerr << "[WARN] Malformed xdt.json file! Reason:" << err.what() << std::endl;
|
||||
}
|
||||
|
||||
}
|
6
src/TableData.hpp
Normal file
6
src/TableData.hpp
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
#include <map>
|
||||
|
||||
namespace TabledataManager {
|
||||
void init();
|
||||
}
|
@@ -9,6 +9,7 @@
|
||||
#include "NPCManager.hpp"
|
||||
#include "TransportManager.hpp"
|
||||
#include "Database.hpp"
|
||||
#include "TableData.hpp"
|
||||
|
||||
#include "settings.hpp"
|
||||
|
||||
@@ -70,6 +71,7 @@ int main() {
|
||||
settings::init();
|
||||
std::cout << "[INFO] Protocol version: " << PROTOCOL_VERSION << std::endl;
|
||||
std::cout << "[INFO] Intializing Packet Managers..." << std::endl;
|
||||
TabledataManager::init();
|
||||
PlayerManager::init();
|
||||
ChatManager::init();
|
||||
CombatManager::init();
|
||||
|
@@ -20,7 +20,7 @@ int settings::SPAWN_Y = 268451;
|
||||
int settings::SPAWN_Z = -4210;
|
||||
std::string settings::GMPASS = "pass";
|
||||
std::string settings::NPCJSON = "data/NPCs.json";
|
||||
std::string settings::WARPJSON = "data/warps.json";
|
||||
std::string settings::XDTJSON = "data/xdt.json";
|
||||
std::string settings::MOBJSON = "data/mobs.json";
|
||||
std::string settings::MOTDSTRING = "Welcome to OpenFusion!";
|
||||
bool settings::GM = false;
|
||||
@@ -50,7 +50,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);
|
||||
XDTJSON = reader.Get("shard", "xdtdata", XDTJSON);
|
||||
MOBJSON = reader.Get("shard", "mobdata", MOBJSON);
|
||||
MOTDSTRING = reader.Get("shard", "motd", MOTDSTRING);
|
||||
GM = reader.GetBoolean("shard", "gm", GM);
|
||||
|
@@ -14,7 +14,7 @@ namespace settings {
|
||||
extern int SPAWN_Z;
|
||||
extern std::string MOTDSTRING;
|
||||
extern std::string NPCJSON;
|
||||
extern std::string WARPJSON;
|
||||
extern std::string XDTJSON;
|
||||
extern std::string MOBJSON;
|
||||
extern std::string GMPASS;
|
||||
extern bool GM;
|
||||
|
Reference in New Issue
Block a user