forked from RyanJGray/AlienIsolation.DevTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZONE_LOADER.cpp
More file actions
63 lines (53 loc) · 1.62 KB
/
Copy pathZONE_LOADER.cpp
File metadata and controls
63 lines (53 loc) · 1.62 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
57
58
59
60
61
62
63
#include "ZONE_LOADER.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <atomic>
namespace
{
// A bit per source that wants every zone in (set when the DLL loads, on the camera task and from other tools' threads)
std::atomic<uint32_t> g_sources = 0;
}
void ZONE_LOADER::SetForced(Source source, bool forced)
{
if (forced)
g_sources |= static_cast<uint32_t>(source);
else
g_sources &= ~static_cast<uint32_t>(source);
}
bool ZONE_LOADER::IsForced()
{
return g_sources != 0;
}
__declspec(noinline)
void __cdecl ZONE_LOADER::h_match_current_zones_to_povs()
{
match_current_zones_to_povs();
if (!IsForced())
return;
char* zoneManager = static_cast<char*>(*zone_manager_instance);
if (!zoneManager)
return;
char* zones = *reinterpret_cast<char**>(zoneManager + kZoneArrayOffset);
if (!zones)
return;
const int count = *reinterpret_cast<int*>(zones + kArrayCountOffset);
char** allocations = *reinterpret_cast<char***>(zones + kArrayDataOffset);
if (!allocations)
return;
for (int i = 0; i < count; i++)
{
char* allocation = allocations[i];
if (!allocation)
continue;
char* zone = *reinterpret_cast<char**>(allocation + kAllocationObjectOffset);
if (!zone)
continue;
add_viewpoint(zoneManager, kPlayerViewer, *reinterpret_cast<unsigned int*>(zone + kZoneIdOffset));
}
}
// For other tools injected into the game (Cinematic Tools toggles this with its free camera). It only switches their
// own request: LoadAllZones and the live link camera keep theirs.
extern "C" __declspec(dllexport) void OpenCAGE_SetForceZoneLoading(bool forced)
{
ZONE_LOADER::SetForced(ZONE_LOADER::Source::External, forced);
}