This commit is contained in:
aozhiwei 2021-09-28 08:42:53 +00:00
parent e323c1685a
commit 42d4d55d71
5 changed files with 24 additions and 2 deletions

View File

@ -90,6 +90,7 @@ void HandlerMgr::RegisterNetMsgHandlers()
RegisterNetMsgHandler(&ggmsghandler, &MatchMgr::_CMMatchCancel);
RegisterNetMsgHandler(&ggmsghandler, &MatchMgr::_CMMatchChoose);
RegisterNetMsgHandler(&ggmsghandler, &MatchMgr::_CMMatchStartGame);
RegisterNetMsgHandler(&ggmsghandler, &MatchMgr::_CMMatchCancelStartGame);
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMMove);
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMExecCommand);

View File

@ -70,6 +70,14 @@ void MatchMgr::_CMMatchStartGame(f8::MsgHdr& hdr, const cs::CMMatchStartGame& ms
}
}
void MatchMgr::_CMMatchCancelStartGame(f8::MsgHdr& hdr, const cs::CMMatchCancelStartGame& msg)
{
auto match_info = GetMatchInfo(hdr.socket_handle);
if (match_info) {
std::get<1>(*match_info)->_CMMatchCancelStartGame(hdr, msg);
}
}
bool MatchMgr::NeedMatch(const cs::CMJoin& msg)
{
bool need = !msg.team_uuid().empty() &&

View File

@ -7,6 +7,7 @@ namespace cs
class CMMatchCancel;
class CMMatchChoose;
class CMMatchStartGame;
class CMMatchStartGameCancel;
}
class MatchTeam;
@ -27,6 +28,7 @@ public:
void _CMMatchCancel(f8::MsgHdr& hdr, const cs::CMMatchCancel& msg);
void _CMMatchChoose(f8::MsgHdr& hdr, const cs::CMMatchChoose& msg);
void _CMMatchStartGame(f8::MsgHdr& hdr, const cs::CMMatchStartGame& msg);
void _CMMatchCancelStartGame(f8::MsgHdr& hdr, const cs::CMMatchCancelStartGame& msg);
void TraverseTeam(std::function<void (MatchTeam*, bool&)> func);
bool NeedMatch(const cs::CMJoin& msg);

View File

@ -93,9 +93,18 @@ void MatchTeam::_CMMatchStartGame(f8::MsgHdr& hdr, const cs::CMMatchStartGame& m
if (phase_ == kMatchChoose) {
auto member = GetMemberBySocket(hdr.socket_handle);
if (member) {
member->state = kMatchPrepare;
}
}
}
void MatchTeam::_CMMatchCancelStartGame(f8::MsgHdr& hdr, const cs::CMMatchCancelStartGame& msg)
{
if (phase_ == kMatchChoose) {
auto member = GetMemberBySocket(hdr.socket_handle);
if (member) {
member->state = kMatchReadying;
}
StartGame();
}
}

View File

@ -36,6 +36,7 @@ struct RawTeamMember
bool is_robot = false;
bool is_leader = false;
int state = kMatchReadying;
int choose_hero_tiems = 0;
MetaData::Robot* robot_meta = nullptr;
void FillMFMatchTeamMember(cs::MFMatchTeamMember* msg);
void InitRobot();
@ -52,6 +53,7 @@ class MatchTeam
void _CMMatchCancel(f8::MsgHdr& hdr, const cs::CMMatchCancel& msg);
void _CMMatchChoose(f8::MsgHdr& hdr, const cs::CMMatchChoose& msg);
void _CMMatchStartGame(f8::MsgHdr& hdr, const cs::CMMatchStartGame& msg);
void _CMMatchCancelStartGame(f8::MsgHdr& hdr, const cs::CMMatchCancelStartGame& msg);
void AddRawMember(f8::MsgHdr& hdr, const cs::CMJoin& msg);
bool IsRawMember(const std::string& account_id);