1
This commit is contained in:
parent
febc83b04d
commit
9d7dead180
@ -2825,6 +2825,9 @@ void Creature::OnBattleStart(Room* room)
|
|||||||
|
|
||||||
bool Creature::CanFollow(Creature* follower)
|
bool Creature::CanFollow(Creature* follower)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
if (follower->GetUniId() == GetUniId()) {
|
if (follower->GetUniId() == GetUniId()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -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 "matchmgr.h"
|
#include "matchmgr.h"
|
||||||
#include "GGListener.h"
|
#include "GGListener.h"
|
||||||
@ -7,7 +9,19 @@
|
|||||||
|
|
||||||
void MatchMgr::Init()
|
void MatchMgr::Init()
|
||||||
{
|
{
|
||||||
|
a8::Timer::Instance()->AddRepeatTimerAndAttach
|
||||||
|
(1000,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(this),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
MatchMgr::Instance()->Output();
|
||||||
|
},
|
||||||
|
&timer_attacher.timer_list_,
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MatchMgr::UnInit()
|
void MatchMgr::UnInit()
|
||||||
@ -30,12 +44,15 @@ void MatchMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
|||||||
GGListener::Instance()->SendToClient(hdr.socket_handle, 0, notifymsg);
|
GGListener::Instance()->SendToClient(hdr.socket_handle, 0, notifymsg);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
MatchTeam* team = GetTeam(msg.account_id());
|
MatchTeam* team = GetTeam(msg.team_uuid());
|
||||||
if (!team) {
|
if (!team) {
|
||||||
team = new MatchTeam();
|
team = new MatchTeam();
|
||||||
team->Init(hdr, msg);
|
team->Init(hdr, msg);
|
||||||
team_hash_[msg.team_uuid()] = team;
|
team_hash_[msg.team_uuid()] = team;
|
||||||
team->TryCombineTeam();
|
team->TryCombineTeam();
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf("newteam %s\n", {msg.team_uuid()});
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
if (team->IsRawMember(msg.account_id())) {
|
if (team->IsRawMember(msg.account_id())) {
|
||||||
return;
|
return;
|
||||||
@ -139,3 +156,14 @@ void MatchMgr::RemoveSocket(int socket_handle)
|
|||||||
socket_hash_.erase(itr);
|
socket_hash_.erase(itr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MatchMgr::Output()
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf(">>>>>>>>>>>>>>>>>>>>>>>>>>\n", {});
|
||||||
|
for (auto& pair : team_hash_) {
|
||||||
|
a8::XPrintf("team:%s \n", {pair.first});
|
||||||
|
}
|
||||||
|
a8::XPrintf("<<<<<<<<<<<<<<<<<<<<<<<<<<\n", {});
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@ -21,6 +21,8 @@ class MatchMgr : public a8::Singleton<MatchMgr>
|
|||||||
friend class a8::Singleton<MatchMgr>;
|
friend class a8::Singleton<MatchMgr>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
a8::TimerAttacher timer_attacher;
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void UnInit();
|
void UnInit();
|
||||||
|
|
||||||
@ -36,6 +38,7 @@ public:
|
|||||||
std::tuple<std::string, MatchTeam*>* GetMatchInfo(int socket_handle);
|
std::tuple<std::string, MatchTeam*>* GetMatchInfo(int socket_handle);
|
||||||
void RemoveTeam(const std::string& team_uuid);
|
void RemoveTeam(const std::string& team_uuid);
|
||||||
void RemoveSocket(int socket_handle);
|
void RemoveSocket(int socket_handle);
|
||||||
|
void Output();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<std::string, MatchTeam*> team_hash_;
|
std::map<std::string, MatchTeam*> team_hash_;
|
||||||
|
@ -152,6 +152,19 @@ void MatchTeam::AddRawMember(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
|||||||
if (!first_member_) {
|
if (!first_member_) {
|
||||||
first_member_ = member;
|
first_member_ = member;
|
||||||
}
|
}
|
||||||
|
if (master_team_ != this) {
|
||||||
|
master_team_->curr_member_hash_.push_back(member);
|
||||||
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf("AddRawMember %s %s %d %d %d\n",
|
||||||
|
{
|
||||||
|
GetTeamUUid(),
|
||||||
|
msg.account_id(),
|
||||||
|
curr_member_hash_.size(),
|
||||||
|
master_team_->curr_member_hash_.size(),
|
||||||
|
master_team_ == this ? 1 : 0
|
||||||
|
});
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MatchTeam::IsRawMember(const std::string &account_id)
|
bool MatchTeam::IsRawMember(const std::string &account_id)
|
||||||
@ -351,38 +364,77 @@ bool MatchTeam::HasSameCurrMember(MatchTeam* b)
|
|||||||
bool MatchTeam::CanCombine(MatchTeam* b)
|
bool MatchTeam::CanCombine(MatchTeam* b)
|
||||||
{
|
{
|
||||||
if (this == b) {
|
if (this == b) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf("CanCombine 1\n", {});
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//已合并
|
//已合并
|
||||||
if (master_team_ != this){
|
if (master_team_ != this){
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf("CanCombine 2\n", {});
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//已合并
|
//已合并
|
||||||
if (b->master_team_ != b) {
|
if (b->master_team_ != b) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf("CanCombine 3\n", {});
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (phase_ != kMatchCombining) {
|
if (phase_ != kMatchCombining) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf("CanCombine 4\n", {});
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (b->phase_ != kMatchCombining) {
|
if (b->phase_ != kMatchCombining) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf("CanCombine 5\n", {});
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (IsShuaRobotTime()) {
|
if (IsShuaRobotTime()) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf("CanCombine 6\n", {});
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (b->IsShuaRobotTime()) {
|
if (b->IsShuaRobotTime()) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf("CanCombine 7\n", {});
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!b->combined_team_hash_.empty()) {
|
if (!b->combined_team_hash_.empty()) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf("CanCombine 8\n", {});
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (GetPredictMemberNum() + b->GetPredictMemberNum() > MAX_TEAM_NUM) {
|
if (GetPredictMemberNum() + b->GetPredictMemberNum() > MAX_TEAM_NUM) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf("CanCombine 9\n", {});
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (combined_team_hash_.find(b->GetTeamUUid()) != combined_team_hash_.end()) {
|
if (combined_team_hash_.find(b->GetTeamUUid()) != combined_team_hash_.end()) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf("CanCombine 10\n", {});
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (b->combined_team_hash_.find(GetTeamUUid()) != b->combined_team_hash_.end()) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf("CanCombine 10\n", {});
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (HasSameCurrMember(b)) {
|
if (HasSameCurrMember(b)) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf("CanCombine 11\n", {});
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -390,6 +442,15 @@ bool MatchTeam::CanCombine(MatchTeam* b)
|
|||||||
|
|
||||||
void MatchTeam::Combine(MatchTeam* b)
|
void MatchTeam::Combine(MatchTeam* b)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf("Combine %s->%s %d:%d",
|
||||||
|
{
|
||||||
|
b->GetTeamUUid(),
|
||||||
|
GetTeamUUid(),
|
||||||
|
b->curr_member_hash_.size(),
|
||||||
|
curr_member_hash_.size()
|
||||||
|
});
|
||||||
|
#endif
|
||||||
combined_team_hash_[b->GetTeamUUid()] = b;
|
combined_team_hash_[b->GetTeamUUid()] = b;
|
||||||
b->master_team_ = this;
|
b->master_team_ = this;
|
||||||
for (auto& member : b->curr_member_hash_) {
|
for (auto& member : b->curr_member_hash_) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user