From ad47449732771aa3e466d7880fb9c2675ea6824a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 19 Apr 2024 17:27:15 +0800 Subject: [PATCH] 1 --- server/gameserver/room.cc | 83 ++------------------------------------- server/gameserver/room.h | 7 ---- 2 files changed, 3 insertions(+), 87 deletions(-) diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 2583f9f3..80065f66 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -1163,86 +1163,6 @@ int Room::GetTeamNum() return num; } -bool Room::CanJoin(const std::string& accountid, - RoomType_e self_room_type, - RoomMode_e self_room_mode, - int self_proto_version, - int self_channel, - int init_map_id, - const cs::CMJoin& msg) -{ - if (lock_room_) { - return false; - } - if (IsCustomBattle()) { - return false; - } - if (IsMobaModeRoom()) { - return false; - } - if (room_mode_ != self_room_mode) { - return false; - } - if (GetGasData().GetGasMode() != GasInactive) { - return false; - } -#if 0 - if (pve_instance) { - if (pve_instance->gemini_id() != msg.pve_instance_id()) { - return false; - } -#if 1 - Team* team = GetAliveTeam(); - if (!team) { - return false; - } - Human* hum = team->GetOneAliveMember(nullptr); - if (!hum) { - return false; - } - if (hum->team_uuid != msg.team_uuid()) { - return false; - } -#endif - } -#endif - if (init_map_id != 0) { - auto map_instance = MapMgr::Instance()->GetMapInstance(init_map_id); - if (map_instance && map_instance->GetMapMeta()->map_mode() == room_mode_ && - map_instance->map_id != map_meta_->map_id()) { - return false; - } - } - if (GetPlayerByAccountId(accountid)) { - return false; - } - if (GetPlayerNum() < (int)GetRoomMaxPlayerNum() && - !msg.team_uuid().empty() && - GetHumanNum() >= GetRoomMaxPlayerNum() - ) { - bool have_team = false; - TraverseHumanList - ( - [&have_team, &msg] (Human* ele_hum) -> bool - { - if (ele_hum->team_uuid == msg.team_uuid()) { - if (ele_hum->GetTeam() && !ele_hum->GetTeam()->IsFull()) { - have_team = true; - return false; - } - } - return true; - }); - if (have_team) { - while (GetHumanNum() >= GetRoomMaxPlayerNum()) { - RandRemoveAndroid(); - break; - } - } - } - return GetPlayerNum() < (int)GetRoomMaxPlayerNum(); -} - void Room::OnPlayerOffline(Player* hum) { if (GetOnlinePlayerNum() <= 0 && game_over_timer.expired()) { @@ -3863,6 +3783,9 @@ bool Room::CanJoin(std::shared_ptr p) if (map_meta_->map_id() != p->GetMapId()) { return false; } + if (GetMapModeMeta()->id() != p->GetMapMode()) { + return false; + } auto p_team = p->GetTeamByIdx(0); if (GetPlayerNum() + p_team->GetMemberNum() > GetRoomMaxPlayerNum()) { diff --git a/server/gameserver/room.h b/server/gameserver/room.h index d31615bb..0186a238 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -215,13 +215,6 @@ public: Team* GetAliveTeam(); void TraverseTeams(std::function cb); void TraverseRawTeams(std::function cb); - bool CanJoin(const std::string& accountid, - RoomType_e self_roomm_type, - RoomMode_e self_room_mode, - int self_proto_version, - int self_channel, - int init_map_id, - const cs::CMJoin& msg); bool CanJoin(std::shared_ptr p); void OnPlayerOffline(Player* hum); void FillSMUiUpdate(cs::SMUiUpdate& msg);