1
This commit is contained in:
parent
f10b913092
commit
19aaa6cd42
@ -33,4 +33,5 @@ public:
|
||||
|
||||
private:
|
||||
std::map<std::string, MatchTeam*> team_hash_;
|
||||
std::map<int, std::string> socket_hash_;
|
||||
};
|
||||
|
@ -8,12 +8,21 @@
|
||||
|
||||
struct RawTeamMember
|
||||
{
|
||||
MatchTeam* team = nullptr;
|
||||
long long add_tick = 0;
|
||||
int socket_handle = 0;
|
||||
std::shared_ptr<cs::CMJoin> msg;
|
||||
cs::CMJoin msg;
|
||||
|
||||
void FillMFMatchTeamMember(cs::MFMatchTeamMember* msg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void MatchTeam::Init(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
{
|
||||
master_team_ = this;
|
||||
create_tick_ = a8::XGetTickCount();
|
||||
a8::Timer::Instance()->AddRepeatTimerAndAttach
|
||||
(1000,
|
||||
@ -25,11 +34,20 @@ void MatchTeam::Init(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
team->Update();
|
||||
},
|
||||
&timer_attacher.timer_list_);
|
||||
AddRawMember(hdr, msg);
|
||||
}
|
||||
|
||||
void MatchTeam::AddRawMember(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
{
|
||||
|
||||
std::shared_ptr<RawTeamMember> member = std::make_shared<RawTeamMember>();
|
||||
member->team = this;
|
||||
member->add_tick = a8::XGetTickCount();
|
||||
member->socket_handle = hdr.socket_handle;
|
||||
member->msg = msg;
|
||||
raw_member_hash_[msg.account_id()] = member;
|
||||
if (!first_member_) {
|
||||
first_member_ = member;
|
||||
}
|
||||
}
|
||||
|
||||
bool MatchTeam::IsRawMember(const std::string &account_id)
|
||||
@ -45,5 +63,15 @@ bool MatchTeam::IsValidMember(const cs::CMJoin& msg)
|
||||
|
||||
void MatchTeam::Update()
|
||||
{
|
||||
|
||||
master_team_->SyncMatchInfo();
|
||||
}
|
||||
|
||||
void MatchTeam::SyncMatchInfo()
|
||||
{
|
||||
cs::SMUpdateMatchInfo notifymsg;
|
||||
for (auto member : curr_member_hash_) {
|
||||
member->FillMFMatchTeamMember(notifymsg.mutable_info()->add_members());
|
||||
}
|
||||
notifymsg.mutable_info()->set_phase(phase_);
|
||||
notifymsg.mutable_info()->set_countdown(countdown_);
|
||||
}
|
||||
|
@ -1,5 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
enum MatchTeamPhase_e
|
||||
{
|
||||
kMatchCombining = 1,
|
||||
kMatchChoose = 2,
|
||||
kMatchLock = 3
|
||||
};
|
||||
|
||||
namespace cs
|
||||
{
|
||||
class CMJoin;
|
||||
@ -20,9 +27,17 @@ class MatchTeam
|
||||
|
||||
private:
|
||||
void Update();
|
||||
void SyncMatchInfo();
|
||||
|
||||
private:
|
||||
int phase_= kMatchCombining;
|
||||
int countdown_ = 0;
|
||||
long long create_tick_ = 0;
|
||||
std::map<std::string, std::shared_ptr<RawTeamMember>> raw_member_hash_;
|
||||
std::shared_ptr<RawTeamMember> first_member_;
|
||||
|
||||
std::map<std::string, MatchTeam*> combined_team_hash_;
|
||||
MatchTeam* master_team_ = nullptr;
|
||||
|
||||
std::list<std::shared_ptr<RawTeamMember>> curr_member_hash_;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user