This commit is contained in:
aozhiwei 2022-03-22 19:12:16 +08:00
parent 0444cd6333
commit aee60ccd96
4 changed files with 38 additions and 19 deletions

View File

@ -574,24 +574,26 @@ void MatchTeam::StartGame()
{
phase_ = kMatchWaitStart;
if (GetValidSocketNum() > 0) {
RoomMgr::Instance()->JoinTeam(this);
}
for (auto& member : curr_member_hash_) {
if (member->socket_handle != 0) {
MatchMgr::Instance()->RemoveSocket(member->socket_handle);
std::vector<std::shared_ptr<cs::CMJoin>> join_msgs;
for (auto& member : GetCurrMembers()) {
if (!member->is_robot) {
join_msgs.push_back(member->msg);
}
}
std::string team_uuid = GetTeamUUid();
auto cb =
[team_uuid] (std::vector<std::tuple<std::shared_ptr<cs::CMJoin>, int, std::string>>& results)
{
MatchTeam* team = MatchMgr::Instance()->GetTeam(team_uuid);
if (team) {
RoomMgr::Instance()->JoinTeam(team);
team->RemoveTeam();
}
};
RoomMgr::Instance()->SendGetBattleData(join_msgs, cb);
} else {
RemoveTeam();
}
for (auto& pair : combined_team_hash_) {
MatchMgr::Instance()->RemoveTeam(pair.first);
}
MatchMgr::Instance()->RemoveTeam(GetTeamUUid());
std::vector<std::shared_ptr<cs::CMJoin>> join_msgs;
auto cb =
[] (std::vector<std::tuple<int, std::string>>& results)
{
};
RoomMgr::Instance()->SendGetBattleData(join_msgs, cb);
}
void MatchTeam::ChooseLeader()
@ -727,3 +729,16 @@ int MatchTeam::GetValidSocketNum()
}
return valid_socket_num;
}
void MatchTeam::RemoveTeam()
{
for (auto& member : curr_member_hash_) {
if (member->socket_handle != 0) {
MatchMgr::Instance()->RemoveSocket(member->socket_handle);
}
}
for (auto& pair : combined_team_hash_) {
MatchMgr::Instance()->RemoveTeam(pair.first);
}
MatchMgr::Instance()->RemoveTeam(GetTeamUUid());
}

View File

@ -93,6 +93,7 @@ class MatchTeam
void CheckChoose();
void CheckPrepare();
int GetValidSocketNum();
void RemoveTeam();
private:
long long phase_start_tick_ = 0;

View File

@ -153,7 +153,8 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
auto ip_saddr = hdr.ip_saddr;
auto socket_handle = hdr.socket_handle;
auto cb =
[ip_saddr, socket_handle, join_msg] (std::vector<std::tuple<int, std::string>>& results)
[ip_saddr, socket_handle, join_msg]
(std::vector<std::tuple<std::shared_ptr<cs::CMJoin>, int, std::string>>& results)
{
cs::CMJoin& msg = *join_msg;
if (RoomMgr::Instance()->IsLimitJoin()) {
@ -769,7 +770,8 @@ void RoomMgr::OnJoinResponse(JoinRequest* req)
#endif
void RoomMgr::SendGetBattleData(std::vector<std::shared_ptr<cs::CMJoin>>& join_msgs,
std::function<void(std::vector<std::tuple<int, std::string>>&)> cb)
std::function<
void(std::vector<std::tuple<std::shared_ptr<cs::CMJoin>, int, std::string>>&)> cb)
{
}

View File

@ -72,7 +72,8 @@ class RoomMgr : public a8::Singleton<RoomMgr>
bool IsGM(const std::string& account_id);
void JoinTeam(MatchTeam* team);
void SendGetBattleData(std::vector<std::shared_ptr<cs::CMJoin>>& join_msgs,
std::function<void(std::vector<std::tuple<int, std::string>>&)> cb);
std::function<
void(std::vector<std::tuple<std::shared_ptr<cs::CMJoin>, int, std::string>>&)> cb);
private:
void InstallReportStateTimer();