Explicitly update buddy records in DB

this should fix the bug where removing a buddy while they're offline won't take you off their list until you disconnect
This commit is contained in:
Gent
2020-11-09 05:01:51 -05:00
parent 8a68958ed4
commit f53de8d521
3 changed files with 46 additions and 1 deletions

View File

@@ -203,6 +203,9 @@ void BuddyManager::reqAcceptBuddy(CNSocket* sock, CNPacketData* data) {
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
otherPlr->buddyIDs[slotB] = plr->PCStyle.iPC_UID;
//std::cout << "Buddy's ID: " << plr->buddyIDs[slotB] << std::endl;
// add record to db
Database::addBuddyship(plr->iID, otherPlr->iID);
}
else
{
@@ -282,6 +285,9 @@ void BuddyManager::reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data) {
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
otherPlr->buddyIDs[slotB] = plr->PCStyle.iPC_UID;
//std::cout << "Buddy's ID: " << plr->buddyIDs[slotB] << std::endl;
// add record to db
Database::addBuddyship(plr->iID, otherPlr->iID);
}
else
{
@@ -405,6 +411,9 @@ void BuddyManager::reqBuddyDelete(CNSocket* sock, CNPacketData* data) {
plr->buddyIDs[resp.iBuddySlot] = 0;
sock->sendPacket((void*)&resp, P_FE2CL_REP_REMOVE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_REMOVE_BUDDY_SUCC));
// remove record from db
Database::removeBuddyship(plr->PCStyle.iPC_UID, pkt->iBuddyPCUID);
// remove buddy on their side, reusing the struct
CNSocket* otherSock = PlayerManager::getSockFromID(pkt->iBuddyPCUID);
if (otherSock == nullptr)