This commit is contained in:
aozhiwei 2023-05-05 10:35:41 +08:00
parent 9cbda99228
commit edb2ce7bc4
2 changed files with 7 additions and 10 deletions

View File

@ -37,9 +37,6 @@ RoomObstacle::~RoomObstacle()
} }
detached_ = true; detached_ = true;
} }
if (!grid_list_) {
A8_SAFE_DELETE(grid_list_);
}
if (!hit_objects_) { if (!hit_objects_) {
A8_SAFE_DELETE(hit_objects_); A8_SAFE_DELETE(hit_objects_);
} }
@ -75,7 +72,7 @@ void RoomObstacle::ActiveTimerFunc()
return; return;
} }
if (!grid_list_) { if (!grid_list_) {
grid_list_ = new std::set<GridCell*>(); grid_list_ = std::make_shared<std::set<GridCell*>>();
room->grid_service->GetAllCellsByXy(room, GetPos().GetX(), GetPos().GetY(), *grid_list_); room->grid_service->GetAllCellsByXy(room, GetPos().GetX(), GetPos().GetY(), *grid_list_);
} }
bool has_hum = false; bool has_hum = false;
@ -100,7 +97,7 @@ void RoomObstacle::ActiveTimerFunc()
void RoomObstacle::UpdateTimerFunc() void RoomObstacle::UpdateTimerFunc()
{ {
if (!grid_list_) { if (!grid_list_) {
grid_list_ = new std::set<GridCell*>(); grid_list_ = std::make_shared<std::set<GridCell*>>();
room->grid_service->GetAllCellsByXy(room, GetPos().GetX(), GetPos().GetY(), *grid_list_); room->grid_service->GetAllCellsByXy(room, GetPos().GetX(), GetPos().GetY(), *grid_list_);
} }
if (grid_list_ && master.Get() && !IsDead(room)) { if (grid_list_ && master.Get() && !IsDead(room)) {
@ -146,7 +143,7 @@ void RoomObstacle::SpecExplosion(int delay_time)
if (meta->damage_dia() > 0.01f) { if (meta->damage_dia() > 0.01f) {
#endif #endif
if (!grid_list_) { if (!grid_list_) {
grid_list_ = new std::set<GridCell*>(); grid_list_ = std::make_shared<std::set<GridCell*>>();
room->grid_service->GetAllCellsByXy(room, GetPos().GetX(), GetPos().GetY(), *grid_list_); room->grid_service->GetAllCellsByXy(room, GetPos().GetX(), GetPos().GetY(), *grid_list_);
} }
Position bomb_born_offset; Position bomb_born_offset;
@ -545,7 +542,7 @@ void RoomObstacle::ActiveKeepRangeBuff()
void RoomObstacle::ProcKeepRangeBuff() void RoomObstacle::ProcKeepRangeBuff()
{ {
if (!grid_list_) { if (!grid_list_) {
grid_list_ = new std::set<GridCell*>(); grid_list_ = std::make_shared<std::set<GridCell*>>();
room->grid_service->GetAllCellsByXy(room, GetPos().GetX(), GetPos().GetY(), *grid_list_); room->grid_service->GetAllCellsByXy(room, GetPos().GetX(), GetPos().GetY(), *grid_list_);
} }
if (!hit_objects_) { if (!hit_objects_) {
@ -727,7 +724,7 @@ void RoomObstacle::DestoryAt(int time)
void RoomObstacle::CalcTempPassObjects() void RoomObstacle::CalcTempPassObjects()
{ {
if (!grid_list_) { if (!grid_list_) {
grid_list_ = new std::set<GridCell*>(); grid_list_ = std::make_shared<std::set<GridCell*>>();
room->grid_service->GetAllCellsByXy(room, GetPos().GetX(), GetPos().GetY(), *grid_list_); room->grid_service->GetAllCellsByXy(room, GetPos().GetX(), GetPos().GetY(), *grid_list_);
} }
if (!temp_pass_objects_) { if (!temp_pass_objects_) {
@ -890,7 +887,7 @@ void RoomObstacle::ActiveMedicalStation()
void RoomObstacle::ForceGridList() void RoomObstacle::ForceGridList()
{ {
if (!grid_list_) { if (!grid_list_) {
grid_list_ = new std::set<GridCell*>(); grid_list_ = std::make_shared<std::set<GridCell*>>();
room->grid_service->GetAllCellsByXy(room, GetPos().GetX(), GetPos().GetZ(), *grid_list_); room->grid_service->GetAllCellsByXy(room, GetPos().GetX(), GetPos().GetZ(), *grid_list_);
} }
} }

View File

@ -66,7 +66,7 @@ protected:
RoomObstacleWeakPtr weak_ptr_; RoomObstacleWeakPtr weak_ptr_;
RoomObstacleWeakPtrChunk weak_ptr_chunk_; RoomObstacleWeakPtrChunk weak_ptr_chunk_;
std::set<GridCell*>* grid_list_ = nullptr; std::shared_ptr<std::set<GridCell*>> grid_list_;
int explosion_times_ = 0; int explosion_times_ = 0;
bool detached_ = false; bool detached_ = false;
std::map<int, CreatureWeakPtr>* hit_objects_ = nullptr; std::map<int, CreatureWeakPtr>* hit_objects_ = nullptr;