Bug fixes and improvements (#984)
* feat(KickFromInterior): improve kick from interior Fixes #968 Fixes #953 Fixes #901 Fixes #899 Fixes #813 Fixes #726 Fixes #723 Co-authored-by: Yimura <24669514+Yimura@users.noreply.github.com>
This commit is contained in:
@ -17,6 +17,7 @@ namespace big
|
||||
locals();
|
||||
script_events();
|
||||
scripts();
|
||||
threads();
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
ImGui::End();
|
||||
|
@ -8,6 +8,7 @@ namespace big::debug
|
||||
extern void misc();
|
||||
extern void script_events();
|
||||
extern void scripts();
|
||||
extern void threads();
|
||||
|
||||
extern void main();
|
||||
}
|
177
src/views/debug/view_debug_threads.cpp
Normal file
177
src/views/debug/view_debug_threads.cpp
Normal file
@ -0,0 +1,177 @@
|
||||
#include "gui/components/components.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "util/system.hpp"
|
||||
#include "util/misc.hpp"
|
||||
#include "view_debug.hpp"
|
||||
#include "network/Network.hpp"
|
||||
#include "script.hpp"
|
||||
#include "gta/joaat.hpp"
|
||||
#include "script_global.hpp"
|
||||
#include "gta_util.hpp"
|
||||
|
||||
#include "core/data/all_script_names.hpp"
|
||||
#include "core/data/stack_sizes.hpp"
|
||||
|
||||
#include "fiber_pool.hpp"
|
||||
|
||||
static rage::scrThread* selected_thread;
|
||||
|
||||
static int selected_stack_size = 128;
|
||||
static int free_stacks = -1;
|
||||
static const char* selected_stack_size_str = "MULTIPLAYER_MISSION";
|
||||
static const char* selected_script = "<SELECT>";
|
||||
|
||||
static std::chrono::high_resolution_clock::time_point last_stack_update_time{};
|
||||
|
||||
namespace
|
||||
{
|
||||
static void update_free_stacks_count()
|
||||
{
|
||||
free_stacks = MISC::GET_NUMBER_OF_FREE_STACKS_OF_THIS_SIZE(selected_stack_size);
|
||||
}
|
||||
}
|
||||
|
||||
namespace big
|
||||
{
|
||||
|
||||
void debug::threads()
|
||||
{
|
||||
if (ImGui::BeginTabItem("Threads"))
|
||||
{
|
||||
if (!g_pointers->m_script_threads)
|
||||
{
|
||||
selected_thread = nullptr;
|
||||
ImGui::EndTabItem();
|
||||
return;
|
||||
}
|
||||
|
||||
components::small_text("Threads");
|
||||
|
||||
if (ImGui::BeginCombo("Thread", selected_thread ? selected_thread->m_name : "NONE"))
|
||||
{
|
||||
for (auto script : *g_pointers->m_script_threads)
|
||||
{
|
||||
if (script)
|
||||
{
|
||||
if (script->m_context.m_state != rage::eThreadState::killed && script->m_context.m_stack_size == 0)
|
||||
continue;
|
||||
|
||||
ImGui::PushID(script->m_context.m_thread_id);
|
||||
|
||||
if (script->m_context.m_state == rage::eThreadState::killed)
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.1f, 0.1f, 1.f));
|
||||
|
||||
if (ImGui::Selectable(script->m_name, selected_thread == script))
|
||||
{
|
||||
selected_thread = script;
|
||||
}
|
||||
|
||||
if (selected_thread == script)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
|
||||
if (script->m_context.m_state == rage::eThreadState::killed)
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
if (selected_thread)
|
||||
{
|
||||
ImGui::Combo("State", (int*)&selected_thread->m_context.m_state, "RUNNING\0WAITING\0KILLED\0PAUSED\0STATE_4");
|
||||
|
||||
ImGui::Text("Stack Pointer / Stack Size %d/%d", selected_thread->m_context.m_stack_pointer, selected_thread->m_context.m_stack_size);
|
||||
ImGui::Text("IP: %X", selected_thread->m_context.m_instruction_pointer);
|
||||
if (selected_thread->m_context.m_state == rage::eThreadState::killed)
|
||||
ImGui::Text("Exit Reason: %s", selected_thread->m_exit_message);
|
||||
|
||||
if (ImGui::Button("Kill"))
|
||||
{
|
||||
if (selected_thread->m_context.m_stack_size != 0)
|
||||
selected_thread->kill();
|
||||
|
||||
selected_thread->m_context.m_state = rage::eThreadState::killed;
|
||||
}
|
||||
}
|
||||
|
||||
components::small_text("New");
|
||||
|
||||
if (ImGui::BeginCombo("Script", selected_script))
|
||||
{
|
||||
for (auto script : all_script_names)
|
||||
{
|
||||
if (ImGui::Selectable(script, script == selected_script))
|
||||
{
|
||||
selected_script = script;
|
||||
|
||||
}
|
||||
|
||||
if (script == selected_script)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
if (ImGui::BeginCombo("Stack Size", selected_stack_size_str))
|
||||
{
|
||||
for (auto& p : stack_sizes)
|
||||
{
|
||||
if (ImGui::Selectable(std::format("{} ({})", p.first, p.second).data(), selected_stack_size == p.second))
|
||||
{
|
||||
selected_stack_size_str = p.first;
|
||||
selected_stack_size = p.second;
|
||||
|
||||
g_fiber_pool->queue_job([]
|
||||
{
|
||||
update_free_stacks_count();
|
||||
});
|
||||
}
|
||||
|
||||
if (p.second == selected_stack_size)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
ImGui::Text("Free Stacks: %d", free_stacks);
|
||||
|
||||
components::button("Start", []
|
||||
{
|
||||
auto hash = rage::joaat(selected_script);
|
||||
|
||||
if (!SCRIPT::DOES_SCRIPT_WITH_NAME_HASH_EXIST(hash))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (MISC::GET_NUMBER_OF_FREE_STACKS_OF_THIS_SIZE(selected_stack_size) == 0)
|
||||
{
|
||||
g_notification_service->push_warning("Script Launcher", "No free stacks for this stack size");
|
||||
}
|
||||
|
||||
while (!SCRIPT::HAS_SCRIPT_WITH_NAME_HASH_LOADED(hash))
|
||||
{
|
||||
SCRIPT::REQUEST_SCRIPT_WITH_NAME_HASH(hash);
|
||||
script::get_current()->yield();
|
||||
}
|
||||
|
||||
SYSTEM::START_NEW_SCRIPT_WITH_NAME_HASH(hash, selected_stack_size);
|
||||
|
||||
SCRIPT::SET_SCRIPT_WITH_NAME_HASH_AS_NO_LONGER_NEEDED(hash);
|
||||
|
||||
update_free_stacks_count();
|
||||
});
|
||||
|
||||
if (*g_pointers->m_game_state != eGameState::Invalid && std::chrono::high_resolution_clock::now() - last_stack_update_time > 100ms)
|
||||
{
|
||||
last_stack_update_time = std::chrono::high_resolution_clock::now();
|
||||
g_fiber_pool->queue_job([]
|
||||
{
|
||||
update_free_stacks_count();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -11,6 +11,8 @@ namespace big
|
||||
{
|
||||
components::small_text("SPOOFING_DESCRIPTION"_T);
|
||||
|
||||
ImGui::Checkbox("Hide From Player List", &g.spoofing.hide_from_player_list);
|
||||
|
||||
components::sub_title("SPOOFING_HIDE_FEATURES"_T);
|
||||
ImGui::Checkbox("SPOOFING_HIDE_GOD_MODE"_T.data(), &g.spoofing.spoof_hide_god);
|
||||
ImGui::Checkbox("SPOOFING_HIDE_SPECTATE"_T.data(), &g.spoofing.spoof_hide_spectate);
|
||||
|
@ -106,7 +106,7 @@ namespace big
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (auto net_player_data = g_player_service->get_selected()->get_net_data(); net_player_data != nullptr)
|
||||
if (auto net_player_data = g_player_service->get_selected()->get_net_data())
|
||||
{
|
||||
ImGui::Text("PLAYER_INFO_RID"_T.data(), net_player_data->m_gamer_handle.m_rockstar_id);
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace big
|
||||
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::Checkbox("God Mode", &g.self.god_mode);
|
||||
components::command_checkbox<"godmode">();
|
||||
components::command_checkbox<"otr">();
|
||||
components::command_checkbox<"freecam">();
|
||||
components::command_checkbox<"nophone">();
|
||||
@ -52,14 +52,13 @@ namespace big
|
||||
|
||||
components::command_checkbox<"invis">();
|
||||
if (g.self.invisibility)
|
||||
components::command_checkbox<"localvis">();
|
||||
components::command_checkbox<"localvis">(); // TODO: does nothing in SP
|
||||
components::command_checkbox<"cleanloop">();
|
||||
components::command_checkbox<"nocollision">();
|
||||
components::command_checkbox<"mobileradio">();
|
||||
components::command_checkbox<"superman">();
|
||||
|
||||
// TODO: fix this, causes a crash
|
||||
// ImGui::Checkbox("DANCE_MODE"_T.data(), &g.self.dance_mode);
|
||||
ImGui::Checkbox("DANCE_MODE"_T.data(), &g.self.dance_mode);
|
||||
|
||||
ImGui::EndGroup();
|
||||
|
||||
|
@ -17,7 +17,7 @@ namespace big
|
||||
|
||||
components::command_checkbox<"infammo">();
|
||||
components::command_checkbox<"infclip">();
|
||||
ImGui::Checkbox("Interior Weapon", &g.weapons.interior_weapon);
|
||||
ImGui::Checkbox("Allow Weapons In Interiors", &g.weapons.interior_weapon);
|
||||
|
||||
ImGui::EndGroup();
|
||||
ImGui::SameLine();
|
||||
|
@ -75,7 +75,6 @@ namespace big
|
||||
if (g.vehicle.vehinvisibility)
|
||||
{
|
||||
components::command_checkbox<"localinvisveh">();
|
||||
components::command_checkbox<"localinvisped">();
|
||||
}
|
||||
|
||||
ImGui::EndGroup();
|
||||
|
Reference in New Issue
Block a user