From ab8144a494b04da0b1ded6a7fe657723ada36ef6 Mon Sep 17 00:00:00 2001 From: mjkzy Date: Fri, 24 Jun 2022 20:45:02 -0500 Subject: [PATCH] add additional help to common errors --- src/client/component/patches.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/client/component/patches.cpp b/src/client/component/patches.cpp index d7786e3a..f1b0c694 100644 --- a/src/client/component/patches.cpp +++ b/src/client/component/patches.cpp @@ -185,6 +185,22 @@ namespace patches cl_gamepad_scrolling_buttons_hook.invoke(local_client_num, a2); } } + + int out_of_memory_text_stub(char* dest, int size, const char* fmt, ...) + { + fmt = "%s (%d)\n\nDisable shader caching, lower graphic settings, free up RAM, or update your GPU drivers.\n\nIf this still occurs, try using the '-memoryfix' parameter to generate the 'players2' folder."; + + char buffer[2048]; + + va_list ap; + va_start(ap, fmt); + + vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, fmt, ap); + + va_end(ap); + + return utils::hook::invoke(SELECT_VALUE(0x429200_b, 0x5AF0F0_b), dest, size, "%s", buffer); + } } class component final : public component_interface @@ -223,6 +239,15 @@ namespace patches // Allow executing custom cfg files with the "exec" command utils::hook::call(SELECT_VALUE(0x376EB5_b, 0x156D41_b), db_read_raw_file_stub); + // Remove useless information from errors + add additional help to common errors + utils::hook::set(SELECT_VALUE(0x7E3DF0_b, 0x937B80_b), + "Create2DTexture( %s, %i, %i, %i, %i ) failed\n\n" + "Disable shader caching, lower graphic settings, free up RAM, or update your GPU drivers."); + utils::hook::set(SELECT_VALUE(0x800EA8_b, 0x954FF0_b), + "IDXGISwapChain::Present failed: %s\n\n" + "Disable shader caching, lower graphic settings, free up RAM, or update your GPU drivers."); + utils::hook::call(SELECT_VALUE(0x457BC9_b, 0x1D8E09_b), out_of_memory_text_stub); // "Out of memory. You are probably low on disk space." + if (!game::environment::is_sp()) { patch_mp();