add matchteam
This commit is contained in:
parent
8c8a330d8c
commit
b61181afd6
@ -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;
|
||||
}
|
||||
|
@ -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_;
|
||||
};
|
||||
|
32
server/gameserver/matchteam.cc
Normal file
32
server/gameserver/matchteam.cc
Normal 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;
|
||||
}
|
23
server/gameserver/matchteam.h
Normal file
23
server/gameserver/matchteam.h
Normal 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_;
|
||||
};
|
@ -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) {
|
||||
|
@ -52,5 +52,6 @@ enum SMMessageId_e
|
||||
_SMGameStart = 1013;
|
||||
_SMSysPiaoMsg = 1014;
|
||||
_SMShowCountdown = 1015;
|
||||
_SMUpdateMatchInfo = 1016;
|
||||
_SMShowTeamUI = 1016;
|
||||
_SMUpdateMatchInfo = 1017;
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user