-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartup_update.cpp
More file actions
57 lines (44 loc) · 1.3 KB
/
startup_update.cpp
File metadata and controls
57 lines (44 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "pch.h"
#include "startup_update.h"
#include "startup_update_internal.h"
#include "mapInfo.h"
#include "runtime.h"
#include <mutex>
namespace mapupdater::startup {
namespace {
std::once_flag g_start_once;
void RunAutoUpdateFlow() {
const auto &state = runtime::GetRuntimeState();
if (!state.config.dota_enabled && !state.config.lod_enabled) {
DebugLog(state.config,
"[Debug] Both dota and lod are disabled, skipping update check.");
return;
}
const auto maps_info = FetchLatestMapsInfo(state.config);
if (!maps_info.has_value()) {
return;
}
const auto missing_items = BuildMissingDownloadItems(state, *maps_info);
if (missing_items.empty()) {
DebugLog(state.config, "[Debug] Required files already exist, skipping update.");
return;
}
(void)RunCustomOverlaySession(missing_items, *maps_info, state.config,
state.config.autoupdate_enabled);
}
} // namespace
void StartAutoUpdateFlowAsyncOnDllAttach() {
std::call_once(g_start_once, []() {
const HANDLE thread = CreateThread(
nullptr, 0,
[](LPVOID) -> DWORD {
RunAutoUpdateFlow();
return 0;
},
nullptr, 0, nullptr);
if (thread != nullptr) {
CloseHandle(thread);
}
});
}
} // namespace mapupdater::startup