Name and status variables for the Script system. (#244)
Co-authored-by: Yimura <andreas.maerten@scarlet.be>
This commit is contained in:
parent
a64f016412
commit
7bfc04bea0
@ -19,4 +19,176 @@ namespace big
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void backend::self_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: Self";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::self_clean_player();
|
||||
looped::self_free_cam();
|
||||
looped::self_godmode();
|
||||
looped::self_invisibility();
|
||||
looped::self_no_ragdoll();
|
||||
looped::self_off_radar();
|
||||
looped::self_police();
|
||||
looped::self_super_run();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
void backend::weapons_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: Weapons";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::weapons_ammo_special_type();
|
||||
looped::weapons_cage_gun();
|
||||
looped::weapons_delete_gun();
|
||||
looped::weapons_force_crosshairs();
|
||||
looped::weapons_gravity_gun();
|
||||
looped::weapons_increased_damage();
|
||||
looped::weapons_infinite_ammo();
|
||||
looped::weapons_infinite_mag();
|
||||
looped::weapons_no_recoil();
|
||||
looped::weapons_no_spread();
|
||||
looped::weapons_repair_gun();
|
||||
looped::weapons_steal_vehicle_gun();
|
||||
looped::weapons_vehicle_gun();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
void backend::vehicles_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: Vehicles";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::vehicle_auto_drive_to_waypoint();
|
||||
looped::vehicle_auto_drive_wander();
|
||||
looped::vehicle_despawn_bypass();
|
||||
looped::vehicle_drive_on_water();
|
||||
looped::vehicle_god_mode();
|
||||
looped::vehicle_horn_boost();
|
||||
looped::vehicle_jump();
|
||||
looped::vehicle_instant_brake();
|
||||
looped::vehicle_is_targetable();
|
||||
looped::vehicle_rainbow_paint();
|
||||
looped::vehicle_seatbelt();
|
||||
looped::vehicle_speedo_meter();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
void backend::turnsignal_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: turnsignal";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::vehicle_turn_signals();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
void backend::rgbrandomizer_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: rgbrandomizer";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::rgb_synced_fade();
|
||||
looped::rgb_synced_spasm();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
void backend::misc_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: Miscellaneous";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::hud_transition_state();
|
||||
looped::tunables_disable_phone();
|
||||
looped::tunables_no_idle_kick();
|
||||
looped::session_local_time();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
void backend::remote_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: Remote";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::player_never_wanted();
|
||||
looped::player_spectate();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
void backend::noclip_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: No clip";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::self_noclip();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
void backend::lscustoms_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: Ls customs";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::vehicle_ls_customs();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
void backend::vehiclefly_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: Vehicle fly";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::vehicle_fly();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
void backend::disable_control_action_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: Disable Control Action";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::self_free_cam_disable_control_action();
|
||||
looped::self_noclip_disable_control_action();
|
||||
|
||||
looped::custom_gun_disable_control_action();
|
||||
|
||||
context_menu_service::disable_control_action_loop();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,177 +10,16 @@ namespace big
|
||||
{
|
||||
public:
|
||||
static void loop();
|
||||
|
||||
static void self_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: Self";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::self_clean_player();
|
||||
looped::self_free_cam();
|
||||
looped::self_godmode();
|
||||
looped::self_invisibility();
|
||||
looped::self_no_ragdoll();
|
||||
looped::self_off_radar();
|
||||
looped::self_police();
|
||||
looped::self_super_run();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
static void weapons_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: Weapons";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::weapons_ammo_special_type();
|
||||
looped::weapons_cage_gun();
|
||||
looped::weapons_delete_gun();
|
||||
looped::weapons_force_crosshairs();
|
||||
looped::weapons_gravity_gun();
|
||||
looped::weapons_increased_damage();
|
||||
looped::weapons_infinite_ammo();
|
||||
looped::weapons_infinite_mag();
|
||||
looped::weapons_no_recoil();
|
||||
looped::weapons_no_spread();
|
||||
looped::weapons_repair_gun();
|
||||
looped::weapons_steal_vehicle_gun();
|
||||
looped::weapons_vehicle_gun();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
static void vehicles_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: Vehicles";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::vehicle_auto_drive_to_waypoint();
|
||||
looped::vehicle_auto_drive_wander();
|
||||
looped::vehicle_despawn_bypass();
|
||||
looped::vehicle_drive_on_water();
|
||||
looped::vehicle_god_mode();
|
||||
looped::vehicle_horn_boost();
|
||||
looped::vehicle_jump();
|
||||
looped::vehicle_instant_brake();
|
||||
looped::vehicle_is_targetable();
|
||||
looped::vehicle_rainbow_paint();
|
||||
looped::vehicle_seatbelt();
|
||||
looped::vehicle_speedo_meter();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
static void turnsignal_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: turnsignal";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::vehicle_turn_signals();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
static void rgbrandomizer_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: rgbrandomizer";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::rgb_synced_fade();
|
||||
looped::rgb_synced_spasm();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
static void misc_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: Miscellaneous";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::hud_transition_state();
|
||||
looped::tunables_disable_phone();
|
||||
looped::tunables_no_idle_kick();
|
||||
looped::session_local_time();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
static void remote_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: Remote";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::player_never_wanted();
|
||||
looped::player_spectate();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
static void noclip_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: No clip";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::self_noclip();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
static void lscustoms_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: Ls customs";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::vehicle_ls_customs();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
static void vehiclefly_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: Vehicle fly";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::vehicle_fly();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
||||
static void disable_control_action_loop()
|
||||
{
|
||||
LOG(INFO) << "Starting script: Disable Control Action";
|
||||
|
||||
while (g_running)
|
||||
{
|
||||
looped::self_free_cam_disable_control_action();
|
||||
looped::self_noclip_disable_control_action();
|
||||
|
||||
looped::custom_gun_disable_control_action();
|
||||
|
||||
context_menu_service::disable_control_action_loop();
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
static void self_loop();
|
||||
static void weapons_loop();
|
||||
static void vehicles_loop();
|
||||
static void turnsignal_loop();
|
||||
static void rgbrandomizer_loop();
|
||||
static void misc_loop();
|
||||
static void remote_loop();
|
||||
static void noclip_loop();
|
||||
static void lscustoms_loop();
|
||||
static void vehiclefly_loop();
|
||||
static void disable_control_action_loop();
|
||||
};
|
||||
}
|
||||
|
@ -50,4 +50,4 @@ namespace big
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#include "common.hpp"
|
||||
#include "common.hpp"
|
||||
#include "core/globals.hpp"
|
||||
#include "features.hpp"
|
||||
#include "fiber_pool.hpp"
|
||||
@ -31,146 +31,146 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
|
||||
|
||||
g_hmodule = hmod;
|
||||
g_main_thread = CreateThread(nullptr, 0, [](PVOID) -> DWORD
|
||||
{
|
||||
while (!FindWindow(L"grcWindow", L"Grand Theft Auto V"))
|
||||
std::this_thread::sleep_for(1s);
|
||||
|
||||
std::filesystem::path base_dir = std::getenv("appdata");
|
||||
base_dir /= "BigBaseV2";
|
||||
auto file_manager_instance = std::make_unique<file_manager>(base_dir);
|
||||
|
||||
auto globals_instance = std::make_unique<menu_settings>(
|
||||
file_manager_instance->get_project_file("./settings.json")
|
||||
);
|
||||
|
||||
auto logger_instance = std::make_unique<logger>(
|
||||
"YimMenu",
|
||||
file_manager_instance->get_project_file("./cout.log")
|
||||
);
|
||||
|
||||
EnableMenuItem(GetSystemMenu(FindWindowA(NULL, "YimMenu"), 0), SC_CLOSE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
|
||||
|
||||
try
|
||||
{
|
||||
LOG(INFO) << "Yim's Menu Initializing";
|
||||
auto pointers_instance = std::make_unique<pointers>();
|
||||
LOG(INFO) << "Pointers initialized.";
|
||||
while (!FindWindow(L"grcWindow", L"Grand Theft Auto V"))
|
||||
std::this_thread::sleep_for(1s);
|
||||
|
||||
auto renderer_instance = std::make_unique<renderer>();
|
||||
LOG(INFO) << "Renderer initialized.";
|
||||
std::filesystem::path base_dir = std::getenv("appdata");
|
||||
base_dir /= "BigBaseV2";
|
||||
auto file_manager_instance = std::make_unique<file_manager>(base_dir);
|
||||
|
||||
auto fiber_pool_instance = std::make_unique<fiber_pool>(11);
|
||||
LOG(INFO) << "Fiber pool initialized.";
|
||||
auto globals_instance = std::make_unique<menu_settings>(
|
||||
file_manager_instance->get_project_file("./settings.json")
|
||||
);
|
||||
|
||||
auto hooking_instance = std::make_unique<hooking>();
|
||||
LOG(INFO) << "Hooking initialized.";
|
||||
auto logger_instance = std::make_unique<logger>(
|
||||
"YimMenu",
|
||||
file_manager_instance->get_project_file("./cout.log")
|
||||
);
|
||||
|
||||
g->load();
|
||||
LOG(INFO) << "Settings Loaded.";
|
||||
EnableMenuItem(GetSystemMenu(FindWindowA(NULL, "YimMenu"), 0), SC_CLOSE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
|
||||
|
||||
auto thread_pool_instance = std::make_unique<thread_pool>();
|
||||
LOG(INFO) << "Thread pool initialized.";
|
||||
try
|
||||
{
|
||||
LOG(INFO) << "Yim's Menu Initializing";
|
||||
auto pointers_instance = std::make_unique<pointers>();
|
||||
LOG(INFO) << "Pointers initialized.";
|
||||
|
||||
auto context_menu_service_instance = std::make_unique<context_menu_service>();
|
||||
auto globals_service_instace = std::make_unique<globals_service>();
|
||||
auto mobile_service_instance = std::make_unique<mobile_service>();
|
||||
auto notification_service_instance = std::make_unique<notification_service>();
|
||||
auto player_service_instance = std::make_unique<player_service>();
|
||||
auto vehicle_preview_service_instance = std::make_unique<vehicle_preview_service>();
|
||||
auto vehicle_service_instance = std::make_unique<vehicle_service>();
|
||||
auto gui_service_instance = std::make_unique<gui_service>();
|
||||
LOG(INFO) << "Registered service instances...";
|
||||
auto renderer_instance = std::make_unique<renderer>();
|
||||
LOG(INFO) << "Renderer initialized.";
|
||||
|
||||
g_script_mgr.add_script(std::make_unique<script>(&features::script_func));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&gui::script_func));
|
||||
auto fiber_pool_instance = std::make_unique<fiber_pool>(11);
|
||||
LOG(INFO) << "Fiber pool initialized.";
|
||||
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::self_loop));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::weapons_loop));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::vehicles_loop));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::misc_loop));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::remote_loop));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::noclip_loop));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::lscustoms_loop));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::vehiclefly_loop));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::rgbrandomizer_loop));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::turnsignal_loop));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::disable_control_action_loop));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&context_menu_service::context_menu));
|
||||
LOG(INFO) << "Scripts registered.";
|
||||
auto hooking_instance = std::make_unique<hooking>();
|
||||
LOG(INFO) << "Hooking initialized.";
|
||||
|
||||
auto native_hooks_instance = std::make_unique<native_hooks>();
|
||||
LOG(INFO) << "Dynamic native hooker initialized.";
|
||||
g->load();
|
||||
LOG(INFO) << "Settings Loaded.";
|
||||
|
||||
g_hooking->enable();
|
||||
LOG(INFO) << "Hooking enabled.";
|
||||
auto thread_pool_instance = std::make_unique<thread_pool>();
|
||||
LOG(INFO) << "Thread pool initialized.";
|
||||
|
||||
g_running = true;
|
||||
auto context_menu_service_instance = std::make_unique<context_menu_service>();
|
||||
auto globals_service_instace = std::make_unique<globals_service>();
|
||||
auto mobile_service_instance = std::make_unique<mobile_service>();
|
||||
auto notification_service_instance = std::make_unique<notification_service>();
|
||||
auto player_service_instance = std::make_unique<player_service>();
|
||||
auto vehicle_preview_service_instance = std::make_unique<vehicle_preview_service>();
|
||||
auto vehicle_service_instance = std::make_unique<vehicle_service>();
|
||||
auto gui_service_instance = std::make_unique<gui_service>();
|
||||
LOG(INFO) << "Registered service instances...";
|
||||
|
||||
while (g_running)
|
||||
std::this_thread::sleep_for(500ms);
|
||||
g_script_mgr.add_script(std::make_unique<script>(&features::script_func, "Backend Main", false));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&gui::script_func, "GUI", false));
|
||||
|
||||
g_hooking->disable();
|
||||
LOG(INFO) << "Hooking disabled.";
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::self_loop, "Self"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::weapons_loop, "Weapon"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::vehicles_loop, "Vehicle"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::misc_loop, "Miscellaneous"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::remote_loop, "Remote"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::noclip_loop, "No Clip"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::lscustoms_loop, "LS Customs"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::vehiclefly_loop, "Vehicle Fly"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::rgbrandomizer_loop, "RGB Randomizer"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::turnsignal_loop, "Turn Signals"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&backend::disable_control_action_loop, "Disable Controls"));
|
||||
g_script_mgr.add_script(std::make_unique<script>(&context_menu_service::context_menu, "Context Menu"));
|
||||
LOG(INFO) << "Scripts registered.";
|
||||
|
||||
native_hooks_instance.reset();
|
||||
LOG(INFO) << "Dynamic native hooker uninitialized.";
|
||||
auto native_hooks_instance = std::make_unique<native_hooks>();
|
||||
LOG(INFO) << "Dynamic native hooker initialized.";
|
||||
|
||||
g_script_mgr.remove_all_scripts();
|
||||
LOG(INFO) << "Scripts unregistered.";
|
||||
g_hooking->enable();
|
||||
LOG(INFO) << "Hooking enabled.";
|
||||
|
||||
gui_service_instance.reset();
|
||||
LOG(INFO) << "Gui Service reset.";
|
||||
vehicle_service_instance.reset();
|
||||
LOG(INFO) << "Vehicle Service reset.";
|
||||
vehicle_preview_service_instance.reset();
|
||||
LOG(INFO) << "Vehicle Preview Service reset.";
|
||||
mobile_service_instance.reset();
|
||||
LOG(INFO) << "Mobile Service reset.";
|
||||
player_service_instance.reset();
|
||||
LOG(INFO) << "Player Service reset.";
|
||||
globals_service_instace.reset();
|
||||
LOG(INFO) << "Globals Service reset.";
|
||||
context_menu_service_instance.reset();
|
||||
LOG(INFO) << "Context Service reset.";
|
||||
LOG(INFO) << "Services uninitialized.";
|
||||
g_running = true;
|
||||
|
||||
// Make sure that all threads created don't have any blocking loops
|
||||
// otherwise make sure that they have stopped executing
|
||||
thread_pool_instance->destroy();
|
||||
LOG(INFO) << "Destroyed thread pool.";
|
||||
while (g_running)
|
||||
std::this_thread::sleep_for(500ms);
|
||||
|
||||
thread_pool_instance.reset();
|
||||
LOG(INFO) << "Thread pool uninitialized.";
|
||||
g_hooking->disable();
|
||||
LOG(INFO) << "Hooking disabled.";
|
||||
|
||||
hooking_instance.reset();
|
||||
LOG(INFO) << "Hooking uninitialized.";
|
||||
native_hooks_instance.reset();
|
||||
LOG(INFO) << "Dynamic native hooker uninitialized.";
|
||||
|
||||
fiber_pool_instance.reset();
|
||||
LOG(INFO) << "Fiber pool uninitialized.";
|
||||
g_script_mgr.remove_all_scripts();
|
||||
LOG(INFO) << "Scripts unregistered.";
|
||||
|
||||
renderer_instance.reset();
|
||||
LOG(INFO) << "Renderer uninitialized.";
|
||||
gui_service_instance.reset();
|
||||
LOG(INFO) << "Gui Service reset.";
|
||||
vehicle_service_instance.reset();
|
||||
LOG(INFO) << "Vehicle Service reset.";
|
||||
vehicle_preview_service_instance.reset();
|
||||
LOG(INFO) << "Vehicle Preview Service reset.";
|
||||
mobile_service_instance.reset();
|
||||
LOG(INFO) << "Mobile Service reset.";
|
||||
player_service_instance.reset();
|
||||
LOG(INFO) << "Player Service reset.";
|
||||
globals_service_instace.reset();
|
||||
LOG(INFO) << "Globals Service reset.";
|
||||
context_menu_service_instance.reset();
|
||||
LOG(INFO) << "Context Service reset.";
|
||||
LOG(INFO) << "Services uninitialized.";
|
||||
|
||||
pointers_instance.reset();
|
||||
LOG(INFO) << "Pointers uninitialized.";
|
||||
}
|
||||
catch (std::exception const &ex)
|
||||
{
|
||||
LOG(WARNING) << ex.what();
|
||||
}
|
||||
// Make sure that all threads created don't have any blocking loops
|
||||
// otherwise make sure that they have stopped executing
|
||||
thread_pool_instance->destroy();
|
||||
LOG(INFO) << "Destroyed thread pool.";
|
||||
|
||||
LOG(INFO) << "Farewell!";
|
||||
logger_instance->destroy();
|
||||
logger_instance.reset();
|
||||
thread_pool_instance.reset();
|
||||
LOG(INFO) << "Thread pool uninitialized.";
|
||||
|
||||
globals_instance.reset();
|
||||
hooking_instance.reset();
|
||||
LOG(INFO) << "Hooking uninitialized.";
|
||||
|
||||
file_manager_instance.reset();
|
||||
fiber_pool_instance.reset();
|
||||
LOG(INFO) << "Fiber pool uninitialized.";
|
||||
|
||||
CloseHandle(g_main_thread);
|
||||
FreeLibraryAndExitThread(g_hmodule, 0);
|
||||
}, nullptr, 0, &g_main_thread_id);
|
||||
renderer_instance.reset();
|
||||
LOG(INFO) << "Renderer uninitialized.";
|
||||
|
||||
pointers_instance.reset();
|
||||
LOG(INFO) << "Pointers uninitialized.";
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
{
|
||||
LOG(WARNING) << ex.what();
|
||||
}
|
||||
|
||||
LOG(INFO) << "Farewell!";
|
||||
logger_instance->destroy();
|
||||
logger_instance.reset();
|
||||
|
||||
globals_instance.reset();
|
||||
|
||||
file_manager_instance.reset();
|
||||
|
||||
CloseHandle(g_main_thread);
|
||||
FreeLibraryAndExitThread(g_hmodule, 0);
|
||||
}, nullptr, 0, &g_main_thread_id);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -18,10 +18,19 @@ namespace big
|
||||
LOG(FATAL) << "Exception Code: " << HEX_TO_UPPER(exp->ExceptionRecord->ExceptionCode) << " Exception Offset: " << HEX_TO_UPPER(offset) << " Fault Module Name: " << buffer;
|
||||
}
|
||||
|
||||
script::script(func_t func, std::optional<std::size_t> stack_size) :
|
||||
m_func(func),
|
||||
script::script(const func_t func, const std::string_view name, const bool toggleable, const std::optional<std::size_t> stack_size) :
|
||||
script(func, stack_size)
|
||||
{
|
||||
m_name = name;
|
||||
m_toggleable = toggleable;
|
||||
}
|
||||
|
||||
script::script(const func_t func, const std::optional<std::size_t> stack_size) :
|
||||
m_enabled(true),
|
||||
m_toggleable(false),
|
||||
m_script_fiber(nullptr),
|
||||
m_main_fiber(nullptr)
|
||||
m_main_fiber(nullptr),
|
||||
m_func(func)
|
||||
{
|
||||
m_script_fiber = CreateFiber(stack_size.has_value() ? stack_size.value() : 0, [](void* param)
|
||||
{
|
||||
@ -36,6 +45,32 @@ namespace big
|
||||
DeleteFiber(m_script_fiber);
|
||||
}
|
||||
|
||||
const char* script::name() const
|
||||
{
|
||||
return m_name.data();
|
||||
}
|
||||
|
||||
bool script::is_enabled() const
|
||||
{
|
||||
return m_enabled;
|
||||
}
|
||||
|
||||
void script::set_enabled(const bool toggle)
|
||||
{
|
||||
if (m_toggleable)
|
||||
m_enabled = toggle;
|
||||
}
|
||||
|
||||
bool* script::toggle_ptr()
|
||||
{
|
||||
return &m_enabled;
|
||||
}
|
||||
|
||||
bool script::is_toggleable() const
|
||||
{
|
||||
return m_toggleable;
|
||||
}
|
||||
|
||||
void script::tick()
|
||||
{
|
||||
m_main_fiber = GetCurrentFiber();
|
||||
@ -70,9 +105,8 @@ namespace big
|
||||
{
|
||||
m_func();
|
||||
}
|
||||
EXCEPT_CLAUSE
|
||||
|
||||
[]() {
|
||||
EXCEPT_CLAUSE
|
||||
[]() {
|
||||
LOG(INFO) << "Script finished!";
|
||||
}();
|
||||
|
||||
@ -81,4 +115,4 @@ namespace big
|
||||
yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -5,18 +5,33 @@ namespace big
|
||||
{
|
||||
class script
|
||||
{
|
||||
std::string_view m_name;
|
||||
bool m_enabled;
|
||||
bool m_toggleable;
|
||||
|
||||
public:
|
||||
using func_t = void(*)();
|
||||
|
||||
public:
|
||||
explicit script(func_t func, std::optional<std::size_t> stack_size = std::nullopt);
|
||||
explicit script(const func_t func, const std::string_view name, const bool toggleable = true, const std::optional<std::size_t> stack_size = std::nullopt);
|
||||
explicit script(const func_t func, const std::optional<std::size_t> stack_size = std::nullopt);
|
||||
~script();
|
||||
|
||||
[[nodiscard]] const char* name() const;
|
||||
[[nodiscard]] bool is_enabled() const;
|
||||
void set_enabled(const bool toggle);
|
||||
[[nodiscard]] bool* toggle_ptr();
|
||||
|
||||
[[nodiscard]] bool is_toggleable() const;
|
||||
|
||||
void tick();
|
||||
void yield(std::optional<std::chrono::high_resolution_clock::duration> time = std::nullopt);
|
||||
static script* get_current();
|
||||
static void script_exception_handler(PEXCEPTION_POINTERS exp);
|
||||
|
||||
private:
|
||||
void fiber_func();
|
||||
|
||||
private:
|
||||
void* m_script_fiber;
|
||||
void* m_main_fiber;
|
||||
@ -29,4 +44,4 @@ namespace big
|
||||
#define EXCEPT_CLAUSE __except (script::script_exception_handler(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER) { }
|
||||
#define QUEUE_JOB_BEGIN_CLAUSE(...) g_fiber_pool->queue_job([__VA_ARGS__] { __try
|
||||
#define QUEUE_JOB_END_CLAUSE __except (script::script_exception_handler(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER) {} });
|
||||
}
|
||||
}
|
@ -21,6 +21,11 @@ namespace big
|
||||
m_scripts.clear();
|
||||
}
|
||||
|
||||
script_list& script_mgr::scripts()
|
||||
{
|
||||
return m_scripts;
|
||||
}
|
||||
|
||||
void script_mgr::tick()
|
||||
{
|
||||
gta_util::execute_as_script(RAGE_JOAAT("main_persistent"), std::mem_fn(&script_mgr::tick_internal), this);
|
||||
@ -32,9 +37,8 @@ namespace big
|
||||
static bool ensure_native_handlers = (g_native_invoker.cache_handlers(), true);
|
||||
|
||||
std::lock_guard lock(m_mutex);
|
||||
for (auto const &script : m_scripts)
|
||||
{
|
||||
script->tick();
|
||||
}
|
||||
for (auto const& script : m_scripts)
|
||||
if (script->is_enabled())
|
||||
script->tick();
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,8 @@
|
||||
|
||||
namespace big
|
||||
{
|
||||
using script_list = std::vector<std::unique_ptr<script>>;
|
||||
|
||||
class script_mgr
|
||||
{
|
||||
public:
|
||||
@ -13,13 +15,15 @@ namespace big
|
||||
void add_script(std::unique_ptr<script> script);
|
||||
void remove_all_scripts();
|
||||
|
||||
script_list& scripts();
|
||||
|
||||
void tick();
|
||||
private:
|
||||
void tick_internal();
|
||||
private:
|
||||
std::recursive_mutex m_mutex;
|
||||
std::vector<std::unique_ptr<script>> m_scripts;
|
||||
script_list m_scripts;
|
||||
};
|
||||
|
||||
inline script_mgr g_script_mgr;
|
||||
}
|
||||
}
|
@ -185,24 +185,16 @@ namespace big
|
||||
const auto cm = g_context_menu_service->get_context_menu();
|
||||
if (cm == nullptr)
|
||||
{
|
||||
script::get_current()->yield();
|
||||
|
||||
continue;
|
||||
g_context_menu_service->enabled = !g_context_menu_service->enabled;
|
||||
}
|
||||
|
||||
if (PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_NEXT))
|
||||
cm->current_option = cm->options.size() <= cm->current_option + 1 ? 0 : cm->current_option + 1;
|
||||
if (PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV))
|
||||
cm->current_option = 0 > cm->current_option - 1 ? static_cast<int>(cm->options.size()) - 1 : cm->current_option - 1;
|
||||
if (PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK) ||
|
||||
PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_SPECIAL_ABILITY))
|
||||
if (g_context_menu_service->enabled)
|
||||
{
|
||||
if (!g_context_menu_service->m_pointer)
|
||||
continue;
|
||||
cm->options.at(cm->current_option).command();
|
||||
}
|
||||
}
|
||||
|
||||
script::get_current()->yield();
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,30 @@
|
||||
#include "views/view.hpp"
|
||||
#include "widgets/imgui_hotkey.hpp"
|
||||
#include "script_mgr.hpp"
|
||||
#include "services/notification_service.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void view::settings() {
|
||||
void scripts_popupmodal()
|
||||
{
|
||||
ImGui::BeginGroup();
|
||||
components::small_text("Scripts");
|
||||
ImGui::SameLine(ImGui::GetWindowWidth() - 100);
|
||||
if (ImGui::Button("Close")) ImGui::CloseCurrentPopup();
|
||||
ImGui::Spacing();
|
||||
components::small_text("These scripts are responsible for all looped features.\nOnly disable if you know what you are doing.");
|
||||
|
||||
for (const auto& script : g_script_mgr.scripts()) {
|
||||
if (script->is_toggleable())
|
||||
if (ImGui::Checkbox(script->name(), script->toggle_ptr()))
|
||||
g_notification_service->push(std::string(script->name()).append(" script"), script->is_enabled() ? "Resumed" : "Halted");
|
||||
}
|
||||
|
||||
ImGui::EndGroup();
|
||||
}
|
||||
|
||||
void view::settings()
|
||||
{
|
||||
components::small_text("Hotkeys");
|
||||
|
||||
ImGui::PushItemWidth(350.f);
|
||||
@ -15,5 +36,19 @@ namespace big
|
||||
ImGui::Hotkey("Teleport to waypoint", &g->settings.hotkeys.teleport_waypoint);
|
||||
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Button("Manage scripts"))
|
||||
ImGui::OpenPopup("Scripts");
|
||||
|
||||
ImGui::SetNextWindowPos({ 780,228 }, ImGuiCond_FirstUseEver);
|
||||
if (ImGui::BeginPopupModal("Scripts", nullptr, ImGuiWindowFlags_AlwaysAutoResize))
|
||||
{
|
||||
scripts_popupmodal();
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user