diff --git a/BigBaseV2/src/core/enums.hpp b/BigBaseV2/src/core/enums.hpp index 146c4613..90452538 100644 --- a/BigBaseV2/src/core/enums.hpp +++ b/BigBaseV2/src/core/enums.hpp @@ -13,6 +13,17 @@ namespace big VEHICLE_GUN }; + enum eVehicleFlags + { + UNK0 = 1 << 0, + DESTROYED = 1 << 1, + HAS_INSURANCE = 1 << 2, + IMPOUNDED = 1 << 6, + UNK1 = 1 << 10, + UNK2 = 1 << 11, + UNK3 = 1 << 16 + }; + enum class ePedTask { TASK_NONE, diff --git a/BigBaseV2/src/gui/window/main/main_tabs.hpp b/BigBaseV2/src/gui/window/main/main_tabs.hpp index 76da0777..63156110 100644 --- a/BigBaseV2/src/gui/window/main/main_tabs.hpp +++ b/BigBaseV2/src/gui/window/main/main_tabs.hpp @@ -4,6 +4,7 @@ namespace big::tab_main { + void tab_mobile(); void tab_tunables(); void tab_self(); void tab_recovery(); diff --git a/BigBaseV2/src/gui/window/main/tab_mobile.cpp b/BigBaseV2/src/gui/window/main/tab_mobile.cpp new file mode 100644 index 00000000..bd627a79 --- /dev/null +++ b/BigBaseV2/src/gui/window/main/tab_mobile.cpp @@ -0,0 +1,29 @@ +#include "main_tabs.hpp" +#include "fiber_pool.hpp" +#include "script.hpp" +#include "util/mobile.hpp" +#include "util/notify.hpp" + +namespace big +{ + void tab_main::tab_mobile() + { + if (ImGui::BeginTabItem("Mobile")) + { + if (ImGui::Button("Mors Mutual Fix All Vehicles")) + { + int amount_fixed = mobile::mors_mutual::fix_all(); + + QUEUE_JOB_BEGIN_CLAUSE(amount_fixed) + { + char vehicles_fixed[42]; + sprintf(vehicles_fixed, "%d vehicle%s been fixed.", amount_fixed, amount_fixed == 1 ? " has" : "s have"); + + notify::above_map(vehicles_fixed); + }QUEUE_JOB_END_CLAUSE + } + + ImGui::EndTabItem(); + } + } +} \ No newline at end of file diff --git a/BigBaseV2/src/gui/window/window_main.cpp b/BigBaseV2/src/gui/window/window_main.cpp index bcf3b8ad..ed11967e 100644 --- a/BigBaseV2/src/gui/window/window_main.cpp +++ b/BigBaseV2/src/gui/window/window_main.cpp @@ -11,6 +11,7 @@ namespace big { ImGui::BeginTabBar("tabbar"); tab_main::tab_self(); + tab_main::tab_mobile(); tab_main::tab_spawn(); tab_main::tab_tunables(); tab_main::tab_teleport(); diff --git a/BigBaseV2/src/util/all.hpp b/BigBaseV2/src/util/all.hpp index c063dd86..ea318667 100644 --- a/BigBaseV2/src/util/all.hpp +++ b/BigBaseV2/src/util/all.hpp @@ -2,6 +2,7 @@ #include "blip.hpp" #include "entity.hpp" #include "math.hpp" +#include "mobile.hpp" #include "notify.hpp" #include "player.hpp" #include "session.hpp" diff --git a/BigBaseV2/src/util/misc.hpp b/BigBaseV2/src/util/misc.hpp new file mode 100644 index 00000000..871421f6 --- /dev/null +++ b/BigBaseV2/src/util/misc.hpp @@ -0,0 +1,34 @@ +#pragma once + +namespace big::misc +{ + inline void clear_bit(int* address, int pos) + { + *address &= ~(1 << pos); + } + + inline void clear_bits(int* address, int bits) + { + *address &= ~(bits); + } + + inline bool has_bit_set(int* address, int pos) + { + return *address & 1 << pos; + } + + inline bool has_bits_set(int* address, int bits) + { + return (*address & bits) == bits; + } + + inline void set_bit(int* address, int pos) + { + *address |= 1 << pos; + } + + inline void set_bits(int* address, int bits) + { + *address |= bits; + } +} \ No newline at end of file diff --git a/BigBaseV2/src/util/mobile.hpp b/BigBaseV2/src/util/mobile.hpp new file mode 100644 index 00000000..59c1ab9b --- /dev/null +++ b/BigBaseV2/src/util/mobile.hpp @@ -0,0 +1,45 @@ +#pragma once +#include "core/enums.hpp" +#include "script_global.hpp" +#include "misc.hpp" + +namespace big::mobile +{ + namespace mors_mutual + { + auto vehicle_global = script_global(1585844); + + bool fix_index(int veh_idx); // forward declare func + inline int fix_all() + { + int fixed_count = 0; + + for (int i = 0; i < *vehicle_global.as(); i++) + if (fix_index(i)) + fixed_count++; + + return fixed_count; + } + + inline bool fix_index(int veh_idx) + { + bool can_be_fixed = misc::has_bits_set( + vehicle_global.at(veh_idx, 142).at(103).as(), + eVehicleFlags::DESTROYED | eVehicleFlags::HAS_INSURANCE + ); + + if (can_be_fixed) + { + misc::clear_bits( + vehicle_global.at(veh_idx, 142).at(103).as(), + eVehicleFlags::DESTROYED | eVehicleFlags::IMPOUNDED | eVehicleFlags::UNK3 + ); + misc::set_bits( + vehicle_global.at(veh_idx, 142).at(103).as(), + eVehicleFlags::UNK0 | eVehicleFlags::UNK2 + ); + } + return can_be_fixed; + } + } +} \ No newline at end of file