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