1
This commit is contained in:
parent
cad0d1c99d
commit
4ca742b8bc
@ -6,6 +6,7 @@
|
|||||||
#include "matchmgr.h"
|
#include "matchmgr.h"
|
||||||
#include "GGListener.h"
|
#include "GGListener.h"
|
||||||
#include "metamgr.h"
|
#include "metamgr.h"
|
||||||
|
#include "roommgr.h"
|
||||||
|
|
||||||
void RawTeamMember::FillMFMatchTeamMember(cs::MFMatchTeamMember* p)
|
void RawTeamMember::FillMFMatchTeamMember(cs::MFMatchTeamMember* p)
|
||||||
{
|
{
|
||||||
@ -335,6 +336,11 @@ std::string MatchTeam::GetTeamUUid()
|
|||||||
return first_member_->msg.team_uuid();
|
return first_member_->msg.team_uuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MatchTeam::GetMapId()
|
||||||
|
{
|
||||||
|
return first_member_->msg.mapid();
|
||||||
|
}
|
||||||
|
|
||||||
bool MatchTeam::IsShuaRobotTime()
|
bool MatchTeam::IsShuaRobotTime()
|
||||||
{
|
{
|
||||||
return phase_ == kMatchCombining &&
|
return phase_ == kMatchCombining &&
|
||||||
@ -371,6 +377,7 @@ void MatchTeam::ShuaRobot()
|
|||||||
|
|
||||||
void MatchTeam::StartGame()
|
void MatchTeam::StartGame()
|
||||||
{
|
{
|
||||||
|
RoomMgr::Instance()->JoinTeam(this);
|
||||||
for (auto& member : curr_member_hash_) {
|
for (auto& member : curr_member_hash_) {
|
||||||
if (member->socket_handle != 0) {
|
if (member->socket_handle != 0) {
|
||||||
MatchMgr::Instance()->RemoveSocket(member->socket_handle);
|
MatchMgr::Instance()->RemoveSocket(member->socket_handle);
|
||||||
|
@ -58,7 +58,9 @@ class MatchTeam
|
|||||||
bool IsValidMember(const cs::CMJoin& msg);
|
bool IsValidMember(const cs::CMJoin& msg);
|
||||||
void TryCombineTeam();
|
void TryCombineTeam();
|
||||||
std::string GetTeamUUid();
|
std::string GetTeamUUid();
|
||||||
|
int GetMapId();
|
||||||
std::list<std::shared_ptr<RawTeamMember>>& GetCurrMembers() { return curr_member_hash_; };
|
std::list<std::shared_ptr<RawTeamMember>>& GetCurrMembers() { return curr_member_hash_; };
|
||||||
|
std::shared_ptr<RawTeamMember> GetOwner() { return first_member_; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Update();
|
void Update();
|
||||||
|
@ -971,6 +971,28 @@ bool Room::CanJoin(const std::string& accountid,
|
|||||||
return GetPlayerNum() < (int)GetRoomMaxPlayerNum();
|
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)
|
void Room::OnPlayerOffline(Player* hum)
|
||||||
{
|
{
|
||||||
if (GetOnlinePlayerNum() <= 0) {
|
if (GetOnlinePlayerNum() <= 0) {
|
||||||
|
@ -185,6 +185,7 @@ public:
|
|||||||
int self_proto_version,
|
int self_proto_version,
|
||||||
int self_channel,
|
int self_channel,
|
||||||
int init_map_id);
|
int init_map_id);
|
||||||
|
bool CanJoin(class MatchTeam* team);
|
||||||
void OnPlayerOffline(Player* hum);
|
void OnPlayerOffline(Player* hum);
|
||||||
void FindLocationWithAabb(ColliderComponent* target_collider,
|
void FindLocationWithAabb(ColliderComponent* target_collider,
|
||||||
const a8::Vec2& aabb_pos,
|
const a8::Vec2& aabb_pos,
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "mapmgr.h"
|
#include "mapmgr.h"
|
||||||
#include "perfmonitor.h"
|
#include "perfmonitor.h"
|
||||||
#include "matchmgr.h"
|
#include "matchmgr.h"
|
||||||
|
#include "matchteam.h"
|
||||||
|
|
||||||
#include "framework/cpp/httpclientpool.h"
|
#include "framework/cpp/httpclientpool.h"
|
||||||
#include "framework/cpp/utils.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)
|
static RoomType_e GetHumanRoomType(const cs::CMJoin& msg, int& game_times)
|
||||||
{
|
{
|
||||||
#if 1
|
#if 1
|
||||||
return RT_OldBrid1;;
|
return RT_OldBrid1;
|
||||||
#endif
|
#endif
|
||||||
game_times = 0;
|
game_times = 0;
|
||||||
std::vector<std::string> tmp_strings;
|
std::vector<std::string> tmp_strings;
|
||||||
@ -318,7 +319,24 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg,
|
|||||||
Room* RoomMgr::GetJoinableRoom(MatchTeam* team)
|
Room* RoomMgr::GetJoinableRoom(MatchTeam* team)
|
||||||
{
|
{
|
||||||
for (auto& pair : inactive_room_hash_) {
|
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)
|
Room* RoomMgr::GetRoomByUuid(long long room_uuid)
|
||||||
@ -580,7 +598,11 @@ bool RoomMgr::IsGM(const std::string& account_id)
|
|||||||
|
|
||||||
void RoomMgr::JoinTeam(MatchTeam* team)
|
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)
|
std::string RoomMgr::GenTeamHashData(const std::string& team_uuid, std::map<std::string, long long>* team_hash)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user