diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index c204c366..befbdfdc 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -1036,6 +1036,26 @@ bool Room::CanJoin(const std::string& accountid, if (GetPlayerByAccountId(accountid)) { return false; } + if (GetPlayerNum() < (int)GetRoomMaxPlayerNum() && + !msg.team_uuid().empty() && + human_hash_.size() >= GetRoomMaxPlayerNum() + ) { + bool have_team = false; + for (auto& pair : human_hash_) { + if (pair.second->team_uuid == msg.team_uuid()) { + if (pair.second->GetTeam() && !pair.second->GetTeam()->IsFull()) { + have_team = true; + break; + } + } + }//end for human_hash_ + if (have_team) { + while (human_hash_.size() >= GetRoomMaxPlayerNum()) { + RandRemoveAndroid(); + break; + } + } + } return GetPlayerNum() < (int)GetRoomMaxPlayerNum(); }