mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 21:40:05 +00:00
Npc Warp implementation (#29)
* Update CNShardServer.hpp * Update ChatManager.cpp * Update ChatManager.hpp * Update NPCManager.cpp * Update NPCManager.hpp * Add files via upload * Update NPCManager.cpp * Update NPCManager.cpp * Update ChatManager.cpp * Update ChatManager.cpp * Update NPCManager.cpp * Update NPCManager.cpp Co-authored-by: CPunch <sethtstubbs@gmail.com>
This commit is contained in:
parent
d6b96389be
commit
1d792a21dd
@ -27,7 +27,6 @@ void ChatManager::chatHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC));
|
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatManager::menuChatHandler(CNSocket* sock, CNPacketData* data) {
|
void ChatManager::menuChatHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_SEND_MENUCHAT_MESSAGE))
|
if (data->size != sizeof(sP_CL2FE_REQ_SEND_MENUCHAT_MESSAGE))
|
||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
@ -37,7 +36,7 @@ void ChatManager::menuChatHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
// send to client
|
// send to client
|
||||||
INITSTRUCT(sP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC, resp);
|
||||||
memcpy(resp.szFreeChat, chat->szFreeChat, sizeof(chat->szFreeChat));
|
memcpy(resp.szFreeChat, chat->szFreeChat, sizeof(chat->szFreeChat));
|
||||||
resp.iPC_ID = plr.plr.iID;
|
resp.iPC_ID = PlayerManager::players[sock].plr.iID;
|
||||||
resp.iEmoteCode = chat->iEmoteCode;
|
resp.iEmoteCode = chat->iEmoteCode;
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC));
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ void NPCManager::init() {
|
|||||||
catch (const std::exception& err) {
|
catch (const std::exception& err) {
|
||||||
std::cerr << "[WARN] Malformed NPC.json file! Reason:" << std::endl << err.what() << std::endl;
|
std::cerr << "[WARN] Malformed NPC.json file! Reason:" << std::endl << err.what() << std::endl;
|
||||||
}
|
}
|
||||||
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_WARP_USE_NPC, npcWarpManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef CHECKNPC
|
#undef CHECKNPC
|
||||||
@ -82,3 +83,25 @@ void NPCManager::updatePlayerNPCS(CNSocket* sock, PlayerView& view) {
|
|||||||
|
|
||||||
PlayerManager::players[sock].viewableNPCs = view.viewableNPCs;
|
PlayerManager::players[sock].viewableNPCs = view.viewableNPCs;
|
||||||
}
|
}
|
||||||
|
void NPCManager::npcWarpManager(CNSocket* sock, CNPacketData* data)
|
||||||
|
{
|
||||||
|
std::ifstream warp_file("warps.json", std::ifstream::binary);
|
||||||
|
nlohmann::json warp;
|
||||||
|
warp_file >> warp;
|
||||||
|
|
||||||
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_WARP_USE_NPC))
|
||||||
|
return; // malformed packet
|
||||||
|
|
||||||
|
sP_CL2FE_REQ_PC_WARP_USE_NPC* warpNpc = (sP_CL2FE_REQ_PC_WARP_USE_NPC*)data->buf;
|
||||||
|
|
||||||
|
//Send to Client
|
||||||
|
INITSTRUCT(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC, resp);
|
||||||
|
resp.iX = warp[std::to_string(warpNpc->iWarpID)]["m_iToX"];
|
||||||
|
resp.iY = warp[std::to_string(warpNpc->iWarpID)]["m_iToY"];
|
||||||
|
resp.iZ = warp[std::to_string(warpNpc->iWarpID)]["m_iToZ"];
|
||||||
|
//Add Instance Stuff Later
|
||||||
|
std::cerr << "OpenFusion: Warp using " << "Warp ID" <<warpNpc->iWarpID << "Warp to Z:"<< warp[std::to_string(warpNpc->iWarpID)]["m_iToZ"] << std::endl;
|
||||||
|
|
||||||
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_WARP_USE_NPC_SUCC, sizeof(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC));
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -12,6 +12,8 @@ namespace NPCManager {
|
|||||||
void init();
|
void init();
|
||||||
|
|
||||||
void updatePlayerNPCS(CNSocket* sock, PlayerView& plr);
|
void updatePlayerNPCS(CNSocket* sock, PlayerView& plr);
|
||||||
|
void npcWarpManager(CNSocket* sock, CNPacketData* data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
1
warps.JSON
Normal file
1
warps.JSON
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user