diff --git a/server/gameserver/handlermgr.cc b/server/gameserver/handlermgr.cc index a344e0e..db902b7 100644 --- a/server/gameserver/handlermgr.cc +++ b/server/gameserver/handlermgr.cc @@ -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); diff --git a/server/gameserver/matchmgr.cc b/server/gameserver/matchmgr.cc index c8fe739..7e460b9 100644 --- a/server/gameserver/matchmgr.cc +++ b/server/gameserver/matchmgr.cc @@ -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() && diff --git a/server/gameserver/matchmgr.h b/server/gameserver/matchmgr.h index dc46ca4..29e2403 100644 --- a/server/gameserver/matchmgr.h +++ b/server/gameserver/matchmgr.h @@ -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 func); bool NeedMatch(const cs::CMJoin& msg); diff --git a/server/gameserver/matchteam.cc b/server/gameserver/matchteam.cc index d293cfa..82b0994 100644 --- a/server/gameserver/matchteam.cc +++ b/server/gameserver/matchteam.cc @@ -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(); } } diff --git a/server/gameserver/matchteam.h b/server/gameserver/matchteam.h index 06a4258..4f80096 100644 --- a/server/gameserver/matchteam.h +++ b/server/gameserver/matchteam.h @@ -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);