2020-08-19 22:21:35 +00:00
|
|
|
#include "NPCManager.hpp"
|
2020-09-09 01:15:25 +00:00
|
|
|
#include "ItemManager.hpp"
|
2020-08-20 21:43:48 +00:00
|
|
|
#include "settings.hpp"
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <list>
|
2020-08-21 22:14:11 +00:00
|
|
|
#include <fstream>
|
2020-08-25 01:34:53 +00:00
|
|
|
#include <vector>
|
2020-08-21 22:14:11 +00:00
|
|
|
|
2020-08-22 02:03:12 +00:00
|
|
|
#include "contrib/JSON.hpp"
|
2020-08-20 21:43:48 +00:00
|
|
|
|
|
|
|
std::map<int32_t, BaseNPC> NPCManager::NPCs;
|
2020-08-23 16:26:25 +00:00
|
|
|
std::map<int32_t, WarpLocation> NPCManager::Warps;
|
2020-08-25 01:34:53 +00:00
|
|
|
std::vector<WarpLocation> NPCManager::RespawnPoints;
|
2020-08-19 22:21:35 +00:00
|
|
|
|
|
|
|
void NPCManager::init() {
|
2020-08-25 02:28:42 +00:00
|
|
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_WARP_USE_NPC, npcWarpHandler);
|
|
|
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NPC_SUMMON, npcSummonHandler);
|
2020-08-29 11:14:21 +00:00
|
|
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_BARKER, npcBarkHandler);
|
2020-09-09 01:15:25 +00:00
|
|
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_VENDOR_START, npcVendorStart);
|
|
|
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_VENDOR_TABLE_UPDATE, npcVendorTable);
|
|
|
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_VENDOR_ITEM_BUY, npcVendorBuy);
|
2020-09-12 02:04:23 +00:00
|
|
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_VENDOR_ITEM_SELL, npcVendorSell);
|
2020-09-14 05:27:20 +00:00
|
|
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_VENDOR_ITEM_RESTORE_BUY, npcVendorRestore);
|
2020-09-09 01:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void NPCManager::npcVendorBuy(CNSocket* sock, CNPacketData* data) {
|
|
|
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_VENDOR_ITEM_BUY))
|
|
|
|
return; // malformed packet
|
|
|
|
|
|
|
|
sP_CL2FE_REQ_PC_VENDOR_ITEM_BUY* req = (sP_CL2FE_REQ_PC_VENDOR_ITEM_BUY*)data->buf;
|
|
|
|
Player *plr = PlayerManager::getPlayer(sock);
|
|
|
|
|
2020-09-14 04:25:14 +00:00
|
|
|
if (!ItemManager::isItemRegistered(req->Item.iID, req->Item.iType)) {
|
2020-09-14 05:27:20 +00:00
|
|
|
std::cout << "[WARN] Item id " << req->Item.iID << " with type " << req->Item.iType << " not found (buy)" << std::endl;
|
2020-09-14 04:25:14 +00:00
|
|
|
// NOTE: VENDOR_ITEM_BUY_FAIL is not actually handled client-side.
|
|
|
|
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL, failResp);
|
|
|
|
failResp.iErrorCode = 0;
|
|
|
|
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL));
|
|
|
|
return;
|
|
|
|
}
|
2020-09-09 01:15:25 +00:00
|
|
|
|
2020-09-14 05:52:15 +00:00
|
|
|
int itemCost = ItemManager::getItemData(req->Item.iID, req->Item.iType).buyPrice * req->Item.iOpt;
|
2020-09-09 01:15:25 +00:00
|
|
|
int slot = ItemManager::findFreeSlot(plr);
|
|
|
|
if (itemCost > plr->money || slot == -1) {
|
|
|
|
// NOTE: VENDOR_ITEM_BUY_FAIL is not actually handled client-side.
|
|
|
|
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL, failResp);
|
|
|
|
failResp.iErrorCode = 0;
|
|
|
|
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (slot != req->iInvenSlotNum) {
|
|
|
|
// possible item stacking?
|
2020-09-12 00:25:45 +00:00
|
|
|
std::cout << "[WARN] Client and server disagree on bought item slot (" << req->iInvenSlotNum << " vs " << slot << ")" << std::endl;
|
2020-09-09 01:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_ITEM_BUY_SUCC, resp);
|
|
|
|
|
|
|
|
plr->money = plr->money - itemCost;
|
|
|
|
plr->Inven[slot] = req->Item;
|
|
|
|
|
|
|
|
resp.iCandy = plr->money;
|
|
|
|
resp.iInvenSlotNum = slot;
|
|
|
|
resp.Item = req->Item;
|
|
|
|
|
|
|
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_VENDOR_ITEM_BUY_SUCC, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_BUY_SUCC));
|
|
|
|
}
|
|
|
|
|
2020-09-12 02:04:23 +00:00
|
|
|
void NPCManager::npcVendorSell(CNSocket* sock, CNPacketData* data) {
|
|
|
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_VENDOR_ITEM_SELL))
|
|
|
|
return; // malformed packet
|
|
|
|
|
|
|
|
sP_CL2FE_REQ_PC_VENDOR_ITEM_SELL* req = (sP_CL2FE_REQ_PC_VENDOR_ITEM_SELL*)data->buf;
|
|
|
|
Player* plr = PlayerManager::getPlayer(sock);
|
|
|
|
|
2020-09-12 14:10:53 +00:00
|
|
|
if (req->iInvenSlotNum < 0 || req->iInvenSlotNum >= AINVEN_COUNT || req->iItemCnt < 0) {
|
2020-09-12 02:04:23 +00:00
|
|
|
std::cout << "[WARN] Client failed to sell item in slot " << req->iInvenSlotNum << std::endl;
|
|
|
|
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL, failResp);
|
|
|
|
failResp.iErrorCode = 0;
|
|
|
|
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-09-12 14:10:53 +00:00
|
|
|
sItemBase* item = &plr->Inven[req->iInvenSlotNum];
|
|
|
|
|
2020-09-14 05:27:20 +00:00
|
|
|
if (!ItemManager::isItemRegistered(item->iID, item->iType) || !ItemManager::getItemData(item->iID, item->iType).sellable) { // sanity + sellable check
|
|
|
|
std::cout << "[WARN] Item id " << item->iID << " with type " << item->iType << " not found (sell)" << std::endl;
|
|
|
|
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL, failResp);
|
|
|
|
failResp.iErrorCode = 0;
|
|
|
|
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sItemBase original;
|
|
|
|
memcpy(&original, item, sizeof(sItemBase));
|
|
|
|
|
2020-09-12 02:04:23 +00:00
|
|
|
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_SUCC, resp);
|
2020-09-14 04:25:14 +00:00
|
|
|
|
2020-09-14 05:27:20 +00:00
|
|
|
int sellValue = ItemManager::getItemData(item->iID, item->iType).sellPrice * req->iItemCnt;
|
2020-09-12 02:04:23 +00:00
|
|
|
|
|
|
|
// increment taros
|
|
|
|
plr->money = plr->money + sellValue;
|
|
|
|
|
2020-09-14 05:52:15 +00:00
|
|
|
// modify item
|
|
|
|
if (plr->Inven[req->iInvenSlotNum].iOpt - req->iItemCnt > 0) { // selling part of a stack
|
|
|
|
item->iOpt -= req->iItemCnt;
|
|
|
|
original.iOpt = req->iItemCnt;
|
|
|
|
}
|
|
|
|
else { // selling entire slot
|
|
|
|
item->iID = 0;
|
|
|
|
item->iOpt = 0;
|
|
|
|
item->iType = 0;
|
|
|
|
item->iTimeLimit = 0;
|
|
|
|
}
|
2020-09-12 02:04:23 +00:00
|
|
|
|
|
|
|
// response parameters
|
|
|
|
resp.iInvenSlotNum = req->iInvenSlotNum;
|
|
|
|
resp.iCandy = plr->money;
|
2020-09-14 05:27:20 +00:00
|
|
|
resp.Item = original; // the item that gets sent to buyback
|
|
|
|
resp.ItemStay = *item; // the void item that gets put in the slot
|
2020-09-12 02:04:23 +00:00
|
|
|
|
|
|
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_VENDOR_ITEM_SELL_SUCC, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_SUCC));
|
|
|
|
}
|
|
|
|
|
2020-09-14 05:27:20 +00:00
|
|
|
void NPCManager::npcVendorRestore(CNSocket* sock, CNPacketData* data) {
|
|
|
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_VENDOR_ITEM_RESTORE_BUY))
|
|
|
|
return; // malformed packet
|
|
|
|
|
|
|
|
sP_CL2FE_REQ_PC_VENDOR_ITEM_RESTORE_BUY* req = (sP_CL2FE_REQ_PC_VENDOR_ITEM_RESTORE_BUY*)data->buf;
|
|
|
|
Player* plr = PlayerManager::getPlayer(sock);
|
|
|
|
|
|
|
|
if (!ItemManager::isItemRegistered(req->Item.iID, req->Item.iType)) {
|
|
|
|
std::cout << "[WARN] Item id " << req->Item.iID << " with type " << req->Item.iType << " not found (rebuy)" << std::endl;
|
|
|
|
// NOTE: VENDOR_ITEM_BUY_FAIL is not actually handled client-side.
|
|
|
|
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_FAIL, failResp);
|
|
|
|
failResp.iErrorCode = 0;
|
|
|
|
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_FAIL));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-09-14 05:52:15 +00:00
|
|
|
int itemCost = ItemManager::getItemData(req->Item.iID, req->Item.iType).sellPrice * req->Item.iOpt; // sell price is used on rebuy
|
2020-09-14 05:27:20 +00:00
|
|
|
int slot = ItemManager::findFreeSlot(plr);
|
|
|
|
if (itemCost > plr->money || slot == -1) {
|
|
|
|
// NOTE: VENDOR_ITEM_BUY_FAIL is not actually handled client-side.
|
|
|
|
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_FAIL, failResp);
|
|
|
|
failResp.iErrorCode = 0;
|
|
|
|
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_FAIL));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (slot != req->iInvenSlotNum) {
|
|
|
|
// possible item stacking?
|
|
|
|
std::cout << "[WARN] Client and server disagree on bought item slot (" << req->iInvenSlotNum << " vs " << slot << ")" << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
plr->money = plr->money - itemCost;
|
|
|
|
plr->Inven[slot] = req->Item;
|
|
|
|
|
|
|
|
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_SUCC, resp);
|
|
|
|
// response parameters
|
|
|
|
resp.iCandy = plr->money;
|
|
|
|
resp.iInvenSlotNum = slot;
|
|
|
|
resp.Item = req->Item;
|
|
|
|
|
|
|
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_SUCC, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_SUCC));
|
|
|
|
}
|
|
|
|
|
2020-09-09 01:15:25 +00:00
|
|
|
void NPCManager::npcVendorTable(CNSocket* sock, CNPacketData* data) {
|
|
|
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_VENDOR_TABLE_UPDATE))
|
|
|
|
return; // malformed packet
|
|
|
|
|
2020-09-13 22:54:47 +00:00
|
|
|
sP_CL2FE_REQ_PC_VENDOR_TABLE_UPDATE* req = (sP_CL2FE_REQ_PC_VENDOR_TABLE_UPDATE*)data->buf;
|
|
|
|
|
|
|
|
if (req->iVendorID != req->iNPC_ID || ItemManager::VendorTables.find(req->iNPC_ID) == ItemManager::VendorTables.end())
|
|
|
|
return;
|
|
|
|
|
|
|
|
std::vector<VendorListing> listings = ItemManager::VendorTables[req->iNPC_ID]; // maybe use iVendorID instead...?
|
|
|
|
|
2020-09-09 01:15:25 +00:00
|
|
|
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_TABLE_UPDATE_SUCC, resp);
|
2020-09-13 22:54:47 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 20; i++) { // 20 is the max
|
|
|
|
|
|
|
|
if (i < listings.size()) { // check to make sure listing exists first
|
|
|
|
sItemBase base;
|
|
|
|
base.iID = listings[i].iID;
|
|
|
|
base.iOpt = 0;
|
|
|
|
base.iTimeLimit = 0;
|
|
|
|
base.iType = listings[i].type;
|
|
|
|
|
|
|
|
sItemVendor vItem;
|
|
|
|
vItem.item = base;
|
|
|
|
vItem.iSortNum = listings[i].sort;
|
|
|
|
vItem.iVendorID = req->iVendorID;
|
2020-09-14 04:25:14 +00:00
|
|
|
//vItem.fBuyCost = listings[i].price;
|
2020-09-13 22:54:47 +00:00
|
|
|
|
|
|
|
resp.item[i] = vItem;
|
|
|
|
}
|
|
|
|
}
|
2020-09-09 01:15:25 +00:00
|
|
|
|
|
|
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_VENDOR_TABLE_UPDATE_SUCC, sizeof(sP_FE2CL_REP_PC_VENDOR_TABLE_UPDATE_SUCC));
|
|
|
|
}
|
|
|
|
|
|
|
|
void NPCManager::npcVendorStart(CNSocket* sock, CNPacketData* data) {
|
|
|
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_VENDOR_START))
|
|
|
|
return; // malformed packet
|
|
|
|
|
|
|
|
sP_CL2FE_REQ_PC_VENDOR_START* req = (sP_CL2FE_REQ_PC_VENDOR_START*)data->buf;
|
|
|
|
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_START_SUCC, resp);
|
|
|
|
|
|
|
|
resp.iNPC_ID = req->iNPC_ID;
|
|
|
|
resp.iVendorID = req->iVendorID;
|
|
|
|
|
|
|
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_VENDOR_START_SUCC, sizeof(sP_FE2CL_REP_PC_VENDOR_START_SUCC));
|
2020-08-20 21:43:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void NPCManager::updatePlayerNPCS(CNSocket* sock, PlayerView& view) {
|
|
|
|
std::list<int32_t> yesView;
|
|
|
|
std::list<int32_t> noView;
|
|
|
|
|
2020-08-22 06:46:52 +00:00
|
|
|
for (auto& pair : NPCs) {
|
2020-08-24 22:02:07 +00:00
|
|
|
int diffX = abs(view.plr->x - pair.second.appearanceData.iX);
|
|
|
|
int diffY = abs(view.plr->y - pair.second.appearanceData.iY);
|
2020-08-20 21:43:48 +00:00
|
|
|
|
2020-08-26 02:53:27 +00:00
|
|
|
if (diffX < settings::NPCDISTANCE && diffY < settings::NPCDISTANCE) {
|
2020-08-20 21:43:48 +00:00
|
|
|
yesView.push_back(pair.first);
|
2020-08-29 11:14:21 +00:00
|
|
|
}
|
|
|
|
else {
|
2020-08-20 21:43:48 +00:00
|
|
|
noView.push_back(pair.first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-23 00:26:18 +00:00
|
|
|
INITSTRUCT(sP_FE2CL_NPC_EXIT, exitData);
|
2020-08-20 21:43:48 +00:00
|
|
|
std::list<int32_t>::iterator i = view.viewableNPCs.begin();
|
|
|
|
while (i != view.viewableNPCs.end()) {
|
|
|
|
int32_t id = *i;
|
|
|
|
|
|
|
|
if (std::find(noView.begin(), noView.end(), id) != noView.end()) {
|
|
|
|
// it shouldn't be visible, send NPC_EXIT
|
2020-08-25 17:42:56 +00:00
|
|
|
|
2020-08-22 23:31:09 +00:00
|
|
|
exitData.iNPC_ID = id;
|
|
|
|
sock->sendPacket((void*)&exitData, P_FE2CL_NPC_EXIT, sizeof(sP_FE2CL_NPC_EXIT));
|
2020-08-25 17:42:56 +00:00
|
|
|
|
2020-08-20 21:43:48 +00:00
|
|
|
// remove from view
|
|
|
|
view.viewableNPCs.erase(i++);
|
2020-08-29 11:14:21 +00:00
|
|
|
}
|
|
|
|
else {
|
2020-08-26 20:22:52 +00:00
|
|
|
i++;
|
2020-08-20 21:43:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-23 00:26:18 +00:00
|
|
|
INITSTRUCT(sP_FE2CL_NPC_ENTER, enterData);
|
2020-08-20 21:43:48 +00:00
|
|
|
for (int32_t id : yesView) {
|
|
|
|
if (std::find(view.viewableNPCs.begin(), view.viewableNPCs.end(), id) == view.viewableNPCs.end()) {
|
|
|
|
// needs to be added to viewableNPCs! send NPC_ENTER
|
|
|
|
|
2020-08-22 23:31:09 +00:00
|
|
|
enterData.NPCAppearanceData = NPCs[id].appearanceData;
|
|
|
|
sock->sendPacket((void*)&enterData, P_FE2CL_NPC_ENTER, sizeof(sP_FE2CL_NPC_ENTER));
|
2020-08-25 17:42:56 +00:00
|
|
|
|
2020-08-22 23:31:09 +00:00
|
|
|
// add to viewable
|
2020-08-20 21:43:48 +00:00
|
|
|
view.viewableNPCs.push_back(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerManager::players[sock].viewableNPCs = view.viewableNPCs;
|
2020-08-23 15:32:25 +00:00
|
|
|
}
|
2020-08-23 16:26:25 +00:00
|
|
|
|
2020-09-06 14:59:43 +00:00
|
|
|
void NPCManager::npcBarkHandler(CNSocket* sock, CNPacketData* data) {} // stubbed for now
|
2020-08-25 02:28:42 +00:00
|
|
|
|
2020-08-29 11:14:21 +00:00
|
|
|
void NPCManager::npcSummonHandler(CNSocket* sock, CNPacketData* data) {
|
2020-08-25 02:28:42 +00:00
|
|
|
if (data->size != sizeof(sP_CL2FE_REQ_NPC_SUMMON))
|
|
|
|
return; // malformed packet
|
|
|
|
|
|
|
|
sP_CL2FE_REQ_NPC_SUMMON* req = (sP_CL2FE_REQ_NPC_SUMMON*)data->buf;
|
|
|
|
INITSTRUCT(sP_FE2CL_NPC_ENTER, resp);
|
2020-08-29 11:14:21 +00:00
|
|
|
Player* plr = PlayerManager::getPlayer(sock);
|
2020-08-25 02:28:42 +00:00
|
|
|
|
|
|
|
// permission & sanity check
|
2020-08-25 17:42:56 +00:00
|
|
|
if (!plr->IsGM || req->iNPCType >= 3314)
|
2020-08-25 02:28:42 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
resp.NPCAppearanceData.iNPC_ID = rand(); // cpunch-style
|
|
|
|
resp.NPCAppearanceData.iNPCType = req->iNPCType;
|
|
|
|
resp.NPCAppearanceData.iHP = 1000; // TODO: placeholder
|
|
|
|
resp.NPCAppearanceData.iX = plr->x;
|
|
|
|
resp.NPCAppearanceData.iY = plr->y;
|
|
|
|
resp.NPCAppearanceData.iZ = plr->z;
|
|
|
|
|
|
|
|
sock->sendPacket((void*)&resp, P_FE2CL_NPC_ENTER, sizeof(sP_FE2CL_NPC_ENTER));
|
2020-09-07 20:12:53 +00:00
|
|
|
for (CNSocket *s : PlayerManager::players[sock].viewable)
|
|
|
|
s->sendPacket((void*)&resp, P_FE2CL_NPC_ENTER, sizeof(sP_FE2CL_NPC_ENTER));
|
2020-08-25 02:28:42 +00:00
|
|
|
}
|
2020-08-29 11:14:21 +00:00
|
|
|
|
|
|
|
void NPCManager::npcWarpHandler(CNSocket* sock, CNPacketData* data) {
|
|
|
|
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;
|
|
|
|
PlayerView& plrv = PlayerManager::players[sock];
|
|
|
|
|
|
|
|
// sanity check
|
|
|
|
if (Warps.find(warpNpc->iWarpID) == Warps.end())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// send to client
|
|
|
|
INITSTRUCT(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC, resp);
|
|
|
|
resp.iX = Warps[warpNpc->iWarpID].x;
|
|
|
|
resp.iY = Warps[warpNpc->iWarpID].y;
|
|
|
|
resp.iZ = Warps[warpNpc->iWarpID].z;
|
|
|
|
|
|
|
|
// force player & NPC reload
|
|
|
|
plrv.viewable.clear();
|
|
|
|
plrv.viewableNPCs.clear();
|
|
|
|
|
|
|
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_WARP_USE_NPC_SUCC, sizeof(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC));
|
2020-09-07 20:12:53 +00:00
|
|
|
}
|