From 8dd18e5aa06516b9a6412f1d5cf5618a79ea70bb Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 31 Aug 2019 18:46:27 +0800 Subject: [PATCH] 1 --- server/gameserver/roommgr.cc | 12 ++++++++++-- server/gameserver/roommgr.h | 1 + server/masterserver/gsmgr.cc | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 1c8533d..656fee3 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -16,7 +16,9 @@ #include "framework/cpp/httpclientpool.h" -const int ROOM_NUM_LIMIT = 20; +const int ROOM_NUM_DOWN_LIMIT = 20; +const int ROOM_NUM_UP_LIMIT = 40; +const int HUM_NUM_DOWN_LIMIT = 500; void RoomMgr::Init() { @@ -50,7 +52,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg) if (!hum_meta) { abort(); } - if (RoomNum() >= ROOM_NUM_LIMIT) { + if (IsLimitJoin()) { { cs::SMJoinedNotify notifymsg; notifymsg.set_error_code(2); @@ -272,3 +274,9 @@ void RoomMgr::InstallReportStateTimer() &reportstate_timer_attacher_.timer_list_); } } + +bool RoomMgr::IsLimitJoin() +{ + return RoomNum() >= ROOM_NUM_UP_LIMIT || + (RoomNum() >= ROOM_NUM_DOWN_LIMIT && App::Instance()->perf.alive_count >= HUM_NUM_DOWN_LIMIT); +} diff --git a/server/gameserver/roommgr.h b/server/gameserver/roommgr.h index 88e262d..426e6ac 100644 --- a/server/gameserver/roommgr.h +++ b/server/gameserver/roommgr.h @@ -34,6 +34,7 @@ class RoomMgr : public a8::Singleton Room* GetJoinableRoom(const std::string& account_id); void ReportServerState(int instance_id, const std::string& host, int port); void FreeOverRoom(long long room_uuid); + bool IsLimitJoin(); private: std::map inactive_room_hash_; diff --git a/server/masterserver/gsmgr.cc b/server/masterserver/gsmgr.cc index a4df45c..6de04bf 100644 --- a/server/masterserver/gsmgr.cc +++ b/server/masterserver/gsmgr.cc @@ -222,4 +222,5 @@ void GSMgr::ClearTimeOutNode() } node_key_hash_.erase(node->key); } + RearrangeNode(); }