diff --git a/server/gameserver/app.h b/server/gameserver/app.h index f45d6fd..2294633 100644 --- a/server/gameserver/app.h +++ b/server/gameserver/app.h @@ -67,6 +67,7 @@ public: 3: battleReport环境 4: 打印性能日志 5: 压力测试 + 6: 删除over room */ std::set flags; diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 2776e33..1faa8d4 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -77,10 +77,22 @@ void Room::Init() void Room::UnInit() { xtimer_attacher.ClearTimerList(); - if (!stats_timer_) { + if (stats_timer_) { a8::Timer::Instance()->DeleteTimer(stats_timer_); stats_timer_ = nullptr; } + for (auto& pair : uniid_hash_) { + delete pair.second; + } + uniid_hash_.clear(); + for (auto& pair : later_add_hash_) { + delete pair.second; + } + later_add_hash_.clear(); + for (auto& pair : removed_robot_hash_) { + delete pair.second; + } + removed_robot_hash_.clear(); } void Room::Update(int delta_time) diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 91f3224..b63797f 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -160,6 +160,13 @@ void RoomMgr::AddOverRoom(long long room_uuid) RoomMgr::Instance()->over_room_hash_[room->room_uuid] = room; } }); + a8::Timer::Instance()->AddDeadLineTimer(1000 + 100, + a8::XParams() + .SetSender(room_uuid), + [] (const a8::XParams& param) + { + RoomMgr::Instance()->FreeOverRoom(param.sender); + }); } void RoomMgr::ActiveRoom(long long room_uuid) @@ -222,3 +229,15 @@ void RoomMgr::ReportServerState(int instance_id, const std::string& host, int po ); delete url_params; } + +void RoomMgr::FreeOverRoom(long long room_uuid) +{ + if (App::Instance()->HasFlag(6)) { + auto itr = over_room_hash_.find(room_uuid); + if (itr != over_room_hash_.end()) { + itr->second->UnInit(); + delete itr->second; + over_room_hash_.erase(itr); + } + } +} diff --git a/server/gameserver/roommgr.h b/server/gameserver/roommgr.h index 46dc299..69da4b5 100644 --- a/server/gameserver/roommgr.h +++ b/server/gameserver/roommgr.h @@ -29,6 +29,7 @@ class RoomMgr : public a8::Singleton private: Room* GetJoinableRoom(const std::string& account_id); void ReportServerState(int instance_id, const std::string& host, int port); + void FreeOverRoom(long long room_uuid); private: std::map inactive_room_hash_;