Harden traffic edge scorer hook
This commit is contained in:
@@ -3827,35 +3827,26 @@ float DetourGpsTrafficEdgeScore(void* aSearchContext, void* aCandidate, void* aR
|
|||||||
baseScore = gOriginalGpsTrafficEdgeScore(aSearchContext, aCandidate, aReferencePoint);
|
baseScore = gOriginalGpsTrafficEdgeScore(aSearchContext, aCandidate, aReferencePoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* query = nullptr;
|
auto* query = ReadPointerField(aSearchContext, 0x10);
|
||||||
void* lane = nullptr;
|
auto* lane = ReadPointerField(aCandidate, 0x00);
|
||||||
uint8_t queryMode = 0xFF;
|
uint8_t queryMode = 0xFF;
|
||||||
uint16_t laneFlags = 0;
|
uint16_t laneFlags = 0;
|
||||||
|
|
||||||
if (aSearchContext)
|
|
||||||
{
|
|
||||||
query = *reinterpret_cast<void**>(reinterpret_cast<uintptr_t>(aSearchContext) + 0x10);
|
|
||||||
}
|
|
||||||
if (query)
|
if (query)
|
||||||
{
|
{
|
||||||
queryMode = *reinterpret_cast<uint8_t*>(reinterpret_cast<uintptr_t>(query) + 0x41);
|
TryReadMemory(reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(query) + 0x41), queryMode);
|
||||||
}
|
|
||||||
if (aCandidate)
|
|
||||||
{
|
|
||||||
lane = *reinterpret_cast<void**>(aCandidate);
|
|
||||||
}
|
}
|
||||||
if (lane)
|
if (lane)
|
||||||
{
|
{
|
||||||
laneFlags = *reinterpret_cast<uint16_t*>(reinterpret_cast<uintptr_t>(lane) + 0x88);
|
TryReadMemory(reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(lane) + 0x88), laneFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto driving = queryMode == 0;
|
const auto driving = queryMode == 0;
|
||||||
const auto multiplier = TrafficEdgeScoreMultiplier(laneFlags, driving);
|
const auto multiplier = TrafficEdgeScoreMultiplier(laneFlags, driving);
|
||||||
const auto patchedScore = baseScore * multiplier;
|
const auto patchedScore = baseScore * multiplier;
|
||||||
|
|
||||||
constexpr LONG kMaxLoggedCalls = 256;
|
constexpr LONG kMaxLoggedCalls = 64;
|
||||||
LONG callCount = -1;
|
LONG callCount = -1;
|
||||||
if (gGpsTrafficEdgeScoreLogCount < kMaxLoggedCalls)
|
if (InterlockedCompareExchange(&gGpsTrafficEdgeScoreLogCount, 0, 0) < kMaxLoggedCalls)
|
||||||
{
|
{
|
||||||
callCount = InterlockedIncrement(&gGpsTrafficEdgeScoreLogCount) - 1;
|
callCount = InterlockedIncrement(&gGpsTrafficEdgeScoreLogCount) - 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user