CPU overhead reduction
This commit is contained in:
@@ -157,10 +157,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) {
|
||||
UltraWideFixEnabled();
|
||||
CameraDistanceFixEnabled();
|
||||
HUDUpdate(true);
|
||||
gPendingDOF = true;
|
||||
gPendingCA = true;
|
||||
gPendingVignetting = true;
|
||||
gPendingFog = true;
|
||||
SetAllEffectsToBeToggled();
|
||||
LogFixToggle(GameFixes::None, g_fix_enabled);
|
||||
}
|
||||
|
||||
@@ -219,6 +216,10 @@ static void ProcessEvent() {
|
||||
PEHook = safetyhook::create_mid(ProcessEventaddress + 0xc,
|
||||
[](SafetyHookContext& ctx) {
|
||||
ULONGLONG now = GetTickCount64();
|
||||
static UC::int32 NAME_Construct = -1;
|
||||
static UC::int32 NAME_Destruct = -1;
|
||||
static UC::int32 NAME_PerceptionTick = -1;
|
||||
|
||||
if (now - lastScanTick >= DEFAULT_DELAY_BETWEEN_TICK) { // Delay between each tick to avoid ProcessEvent stuttering
|
||||
lastScanTick = now;
|
||||
GetResolution(screenWidth, screenHeight, g_AspectRatio);
|
||||
@@ -228,31 +229,35 @@ static void ProcessEvent() {
|
||||
UFunction* func = (UFunction*)ctx.rdx;
|
||||
if (!object || !func) return;
|
||||
|
||||
std::string funcName = func->GetName();
|
||||
UC::int32 comparisonIndex = func->Name.ComparisonIndex; // Make function comparision faster than allocating std::srting
|
||||
if (NAME_PerceptionTick == -1 && func->Name.ToString() == "OnPerceptionIntensityUpdated")
|
||||
NAME_PerceptionTick = comparisonIndex;
|
||||
|
||||
// Full stealth fix: disable AI perception.
|
||||
if (object->IsA(AStyx3AIController::StaticClass()) && funcName == "OnPerceptionIntensityUpdated") {
|
||||
if (NAME_PerceptionTick == comparisonIndex && object->IsA(AStyx3AIController::StaticClass())) {
|
||||
auto* AIController = static_cast<AStyx3AIController*>(object);
|
||||
|
||||
if (g_Player && AIController->PerceptionGaugeComponent) {
|
||||
if (g_Stealth_fix_enabled) {
|
||||
if (g_Stealth_fix_enabled)
|
||||
AIController->PerceptionGaugeComponent->ResetGauges(g_Player);
|
||||
if (g_Player) g_Player->bIsPerceptible = false;
|
||||
}
|
||||
else {
|
||||
AIController->PerceptionGaugeComponent->SetActiveBufferDetection(g_Player, true);
|
||||
if (g_Player) g_Player->bIsPerceptible = true;
|
||||
else AIController->PerceptionGaugeComponent->SetActiveBufferDetection(g_Player, true);
|
||||
|
||||
g_Player->bIsPerceptible = !g_Stealth_fix_enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (object->IsA(UUserWidget::StaticClass()) && (funcName == "Construct" || funcName == "Destruct" || funcName == "Tick")) {
|
||||
std::string objectName = object->GetName();
|
||||
if (object->IsA(UUserWidget::StaticClass())) {
|
||||
if (NAME_Construct == -1 && func->Name.ToString() == "Construct") NAME_Construct = func->Name.ComparisonIndex;
|
||||
if (NAME_Destruct == -1 && func->Name.ToString() == "Destruct") NAME_Destruct = func->Name.ComparisonIndex;
|
||||
// UI scaling
|
||||
auto HandleWidget = [&](auto* typedWidget, auto*& gWidgetPtr) { // Lambda to initialize pointers on Construct and nullify them on Destruct
|
||||
if (funcName == "Construct") {
|
||||
if (NAME_Construct == comparisonIndex || NAME_Destruct == comparisonIndex) {
|
||||
std::string objectName = object->GetName();
|
||||
// Lambda to initialize pointers on Construct and nullify them on Destruct
|
||||
auto HandleWidget = [&](auto* typedWidget, auto*& gWidgetPtr) {
|
||||
if (NAME_Construct == comparisonIndex) {
|
||||
gWidgetPtr = typedWidget;
|
||||
HUDUpdate(false);
|
||||
}
|
||||
else if (funcName == "Destruct") gWidgetPtr = nullptr;
|
||||
else if (NAME_Destruct == comparisonIndex) gWidgetPtr = nullptr;
|
||||
};
|
||||
|
||||
if (object->IsA(UUI_Settings_C::StaticClass()))
|
||||
@@ -292,7 +297,7 @@ static void ProcessEvent() {
|
||||
if (!g_StatusWidget && match("StatusWidget")) g_StatusWidget = Widget;
|
||||
else if (!g_GaugesWidget && match("Gauges")) g_GaugesWidget = Widget;
|
||||
else if (!g_ChangeWheelWidget && match("ChangeWheel")) g_ChangeWheelWidget = Widget;
|
||||
else if (!g_AbilityWheelWidget && match("AbilityWheel")) g_AbilityWheelWidget = Widget; // g_QuestWidget
|
||||
else if (!g_AbilityWheelWidget && match("AbilityWheel")) g_AbilityWheelWidget = Widget;
|
||||
else if (!g_QuestWidget && match("Notifications_Missions")) g_QuestWidget = Widget;
|
||||
else if (!g_LootWidget && match("Notifications_Loot")) g_LootWidget = Widget;
|
||||
|
||||
@@ -314,21 +319,21 @@ static void ProcessEvent() {
|
||||
};
|
||||
|
||||
if (objectName.rfind("Crafting", 0) == 0) {
|
||||
if (funcName == "Construct") {
|
||||
if (NAME_Construct == comparisonIndex) {
|
||||
g_CraftingWidget = static_cast<UUserWidget*>(object);
|
||||
HUDUpdate(false);
|
||||
}
|
||||
else if (funcName == "Destruct") g_CraftingWidget = nullptr;
|
||||
else if (NAME_Destruct == comparisonIndex) g_CraftingWidget = nullptr;
|
||||
}
|
||||
else if (objectName.rfind("HUD_Widget_C", 0) == 0) {
|
||||
auto* HUDWidget = static_cast<UUserWidget*>(object);
|
||||
if (funcName == "Construct") {
|
||||
if (NAME_Construct == comparisonIndex) {
|
||||
if (HUDWidget && HUDWidget->Class) {
|
||||
FindWidgets(HUDWidget->WidgetTree->RootWidget);
|
||||
HUDUpdate(false);
|
||||
}
|
||||
}
|
||||
else if (funcName == "Destruct") {
|
||||
else if (NAME_Destruct == comparisonIndex) {
|
||||
g_QuestWidget = nullptr;
|
||||
g_LootWidget = nullptr;
|
||||
g_StatusWidget = nullptr;
|
||||
@@ -339,6 +344,7 @@ static void ProcessEvent() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user