1
This commit is contained in:
parent
b648b75152
commit
87ed2d19c1
@ -251,6 +251,12 @@ void Player::_CMFriendAgree(f8::MsgHdr& hdr, const cs::CMFriendAgree& msg)
|
||||
SendMsg(respmsg);
|
||||
return;
|
||||
}
|
||||
if (!CanAddFriend(msg.apply().base_data().account_id())) {
|
||||
respmsg.set_errcode(3);
|
||||
respmsg.set_errmsg("您的好友数已达到上限");
|
||||
SendMsg(respmsg);
|
||||
return;
|
||||
}
|
||||
Friend* friendobj = new Friend;
|
||||
TypeConvert::Convert(msg.apply().base_data(), friendobj->base_data);
|
||||
if (AddFriend(friendobj) == 0) {
|
||||
@ -952,7 +958,7 @@ void Player::OnFriendAgreeEvent(Event& event)
|
||||
if (GetFriendById(event.sender_id)) {
|
||||
return;
|
||||
}
|
||||
if (GetFriendNum() >= MAX_FRIEND_NUM) {
|
||||
if (!CanAddFriend(event.sender_id)) {
|
||||
return;
|
||||
}
|
||||
Friend* friendobj = new Friend;
|
||||
@ -972,3 +978,14 @@ void Player::OnFriendDeleteEvent(Event& event)
|
||||
}
|
||||
RemoveFriend(event.sender_id);
|
||||
}
|
||||
|
||||
bool Player::CanAddFriend(const std::string& account_id)
|
||||
{
|
||||
if (GetFriendNum() >= MAX_FRIEND_NUM) {
|
||||
return false;
|
||||
}
|
||||
if (GetFriendById(account_id)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -126,6 +126,7 @@ private:
|
||||
void ProcessEvent();
|
||||
void OnFriendAgreeEvent(Event& event);
|
||||
void OnFriendDeleteEvent(Event& event);
|
||||
bool CanAddFriend(const std::string& account_id);
|
||||
|
||||
private:
|
||||
bool dirty_ = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user