From aedbbe72d0b50a972f6e595621c22c34fb1554fa Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 9 Jul 2020 19:21:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=81=E7=94=A8=E6=88=B7=E8=BF=9B=EF=BC=94?= =?UTF-8?q?=EF=BC=90=E4=BA=BA=E6=88=BF=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/room.cc | 8 ++++++++ server/gameserver/room.h | 1 + server/gameserver/roommgr.cc | 17 +++++++++++------ server/gameserver/roommgr.h | 7 +++++-- server/gameserver/types.h | 1 + 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 0d92d0b..0f1d4a1 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -48,6 +48,7 @@ void Room::InitData(RoomInitInfo& init_info) room_uuid_ = init_info.room_uuid; room_type_ = init_info.room_type; creator_game_times_ = init_info.creator_game_times; + creator_register_time_ = init_info.creator_register_time; map_tpl_name_ = init_info.map_tpl_name; grid_service = init_info.grid_service; @@ -2852,6 +2853,13 @@ void Room::ShuaLastGas() bool Room::IsMiniRoom() { + if (GetRoomType() == RT_NewBrid || + GetRoomType() == RT_MidBrid) { + if (a8::BetweenDays(Global::g_nowtime, creator_register_time_) > 0) { + return false; + } + } + return GetRoomType() == RT_NewBrid || GetRoomType() == RT_MidBrid || diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 122b880..8810a28 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -235,6 +235,7 @@ private: int level1room_born_point_uniid_ = 0; bool show_handed_ = false; int creator_game_times_ = 0; + int creator_register_time_ = 0; int current_teamid_ = 0; int current_uniid_ = FIXED_OBJECT_MAXID; diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 965ad5e..e0a9fd1 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -160,7 +160,8 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg) } int game_times = 0; RoomType_e self_room_type = GetHumanRoomType(msg, game_times); - Room* room = GetJoinableRoom(msg, self_room_type, game_times); + time_t register_time = f8::ExtractRegisterTimeFromSessionId(msg.session_id()); + Room* room = GetJoinableRoom(msg, self_room_type, game_times, register_time); if (!room) { JoinErrorHandle(msg, 3, hdr.socket_handle); return; @@ -190,7 +191,10 @@ int RoomMgr::OverRoomNum() return over_room_hash_.size(); } -Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg, const RoomType_e self_room_type, int game_times) +Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg, + const RoomType_e self_room_type, + int game_times, + int creator_register_time) { std::vector> group_rooms; for (int i = 0; i < RT_Max; ++i) { @@ -210,10 +214,10 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg, const RoomType_e self_room return group_rooms[self_room_type][rand() % group_rooms[self_room_type].size()]; } if (self_room_type == RT_NewBrid) { - return CreateRoom(self_room_type, game_times); + return CreateRoom(self_room_type, game_times, creator_register_time); } if (self_room_type == RT_MidBrid) { - return CreateRoom(self_room_type, game_times); + return CreateRoom(self_room_type, game_times, creator_register_time); } for (int i = 0; i < RT_Max; ++i) { for (Room* room : group_rooms[i]) { @@ -222,7 +226,7 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg, const RoomType_e self_room } } } - return CreateRoom(self_room_type, game_times); + return CreateRoom(self_room_type, game_times, creator_register_time); } Room* RoomMgr::GetRoomByUuid(long long room_uuid) @@ -395,7 +399,7 @@ int RoomMgr::AllocRoomIdx() return current_room_idx_; } -Room* RoomMgr::CreateRoom(RoomType_e room_type, int game_times) +Room* RoomMgr::CreateRoom(RoomType_e room_type, int game_times, int creator_register_time) { int room_idx = AllocRoomIdx(); if (room_idx < 1) { @@ -407,6 +411,7 @@ Room* RoomMgr::CreateRoom(RoomType_e room_type, int game_times) init_info.room_uuid = App::Instance()->NewUuid(); init_info.room_type = room_type; init_info.creator_game_times = game_times; + init_info.creator_register_time = creator_register_time; if (GetRoomByUuid(init_info.room_uuid)) { abort(); } diff --git a/server/gameserver/roommgr.h b/server/gameserver/roommgr.h index 1a325a6..311aa38 100644 --- a/server/gameserver/roommgr.h +++ b/server/gameserver/roommgr.h @@ -33,13 +33,16 @@ class RoomMgr : public a8::Singleton private: void InstallReportStateTimer(); Room* GetRoomByIdx(int room_idx); - Room* GetJoinableRoom(const cs::CMJoin& msg, const RoomType_e self_room_type, int game_times); + Room* GetJoinableRoom(const cs::CMJoin& msg, + const RoomType_e self_room_type, + int game_times, + int creator_register_time); void ReportServerState(int instance_id, const std::string& host, int port); void FreeOverRoom(long long room_uuid); bool IsLimitJoin(); int AllocRoomIdx(); - Room* CreateRoom(RoomType_e room_type, int game_times); + Room* CreateRoom(RoomType_e room_type, int game_times, int creator_register_time); void JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_handle); private: diff --git a/server/gameserver/types.h b/server/gameserver/types.h index ccfa369..86a4ac1 100755 --- a/server/gameserver/types.h +++ b/server/gameserver/types.h @@ -154,6 +154,7 @@ struct RoomInitInfo long long room_uuid = 0; RoomType_e room_type = RT_NewBrid; int creator_game_times = 0; + int creator_register_time = 0; const MetaData::Map* map_meta = nullptr; std::string map_tpl_name;