This commit is contained in:
aozhiwei 2024-05-17 17:45:34 +08:00
parent 8acbe0abf6
commit 2decd9f875
2 changed files with 10 additions and 4 deletions

View File

@ -2266,10 +2266,11 @@ void Human::ReJoin(long ip_saddr, int socket_handle)
if (!IsPlayer()) { if (!IsPlayer()) {
abort(); abort();
} }
if (socket_handle == 0 && GetSocketHandle() != 0) {
A8_ABORT();
}
auto old_socket_handle = GetSocketHandle(); auto old_socket_handle = GetSocketHandle();
if (SocketIsValid()) {
GGListener::Instance()->ForceCloseChildSocket(GetSocketHandle());
PlayerMgr::Instance()->RemovePlayerBySocket(GetSocketHandle());
}
SetIpSaddr(ip_saddr); SetIpSaddr(ip_saddr);
SetSocketHandle(socket_handle); SetSocketHandle(socket_handle);
room->frame_event.AddEnterGame(GetWeakPtrRef()); room->frame_event.AddEnterGame(GetWeakPtrRef());
@ -2280,7 +2281,9 @@ void Human::ReJoin(long ip_saddr, int socket_handle)
PushJoinRoomMsg(); PushJoinRoomMsg();
RefreshView(); RefreshView();
room->NotifyUiUpdate(); room->NotifyUiUpdate();
PlayerMgr::Instance()->ReBindSocket(AsPlayer()); if (SocketIsValid()) {
PlayerMgr::Instance()->ReBindSocket(AsPlayer());
}
#ifdef MYDEBUG #ifdef MYDEBUG
a8::XPrintf("ReJoin account_id:%s old_socket_handle:%d new_socket_handle:%d socket_handle:%d\n", a8::XPrintf("ReJoin account_id:%s old_socket_handle:%d new_socket_handle:%d socket_handle:%d\n",
{ {

View File

@ -124,6 +124,9 @@ void PlayerMgr::DecAccountNum(const std::string& account_id)
void PlayerMgr::ReBindSocket(Player* hum) void PlayerMgr::ReBindSocket(Player* hum)
{ {
if (!hum->SocketIsValid()) {
A8_ABORT();
}
#ifdef MYDEBUG #ifdef MYDEBUG
a8::XPrintf("ReBindSocket account_id:%s socket_handle:%d\n", a8::XPrintf("ReBindSocket account_id:%s socket_handle:%d\n",
{ {