1
This commit is contained in:
parent
b61181afd6
commit
f10b913092
@ -468,6 +468,9 @@ void App::ProcessGameGateMsg(f8::MsgHdr& hdr)
|
||||
case HID_RoomMgr:
|
||||
ProcessNetMsg(handler, RoomMgr::Instance(), hdr);
|
||||
break;
|
||||
case HID_MatchMgr:
|
||||
ProcessNetMsg(handler, MatchMgr::Instance(), hdr);
|
||||
break;
|
||||
case HID_PlayerMgr:
|
||||
ProcessNetMsg(handler, PlayerMgr::Instance(), hdr);
|
||||
break;
|
||||
|
@ -24,6 +24,7 @@ enum NetHandler_e
|
||||
HID_PlayerMgr,
|
||||
HID_Room,
|
||||
HID_RoomMgr,
|
||||
HID_MatchMgr,
|
||||
HID_GGListener,
|
||||
};
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "ss_proto.pb.h"
|
||||
#include "jsondatamgr.h"
|
||||
#include "perfmonitor.h"
|
||||
#include "matchmgr.h"
|
||||
|
||||
static void _GMOpsSelfChecking(f8::JsonHttpRequest* request)
|
||||
{
|
||||
@ -86,6 +87,10 @@ void HandlerMgr::RegisterNetMsgHandlers()
|
||||
RegisterNetMsgHandler(&ggmsghandler, &RoomMgr::_CMJoin);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &RoomMgr::_CMReconnect);
|
||||
|
||||
RegisterNetMsgHandler(&ggmsghandler, &MatchMgr::_CMMatchCancel);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &MatchMgr::_CMMatchChoose);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &MatchMgr::_CMMatchStartGame);
|
||||
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMMove);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMExecCommand);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMEmote);
|
||||
|
@ -15,23 +15,6 @@ 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)) {
|
||||
@ -53,6 +36,38 @@ void MatchMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
}
|
||||
}
|
||||
|
||||
void MatchMgr::_CMMatchCancel(f8::MsgHdr& hdr, const cs::CMMatchCancel& msg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MatchMgr::_CMMatchChoose(f8::MsgHdr& hdr, const cs::CMMatchChoose& msg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MatchMgr::_CMMatchStartGame(f8::MsgHdr& hdr, const cs::CMMatchStartGame& msg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
MatchTeam* MatchMgr::GetTeam(const std::string& team_uuid)
|
||||
{
|
||||
auto itr = team_hash_.find(team_uuid);
|
||||
|
@ -4,11 +4,16 @@ namespace cs
|
||||
{
|
||||
class CMJoin;
|
||||
class CMReconnect;
|
||||
class CMMatchCancel;
|
||||
class CMMatchChoose;
|
||||
class CMMatchStartGame;
|
||||
}
|
||||
|
||||
class MatchTeam;
|
||||
class MatchMgr : public a8::Singleton<MatchMgr>
|
||||
{
|
||||
public:
|
||||
enum { HID = HID_RoomMgr };
|
||||
|
||||
private:
|
||||
MatchMgr() {};
|
||||
@ -18,8 +23,12 @@ public:
|
||||
void Init();
|
||||
void UnInit();
|
||||
|
||||
bool NeedMatch(const cs::CMJoin& msg);
|
||||
void _CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg);
|
||||
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);
|
||||
|
||||
bool NeedMatch(const cs::CMJoin& msg);
|
||||
MatchTeam* GetTeam(const std::string& team_uuid);
|
||||
|
||||
private:
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include <a8/timer.h>
|
||||
|
||||
#include "cs_proto.pb.h"
|
||||
#include "matchteam.h"
|
||||
#include "matchmgr.h"
|
||||
@ -13,6 +15,16 @@ struct RawTeamMember
|
||||
void MatchTeam::Init(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
{
|
||||
create_tick_ = a8::XGetTickCount();
|
||||
a8::Timer::Instance()->AddRepeatTimerAndAttach
|
||||
(1000,
|
||||
a8::XParams()
|
||||
.SetSender(this),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
MatchTeam* team = (MatchTeam*)param.sender.GetUserData();
|
||||
team->Update();
|
||||
},
|
||||
&timer_attacher.timer_list_);
|
||||
}
|
||||
|
||||
void MatchTeam::AddRawMember(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
@ -30,3 +42,8 @@ bool MatchTeam::IsValidMember(const cs::CMJoin& msg)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void MatchTeam::Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -6,16 +6,21 @@ namespace cs
|
||||
class CMReconnect;
|
||||
}
|
||||
|
||||
struct timer_list;
|
||||
struct RawTeamMember;
|
||||
class MatchTeam
|
||||
{
|
||||
public:
|
||||
a8::TimerAttacher timer_attacher;
|
||||
|
||||
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:
|
||||
void Update();
|
||||
|
||||
private:
|
||||
long long create_tick_ = 0;
|
||||
std::map<std::string, std::shared_ptr<RawTeamMember>> raw_member_hash_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user