This commit is contained in:
aozhiwei 2023-11-04 11:38:34 +08:00
parent 6d7805223f
commit de8af0c10f

View File

@ -299,21 +299,21 @@ void MatchTeam::SyncMatchInfo()
void MatchTeam::TryCombineTeam() void MatchTeam::TryCombineTeam()
{ {
if (HaveEmptySlot()) { if (HaveEmptySlot()) {
MatchTeam* matched_team = nullptr; std::shared_ptr<MatchTeam> matched_team;
MatchMgr::Instance()->TraverseTeam MatchMgr::Instance()->TraverseTeam
( (
[this, &matched_team] (MatchTeam* team, bool& stop) [this, &matched_team] (std::shared_ptr<MatchTeam>& team, bool& stop)
{ {
if (team == this) { if (team.get() == this) {
return; return;
} }
if (CanCombine(team)) { if (CanCombine(team.get())) {
matched_team = team; matched_team = team;
stop = true; stop = true;
} }
}); });
if (matched_team) { if (matched_team) {
Combine(matched_team); Combine(matched_team.get());
} }
} }
} }
@ -638,7 +638,7 @@ void MatchTeam::StartGame()
auto cb = auto cb =
[team_uuid] (std::vector<std::shared_ptr<BattleDataContext>>& results) [team_uuid] (std::vector<std::shared_ptr<BattleDataContext>>& results)
{ {
MatchTeam* team = MatchMgr::Instance()->GetTeam(team_uuid); auto team = MatchMgr::Instance()->GetTeam(team_uuid);
if (team) { if (team) {
for (auto context : results) { for (auto context : results) {
bool found = false; bool found = false;
@ -656,7 +656,7 @@ void MatchTeam::StartGame()
abort(); abort();
} }
} }
RoomMgr::Instance()->JoinTeam(team); RoomMgr::Instance()->JoinTeam(team.get());
team->RemoveTeam(); team->RemoveTeam();
} }
}; };