1
This commit is contained in:
parent
0444cd6333
commit
aee60ccd96
@ -574,24 +574,26 @@ void MatchTeam::StartGame()
|
|||||||
{
|
{
|
||||||
phase_ = kMatchWaitStart;
|
phase_ = kMatchWaitStart;
|
||||||
if (GetValidSocketNum() > 0) {
|
if (GetValidSocketNum() > 0) {
|
||||||
RoomMgr::Instance()->JoinTeam(this);
|
std::vector<std::shared_ptr<cs::CMJoin>> join_msgs;
|
||||||
}
|
for (auto& member : GetCurrMembers()) {
|
||||||
for (auto& member : curr_member_hash_) {
|
if (!member->is_robot) {
|
||||||
if (member->socket_handle != 0) {
|
join_msgs.push_back(member->msg);
|
||||||
MatchMgr::Instance()->RemoveSocket(member->socket_handle);
|
}
|
||||||
}
|
}
|
||||||
|
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()
|
void MatchTeam::ChooseLeader()
|
||||||
@ -727,3 +729,16 @@ int MatchTeam::GetValidSocketNum()
|
|||||||
}
|
}
|
||||||
return valid_socket_num;
|
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());
|
||||||
|
}
|
||||||
|
@ -93,6 +93,7 @@ class MatchTeam
|
|||||||
void CheckChoose();
|
void CheckChoose();
|
||||||
void CheckPrepare();
|
void CheckPrepare();
|
||||||
int GetValidSocketNum();
|
int GetValidSocketNum();
|
||||||
|
void RemoveTeam();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long long phase_start_tick_ = 0;
|
long long phase_start_tick_ = 0;
|
||||||
|
@ -153,7 +153,8 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
|||||||
auto ip_saddr = hdr.ip_saddr;
|
auto ip_saddr = hdr.ip_saddr;
|
||||||
auto socket_handle = hdr.socket_handle;
|
auto socket_handle = hdr.socket_handle;
|
||||||
auto cb =
|
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;
|
cs::CMJoin& msg = *join_msg;
|
||||||
if (RoomMgr::Instance()->IsLimitJoin()) {
|
if (RoomMgr::Instance()->IsLimitJoin()) {
|
||||||
@ -769,7 +770,8 @@ void RoomMgr::OnJoinResponse(JoinRequest* req)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void RoomMgr::SendGetBattleData(std::vector<std::shared_ptr<cs::CMJoin>>& join_msgs,
|
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)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,8 @@ class RoomMgr : public a8::Singleton<RoomMgr>
|
|||||||
bool IsGM(const std::string& account_id);
|
bool IsGM(const std::string& account_id);
|
||||||
void JoinTeam(MatchTeam* team);
|
void JoinTeam(MatchTeam* team);
|
||||||
void SendGetBattleData(std::vector<std::shared_ptr<cs::CMJoin>>& join_msgs,
|
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:
|
private:
|
||||||
void InstallReportStateTimer();
|
void InstallReportStateTimer();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user