Make GPS solver hook node-only
This commit is contained in:
@@ -100,6 +100,8 @@ constexpr bool kEnableVerboseJournalListenerHooks = false;
|
||||
constexpr bool kEnableVerboseRouteObserverHooks = false;
|
||||
constexpr bool kEnableVerboseMappinRouteState = false;
|
||||
constexpr bool kEnableGpsMultiplierHooks = true;
|
||||
constexpr bool kEnableGpsAuxMultiplierHook = false;
|
||||
constexpr bool kEnableGpsMultiplierSignatureTrace = false;
|
||||
constexpr bool kEnableGpsCostTablePatch = false;
|
||||
constexpr bool kEnableGpsProviderClassPatch = false;
|
||||
constexpr bool kEnableGpsProviderClassPatchTrace = false;
|
||||
@@ -4859,8 +4861,11 @@ float DetourGpsAuxMultiplier(void* aJob, void* aNode)
|
||||
result = gOriginalGpsAuxMultiplier(aJob, aNode);
|
||||
}
|
||||
|
||||
LogGpsMultiplierSignature("GPSAuxMultiplier", kGpsAuxMultiplierRva, true, aJob, aNode, result,
|
||||
__builtin_return_address(0));
|
||||
if (kEnableGpsMultiplierSignatureTrace)
|
||||
{
|
||||
LogGpsMultiplierSignature("GPSAuxMultiplier", kGpsAuxMultiplierRva, true, aJob, aNode, result,
|
||||
__builtin_return_address(0));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -4872,18 +4877,12 @@ float DetourGpsNodeMultiplier(void* aJob, void* aNode)
|
||||
result = gOriginalGpsNodeMultiplier(aJob, aNode);
|
||||
}
|
||||
|
||||
const auto vanillaResult = result;
|
||||
uint32_t mode = 0;
|
||||
uint32_t retry = 0;
|
||||
uint16_t nodeFlags = 0;
|
||||
const auto jobAddress = reinterpret_cast<uintptr_t>(aJob);
|
||||
const auto nodeAddress = reinterpret_cast<uintptr_t>(aNode);
|
||||
const auto hasMode = aJob && TryReadMemory(reinterpret_cast<const void*>(jobAddress + 0xC4), mode);
|
||||
const auto hasFlags = aNode && TryReadMemory(reinterpret_cast<const void*>(nodeAddress + 0x88), nodeFlags);
|
||||
if (aJob)
|
||||
{
|
||||
TryReadMemory(reinterpret_cast<const void*>(jobAddress + 0x54), retry);
|
||||
}
|
||||
|
||||
if (hasMode && hasFlags && mode == 2 && std::isfinite(result))
|
||||
{
|
||||
@@ -4891,36 +4890,14 @@ float DetourGpsNodeMultiplier(void* aJob, void* aNode)
|
||||
if (patchMultiplier != 1.0f)
|
||||
{
|
||||
result *= patchMultiplier;
|
||||
|
||||
constexpr LONG kMaxLoggedCalls = 96;
|
||||
LONG callCount = -1;
|
||||
if (InterlockedCompareExchange(&gGpsSolverNodeWeightPatchLogCount, 0, 0) < kMaxLoggedCalls)
|
||||
{
|
||||
callCount = InterlockedIncrement(&gGpsSolverNodeWeightPatchLogCount) - 1;
|
||||
}
|
||||
|
||||
if (callCount >= 0 && callCount < kMaxLoggedCalls)
|
||||
{
|
||||
std::ostringstream line;
|
||||
const auto flags = line.flags();
|
||||
const auto precision = line.precision();
|
||||
line << "hook GPSNodeMultiplierPatch 0x" << std::hex << kGpsNodeMultiplierRva << std::dec
|
||||
<< " call=" << callCount << " category=" << TrafficLaneCategory(nodeFlags)
|
||||
<< " mode=" << mode << " retry=" << retry << " flags88=0x" << std::hex << nodeFlags
|
||||
<< std::dec << " vanilla=" << std::fixed << std::setprecision(3) << vanillaResult
|
||||
<< " multiplier=" << patchMultiplier << " result=" << result;
|
||||
line.flags(flags);
|
||||
line.precision(precision);
|
||||
AppendPointerWithRva(line, "job", aJob);
|
||||
AppendPointerWithRva(line, "node", aNode);
|
||||
AppendReturnRva(line, __builtin_return_address(0));
|
||||
LogRed4ext(line.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LogGpsMultiplierSignature("GPSNodeMultiplier", kGpsNodeMultiplierRva, false, aJob, aNode, vanillaResult,
|
||||
__builtin_return_address(0));
|
||||
if (kEnableGpsMultiplierSignatureTrace)
|
||||
{
|
||||
LogGpsMultiplierSignature("GPSNodeMultiplier", kGpsNodeMultiplierRva, false, aJob, aNode, result,
|
||||
__builtin_return_address(0));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -5349,9 +5326,12 @@ RED4EXT_C_EXPORT bool RED4EXT_CALL Main(RED4ext::v1::PluginHandle aHandle, RED4e
|
||||
}
|
||||
if (kEnableGpsMultiplierHooks)
|
||||
{
|
||||
AttachProbeHook("GPSAuxMultiplier 0x40bb00", kGpsAuxMultiplierRva,
|
||||
reinterpret_cast<void*>(&DetourGpsAuxMultiplier),
|
||||
reinterpret_cast<void**>(&gOriginalGpsAuxMultiplier));
|
||||
if (kEnableGpsAuxMultiplierHook)
|
||||
{
|
||||
AttachProbeHook("GPSAuxMultiplier 0x40bb00", kGpsAuxMultiplierRva,
|
||||
reinterpret_cast<void*>(&DetourGpsAuxMultiplier),
|
||||
reinterpret_cast<void**>(&gOriginalGpsAuxMultiplier));
|
||||
}
|
||||
AttachProbeHook("GPSNodeMultiplier 0x40bb40", kGpsNodeMultiplierRva,
|
||||
reinterpret_cast<void*>(&DetourGpsNodeMultiplier),
|
||||
reinterpret_cast<void**>(&gOriginalGpsNodeMultiplier));
|
||||
@@ -5532,7 +5512,10 @@ RED4EXT_C_EXPORT bool RED4EXT_CALL Main(RED4ext::v1::PluginHandle aHandle, RED4e
|
||||
}
|
||||
if (kEnableGpsMultiplierHooks)
|
||||
{
|
||||
DetachProbeHook("GPSAuxMultiplier 0x40bb00", kGpsAuxMultiplierRva);
|
||||
if (kEnableGpsAuxMultiplierHook)
|
||||
{
|
||||
DetachProbeHook("GPSAuxMultiplier 0x40bb00", kGpsAuxMultiplierRva);
|
||||
}
|
||||
DetachProbeHook("GPSNodeMultiplier 0x40bb40", kGpsNodeMultiplierRva);
|
||||
}
|
||||
if (kEnableRouteUiTraceHooks)
|
||||
|
||||
Reference in New Issue
Block a user