From 199894055028c114a3a05b048bdb1b790a3e4872 Mon Sep 17 00:00:00 2001 From: quaK <38787176+Joelrau@users.noreply.github.com> Date: Sun, 30 Apr 2023 20:42:58 +0300 Subject: [PATCH] Fix bone index stub maybe --- src/client/component/weapon.cpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/client/component/weapon.cpp b/src/client/component/weapon.cpp index 330525f0..3b2c1713 100644 --- a/src/client/component/weapon.cpp +++ b/src/client/component/weapon.cpp @@ -45,21 +45,32 @@ namespace weapon } utils::hook::detour xmodel_get_bone_index_hook; - __int64 xmodel_get_bone_index_stub(game::XModel* model, game::scr_string_t name, unsigned int offset, char* index) + int xmodel_get_bone_index_stub(game::XModel* model, game::scr_string_t name, unsigned int offset, char* index) { - auto result = xmodel_get_bone_index_hook.invoke<__int64>(model, name, offset, index); - if (!result) + auto result = xmodel_get_bone_index_hook.invoke(model, name, offset, index); + if (result) { - if (name == game::SL_GetString("tag_weapon_right", 0) || - name == game::SL_GetString("tag_knife_attach", 0)) + return result; + } + + const auto original_index = *index; + const auto original_result = result; + + if (name == game::SL_FindString("tag_weapon_right") || + name == game::SL_FindString("tag_knife_attach")) + { + const auto tag_weapon = game::SL_FindString("tag_weapon"); + result = xmodel_get_bone_index_hook.invoke(model, tag_weapon, offset, index); + if (result) { - result = xmodel_get_bone_index_hook.invoke<__int64>(model, game::SL_GetString("tag_weapon", 0), offset, index); - if (result) - { - console::debug("using tag_weapon instead of %s (%s, %d)\n", game::SL_ConvertToString(name), model->name, offset); - } + console::debug("using tag_weapon instead of %s (%s, %d, %d)\n", game::SL_ConvertToString(name), model->name, offset, *index); + return result; } } + + *index = original_index; + result = original_result; + return result; }