mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 06:50:04 +00:00
Disallow selling Croc-Potted items
Also, make sure to explicitly terminate the connection when a player is kicked, and align a few fields in tables.sql.
This commit is contained in:
parent
f2b1a84ef4
commit
5e569d4324
@ -171,10 +171,12 @@ void NPCManager::npcVendorSell(CNSocket* sock, CNPacketData* data) {
|
|||||||
sP_CL2FE_REQ_PC_VENDOR_ITEM_SELL* req = (sP_CL2FE_REQ_PC_VENDOR_ITEM_SELL*)data->buf;
|
sP_CL2FE_REQ_PC_VENDOR_ITEM_SELL* req = (sP_CL2FE_REQ_PC_VENDOR_ITEM_SELL*)data->buf;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (req->iInvenSlotNum < 0 || req->iInvenSlotNum >= AINVEN_COUNT || req->iItemCnt < 0) {
|
// prepare a fail packet
|
||||||
std::cout << "[WARN] Client failed to sell item in slot " << req->iInvenSlotNum << std::endl;
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL, failResp);
|
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL, failResp);
|
||||||
failResp.iErrorCode = 0;
|
failResp.iErrorCode = 0;
|
||||||
|
|
||||||
|
if (req->iInvenSlotNum < 0 || req->iInvenSlotNum >= AINVEN_COUNT || req->iItemCnt < 0) {
|
||||||
|
std::cout << "[WARN] Client failed to sell item in slot " << req->iInvenSlotNum << std::endl;
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL));
|
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -184,8 +186,12 @@ void NPCManager::npcVendorSell(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
if (itemData == nullptr || !itemData->sellable || plr->Inven[req->iInvenSlotNum].iOpt < req->iItemCnt) { // sanity + sellable check
|
if (itemData == nullptr || !itemData->sellable || plr->Inven[req->iInvenSlotNum].iOpt < req->iItemCnt) { // sanity + sellable check
|
||||||
std::cout << "[WARN] Item id " << item->iID << " with type " << item->iType << " not found (sell)" << std::endl;
|
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);
|
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL));
|
||||||
failResp.iErrorCode = 0;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fail to sell croc-potted items
|
||||||
|
if (plr->Inven[req->iInvenSlotNum].iOpt >= 1 << 16) {
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL));
|
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1082,6 +1082,9 @@ void PlayerManager::kickPlayer(CNSocket *sock, CNPacketData *data) {
|
|||||||
|
|
||||||
// send to target player
|
// send to target player
|
||||||
otherSock->sendPacket((void*)&response, P_FE2CL_REP_PC_EXIT_SUCC, sizeof(sP_FE2CL_REP_PC_EXIT_SUCC));
|
otherSock->sendPacket((void*)&response, P_FE2CL_REP_PC_EXIT_SUCC, sizeof(sP_FE2CL_REP_PC_EXIT_SUCC));
|
||||||
|
|
||||||
|
// ensure that the connection has terminated
|
||||||
|
otherSock->kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerManager::warpToPlayer(CNSocket *sock, CNPacketData *data) {
|
void PlayerManager::warpToPlayer(CNSocket *sock, CNPacketData *data) {
|
||||||
|
Loading…
Reference in New Issue
Block a user