From 8c8f3ff3978ff3def905bc959c86028f7c27034c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 4 Nov 2023 10:03:48 +0800 Subject: [PATCH] 1 --- server/gameserver/room.cc | 9 ++++----- server/gameserver/room.h | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 68c84d0e..512df070 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -121,7 +121,7 @@ void Room::Init() xtimer_attacher_.SetOwner(&xtimer); frame_event.room = this; - frame_event_data = new FrameEventData(); + frame_event_data = std::make_shared(); air_drop_ = std::make_shared(this); air_raid_ = std::make_shared(this); @@ -134,7 +134,7 @@ void Room::Init() CreateSpawnPoints(); CreateWorldObjects(); ShuaAndroid(); - incubator_ = new Incubator(); + incubator_ = std::make_shared(Incubator>(); incubator_->room = this; incubator_->Init(); sand_table_ = std::make_shared(this); @@ -166,8 +166,7 @@ void Room::UnInit() #ifdef DEBUG UnInitDebugInfo(); #endif - incubator_->UnInit(); - A8_SAFE_DELETE(incubator_); + incubator_ = nullptr; timer_attacher.ClearTimerList(); xtimer_attacher_.ClearTimerList(); grid_service->ClearRoomData(this); @@ -192,7 +191,7 @@ void Room::UnInit() f8::BtMgr::Instance()->BtDestory(room_agent_); room_agent_ = nullptr; team_hash_.clear(); - A8_SAFE_DELETE(frame_event_data); + frame_event_data = nullptr; PerfMonitor::Instance()->alive_count -= alive_count_; } diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 8a0a2910..cbd4f372 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -74,7 +74,7 @@ class Room { public: FrameEvent frame_event; - FrameEventData* frame_event_data = nullptr; + std::shared_ptr frame_event_data; FrameMaker frame_maker; a8::XTimer xtimer; Plane plane; @@ -235,7 +235,7 @@ public: RoomObstacle* CreateObstacle(int id, float x, float y, float z, std::shared_ptr init_args = nullptr); int AllocUniid(); - Incubator* GetIncubator() { return incubator_;}; + std::shared_ptr& GetIncubator() { return incubator_;}; void GetPartObjectWatchList(Entity* entity, std::vector& watch_list); void SetInfiniteBulletMode(); bool IsInfiniteBulletMode() { return infinite_bullet_mode_; }; @@ -410,7 +410,7 @@ private: a8::XTimerWp auto_jump_timer_; - Incubator* incubator_ = nullptr; + std::shared_ptr incubator_; std::shared_ptr sand_table_; std::shared_ptr custom_battle_;