This commit is contained in:
aozhiwei 2020-08-11 16:25:36 +08:00
parent c2eb1b4e40
commit f07f400287
4 changed files with 25 additions and 5 deletions

View File

@ -914,6 +914,11 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
void Player::_CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg)
{
int old_socket_handle = socket_handle;
if (socket_handle != 0) {
GGListener::Instance()->ForceCloseChildSocket(socket_handle);
PlayerMgr::Instance()->RemovePlayerBySocket(socket_handle);
}
socket_handle = hdr.socket_handle;
#if 0
TouchAllLayerHumanList
@ -930,6 +935,13 @@ void Player::_CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg)
respmsg.set_errmsg("战斗重连成功");
SendNotifyMsg(respmsg);
PlayerMgr::Instance()->ReBindSocket(this);
a8::UdpLog::Instance()->Debug
("战斗服重连成功 %s %d %d",
{
account_id,
hdr.socket_handle,
old_socket_handle
});
}
void Player::UpdateDropWeapon()

View File

@ -747,18 +747,19 @@ bool Room::CanJoin(const std::string& accountid)
void Room::OnPlayerOffline(Player* hum)
{
if (GetOnlinePlayerNum() <= 0) {
xtimer.AddDeadLineTimer
xtimer.AddDeadLineTimerAndAttach
(
SERVER_FRAME_RATE * 40,
SERVER_FRAME_RATE * 15,
a8::XParams()
.SetSender(this),
[] (const a8::XParams& param)
{
Room* room = (Room*)param.sender.GetUserData();
if (room->GetOnlinePlayerNum() <= 0) {
if (room->GetOnlinePlayerNum() <= 0 && !room->added_to_over_room) {
RoomMgr::Instance()->AddOverRoom(room->room_uuid);
}
});
},
&xtimer_attacher.timer_list_);
}
}

View File

@ -49,6 +49,7 @@ public:
long long pending_request = 0;
long long last_debugout_tick = 0;
a8::Vec2 last_player_jump_pos;
bool added_to_over_room = false;
~Room();
void Init();

View File

@ -128,7 +128,7 @@ void RoomMgr::_CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg)
.SetSender(socket_handle),
[] (const a8::XParams& param)
{
GGListener::Instance()->ForceCloseClient(param.sender);
GGListener::Instance()->ForceCloseChildSocket(param.sender);
}
);
};
@ -136,6 +136,11 @@ void RoomMgr::_CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg)
Room* room = GetRoomByUuid(a8::XValue(msg.room_uuid()));
if (!room) {
send_reconnect_failed(hdr.socket_handle, 1, "房间已销毁");
a8::UdpLog::Instance()->Debug
("房间已销毁 %s",
{
msg.room_uuid()
});
return;
}
Player* hum = room->GetPlayerByAccountId(msg.account_id());
@ -190,6 +195,7 @@ void RoomMgr::AddOverRoom(long long room_uuid)
inactive_room_hash_.erase(room_uuid);
Room* room = GetRoomByUuid(room_uuid);
if (room) {
room->added_to_over_room = true;
room->game_over_tick = a8::XGetTickCount();
room->game_over_timer = a8::Timer::Instance()->AddRepeatTimer(500,
a8::XParams()