diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 1ee5b31..b7222ab 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -715,6 +715,9 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) member->SendGameOver(); } } + if (team_members != members) { + SendGameOver(); + } } DeadDrop(); } @@ -1960,6 +1963,7 @@ void Human::InternalSendGameOver() int hum_uniid = param.param1; Room* room = RoomMgr::Instance()->GetRoomByUuid(room_uuid); if (room) { + room->pending_request--; Entity* entity = room->GetEntityByUniId(hum_uniid); if (entity && entity->entity_type == ET_Player) { Human* hum = (Human*)entity; @@ -1972,14 +1976,6 @@ void Human::InternalSendGameOver() cs::SMGameOver msg; hum->FillSMGameOver(msg); hum->SendNotifyMsg(msg); - if (hum->socket_handle == 0) { - a8::UdpLog::Instance()->Error("battleReport socket_handle error room_uuid:%s account_id:%s nickname:%s ", - { - room_uuid, - hum->account_id, - hum->name - }); - } if (!hum->sent_game_end_ && hum->entity_subtype == EST_Player) { GameLog::Instance()->GameEnd((Player*)hum); hum->sent_game_end_ = true; @@ -1998,6 +1994,7 @@ void Human::InternalSendGameOver() int hum_uniid = param.param1; Room* room = RoomMgr::Instance()->GetRoomByUuid(room_uuid); if (room) { + room->pending_request--; Entity* entity = room->GetEntityByUniId(hum_uniid); if (entity && entity->entity_type == ET_Player) { Human* hum = (Human*)entity; @@ -2019,6 +2016,7 @@ void Human::InternalSendGameOver() } else { url = "https://game2001api.kingsome.cn/webapp/index.php?c=Role&a=battleReport"; } + room->pending_request++; std::string data; params->ToUrlEncodeStr(data); f8::HttpClientPool::Instance()->HttpGet( diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 94fae02..8c7b1f3 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -75,6 +75,10 @@ void Room::Init() void Room::UnInit() { + if (game_over_timer) { + a8::Timer::Instance()->DeleteTimer(game_over_timer); + game_over_timer = nullptr; + } xtimer_attacher.ClearTimerList(); if (stats_timer_) { a8::Timer::Instance()->DeleteTimer(stats_timer_); diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 38efd05..dd83210 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -42,12 +42,15 @@ public: GasData gas_data; bool game_over = false; long long game_over_frameno = 0; + long long game_over_tick = 0; + timer_list* game_over_timer = nullptr; RoomProfile profile; a8::XTimer xtimer; Plane plane; GridService grid_service; MapService map_service; long long battle_start_frameno_ = 0; + long long pending_request = 0; ~Room(); void Init(); diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index b4bc367..07d7c87 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -104,25 +104,28 @@ Room* RoomMgr::GetRoomByUuid(long long room_uuid) void RoomMgr::AddOverRoom(long long room_uuid) { + auto callback = [] (const a8::XParams& param) + { + Room* room = RoomMgr::Instance()->GetRoomByUuid(param.sender); + if (room) { + if ((room->pending_request <= 0) || + (a8::XGetTickCount() - room->game_over_tick > 1000 * 8)) { + RoomMgr::Instance()->room_hash_.erase(room->room_uuid); + RoomMgr::Instance()->over_room_hash_[room->room_uuid] = room; + RoomMgr::Instance()->FreeOverRoom(param.sender); + } + } + }; + inactive_room_hash_.erase(room_uuid); - a8::Timer::Instance()->AddDeadLineTimer(1000, - a8::XParams() - .SetSender(room_uuid), - [] (const a8::XParams& param) - { - Room* room = RoomMgr::Instance()->GetRoomByUuid(param.sender); - if (room) { - RoomMgr::Instance()->room_hash_.erase(room->room_uuid); - RoomMgr::Instance()->over_room_hash_[room->room_uuid] = room; - } - }); - a8::Timer::Instance()->AddDeadLineTimer(1000 + 100, - a8::XParams() - .SetSender(room_uuid), - [] (const a8::XParams& param) - { - RoomMgr::Instance()->FreeOverRoom(param.sender); - }); + Room* room = GetRoomByUuid(room_uuid); + if (room) { + room->game_over_tick = a8::XGetTickCount(); + room->game_over_timer = a8::Timer::Instance()->AddRepeatTimer(500, + a8::XParams() + .SetSender(room_uuid), + callback); + } } void RoomMgr::ActiveRoom(long long room_uuid) diff --git a/server/tools/protobuild/ss_msgid.proto b/server/tools/protobuild/ss_msgid.proto index 1b5e467..0595eb5 100644 --- a/server/tools/protobuild/ss_msgid.proto +++ b/server/tools/protobuild/ss_msgid.proto @@ -9,5 +9,6 @@ enum SSMessageId_e _SS_WSP_SocketDisconnect = 10; _SS_WSP_RequestTargetServer = 11; _SS_MS_ResponseTargetServer = 12; + _SS_ForceCloseSocket = 13; } diff --git a/server/tools/protobuild/ss_proto.proto b/server/tools/protobuild/ss_proto.proto index e48d39d..be04905 100755 --- a/server/tools/protobuild/ss_proto.proto +++ b/server/tools/protobuild/ss_proto.proto @@ -29,3 +29,7 @@ message SS_MS_ResponseTargetServer optional string host = 4; optional int32 port = 5; } + +message SS_ForceCloseSocket +{ +}