From bba1e6ba8e4a66d6abb3505f3dacc482191000da Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 26 Nov 2021 15:36:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8C=B9=E9=85=8D=E6=97=B6?= =?UTF-8?q?=E7=BB=84=E9=98=9F=E5=86=85=E6=88=90=E5=91=98=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/matchmgr.cc | 16 +++++++++ server/gameserver/matchmgr.h | 4 +++ server/gameserver/matchteam.cc | 46 +++++++++++++++++++++++--- server/gameserver/matchteam.h | 2 ++ server/tools/protobuild/cs_msgid.proto | 3 ++ server/tools/protobuild/cs_proto.proto | 23 +++++++++++++ 6 files changed, 90 insertions(+), 4 deletions(-) diff --git a/server/gameserver/matchmgr.cc b/server/gameserver/matchmgr.cc index 0038013..05acb51 100644 --- a/server/gameserver/matchmgr.cc +++ b/server/gameserver/matchmgr.cc @@ -95,6 +95,22 @@ void MatchMgr::_CMMatchCancelStartGame(f8::MsgHdr& hdr, const cs::CMMatchCancelS } } +void MatchMgr::_CMMatchSendMsg(f8::MsgHdr& hdr, const cs::CMMatchSendMsg& msg) +{ + auto match_info = GetMatchInfo(hdr.socket_handle); + if (match_info) { + std::get<1>(*match_info)->_CMMatchSendMsg(hdr, msg); + } +} + +void MatchMgr::_CMMatchBroadcastMsg(f8::MsgHdr& hdr, const cs::CMMatchBroadcastMsg& msg) +{ + auto match_info = GetMatchInfo(hdr.socket_handle); + if (match_info) { + std::get<1>(*match_info)->_CMMatchBroadcastMsg(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 216b87f..491156d 100644 --- a/server/gameserver/matchmgr.h +++ b/server/gameserver/matchmgr.h @@ -8,6 +8,8 @@ namespace cs class CMMatchChoose; class CMMatchStartGame; class CMMatchCancelStartGame; + class CMMatchSendMsg; + class CMMatchBroadcastMsg; } class MatchTeam; @@ -31,6 +33,8 @@ public: 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 _CMMatchSendMsg(f8::MsgHdr& hdr, const cs::CMMatchSendMsg& msg); + void _CMMatchBroadcastMsg(f8::MsgHdr& hdr, const cs::CMMatchBroadcastMsg& 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 3d6390a..28ad946 100644 --- a/server/gameserver/matchteam.cc +++ b/server/gameserver/matchteam.cc @@ -94,10 +94,6 @@ void MatchTeam::Init(f8::MsgHdr& hdr, const cs::CMJoin& msg) void MatchTeam::_CMMatchCancel(f8::MsgHdr& hdr, const cs::CMMatchCancel& msg) { - auto member = GetMemberBySocket(hdr.socket_handle); - if (member) { - - } } void MatchTeam::_CMMatchChoose(f8::MsgHdr& hdr, const cs::CMMatchChoose& msg) @@ -158,6 +154,48 @@ void MatchTeam::_CMMatchCancelStartGame(f8::MsgHdr& hdr, const cs::CMMatchCancel } } +void MatchTeam::_CMMatchSendMsg(f8::MsgHdr& hdr, const cs::CMMatchSendMsg& msg) +{ + auto sender = GetMemberBySocket(hdr.socket_handle); + if (sender) { + for (auto member : master_team_->curr_member_hash_) { + if (member->socket_handle != 0) { + bool found = false; + for (auto& target : msg.target_list()) { + if (target == member->msg.account_id()) { + found = true; + break; + } + } + if (found) { + cs::SMMatchMemberMsgNotify notifymsg; + notifymsg.set_sender(sender->msg.account_id()); + notifymsg.set_content(msg.content()); + GGListener::Instance()->SendToClient(member->socket_handle, 0, notifymsg); + } + } + } + } +} + +void MatchTeam::_CMMatchBroadcastMsg(f8::MsgHdr& hdr, const cs::CMMatchBroadcastMsg& msg) +{ + auto sender = GetMemberBySocket(hdr.socket_handle); + if (sender) { + for (auto member : master_team_->curr_member_hash_) { + if (member->socket_handle != 0) { + if (!msg.exclude_self() || + (msg.exclude_self() && sender->msg.account_id() != member->msg.account_id())) { + cs::SMMatchMemberMsgNotify notifymsg; + notifymsg.set_sender(sender->msg.account_id()); + notifymsg.set_content(msg.content()); + GGListener::Instance()->SendToClient(member->socket_handle, 0, notifymsg); + } + } + } + } +} + void MatchTeam::AddRawMember(f8::MsgHdr& hdr, const cs::CMJoin& msg) { std::shared_ptr member = std::make_shared(); diff --git a/server/gameserver/matchteam.h b/server/gameserver/matchteam.h index e0d19ab..b76402a 100644 --- a/server/gameserver/matchteam.h +++ b/server/gameserver/matchteam.h @@ -54,6 +54,8 @@ class MatchTeam 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 _CMMatchSendMsg(f8::MsgHdr& hdr, const cs::CMMatchSendMsg& msg); + void _CMMatchBroadcastMsg(f8::MsgHdr& hdr, const cs::CMMatchBroadcastMsg& msg); void AddRawMember(f8::MsgHdr& hdr, const cs::CMJoin& msg); bool IsRawMember(const std::string& account_id); diff --git a/server/tools/protobuild/cs_msgid.proto b/server/tools/protobuild/cs_msgid.proto index 2d9cf2d..911d92b 100644 --- a/server/tools/protobuild/cs_msgid.proto +++ b/server/tools/protobuild/cs_msgid.proto @@ -25,6 +25,8 @@ enum CMMessageId_e _CMMatchChoose = 219; _CMMatchStartGame = 220; _CMMatchCancelStartGame = 221; + _CMMatchSendMsg = 222; + _CMMatchBroadcastMsg = 223; } enum SMMessageId_e @@ -56,4 +58,5 @@ enum SMMessageId_e _SMShowTeamUI = 1016; _SMUpdateMatchInfo = 1017; _SMGetItemNotify = 1018; + _SMMatchMemberMsgNotify = 1019; } diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index b31ee33..0ee6a1f 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -1134,6 +1134,22 @@ message CMMatchCancelStartGame { } +//组队匹配-指定成员发送消息 +message CMMatchSendMsg +{ + //成员将收到SMMatchMemberMsgNotify消息 + repeated string target_list = 1; //目标列表,目标收到SMMatchMemberMsgNotify消息 + optional string content = 2; //消息内容 +} + +//组队匹配-队伍内广播消息 +message CMMatchBroadcastMsg +{ + //成员将收到SMMatchMemberMsgNotify消息 + optional int32 exclude_self = 1; //include_self!=0时排除自己 + optional string content = 2; //消息内容 +} + //endcmmsg //观战error_code == 0 时关闭结算界面,回到战斗界面 @@ -1337,6 +1353,13 @@ message SMUpdateMatchInfo optional MFMatchInfo info = 1; //匹配信息 } +//匹配-队伍成员消息 +message SMMatchMemberMsgNotify +{ + optional string sender = 1; //消息发送者 + optional string content = 2; //消息内容 +} + //获得物品 message SMGetItemNotify {