From 448443662994e2ad88a25ff0d81c5e998c47a645 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 25 Mar 2024 21:02:00 +0800 Subject: [PATCH] 1 --- server/gameserver/custom_battle.cc | 15 +++++++++++++++ server/gameserver/custom_battle.h | 1 + server/gameserver/custom_member.h | 1 + 3 files changed, 17 insertions(+) diff --git a/server/gameserver/custom_battle.cc b/server/gameserver/custom_battle.cc index d7391b44..bfe36402 100644 --- a/server/gameserver/custom_battle.cc +++ b/server/gameserver/custom_battle.cc @@ -184,6 +184,18 @@ bool CustomBattle::AllIsJoined() return ok; } +bool CustomBattle::AllIsReady() +{ + bool ok = true; + for (auto& pair : member_id_hash_) { + if (!pair.second->IsReady()) { + ok = false; + break; + } + } + return ok; +} + int CustomBattle::GetMemberNum() { return member_id_hash_.size(); @@ -304,5 +316,8 @@ void CustomBattle::OnEnter(std::shared_ptr join_msg, long ip_saddr, void CustomBattle::OnMemberReady(CustomMember* member) { + if (state_ == 0 && AllIsReady()) { + state_ = 1; + } NotifyState(); } diff --git a/server/gameserver/custom_battle.h b/server/gameserver/custom_battle.h index 080aaea4..673218e7 100644 --- a/server/gameserver/custom_battle.h +++ b/server/gameserver/custom_battle.h @@ -34,6 +34,7 @@ class CustomBattle std::shared_ptr GetTeamByTeamUuid(const std::string& team_uuid); std::shared_ptr GetObByAccountId(const std::string& account_id); bool AllIsJoined(); + bool AllIsReady(); int GetMemberNum(); int GetTeamNum(); void TraverseMemberList(std::function func); diff --git a/server/gameserver/custom_member.h b/server/gameserver/custom_member.h index a91730b2..126a352d 100644 --- a/server/gameserver/custom_member.h +++ b/server/gameserver/custom_member.h @@ -32,6 +32,7 @@ class CustomMember std::shared_ptr& GetNetData() { return battle_context_; }; void _CMBattlePreSetReady(f8::MsgHdr* hdr, const cs::CMBattlePreSetReady& msg); bool IsAndroid(); + bool IsReady() { return is_ready_; } private: std::shared_ptr join_msg_;