add matchteam

This commit is contained in:
aozhiwei 2021-09-27 07:14:46 +00:00
parent 8c8a330d8c
commit b61181afd6
7 changed files with 135 additions and 4 deletions

View File

@ -1,6 +1,9 @@
#include "precompile.h"
#include "cs_proto.pb.h"
#include "matchmgr.h"
#include "GGListener.h"
#include "matchteam.h"
void MatchMgr::Init()
{
@ -11,3 +14,47 @@ void MatchMgr::UnInit()
{
}
bool MatchMgr::NeedMatch(const cs::CMJoin& msg)
{
bool need = !msg.team_uuid().empty() &&
msg.show_team_ui() &&
msg.team_mode() == 1 &&
msg.auto_fill() &&
msg.team_members().size() > 0 &&
msg.team_members().size() < 4;
if (need) {
MatchTeam* team = GetTeam(msg.team_uuid());
if (team && !team->IsValidMember(msg)) {
need = false;
}
}
return need;
}
void MatchMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
{
if (!NeedMatch(msg)) {
return;
}
{
cs::SMShowTeamUI notifymsg;
GGListener::Instance()->SendToClient(hdr.socket_handle, 0, notifymsg);
}
{
MatchTeam* team = GetTeam(msg.account_id());
if (!team) {
team = new MatchTeam();
team->Init(hdr, msg);
team_hash_[msg.team_uuid()] = team;
} else {
team->AddRawMember(hdr, msg);
}
}
}
MatchTeam* MatchMgr::GetTeam(const std::string& team_uuid)
{
auto itr = team_hash_.find(team_uuid);
return itr != team_hash_.end() ? itr->second : nullptr;
}

View File

@ -1,6 +1,12 @@
#pragma once
class Room;
namespace cs
{
class CMJoin;
class CMReconnect;
}
class MatchTeam;
class MatchMgr : public a8::Singleton<MatchMgr>
{
@ -12,4 +18,10 @@ public:
void Init();
void UnInit();
bool NeedMatch(const cs::CMJoin& msg);
void _CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg);
MatchTeam* GetTeam(const std::string& team_uuid);
private:
std::map<std::string, MatchTeam*> team_hash_;
};

View File

@ -0,0 +1,32 @@
#include "precompile.h"
#include "cs_proto.pb.h"
#include "matchteam.h"
#include "matchmgr.h"
struct RawTeamMember
{
int socket_handle = 0;
std::shared_ptr<cs::CMJoin> msg;
};
void MatchTeam::Init(f8::MsgHdr& hdr, const cs::CMJoin& msg)
{
create_tick_ = a8::XGetTickCount();
}
void MatchTeam::AddRawMember(f8::MsgHdr& hdr, const cs::CMJoin& msg)
{
}
bool MatchTeam::IsRawMember(const std::string &account_id)
{
auto itr = raw_member_hash_.find(account_id);
return itr != raw_member_hash_.end();
}
bool MatchTeam::IsValidMember(const cs::CMJoin& msg)
{
return false;
}

View File

@ -0,0 +1,23 @@
#pragma once
namespace cs
{
class CMJoin;
class CMReconnect;
}
struct RawTeamMember;
class MatchTeam
{
public:
void Init(f8::MsgHdr& hdr, const cs::CMJoin& msg);
void AddRawMember(f8::MsgHdr& hdr, const cs::CMJoin& msg);
bool IsRawMember(const std::string& account_id);
bool IsValidMember(const cs::CMJoin& msg);
private:
long long create_tick_ = 0;
std::map<std::string, std::shared_ptr<RawTeamMember>> raw_member_hash_;
std::shared_ptr<RawTeamMember> first_member_;
};

View File

@ -15,6 +15,7 @@
#include "playermgr.h"
#include "mapmgr.h"
#include "perfmonitor.h"
#include "matchmgr.h"
#include "framework/cpp/httpclientpool.h"
#include "framework/cpp/utils.h"
@ -141,6 +142,10 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
}
}
#endif
if (MatchMgr::Instance()->NeedMatch(msg)) {
MatchMgr::Instance()->_CMJoin(hdr, msg);
return;
}
int game_times = 0;
RoomType_e self_room_type = GetHumanRoomType(msg, game_times);
if (self_room_type < RT_OldBrid1) {

View File

@ -52,5 +52,6 @@ enum SMMessageId_e
_SMGameStart = 1013;
_SMSysPiaoMsg = 1014;
_SMShowCountdown = 1015;
_SMUpdateMatchInfo = 1016;
_SMShowTeamUI = 1016;
_SMUpdateMatchInfo = 1017;
}

View File

@ -937,6 +937,14 @@ message CMJoin
repeated MFPair skill_list = 54; // key:id value:,0
optional string user_data = 60 [default = ""]; //
optional int32 hero_id = 61; //id
/*
(getSwitch返回的结果)
1:
show_team_ui=1
show_team_ui() && team_mode() == 1 && auto_fill() && team_members().size() < 4
UI时回复SMShowTeamUI
*/
optional int32 show_team_ui = 62;
}
//线
@ -1131,8 +1139,6 @@ message SMJoinedNotify
optional int32 room_mode = 8; //0: 1:
optional string server_info = 9; //使
optional int32 show_team_ui = 10; // 1: 0:
}
//
@ -1296,6 +1302,11 @@ message SMShowCountdown
optional int32 msg_type = 3; //
}
//ui
message SMShowTeamUI
{
}
//
message SMUpdateMatchInfo
{