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