mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Common/TraversalClient: Use correct deleter with g_MainNetHost
Previously this was using the default deleter (which just calls delete on the pointer), which is incorrect, since the ENetHost instance is allocated through ENet's C API, so we need to use its functions to deallocate the host instead.
This commit is contained in:
@ -304,7 +304,7 @@ int ENET_CALLBACK TraversalClient::InterceptCallback(ENetHost* host, ENetEvent*
|
||||
}
|
||||
|
||||
std::unique_ptr<TraversalClient> g_TraversalClient;
|
||||
std::unique_ptr<ENetHost> g_MainNetHost;
|
||||
Common::ENet::ENetHostPtr g_MainNetHost;
|
||||
|
||||
// The settings at the previous TraversalClient reset - notably, we
|
||||
// need to know not just what port it's on, but whether it was
|
||||
@ -323,18 +323,18 @@ bool EnsureTraversalClient(const std::string& server, u16 server_port, u16 liste
|
||||
g_OldListenPort = listen_port;
|
||||
|
||||
ENetAddress addr = {ENET_HOST_ANY, listen_port};
|
||||
ENetHost* host = enet_host_create(&addr, // address
|
||||
50, // peerCount
|
||||
NetPlay::CHANNEL_COUNT, // channelLimit
|
||||
0, // incomingBandwidth
|
||||
0); // outgoingBandwidth
|
||||
auto host = Common::ENet::ENetHostPtr{enet_host_create(&addr, // address
|
||||
50, // peerCount
|
||||
NetPlay::CHANNEL_COUNT, // channelLimit
|
||||
0, // incomingBandwidth
|
||||
0)}; // outgoingBandwidth
|
||||
if (!host)
|
||||
{
|
||||
g_MainNetHost.reset();
|
||||
return false;
|
||||
}
|
||||
host->mtu = std::min(host->mtu, NetPlay::MAX_ENET_MTU);
|
||||
g_MainNetHost.reset(host);
|
||||
g_MainNetHost = std::move(host);
|
||||
g_TraversalClient.reset(new TraversalClient(g_MainNetHost.get(), server, server_port));
|
||||
}
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user