From d2be79235a87341943a969a4603068c397285495 Mon Sep 17 00:00:00 2001 From: r3nzthecodegod Date: Wed, 26 Jan 2022 23:37:54 +0300 Subject: [PATCH] Fix bug that caused Target Dummys to appear as champions --- R3nzSkin/GUI.cpp | 79 ++++++++++++++++++++++++++-------------------- R3nzSkin/Hooks.cpp | 5 ++- 2 files changed, 49 insertions(+), 35 deletions(-) diff --git a/R3nzSkin/GUI.cpp b/R3nzSkin/GUI.cpp index 7c3e0093..b26e69a0 100644 --- a/R3nzSkin/GUI.cpp +++ b/R3nzSkin/GUI.cpp @@ -22,6 +22,44 @@ void TextCenter(const std::string text) noexcept ImGui::Text(text.c_str()); } +void __fastcall rainbowText() noexcept +{ + static float r{ 1.0f }; + static float g{ 0.f }; + static float b{ 0.f }; + + if (Config::config.rainbowText) { + if (r == 1.f && g >= 0.f && b <= 0.f) { + g += 0.005f; + b = 0.f; + } + if (r <= 1.f && g >= 1.f && b == 0.f) { + g = 1.f; + r -= 0.005f; + } + if (r <= 0.f && g == 1.f && b >= 0.f) { + r = 0.f; + b += 0.005f; + } + if (r == 0.f && g <= 1.f && b >= 1.f) { + b = 1.f; + g -= 0.005f; + } + if (r >= 0.f && g <= 0.f && b == 1.f) { + g = 0.f; + r += 0.005f; + } + if (r >= 1.f && g >= 0.f && b <= 1.f) { + r = 1.f; + b -= 0.005f; + } + ImGui::GetStyle().Colors[ImGuiCol_Text] = ImVec4(r, g, b, 1.00f); + } else { + if (auto& clr{ ImGui::GetStyle().Colors[ImGuiCol_Text] }; clr.x != 0.92f && clr.y != 0.92f && clr.z != 0.92f) + clr = ImVec4(0.92f, 0.92f, 0.92f, 0.92f); + } +} + char str_buffer[256]; void GUI::render() noexcept { @@ -30,39 +68,8 @@ void GUI::render() noexcept static const auto player{ Memory::getLocalPlayer() }; static const auto heroes{ Memory::getHeroes() }; static const auto my_team{ player ? player->get_team() : 100 }; - static float r{ 1.0f }; - static float g{ 0.f }; - static float b{ 0.f }; - - if (Config::config.rainbowText) { - if (r == 1.f && g >= 0.f && b <= 0.f) { - g += 0.005f; - b = 0.f; - } - if (r <= 1.f && g >= 1.f && b == 0.f) { - g = 1.f; - r -= 0.005f; - } - if (r <= 0.f && g == 1.f && b >= 0.f) { - r = 0.f; - b += 0.005f; - } - if (r == 0.f && g <= 1.f && b >= 1.f) { - b = 1.f; - g -= 0.005f; - } - if (r >= 0.f && g <= 0.f && b == 1.f) { - g = 0.f; - r += 0.005f; - } - if (r >= 1.f && g >= 0.f && b <= 1.f) { - r = 1.f; - b -= 0.005f; - } - ImGui::GetStyle().Colors[ImGuiCol_Text] = ImVec4(r, g, b, 1.00f); - } else - if (auto& clr{ ImGui::GetStyle().Colors[ImGuiCol_Text] }; clr.x != 0.92f && clr.y != 0.92f && clr.z != 0.92f) - clr = ImVec4(0.92f, 0.92f, 0.92f, 0.92f); + + rainbowText(); static const auto vector_getter_skin = [](void* vec, std::int32_t idx, const char** out_text) { const auto& vector{ *static_cast*>(vec) }; @@ -96,9 +103,14 @@ void GUI::render() noexcept int32_t last_team{ 0 }; for (auto i{ 0u }; i < heroes->length; ++i) { const auto hero{ heroes->list[i] }; + if (hero == player) continue; + const auto champion_name_hash{ fnv::hash_runtime(hero->get_character_data_stack()->base_skin.model.str) }; + if (champion_name_hash == FNV("PracticeTool_TargetDummy")) + continue; + const auto hero_team{ hero->get_team() }; const auto is_enemy{ hero_team != my_team }; @@ -113,7 +125,6 @@ void GUI::render() noexcept } auto& config_array{ is_enemy ? Config::config.current_combo_enemy_skin_index : Config::config.current_combo_ally_skin_index }; - const auto champion_name_hash{ fnv::hash_runtime(hero->get_character_data_stack()->base_skin.model.str) }; const auto config_entry{ config_array.insert({ champion_name_hash, 0 }) }; snprintf(str_buffer, 256, Config::config.heroName ? "HeroName: [ %s ]##%X" : "PlayerName: [ %s ]##%X", Config::config.heroName ? hero->get_character_data_stack()->base_skin.model.str : hero->get_name().c_str(), reinterpret_cast(hero)); diff --git a/R3nzSkin/Hooks.cpp b/R3nzSkin/Hooks.cpp index 6ce64605..b94c3a2f 100644 --- a/R3nzSkin/Hooks.cpp +++ b/R3nzSkin/Hooks.cpp @@ -296,9 +296,12 @@ void Hooks::init() noexcept if (hero == player) continue; + const auto champion_name_hash{ fnv::hash_runtime(hero->get_character_data_stack()->base_skin.model.str) }; + if (champion_name_hash == FNV("PracticeTool_TargetDummy")) + continue; + const auto is_enemy{ my_team != hero->get_team() }; const auto& config_array{ is_enemy ? Config::config.current_combo_enemy_skin_index : Config::config.current_combo_ally_skin_index }; - const auto champion_name_hash{ fnv::hash_runtime(hero->get_character_data_stack()->base_skin.model.str) }; const auto config_entry{ config_array.find(champion_name_hash) }; if (config_entry == config_array.end()) continue;