diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp index bb449c4c76..e351c70bb0 100644 --- a/Source/Core/Core/NetPlayServer.cpp +++ b/Source/Core/Core/NetPlayServer.cpp @@ -450,18 +450,18 @@ void NetPlayServer::AdjustPadBufferSize(unsigned int size) m_target_buffer_size = size; // tell clients to change buffer size - sf::Packet* spac = new sf::Packet; - *spac << (MessageId)NP_MSG_PAD_BUFFER; - *spac << (u32)m_target_buffer_size; + auto spac = std::make_unique(); + *spac << static_cast(NP_MSG_PAD_BUFFER); + *spac << static_cast(m_target_buffer_size); - SendAsyncToClients(spac); + SendAsyncToClients(std::move(spac)); } -void NetPlayServer::SendAsyncToClients(sf::Packet* packet) +void NetPlayServer::SendAsyncToClients(std::unique_ptr packet) { { std::lock_guard lkq(m_crit.async_queue_write); - m_async_queue.Push(std::unique_ptr(packet)); + m_async_queue.Push(std::move(packet)); } ENetUtil::WakeupThread(m_server); } @@ -674,12 +674,12 @@ void NetPlayServer::OnTraversalStateChanged() // called from ---GUI--- thread void NetPlayServer::SendChatMessage(const std::string& msg) { - sf::Packet* spac = new sf::Packet; + auto spac = std::make_unique(); *spac << (MessageId)NP_MSG_CHAT_MESSAGE; *spac << (PlayerId)0; // server id always 0 *spac << msg; - SendAsyncToClients(spac); + SendAsyncToClients(std::move(spac)); } // called from ---GUI--- thread @@ -690,11 +690,11 @@ bool NetPlayServer::ChangeGame(const std::string &game) m_selected_game = game; // send changed game to clients - sf::Packet* spac = new sf::Packet; + auto spac = std::make_unique(); *spac << (MessageId)NP_MSG_CHANGE_GAME; *spac << game; - SendAsyncToClients(spac); + SendAsyncToClients(std::move(spac)); return true; } @@ -719,7 +719,7 @@ bool NetPlayServer::StartGame() g_netplay_initial_gctime = Common::Timer::GetLocalTimeSinceJan1970(); // tell clients to start game - sf::Packet* spac = new sf::Packet; + auto spac = std::make_unique(); *spac << (MessageId)NP_MSG_START_GAME; *spac << m_current_game; *spac << m_settings.m_CPUthread; @@ -738,7 +738,7 @@ bool NetPlayServer::StartGame() *spac << (u32)g_netplay_initial_gctime; *spac << (u32)(g_netplay_initial_gctime >> 32); - SendAsyncToClients(spac); + SendAsyncToClients(std::move(spac)); m_is_running = true; diff --git a/Source/Core/Core/NetPlayServer.h b/Source/Core/Core/NetPlayServer.h index 05a5984f2a..f85383c120 100644 --- a/Source/Core/Core/NetPlayServer.h +++ b/Source/Core/Core/NetPlayServer.h @@ -22,7 +22,7 @@ class NetPlayServer : public TraversalClientClient { public: void ThreadFunc(); - void SendAsyncToClients(sf::Packet* packet); + void SendAsyncToClients(std::unique_ptr packet); NetPlayServer(const u16 port, bool traversal, const std::string& centralServer, u16 centralPort); ~NetPlayServer();