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 CMMatchChoose;
class CMMatchStartGame;
class CMMatchStartGameCancel;
class CMMatchCancelStartGame;
}
class MatchTeam;

View File

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