mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-12-23 11:50:04 +00:00
Fix players being able to become buddies twice
This commit is contained in:
parent
f0ded0886c
commit
8a68958ed4
@ -170,7 +170,7 @@ void BuddyManager::reqAcceptBuddy(CNSocket* sock, CNPacketData* data) {
|
||||
if (slotA == -1 || slotB == -1)
|
||||
return; // sanity check
|
||||
|
||||
if (req->iAcceptFlag == 1 && plr->iID != otherPlr->iID)
|
||||
if (req->iAcceptFlag == 1 && plr->iID != otherPlr->iID && !playerHasBuddyWithID(plr, otherPlr->iID))
|
||||
{
|
||||
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, resp);
|
||||
|
||||
@ -250,7 +250,7 @@ void BuddyManager::reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data) {
|
||||
if (slotA == -1 || slotB == -1)
|
||||
return; // sanity check
|
||||
|
||||
if (pkt->iAcceptFlag == 1 && plr->iID != otherPlr->iID) {
|
||||
if (pkt->iAcceptFlag == 1 && plr->iID != otherPlr->iID && !playerHasBuddyWithID(plr, otherPlr->iID)) {
|
||||
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, resp);
|
||||
|
||||
// A to B
|
||||
@ -716,4 +716,12 @@ bool BuddyManager::NameCheck(char16_t reqName[], char16_t resName[], int sizeOfL
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BuddyManager::playerHasBuddyWithID(Player* plr, int buddyID) {
|
||||
for (int i = 0; i < 50; i++) {
|
||||
if (plr->buddyIDs[i] == buddyID)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
@ -51,4 +51,5 @@ namespace BuddyManager {
|
||||
// Name checks
|
||||
int getAvailableBuddySlot(Player* plr);
|
||||
bool NameCheck(char16_t reqName[], char16_t resName[], int sizeOfReq, int sizeOfRes); // checks if the request and requested player's names match
|
||||
bool playerHasBuddyWithID(Player* plr, int buddyID);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user