This commit is contained in:
aozhiwei 2021-09-29 06:02:36 +00:00
commit 55704cc560
3 changed files with 17 additions and 11 deletions

View File

@ -7,7 +7,7 @@ namespace cs
class CMMatchCancel; class CMMatchCancel;
class CMMatchChoose; class CMMatchChoose;
class CMMatchStartGame; class CMMatchStartGame;
class CMMatchStartGameCancel; class CMMatchCancelStartGame;
} }
class MatchTeam; class MatchTeam;

View File

@ -84,13 +84,7 @@ void MatchTeam::Init(f8::MsgHdr& hdr, const cs::CMJoin& msg)
MatchTeam* team = (MatchTeam*)param.sender.GetUserData(); MatchTeam* team = (MatchTeam*)param.sender.GetUserData();
team->Update(); team->Update();
}, },
&timer_attacher.timer_list_, &timer_attacher.timer_list_
[] (const a8::XParams& param)
{
#ifdef DEBUG
a8::XPrintf("~MatchTeam.timer\n", {});
#endif
}
); );
phase_= kMatchCombining; phase_= kMatchCombining;
phase_start_tick_ = a8::XGetTickCount(); phase_start_tick_ = a8::XGetTickCount();
@ -261,7 +255,7 @@ void MatchTeam::UpdateMaster()
TryCombineTeam(); TryCombineTeam();
} }
} }
if (phase_left_time_ <= 0) { if (phase_left_time_ <= 0 || GetPredictMemberNum() >= MAX_TEAM_NUM) {
ChooseLeader(); ChooseLeader();
phase_ = kMatchChoose; phase_ = kMatchChoose;
phase_start_tick_ = a8::XGetTickCount(); phase_start_tick_ = a8::XGetTickCount();
@ -282,8 +276,8 @@ void MatchTeam::UpdateMaster()
} }
} }
} }
if (phase_left_time_ <= MetaMgr::Instance()->match_lock_time) { if ((phase_left_time_ <= MetaMgr::Instance()->match_lock_time) || IsAllPrepare()) {
for (int i = 0; i < 4; ++i) { for (int i = 0; i < MAX_TEAM_NUM; ++i) {
AutoChoose(true); AutoChoose(true);
} }
for (auto& member : curr_member_hash_) { for (auto& member : curr_member_hash_) {
@ -545,3 +539,14 @@ void MatchTeam::AutoChoose(bool force)
} }
} }
} }
bool MatchTeam::IsAllPrepare()
{
int num = 0;
for (auto& member : curr_member_hash_) {
if (member->state == kMatchPrepare) {
++num;
}
}
return num >= MAX_TEAM_NUM;
}

View File

@ -84,6 +84,7 @@ class MatchTeam
void StartGame(); void StartGame();
void ChooseLeader(); void ChooseLeader();
void AutoChoose(bool force = false); void AutoChoose(bool force = false);
bool IsAllPrepare();
private: private:
long long phase_start_tick_ = 0; long long phase_start_tick_ = 0;