This repository was archived by the owner on Oct 18, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathVRAddressMap.cpp
More file actions
125 lines (102 loc) · 3.4 KB
/
Copy pathVRAddressMap.cpp
File metadata and controls
125 lines (102 loc) · 3.4 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include <TiltedOnlinePCH.h>
#include "VRAddressMap.h"
#if TP_SKYRIMVR
#include <algorithm>
#include <spdlog/spdlog.h>
namespace
{
#include "VRAddressMap.inl"
constexpr size_t kEntryCount = sizeof(kVRAddressMap) / sizeof(kVRAddressMap[0]);
const char* ConfidenceName(uint8_t aConfidence) noexcept
{
switch (aConfidence)
{
case 5: return "override";
case 4: return "curated-identical";
case 3: return "curated-verified";
case 2: return "curated-weak";
case 1: return "auto-diff";
default: return "addrlib";
}
}
} // namespace
namespace VRAddresses
{
const VRAddress* Data() noexcept
{
return kVRAddressMap;
}
size_t Count() noexcept
{
return kEntryCount;
}
const VRAddress* Lookup(uint64_t aeId) noexcept
{
if (aeId > UINT32_MAX)
return nullptr;
const VRAddress* pEnd = kVRAddressMap + kEntryCount;
const VRAddress* pIt = std::lower_bound(kVRAddressMap, pEnd, static_cast<uint32_t>(aeId), [](const VRAddress& acEntry, uint32_t aId) { return acEntry.aeId < aId; });
return (pIt != pEnd && pIt->aeId == aeId) ? pIt : nullptr;
}
void ReportMissing(uint64_t aeId) noexcept
{
const VRAddress* pEntry = Lookup(aeId);
char message[512];
if (pEntry)
{
_snprintf_s(message, sizeof(message),
"Address Library id %llu (%s) has no SkyrimVR address yet.\n\n"
"Add a verified address to Tools/vr_addresses/overrides.csv, then re-run\n"
" node Tools/vr_addresses/resolve.mjs",
aeId, pEntry->name);
}
else
{
_snprintf_s(message, sizeof(message),
"Address Library id %llu is not in the generated VR address table.\n\n"
"Re-run node Tools/vr_addresses/resolve.mjs to pick up newly added ids.",
aeId);
}
spdlog::critical("{}", message);
if (spdlog::default_logger())
spdlog::default_logger()->flush();
OutputDebugStringA(message);
OutputDebugStringA("\n");
if (IsDebuggerPresent())
__debugbreak();
MessageBoxA(nullptr, message, "Skyrim Together VR", MB_OK | MB_ICONERROR);
TerminateProcess(GetCurrentProcess(), 4);
__assume(0);
}
void LogSummary() noexcept
{
size_t byConfidence[6]{};
size_t unmapped = 0;
for (const VRAddress& entry : kVRAddressMap)
{
if (entry.vrOffset == 0)
++unmapped;
else
++byConfidence[entry.confidence < 6 ? entry.confidence : 0];
}
spdlog::info("VR address table: {} ids, {} mapped, {} unmapped", kEntryCount, kEntryCount - unmapped, unmapped);
for (int i = 5; i >= 0; --i)
{
if (byConfidence[i])
spdlog::info(" {:<18} {}", ConfidenceName(static_cast<uint8_t>(i)), byConfidence[i]);
}
// Confidence 0 and 1 come from automated binary diffing, which is roughly 99.9% accurate.
// Naming them here means a bad address has a short list of suspects instead of none.
for (const VRAddress& entry : kVRAddressMap)
{
if (entry.vrOffset != 0 && entry.confidence <= 1)
spdlog::debug(" unverified: id {} ({}) -> +0x{:X} [{}]", entry.aeId, entry.name, entry.vrOffset, ConfidenceName(entry.confidence));
}
for (const VRAddress& entry : kVRAddressMap)
{
if (entry.vrOffset == 0)
spdlog::warn(" no VR address: id {} ({})", entry.aeId, entry.name);
}
}
} // namespace VRAddresses
#endif