From 1afd961b73dd7f02a372caa57224033df3c30d4c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 23 Jun 2020 18:51:01 +0800 Subject: [PATCH] 1 --- server/imserver/constant.h | 2 +- server/imserver/player.cc | 29 ++++++++++++++++++++++++++++- server/imserver/player.h | 1 + 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/server/imserver/constant.h b/server/imserver/constant.h index f718970..d30c085 100644 --- a/server/imserver/constant.h +++ b/server/imserver/constant.h @@ -47,7 +47,7 @@ const char* const EVENT_FRIEND_DELETE = "friend.delete"; const int MAX_INSTANCE_ID = 1023; -const int MAX_FRIEND_NUM = 50; +const int MAX_FRIEND_NUM = 30; const int DAILY_JOIN_FRIEND_TIMES = 100; const int DAILY_APPLY_FRIEND_TIMES = 100; diff --git a/server/imserver/player.cc b/server/imserver/player.cc index 4ab10ec..43ae9bd 100644 --- a/server/imserver/player.cc +++ b/server/imserver/player.cc @@ -489,7 +489,7 @@ void Player::_SS_IM_FriendAgreeRequest(f8::MsgHdr& hdr, const ss::SS_IM_FriendAg return; } } - + RemoveHandledApply(); f8::MsgHdr* hdr_copy = hdr.Clone(); ss::SS_IM_FriendAgreeRequest* msg_copy = new ss::SS_IM_FriendAgreeRequest; *msg_copy = msg; @@ -668,6 +668,7 @@ Friend* Player::GetFriendById(const std::string& friend_id) void Player::FillApplyList(const cs::MFPaging& paging, cs::SMFriendApplyList& respmsg) { + RemoveHandledApply(); int i = 0; int start = paging.curr_page() * paging.page_size(); for (auto& pair : apply_hash_) { @@ -1155,3 +1156,29 @@ void Player::RefreshFriendData() { } + +void Player::RemoveHandledApply() +{ + std::vector handled_idxs; + for (auto& pair : apply_hash_) { + if (GetFriendById(pair.second->base_data.account_id)) { + handled_idxs.push_back(pair.first); + } + } + for (long long idx : handled_idxs) { + auto itr = apply_hash_.find(idx); + if (itr != apply_hash_.end()) { + auto& apply = itr->second; + DBHelper::Instance()->SetFriendApplyStatus + ( + myself.crc32_code, + apply->idx, + apply->base_data.account_id, + AccountId(), + 3 + ); + delete itr->second; + apply_hash_.erase(itr); + } + } +} diff --git a/server/imserver/player.h b/server/imserver/player.h index 1b85133..8c2f9b7 100644 --- a/server/imserver/player.h +++ b/server/imserver/player.h @@ -134,6 +134,7 @@ private: void ClearApplyByIdx(long long idx); void ClearApplyByTarget(const std::string& target_id); void RefreshFriendData(); + void RemoveHandledApply(); private: bool dirty_ = false;