This commit is contained in:
aozhiwei 2023-06-20 15:48:36 +08:00
parent 0996109eae
commit 4ceff51f7d

View File

@ -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();
}