From f6969d88c570bded3357c607486488cbc178c0ce Mon Sep 17 00:00:00 2001 From: Andreas Maerten <24669514+Yimura@users.noreply.github.com> Date: Wed, 28 Jun 2023 11:20:48 +0200 Subject: [PATCH] Bug fix time (#1549) * fix(PlayerTP): Get Current only works once * chore(README): removed features from TOC * fix(ViewNetwork): SCTV join translation * refactor: Use tunable service for no idle kick * fix(Spoofing): check for valid model before spoofing * feat(Spectate): Remove freeze and hide player blip * fix(Spectate): case of chat not being visible as spectator. * feat(Matchmaking): safer max search limit for match searching * fix(Player/Toxic): Wanted Level small text translation --- README.md | 1 - src/backend/looped/player/spectate.cpp | 10 ++-- src/backend/looped/tunables/no_idle_kick.cpp | 57 +++++++++++++++++++ src/backend/script_patches.hpp | 7 --- .../write_player_appearance_data_node.cpp | 6 +- .../matchmaking/matchmaking_service.hpp | 2 +- src/views/network/view_network.cpp | 2 +- src/views/players/player/player_teleport.cpp | 7 +-- src/views/players/player/player_toxic.cpp | 2 +- src/views/self/view_self.cpp | 2 +- 10 files changed, 72 insertions(+), 24 deletions(-) create mode 100644 src/backend/looped/tunables/no_idle_kick.cpp diff --git a/README.md b/README.md index 4a663def..68be46ed 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,6 @@ So here I am with an up-to-date menu focusing on protecting the user from toxic * [Make your own flavour of YimMenu](#make-your-own-flavour-of-yimmenu) * [Staying Up To Date](#staying-up-to-date) * [Project Structure](#project-structure) - * [Features](#features) * [Contributing](#contributing) ## How to compile YimMenu diff --git a/src/backend/looped/player/spectate.cpp b/src/backend/looped/player/spectate.cpp index ac795665..8b406742 100644 --- a/src/backend/looped/player/spectate.cpp +++ b/src/backend/looped/player/spectate.cpp @@ -22,10 +22,9 @@ namespace big bReset = true; NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(false, -1); + NETWORK::NETWORK_OVERRIDE_RECEIVE_RESTRICTIONS_ALL(false); HUD::SET_MINIMAP_IN_SPECTATOR_MODE(false, -1); - - ENTITY::FREEZE_ENTITY_POSITION(ped, false); - ENTITY::FREEZE_ENTITY_POSITION(vehicle, false); + HUD::SET_BLIP_ALPHA(HUD::GET_MAIN_PLAYER_BLIP_ID(), 255); STREAMING::SET_FOCUS_ENTITY(ped); } @@ -36,10 +35,9 @@ namespace big const auto target = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player_service->get_selected()->id()); NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(true, target); + NETWORK::NETWORK_OVERRIDE_RECEIVE_RESTRICTIONS_ALL(false); HUD::SET_MINIMAP_IN_SPECTATOR_MODE(true, target); - - ENTITY::FREEZE_ENTITY_POSITION(ped, true); - ENTITY::FREEZE_ENTITY_POSITION(vehicle, true); + HUD::SET_BLIP_ALPHA(HUD::GET_MAIN_PLAYER_BLIP_ID(), 255); STREAMING::SET_FOCUS_ENTITY(target); diff --git a/src/backend/looped/tunables/no_idle_kick.cpp b/src/backend/looped/tunables/no_idle_kick.cpp new file mode 100644 index 00000000..4ebdc436 --- /dev/null +++ b/src/backend/looped/tunables/no_idle_kick.cpp @@ -0,0 +1,57 @@ +#include "backend/looped_command.hpp" +#include "services/tunables/tunables_service.hpp" + +namespace big +{ + class no_idle_kick : looped_command + { + using looped_command::looped_command; + + std::array m_tunables = { nullptr }; + std::array m_restore; + bool m_ready_to_use; + + virtual void on_tick() override + { + if (!m_ready_to_use) + { + m_tunables[0] = g_tunables_service->get_tunable(RAGE_JOAAT("IDLEKICK_WARNING1")); + m_tunables[1] = g_tunables_service->get_tunable(RAGE_JOAAT("IDLEKICK_WARNING2")); + m_tunables[2] = g_tunables_service->get_tunable(RAGE_JOAAT("IDLEKICK_WARNING3")); + m_tunables[3] = g_tunables_service->get_tunable(RAGE_JOAAT("IDLEKICK_KICK")); + m_tunables[4] = g_tunables_service->get_tunable(RAGE_JOAAT("ConstrainedKick_Warning1")); + m_tunables[5] = g_tunables_service->get_tunable(RAGE_JOAAT("ConstrainedKick_Warning2")); + m_tunables[6] = g_tunables_service->get_tunable(RAGE_JOAAT("ConstrainedKick_Warning3")); + m_tunables[7] = g_tunables_service->get_tunable(RAGE_JOAAT("ConstrainedKick_Kick")); + + // create backup of tunables + m_ready_to_use = true; + for (int i = 0; i < m_restore.size(); ++i) + { + if (m_ready_to_use = m_tunables[i]; !m_ready_to_use) + break; + m_restore[i] = *m_tunables[i]; + } + } + else + { + for (const auto& tunable : m_tunables) + { + if (tunable) + *tunable = INT_MAX; + } + } + } + + virtual void on_disable() override + { + for (int i = 0; m_ready_to_use && i < m_restore.size(); ++i) + { + if (m_tunables[i]) + *m_tunables[i] = m_restore[i]; + } + } + }; + + no_idle_kick g_no_idle_kick("noidlekick", "NO_IDLE_KICK", "Prevents you from being kicked while idling.", g.tunables.no_idle_kick); +} diff --git a/src/backend/script_patches.hpp b/src/backend/script_patches.hpp index 4d704ee3..118e2743 100644 --- a/src/backend/script_patches.hpp +++ b/src/backend/script_patches.hpp @@ -11,13 +11,6 @@ namespace big g_script_patcher_service->add_patch( {RAGE_JOAAT("freemode"), "2D 01 08 00 ? 38 00 5D ? ? ? 2A 06", 5, {0x71, 0x2E, 0x01, 0x01}, &g.session.decloak_players}); g_script_patcher_service->add_patch({RAGE_JOAAT("freemode"), "2D 01 04 00 ? 2C ? ? ? 5D ? ? ? 71 57 ? ? 2C", 5, {0x2E, 0x01, 0x00}, nullptr}); // script host kick - g_script_patcher_service->add_patch( - {RAGE_JOAAT("freemode"), "2D 00 03 00 00 5D ? ? ? 71 08", 5, {0x2E, 0x00, 0x00}, &g.tunables.no_idle_kick}); - g_script_patcher_service->add_patch({RAGE_JOAAT("freemode"), - "2D 00 03 00 00 5D ? ? ? 56 ? ? 72 2E ? ? 62", - 5, - {0x72, 0x2E, 0x00, 0x01}, - &g.tunables.no_idle_kick}); g_script_patcher_service->add_patch({RAGE_JOAAT("freemode"), "5D ? ? ? 76 57 ? ? 5D ? ? ? 76", 0, {0x2E, 0x00, 0x00}, nullptr}); // end session kick protection g_script_patcher_service->add_patch({RAGE_JOAAT("freemode"), "2D 01 09 00 00 5D ? ? ? 56 ? ? 2E", 5, {0x2E, 0x01, 0x00}, nullptr}); // disable death when undermap/spectating g_script_patcher_service->add_patch({RAGE_JOAAT("freemode"), "71 2E ? ? 55 ? ? 61 ? ? ? 47 ? ? 63", 0, {0x72}, nullptr}); // load island even if stranded animal IPL choice is not set diff --git a/src/hooks/spoofing/write_player_appearance_data_node.cpp b/src/hooks/spoofing/write_player_appearance_data_node.cpp index 781c218d..d4dcd5c2 100644 --- a/src/hooks/spoofing/write_player_appearance_data_node.cpp +++ b/src/hooks/spoofing/write_player_appearance_data_node.cpp @@ -1,4 +1,5 @@ #include "hooking.hpp" +#include "util/model_info.hpp" #include @@ -10,7 +11,10 @@ namespace big if (g.spoofing.spoof_player_model) { - node->m_model_hash = rage::joaat(g.spoofing.player_model); + if (const auto model_hash = rage::joaat(g.spoofing.player_model); model_info::does_model_exist(model_hash)) + { + node->m_model_hash = model_hash; + } node->m_has_head_blend_data = false; node->components.m_component_bitset = 0; } diff --git a/src/services/matchmaking/matchmaking_service.hpp b/src/services/matchmaking/matchmaking_service.hpp index d1b6ca6f..414c0cd8 100644 --- a/src/services/matchmaking/matchmaking_service.hpp +++ b/src/services/matchmaking/matchmaking_service.hpp @@ -5,7 +5,7 @@ namespace big class matchmaking_service { public: - constexpr static int MAX_SESSIONS_TO_FIND = 1063; + constexpr static int MAX_SESSIONS_TO_FIND = 1000; struct session_attributes { diff --git a/src/views/network/view_network.cpp b/src/views/network/view_network.cpp index 633b76d5..5a8e1469 100644 --- a/src/views/network/view_network.cpp +++ b/src/views/network/view_network.cpp @@ -101,7 +101,7 @@ namespace big components::sub_title("Misc"); if (ImGui::BeginListBox("##miscsession", get_listbox_dimensions())) { - ImGui::Checkbox("Join Sctv", &g.session.join_in_sctv_slots); //CHANGE TRANSLATION JOIN_IN_SCTV + ImGui::Checkbox("JOIN_IN_SCTV"_T.data(), &g.session.join_in_sctv_slots); if (ImGui::IsItemHovered()) ImGui::SetTooltip("JOIN_IN_SCTV_DESC"_T.data()); diff --git a/src/views/players/player/player_teleport.cpp b/src/views/players/player/player_teleport.cpp index 706efd92..5d723359 100644 --- a/src/views/players/player/player_teleport.cpp +++ b/src/views/players/player/player_teleport.cpp @@ -116,16 +116,13 @@ namespace big "Interior"); static float new_location[3]; - static float current_location[3] = { - g_player_service->get_selected()->get_ped()->m_navigation->get_position()->x, - g_player_service->get_selected()->get_ped()->m_navigation->get_position()->y, - g_player_service->get_selected()->get_ped()->m_navigation->get_position()->z}; + auto& current_location = *reinterpret_cast(g_player_service->get_selected()->get_ped()->m_navigation->get_position()); components::small_text("Custom TP"); ImGui::SetNextItemWidth(400); ImGui::InputFloat3("##customlocation", new_location); components::button("TP", [] { - teleport::teleport_player_to_coords(g_player_service->get_selected(), {new_location[0], new_location[1], new_location[2]}); + teleport::teleport_player_to_coords(g_player_service->get_selected(), *reinterpret_cast(&new_location)); }); ImGui::SameLine(); if (ImGui::Button("Get current")) diff --git a/src/views/players/player/player_toxic.cpp b/src/views/players/player/player_toxic.cpp index 91bb2b13..c8bfe846 100644 --- a/src/views/players/player/player_toxic.cpp +++ b/src/views/players/player/player_toxic.cpp @@ -47,7 +47,7 @@ namespace big components::player_command_button<"fakeban">(g_player_service->get_selected(), {}); static int wanted_level; - components::small_text("WANTED_LVL"); + components::small_text("WANTED_LVL"_T); ImGui::SliderInt("##wantedlevelslider", &wanted_level, 0, 5); ImGui::SameLine(); components::player_command_button<"wanted">(g_player_service->get_selected(), {(uint64_t)wanted_level}, "Set"); diff --git a/src/views/self/view_self.cpp b/src/views/self/view_self.cpp index e3154198..6d98d1d0 100644 --- a/src/views/self/view_self.cpp +++ b/src/views/self/view_self.cpp @@ -45,7 +45,7 @@ namespace big components::command_checkbox<"noclip">(); components::command_checkbox<"noragdoll">(); components::command_checkbox<"fastrun">(); - ImGui::Checkbox("NO_IDLE_KICK"_T.data(), &g.tunables.no_idle_kick); + components::command_checkbox<"noidlekick">(); components::command_checkbox<"walkunder">(); if (!g.self.super_jump) components::command_checkbox<"beastjump">();