From de8af0c10fc83d4a007509e4893c1679506c0f1e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 4 Nov 2023 11:38:34 +0800 Subject: [PATCH] 1 --- server/gameserver/matchteam.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/gameserver/matchteam.cc b/server/gameserver/matchteam.cc index d6eb23cb..e2e47389 100644 --- a/server/gameserver/matchteam.cc +++ b/server/gameserver/matchteam.cc @@ -299,21 +299,21 @@ void MatchTeam::SyncMatchInfo() void MatchTeam::TryCombineTeam() { if (HaveEmptySlot()) { - MatchTeam* matched_team = nullptr; + std::shared_ptr matched_team; MatchMgr::Instance()->TraverseTeam ( - [this, &matched_team] (MatchTeam* team, bool& stop) + [this, &matched_team] (std::shared_ptr& team, bool& stop) { - if (team == this) { + if (team.get() == this) { return; } - if (CanCombine(team)) { + if (CanCombine(team.get())) { matched_team = team; stop = true; } }); if (matched_team) { - Combine(matched_team); + Combine(matched_team.get()); } } } @@ -638,7 +638,7 @@ void MatchTeam::StartGame() auto cb = [team_uuid] (std::vector>& results) { - MatchTeam* team = MatchMgr::Instance()->GetTeam(team_uuid); + auto team = MatchMgr::Instance()->GetTeam(team_uuid); if (team) { for (auto context : results) { bool found = false; @@ -656,7 +656,7 @@ void MatchTeam::StartGame() abort(); } } - RoomMgr::Instance()->JoinTeam(team); + RoomMgr::Instance()->JoinTeam(team.get()); team->RemoveTeam(); } };