From 6a1d1c0b0abf5a8a96e93c19f3fb3807bfa11e5a Mon Sep 17 00:00:00 2001 From: quaK <38787176+Joelrau@users.noreply.github.com> Date: Mon, 12 Sep 2022 04:33:58 +0300 Subject: [PATCH] fix custom weapon index mismatch fix for custom attachments --- src/client/component/weapon.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/client/component/weapon.cpp b/src/client/component/weapon.cpp index 66c4a7a7..86ed93cd 100644 --- a/src/client/component/weapon.cpp +++ b/src/client/component/weapon.cpp @@ -61,6 +61,26 @@ namespace weapon return result; } + void cw_mismatch_error_stub(int, const char* msg, ...) + { + char buffer[0x100]; + + va_list ap; + va_start(ap, msg); + + vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, msg, ap); + + va_end(ap); + + console::error(buffer); + } + + int g_find_config_string_index_stub(const char* string, int start, int max, int create, const char* errormsg) + { + create = 1; + return utils::hook::invoke(0x8B530_b, string, start, max, create, errormsg); // G_FindConfigstringIndex + } + template void set_weapon_field(const std::string& weapon_name, unsigned int field, T value) { @@ -111,8 +131,11 @@ namespace weapon // use tag_weapon if tag_weapon_right or tag_knife_attach are not found on model xmodel_get_bone_index_hook.create(0x5C82B0_b, xmodel_get_bone_index_stub); - // disable custom weapon index mismatch (fix for custom attachments) (NEEDS TESTING) - //utils::hook::set(0x11B910_b, 0xC3); // CG_SetupCustomWeapon + // make custom weapon index mismatch not drop in CG_SetupCustomWeapon + utils::hook::call(0x11B9AF_b, cw_mismatch_error_stub); + + // patch attachment configstring so it will create if not found + utils::hook::call(0x41C595_b, g_find_config_string_index_stub); } #ifdef DEBUG