1
This commit is contained in:
parent
1b73729a60
commit
15afd14d88
@ -49,7 +49,7 @@ void PlayerMgr::_CMLogin(f8::MsgHdr& hdr, const cs::CMLogin& msg)
|
||||
return;
|
||||
}
|
||||
f8::MsgHdr* new_hdr = hdr.Clone();
|
||||
pending_socket_hash_[hdr.socket_handle] = new_hdr;
|
||||
pending_socket_hash_[hdr.socket_handle] = std::make_tuple(msg.account_id(), new_hdr);
|
||||
pending_account_hash_[msg.account_id()] = new_hdr;
|
||||
AsyncLogin1(msg);
|
||||
}
|
||||
@ -125,7 +125,7 @@ void PlayerMgr::RemovePlayerBySocket(int socket_handle)
|
||||
f8::MsgHdr* PlayerMgr::GetHdrBySocket(int socket_handle)
|
||||
{
|
||||
auto itr = pending_socket_hash_.find(socket_handle);
|
||||
return itr != pending_socket_hash_.end() ? itr->second : nullptr;
|
||||
return itr != pending_socket_hash_.end() ? std::get<1>(itr->second) : nullptr;
|
||||
}
|
||||
|
||||
f8::MsgHdr* PlayerMgr::GetHdrByAccountId(const std::string& account_id)
|
||||
@ -270,10 +270,7 @@ void PlayerMgr::AsyncLoginOnOk(const std::string& account_id,
|
||||
}
|
||||
pending_socket_hash_.erase(hdr->socket_handle);
|
||||
pending_account_hash_.erase(account_id);
|
||||
if (hdr->buf) {
|
||||
free((void*)hdr->buf);
|
||||
}
|
||||
free((void*)hdr);
|
||||
f8::MsgHdr::Destroy(hdr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,22 +281,18 @@ void PlayerMgr::AsyncLoginOnError(const std::string& account_id, int step,
|
||||
if (hdr) {
|
||||
pending_socket_hash_.erase(hdr->socket_handle);
|
||||
pending_account_hash_.erase(account_id);
|
||||
if (hdr->buf) {
|
||||
free((void*)hdr->buf);
|
||||
}
|
||||
free((void*)hdr);
|
||||
f8::MsgHdr::Destroy(hdr);
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerMgr::OnClientSocketDisconnect(int socket_handle)
|
||||
{
|
||||
{
|
||||
f8::MsgHdr* hdr = GetHdrBySocket(socket_handle);
|
||||
if (hdr) {
|
||||
if (hdr->buf) {
|
||||
free((void*)hdr->buf);
|
||||
}
|
||||
free((void*)hdr);
|
||||
auto itr = pending_socket_hash_.find(socket_handle);
|
||||
if (itr != pending_socket_hash_.end()) {
|
||||
pending_account_hash_.erase(std::get<0>(itr->second));
|
||||
f8::MsgHdr::Destroy(std::get<1>(itr->second));
|
||||
pending_socket_hash_.erase(itr);
|
||||
}
|
||||
}
|
||||
{
|
||||
|
@ -60,6 +60,6 @@ class PlayerMgr : public a8::Singleton<PlayerMgr>
|
||||
std::map<int, Player*> socket_hash_;
|
||||
std::map<std::string, Player*> accountid_hash_;
|
||||
|
||||
std::map<int, f8::MsgHdr*> pending_socket_hash_;
|
||||
std::map<int, std::tuple<std::string, f8::MsgHdr*>> pending_socket_hash_;
|
||||
std::map<std::string, f8::MsgHdr*> pending_account_hash_;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user