diff --git a/server/imserver/player.cc b/server/imserver/player.cc index e93a058..690ec76 100644 --- a/server/imserver/player.cc +++ b/server/imserver/player.cc @@ -44,10 +44,6 @@ void Player::Init() }, &timer_attacher.timer_list_ ); - #ifdef DEBUG - red_point_flags_ = 1; - SyncRedPoint(); - #endif if (App::Instance()->IsTimeToReset(role_data.last_save_time)) { OnDailyReset(); } @@ -63,6 +59,9 @@ void Player::UnInit() delete pair.second; } } + for (auto& pair : apply_hash_) { + delete pair.second; + } friend_hash_.clear(); NotifyOffline(); } @@ -203,16 +202,13 @@ void Player::_CMFriendApplyList(f8::MsgHdr& hdr, const cs::CMFriendApplyList& ms apply.base_data.user_value2 = a8::XValue(row[9]); apply.base_data.user_value3 = a8::XValue(row[10]); hum->apply_list_.push_back(apply); - #if 0 if (apply.idx > hum->last_apply_idx_) { hum->last_apply_idx_ = apply.idx; } - #endif } cs::SMFriendApplyList respmsg; hum->FillApplyList(*paging, respmsg); hum->SendMsg(respmsg); - hum->apply_list_.clear(); a8::UnSetBitFlag(hum->red_point_flags_, RPF_Apply); hum->SyncRedPoint(); } @@ -303,6 +299,7 @@ void Player::_CMFriendAgree(f8::MsgHdr& hdr, const cs::CMFriendAgree& msg) AccountId(), 1 ); + ClearApplyByTarget(msg.apply().target_id()); } void Player::_CMFriendRefuse(f8::MsgHdr& hdr, const cs::CMFriendRefuse& msg) @@ -318,6 +315,7 @@ void Player::_CMFriendRefuse(f8::MsgHdr& hdr, const cs::CMFriendRefuse& msg) AccountId(), 2 ); + ClearApplyByIdx(msg.apply().idx()); } void Player::_CMFriendDelete(f8::MsgHdr& hdr, const cs::CMFriendDelete& msg) @@ -1061,3 +1059,30 @@ void Player::OnDailyReset() { role_data.today_apply_times = 0; } + +void Player::RecalcRedPoint() +{ + +} + +void Player::ClearApplyByIdx(long long idx) +{ + auto itr = apply_hash_.find(idx); + if (itr != apply_hash_.end()) { + delete itr->second; + apply_hash_.erase(itr); + } +} + +void Player::ClearApplyByTarget(const std::string& target_id) +{ + std::vector deleted_applys; + for (auto& pair : apply_hash_) { + if (pair.second->target_id == target_id) { + deleted_applys.push_back(pair.first); + } + } + for (auto idx : deleted_applys) { + ClearApplyByIdx(idx); + } +} diff --git a/server/imserver/player.h b/server/imserver/player.h index 60d6521..3acd28d 100644 --- a/server/imserver/player.h +++ b/server/imserver/player.h @@ -130,6 +130,9 @@ private: bool CanAddFriend(const std::string& account_id); void SyncRedPoint(); void OnDailyReset(); + void RecalcRedPoint(); + void ClearApplyByIdx(long long idx); + void ClearApplyByTarget(const std::string& target_id); private: bool dirty_ = false;