[QuickPatch] Fix upnp memory leak
This commit is contained in:
parent
cfb252b3ee
commit
4d088cd620
@ -246,13 +246,12 @@ namespace Components
|
||||
|
||||
void Console::Destroy()
|
||||
{
|
||||
delwin(Console::OutputWindow);
|
||||
delwin(Console::InputWindow);
|
||||
delwin(Console::InfoWindow);
|
||||
endwin();
|
||||
|
||||
try
|
||||
{
|
||||
delwin(Console::OutputWindow);
|
||||
delwin(Console::InputWindow);
|
||||
delwin(Console::InfoWindow);
|
||||
endwin();
|
||||
delscreen(SP);
|
||||
}
|
||||
catch (...)
|
||||
|
@ -397,13 +397,14 @@ namespace Components
|
||||
|
||||
#ifdef USE_LEGACY_SERVER_LIST
|
||||
// Heartbeats
|
||||
Scheduler::Once(Dedicated::Heartbeat);
|
||||
Scheduler::OnFrame([] ()
|
||||
{
|
||||
static int LastHeartbeat = 0;
|
||||
static Utils::Time::Interval interval;
|
||||
|
||||
if (Dvar::Var("sv_maxclients").get<int>() > 0 && !LastHeartbeat || (Game::Com_Milliseconds() - LastHeartbeat) > 120 * 1000)
|
||||
if (Dvar::Var("sv_maxclients").get<int>() > 0 && interval.elapsed(2min))
|
||||
{
|
||||
LastHeartbeat = Game::Com_Milliseconds();
|
||||
interval.update();
|
||||
Dedicated::Heartbeat();
|
||||
}
|
||||
});
|
||||
|
@ -260,20 +260,17 @@ namespace Components
|
||||
// spawn upnp thread when UPNP_init returns
|
||||
Utils::Hook::Hook(0x47982B, []()
|
||||
{
|
||||
std::thread upnpThread([]()
|
||||
std::thread([]()
|
||||
{
|
||||
// check natpmpstate
|
||||
// state 4 is no more devices to query
|
||||
while (true)
|
||||
while (Utils::Hook::Get<int>(0x66CE200) < 4)
|
||||
{
|
||||
if (Utils::Hook::Get<int>(0x66CE200) < 4)
|
||||
{
|
||||
Utils::Hook::Call<void()>(0x4D7030)();
|
||||
}
|
||||
Utils::Hook::Call<void()>(0x4D7030)();
|
||||
std::this_thread::sleep_for(500ms);
|
||||
}
|
||||
});
|
||||
}, HOOK_JUMP);
|
||||
}).detach();
|
||||
}, HOOK_JUMP).install()->quick();
|
||||
|
||||
// disable the IWNet IP detection (default 'got ipdetect' flag to 1)
|
||||
Utils::Hook::Set<BYTE>(0x649D6F0, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user