This commit is contained in:
aozhiwei 2024-02-02 16:18:17 +08:00
parent 18367b8c17
commit 88797a0fa6

View File

@ -1704,16 +1704,27 @@ bool Room::GenSmallCircle()
void Room::MatchTeam(Human* hum) void Room::MatchTeam(Human* hum)
{ {
if (!hum->team_uuid.empty()) { if (!hum->team_uuid.empty()) {
for (auto& pair : human_hash_) { {
if (pair.second != hum) { bool match_ok = false;
if (pair.second->team_uuid == hum->team_uuid) { TraverseHumanList
if (pair.second->GetTeam() && !pair.second->GetTeam()->IsFull()) { (
pair.second->GetTeam()->AddMember(hum); [&match_ok, hum] (Human* ele_hum) -> bool
return; {
} if (ele_hum != hum) {
} if (ele_hum->team_uuid == hum->team_uuid) {
if (ele_hum->GetTeam() && !ele_hum->GetTeam()->IsFull()) {
ele_hum->GetTeam()->AddMember(hum);
match_ok = true;
return false;
}
}
}
return true;
});
if (match_ok) {
return;
} }
}//end for human_hash_ }
if (mt::Param::s().prebattle_combine_team) { if (mt::Param::s().prebattle_combine_team) {
if (!hum->GetTeam() && hum->auto_fill && combineable_team_hash_.size() > 1) { if (!hum->GetTeam() && hum->auto_fill && combineable_team_hash_.size() > 1) {
for (auto& pair : combineable_team_hash_) { for (auto& pair : combineable_team_hash_) {