diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index 8382f4424..7dac44de6 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -41,9 +41,9 @@ Networking::Networking(RakNet::RakPeerInterface *peer) : mclient(nullptr) sThis = this; this->peer = peer; - playerPacketController = new PlayerPacketController(peer); - actorPacketController = new ActorPacketController(peer); - worldPacketController = new WorldPacketController(peer); + playerPacketController = make_unique(peer); + actorPacketController = make_unique(peer); + worldPacketController = make_unique(peer); // Set send stream playerPacketController->SetStream(nullptr, &bsOut); @@ -62,10 +62,6 @@ Networking::Networking(RakNet::RakPeerInterface *peer) : mclient(nullptr) Networking::~Networking() { luaState.getEventCtrl().Call(false); - - delete playerPacketController; - delete actorPacketController; - delete worldPacketController; } void Networking::setServerPassword(std::string passw) noexcept @@ -334,17 +330,17 @@ void Networking::disconnectPlayer(RakNet::RakNetGUID guid) PlayerPacketController *Networking::getPlayerPacketController() const { - return playerPacketController; + return playerPacketController.get(); } ActorPacketController *Networking::getActorPacketController() const { - return actorPacketController; + return actorPacketController.get(); } WorldPacketController *Networking::getWorldPacketController() const { - return worldPacketController; + return worldPacketController.get(); } BaseActorList *Networking::getLastActorList() @@ -525,12 +521,12 @@ int Networking::getAvgPing(RakNet::AddressOrGUID addr) const MasterClient *Networking::getMasterClient() { - return mclient; + return mclient.get(); } void Networking::InitQuery(const std::string &queryAddr, unsigned short queryPort) { - mclient = new MasterClient(peer, queryAddr, queryPort); + mclient = make_unique(peer, queryAddr, queryPort); } void Networking::postInit() diff --git a/apps/openmw-mp/Networking.hpp b/apps/openmw-mp/Networking.hpp index 6d936b0cc..1a37b474f 100644 --- a/apps/openmw-mp/Networking.hpp +++ b/apps/openmw-mp/Networking.hpp @@ -87,14 +87,14 @@ namespace mwmp RakNet::RakPeerInterface *peer; RakNet::BitStream bsOut; - MasterClient *mclient; + std::unique_ptr mclient; BaseActorList baseActorList; BaseEvent baseEvent; - PlayerPacketController *playerPacketController; - ActorPacketController *actorPacketController; - WorldPacketController *worldPacketController; + std::unique_ptr playerPacketController; + std::unique_ptr actorPacketController; + std::unique_ptr worldPacketController; bool running; int exitCode;