From 5d161ae4af609955cd6d5d41319050fa9363f252 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 11 May 2020 11:18:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E6=89=8B=E7=8E=A9?= =?UTF-8?q?=E5=AE=B6=E8=BF=9B=E6=B8=B8=E6=88=8F=E7=AD=89=E5=BE=85=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/metamgr.cc | 1 + server/gameserver/metamgr.h | 1 + server/gameserver/room.cc | 10 +++++++++- server/gameserver/room.h | 2 +- server/gameserver/roommgr.cc | 4 ++-- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/server/gameserver/metamgr.cc b/server/gameserver/metamgr.cc index 9d0ad01..895bcab 100755 --- a/server/gameserver/metamgr.cc +++ b/server/gameserver/metamgr.cc @@ -128,6 +128,7 @@ public: #if 1 { MetaMgr::Instance()->gas_inactive_time = MetaMgr::Instance()->GetSysParamAsInt("gas_inactive_time"); + MetaMgr::Instance()->newbie_wait_time = MetaMgr::Instance()->GetSysParamAsInt("newbie_wait_time", 10); MetaMgr::Instance()->jump_time = MetaMgr::Instance()->GetSysParamAsFloat("jump_time"); MetaMgr::Instance()->K = MetaMgr::Instance()->GetSysParamAsFloat("K"); MetaMgr::Instance()->kill_param = MetaMgr::Instance()->GetSysParamAsFloat("kill_parameter"); diff --git a/server/gameserver/metamgr.h b/server/gameserver/metamgr.h index 9e759d0..fbe222a 100755 --- a/server/gameserver/metamgr.h +++ b/server/gameserver/metamgr.h @@ -47,6 +47,7 @@ class MetaMgr : public a8::Singleton MetaData::Robot* GetRobot(int robot_id); int gas_inactive_time = 10; + int newbie_wait_time = 10; int jump_time = 10; float K = 100.0f; float kill_param = 0.0f; diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index b078566..6c7fa33 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -741,7 +741,7 @@ int Room::GetAliveTeamNum() return num; } -bool Room::CanJoin(const std::string& accountid) +bool Room::CanJoin(const std::string& accountid, RoomType_e self_room_type) { if (gas_data.gas_mode != GasInactive) { return false; @@ -749,6 +749,14 @@ bool Room::CanJoin(const std::string& accountid) if (accountid_hash_.find(accountid) != accountid_hash_.end()) { return false; } + if (self_room_type == RT_NewBrid) { + int remain_time_ms = MetaMgr::Instance()->gas_inactive_time * 1000 - + (frame_no - gas_data.gas_start_frameno) * FRAME_RATE_MS; + remain_time_ms = std::max(remain_time_ms, 0); + if (remain_time_ms <= MetaMgr::Instance()->newbie_wait_time * 1000) { + return false; + } + } return accountid_hash_.size() < ROOM_MAX_PLAYER_NUM; } diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 4c704cc..b8d9106 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -92,7 +92,7 @@ public: bool BattleStarted(); int GetAliveTeamNum(); std::set* GetAliveTeam(); - bool CanJoin(const std::string& accountid); + bool CanJoin(const std::string& accountid, RoomType_e self_roomm_type); void OnPlayerOffline(Player* hum); Entity* FindFirstCollisonEntity(const a8::Vec2& aabb_pos, AabbCollider& aabb_box); void FindLocationWithAabb(Entity* target, const a8::Vec2& aabb_pos, AabbCollider* aabb_box, diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index f0e0fb4..6da4dae 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -142,7 +142,7 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg, const RoomType_e self_room { #if 0 for (auto& pair : inactive_room_hash_) { - if (pair.second->CanJoin(msg.account_id())) { + if (pair.second->CanJoin(msg.account_id(), self_room_type)) { return pair.second; } } @@ -154,7 +154,7 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg, const RoomType_e self_room } for (auto& pair : inactive_room_hash_) { Room* room = pair.second; - if (room->CanJoin(msg.account_id())) { + if (room->CanJoin(msg.account_id(), self_room_type)) { if (!msg.team_uuid().empty() && room->HaveMyTeam(msg.team_uuid())) { return room; }