csgo-vk-fix: avoid crashing on missing fns

This commit is contained in:
Vaxry 2024-07-22 19:13:25 +02:00
parent 03df2bceb9
commit 4c2cef8326

View file

@ -106,7 +106,6 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
g_pSurfaceSizeHook = HyprlandAPI::createFunctionHook(PHANDLE, fn.address, (void*)::hkSetWindowSize);
}
success = success && g_pSurfaceSizeHook;
FNS = HyprlandAPI::findFunctionsByName(PHANDLE, "computeDamage");
for (auto& r : FNS) {
@ -117,6 +116,12 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
break;
}
success = success && g_pSurfaceSizeHook && g_pWLSurfaceDamageHook && g_pMouseMotionHook;
if (!success) {
HyprlandAPI::addNotification(PHANDLE, "[csgo-vulkan-fix] Failure in initialization: Failed to find required hook fns", CColor{1.0, 0.2, 0.2, 1.0}, 5000);
throw std::runtime_error("[vkfix] Hooks fn init failed");
}
success = success && g_pWLSurfaceDamageHook->hook();
success = success && g_pMouseMotionHook->hook();
success = success && g_pSurfaceSizeHook->hook();