From 9f4c0e5cafa8ca2ececef62022a297efc8dedf0b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 23 Jun 2020 13:11:34 +0800 Subject: [PATCH] 1 --- server/imserver/player.cc | 34 +++++++++++++++++----------------- server/imserver/player.h | 1 - 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/server/imserver/player.cc b/server/imserver/player.cc index 10fb59d..a5ba8a8 100644 --- a/server/imserver/player.cc +++ b/server/imserver/player.cc @@ -191,21 +191,21 @@ void Player::_CMFriendApplyList(f8::MsgHdr& hdr, const cs::CMFriendApplyList& ms Player* hum = PlayerMgr::Instance()->GetPlayerByAccountId(param.sender.GetString()); if (hum && hum->socket_handle == param.param1.GetInt()) { for (auto& row : *data_set) { - FriendApply apply; - apply.idx = a8::XValue(row[0]); - apply.applyid = a8::XValue(row[1]); - apply.target_id = row[2]; - apply.base_data.account_id = row[3]; - apply.base_data.nickname = row[4]; - apply.base_data.avatar_url = row[5]; - apply.base_data.sex = a8::XValue(row[6]); - apply.base_data.base_data_version = a8::XValue(row[7]); - apply.base_data.user_value1 = a8::XValue(row[8]); - 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 (apply.idx > hum->last_apply_idx_) { - hum->last_apply_idx_ = apply.idx; + FriendApply* apply = new FriendApply; + apply->idx = a8::XValue(row[0]); + apply->applyid = a8::XValue(row[1]); + apply->target_id = row[2]; + apply->base_data.account_id = row[3]; + apply->base_data.nickname = row[4]; + apply->base_data.avatar_url = row[5]; + apply->base_data.sex = a8::XValue(row[6]); + apply->base_data.base_data_version = a8::XValue(row[7]); + apply->base_data.user_value1 = a8::XValue(row[8]); + apply->base_data.user_value2 = a8::XValue(row[9]); + apply->base_data.user_value3 = a8::XValue(row[10]); + hum->apply_hash_[apply->idx] = apply; + if (apply->idx > hum->last_apply_idx_) { + hum->last_apply_idx_ = apply->idx; } } cs::SMFriendApplyList respmsg; @@ -660,9 +660,9 @@ void Player::FillApplyList(const cs::MFPaging& paging, cs::SMFriendApplyList& re { int i = 0; int start = paging.curr_page() * paging.page_size(); - for (const FriendApply& apply : apply_list_) { + for (auto& pair : apply_hash_) { if (i >= start && i < start + paging.page_size()) { - TypeConvert::Convert(apply, *respmsg.add_apply_list()); + TypeConvert::Convert(*pair.second, *respmsg.add_apply_list()); } ++i; } diff --git a/server/imserver/player.h b/server/imserver/player.h index daecc2a..376c8c3 100644 --- a/server/imserver/player.h +++ b/server/imserver/player.h @@ -148,5 +148,4 @@ private: std::map friend_hash_; std::map apply_hash_; - std::list apply_list_; };