diff --git a/server/gameserver/mapservice.cc b/server/gameserver/mapservice.cc index 8f4a1544..9fd74a55 100644 --- a/server/gameserver/mapservice.cc +++ b/server/gameserver/mapservice.cc @@ -60,7 +60,7 @@ void MapService::UnInit() CellNode, entry); list_del_init(&e->entry); - delete e; + e->holder = nullptr; } } if (map_cells_) { diff --git a/server/gameserver/matchpool.cc b/server/gameserver/matchpool.cc index 20d4e4e6..54013ae9 100644 --- a/server/gameserver/matchpool.cc +++ b/server/gameserver/matchpool.cc @@ -28,13 +28,13 @@ void MatchPool::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg) { } -MatchTeamNew* MatchPool::GetTeam(const std::string& team_uuid) +std::shared_ptr MatchPool::GetTeam(const std::string& team_uuid) { auto itr = team_hash_.find(team_uuid); return itr != team_hash_.end() ? itr->second : nullptr; } -void MatchPool::TraverseTeam(std::function func) +void MatchPool::TraverseTeam(std::function&, bool&)> func) { if (!func) { return; @@ -54,7 +54,6 @@ void MatchPool::RemoveTeam(const std::string& team_uuid) { auto itr = team_hash_.find(team_uuid); if (itr != team_hash_.end()) { - delete itr->second; team_hash_.erase(itr); } } diff --git a/server/gameserver/matchpool.h b/server/gameserver/matchpool.h index a96d5a78..0c57fad2 100644 --- a/server/gameserver/matchpool.h +++ b/server/gameserver/matchpool.h @@ -25,18 +25,18 @@ public: private: - void TraverseTeam(std::function func); + void TraverseTeam(std::function&, bool&)> func); bool NeedMatch(const cs::CMJoin& msg); - MatchTeamNew* GetTeam(const std::string& team_uuid); + std::shared_ptr GetTeam(const std::string& team_uuid); void RemoveTeam(const std::string& team_uuid); void RemoveSocket(int socket_handle); void Update(); private: f8::Attacher timer_attacher_; - std::map team_hash_; - std::map> socket_hash_; + std::map> team_hash_; + std::map>> socket_hash_; std::map> group_hash_; std::map> matching_list_; diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 8304e35e..06fb1d13 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -376,7 +376,6 @@ void Room::AddPlayer(Player* hum, std::shared_ptr init_born_point, bo Team* t = a->GetTeam(); leader->GetTeam()->CombineTeam(a->GetTeam()); team_hash_.erase(t->GetTeamId()); - delete t; } } leader = humans.at(3); @@ -393,7 +392,6 @@ void Room::AddPlayer(Player* hum, std::shared_ptr init_born_point, bo Team* t = a->GetTeam(); leader->GetTeam()->CombineTeam(a->GetTeam()); team_hash_.erase(t->GetTeamId()); - delete t; } } }