This commit is contained in:
aozhiwei 2023-12-28 11:31:11 +08:00
parent ed6a817056
commit 8be61c1810
3 changed files with 18 additions and 0 deletions

View File

@ -48,3 +48,12 @@ void MobaBattle::TraverseMemberList(std::function<bool (MobaMember*)> func)
}
}
}
void MobaBattle::TraverseTeam(std::function<bool (std::shared_ptr<MobaTeam>)> cb)
{
for (auto& pair : uuid_hash_) {
if (!cb(pair.second)) {
break;
}
}
}

View File

@ -28,6 +28,7 @@ class MobaBattle
int GetMemberNum();
int GetTeamNum();
void TraverseMemberList(std::function<bool (MobaMember*)> func);
void TraverseTeam(std::function<bool (std::shared_ptr<MobaTeam>)> cb);
private:
bool parse_ok_ = false;

View File

@ -2244,6 +2244,14 @@ void Room::NotifyKillList(const std::vector<int>& uniid_list)
int Room::InitWithMobaBattle(long ip_saddr, int socket_handle, std::shared_ptr<cs::CMJoin> msg,
std::shared_ptr<MobaBattle> p)
{
std::vector<std::shared_ptr<MobaTeam>> moba_teams;
p->TraverseTeam
(
[&moba_teams] (std::shared_ptr<MobaTeam> team) -> bool
{
moba_teams.push_back(team);
return true;
});
p->TraverseMemberList
(
[p, msg, ip_saddr, socket_handle] (MobaMember* m) -> bool