This commit is contained in:
aozhiwei 2021-09-28 16:09:58 +08:00
parent cad0d1c99d
commit 4ca742b8bc
5 changed files with 56 additions and 2 deletions

View File

@ -6,6 +6,7 @@
#include "matchmgr.h"
#include "GGListener.h"
#include "metamgr.h"
#include "roommgr.h"
void RawTeamMember::FillMFMatchTeamMember(cs::MFMatchTeamMember* p)
{
@ -335,6 +336,11 @@ std::string MatchTeam::GetTeamUUid()
return first_member_->msg.team_uuid();
}
int MatchTeam::GetMapId()
{
return first_member_->msg.mapid();
}
bool MatchTeam::IsShuaRobotTime()
{
return phase_ == kMatchCombining &&
@ -371,6 +377,7 @@ void MatchTeam::ShuaRobot()
void MatchTeam::StartGame()
{
RoomMgr::Instance()->JoinTeam(this);
for (auto& member : curr_member_hash_) {
if (member->socket_handle != 0) {
MatchMgr::Instance()->RemoveSocket(member->socket_handle);

View File

@ -58,7 +58,9 @@ class MatchTeam
bool IsValidMember(const cs::CMJoin& msg);
void TryCombineTeam();
std::string GetTeamUUid();
int GetMapId();
std::list<std::shared_ptr<RawTeamMember>>& GetCurrMembers() { return curr_member_hash_; };
std::shared_ptr<RawTeamMember> GetOwner() { return first_member_; };
private:
void Update();

View File

@ -971,6 +971,28 @@ bool Room::CanJoin(const std::string& accountid,
return GetPlayerNum() < (int)GetRoomMaxPlayerNum();
}
bool Room::CanJoin(class MatchTeam* team)
{
if (gas_data_.gas_mode != GasInactive) {
return false;
}
if (map_instance->map_id != team->GetMapId()) {
return false;
}
if (team->GetCurrMembers().size() != MAX_TEAM_NUM) {
return false;
}
if (GetPlayerNum() < (int)GetRoomMaxPlayerNum()) {
return false;
}
for (auto& member : team->GetCurrMembers()) {
if (GetPlayerByAccountId(member->msg.account_id())) {
return false;
}
}
return false;
}
void Room::OnPlayerOffline(Player* hum)
{
if (GetOnlinePlayerNum() <= 0) {

View File

@ -185,6 +185,7 @@ public:
int self_proto_version,
int self_channel,
int init_map_id);
bool CanJoin(class MatchTeam* team);
void OnPlayerOffline(Player* hum);
void FindLocationWithAabb(ColliderComponent* target_collider,
const a8::Vec2& aabb_pos,

View File

@ -16,6 +16,7 @@
#include "mapmgr.h"
#include "perfmonitor.h"
#include "matchmgr.h"
#include "matchteam.h"
#include "framework/cpp/httpclientpool.h"
#include "framework/cpp/utils.h"
@ -26,7 +27,7 @@ const int HUM_NUM_DOWN_LIMIT = 2500;
static RoomType_e GetHumanRoomType(const cs::CMJoin& msg, int& game_times)
{
#if 1
return RT_OldBrid1;;
return RT_OldBrid1;
#endif
game_times = 0;
std::vector<std::string> tmp_strings;
@ -318,7 +319,24 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg,
Room* RoomMgr::GetJoinableRoom(MatchTeam* team)
{
for (auto& pair : inactive_room_hash_) {
Room* room = pair.second;
if (room->CanJoin(team)) {
return room;
}
}
int game_times = 0;
RoomType_e self_room_type = RT_OldBrid1;
time_t register_time = f8::ExtractRegisterTimeFromSessionId(team->GetOwner()->msg.session_id());
int proto_version = team->GetOwner()->msg.proto_version();
int channel = f8::ExtractChannelIdFromAccountId(team->GetOwner()->msg.account_id());
return CreateRoom(team->GetOwner()->msg,
self_room_type,
game_times,
register_time,
proto_version,
channel,
team->GetOwner()->msg.mapid());
}
Room* RoomMgr::GetRoomByUuid(long long room_uuid)
@ -580,7 +598,11 @@ bool RoomMgr::IsGM(const std::string& account_id)
void RoomMgr::JoinTeam(MatchTeam* team)
{
Room* room = GetJoinableRoom(team);
if (!room) {
return;
}
room->AddTeam(team);
}
std::string RoomMgr::GenTeamHashData(const std::string& team_uuid, std::map<std::string, long long>* team_hash)