[Download] Optimize map download
This commit is contained in:
parent
fc6c24ca30
commit
7dd6ff0fe2
@ -6,6 +6,9 @@ namespace Components
|
||||
Download::ClientDownload Download::CLDownload;
|
||||
std::vector<std::shared_ptr<Download::ScriptDownload>> Download::ScriptDownloads;
|
||||
|
||||
std::thread Download::ServerThread;
|
||||
bool Download::Terminate;
|
||||
|
||||
#pragma region Client
|
||||
|
||||
void Download::InitiateMapDownload(std::string map)
|
||||
@ -703,6 +706,7 @@ namespace Components
|
||||
{
|
||||
if (Dedicated::IsEnabled())
|
||||
{
|
||||
Download::Terminate = false;
|
||||
ZeroMemory(&Download::Mgr, sizeof Download::Mgr);
|
||||
mg_mgr_init(&Download::Mgr, nullptr);
|
||||
|
||||
@ -726,9 +730,13 @@ namespace Components
|
||||
}
|
||||
});
|
||||
|
||||
QuickPatch::OnFrame([]
|
||||
Download::Terminate = false;
|
||||
Download::ServerThread = std::thread([]
|
||||
{
|
||||
mg_mgr_poll(&Download::Mgr, 0);
|
||||
while (!Download::Terminate)
|
||||
{
|
||||
mg_mgr_poll(&Download::Mgr, 100);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
@ -820,6 +828,12 @@ namespace Components
|
||||
|
||||
Download::~Download()
|
||||
{
|
||||
Download::Terminate = true;
|
||||
if (Download::ServerThread.joinable())
|
||||
{
|
||||
Download::ServerThread.join();
|
||||
}
|
||||
|
||||
if (Dedicated::IsEnabled())
|
||||
{
|
||||
mg_mgr_free(&Download::Mgr);
|
||||
|
@ -210,6 +210,8 @@ namespace Components
|
||||
static mg_mgr Mgr;
|
||||
static ClientDownload CLDownload;
|
||||
static std::vector<std::shared_ptr<ScriptDownload>> ScriptDownloads;
|
||||
static std::thread ServerThread;
|
||||
static bool Terminate;
|
||||
|
||||
static void EventHandler(mg_connection *nc, int ev, void *ev_data);
|
||||
static void ListHandler(mg_connection *nc, int ev, void *ev_data);
|
||||
|
@ -453,9 +453,7 @@ namespace Components
|
||||
Command::Execute("awaitDatabase", false); // Wait for the database to load
|
||||
Command::Execute("wait 100", false);
|
||||
Command::Execute("openmenu popup_reconnectingtoparty", false);
|
||||
Command::Execute("wait 8000", false); // Seems like 8000ms?
|
||||
Command::Execute("closemenu popup_reconnectingtoparty", false);
|
||||
Command::Execute("reconnect", false);
|
||||
Command::Execute("delayReconnect", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -933,6 +931,15 @@ namespace Components
|
||||
Utils::Hook(0x5A9D51, Maps::LoadMapLoadscreenStub, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x5B34DD, Maps::LoadMapLoadscreenStub, HOOK_CALL).install()->quick();
|
||||
|
||||
Command::Add("delayReconnect", [](Command::Params*)
|
||||
{
|
||||
Renderer::OnDelay([]()
|
||||
{
|
||||
Command::Execute("closemenu popup_reconnectingtoparty", false);
|
||||
Command::Execute("reconnect", false);
|
||||
}, 6s);
|
||||
});
|
||||
|
||||
// Download the map before a maprotation if necessary
|
||||
// Conflicts with Theater's SV map rotation check, but this one is safer!
|
||||
Utils::Hook(0x5AA91C, Maps::RotateCheckStub, HOOK_CALL).install()->quick();
|
||||
|
Loading…
Reference in New Issue
Block a user