General fixes (#1251)

This commit is contained in:
maybegreat48 2023-04-16 18:28:49 +00:00 committed by GitHub
parent 958463d5ff
commit 3c2245f780
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 797 additions and 680 deletions

View File

@ -0,0 +1,49 @@
#include "backend/looped_command.hpp"
#include "natives.hpp"
namespace big
{
class hudcolor_looped : looped_command
{
using looped_command::looped_command;
virtual void on_enable() override
{
for (int i = 0; i < hud_colors.size(); i++)
{
color col{};
HUD::GET_HUD_COLOUR(i, &col.r, &col.g, &col.b, &col.a);
g.self.hud.hud_color_defaults[i] = col;
}
if (!g.self.hud.color_override_initialized)
{
g.self.hud.hud_color_overrides = g.self.hud.hud_color_defaults;
g.self.hud.color_override_initialized = true;
}
else
{
for (int i = 0; i < hud_colors.size(); i++)
{
auto& col = g.self.hud.hud_color_overrides[i];
HUD::REPLACE_HUD_COLOUR_WITH_RGBA(i, col.r, col.g, col.b, col.a);
}
}
}
virtual void on_tick() override
{
}
virtual void on_disable() override
{
for (int i = 0; i < hud_colors.size(); i++)
{
auto& col = g.self.hud.hud_color_defaults[i];
HUD::REPLACE_HUD_COLOUR_WITH_RGBA(i, col.r, col.g, col.b, col.a);
}
}
};
hudcolor_looped g_hudcolor_looped("hudcolor", "Override HUD Color", "Override HUD colors", g.self.hud.color_override);
}

View File

@ -1,33 +0,0 @@
#include "natives.hpp"
#include "backend/looped_command.hpp"
namespace big
{
class hudcolor_looped : looped_command
{
using looped_command::looped_command;
virtual void on_tick() override
{
if (g.self.hud.shcolor)
{
HUD::REPLACE_HUD_COLOUR_WITH_RGBA(g.self.hud.index, g.self.hud.r, g.self.hud.g, g.self.hud.b, g.self.hud.a);
}
if (g.self.hud.mhcolor)
{
HUD::SET_CUSTOM_MP_HUD_COLOR(g.self.hud.hcolor);
}
if (g.self.hud.mtcolor)
{
HUD::OVERRIDE_MP_TEXT_CHAT_COLOR(0, g.self.hud.tcolor);
}
}
};
hudcolor_looped g_hudcolor_looped("hudcolor", "Hudcolor Overide", "Replaces features of your hud with custom colors you set",
g.self.hud.hudcolor);
bool_command g_shcolor("singlehudcol", "Hud Color", "enables the singlehudcol", g.self.hud.shcolor);
bool_command g_mhcolor("mphudcol", "MP Hud Color", "enables the mphudcol", g.self.hud.mhcolor);
bool_command g_mtcolor("mptextcol", "MP Text Color", "enables the mptextcol", g.self.hud.mtcolor);
}

View File

@ -7,7 +7,7 @@ namespace big
{ {
void looped::weapons_cage_gun() void looped::weapons_cage_gun()
{ {
if (const bool bCageGun = g.weapons.custom_weapon == CustomWeapon::CAGE_GUN; bCageGun && (!g.self.custom_weapon_stop || WEAPON::IS_PED_ARMED(self::ped, 4 | 2))) if (g.weapons.custom_weapon == CustomWeapon::CAGE_GUN && (!g.self.custom_weapon_stop || WEAPON::IS_PED_ARMED(self::ped, 4 | 2)))
{ {
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM))
{ {

View File

@ -8,7 +8,7 @@ namespace big
{ {
void looped::weapons_delete_gun() void looped::weapons_delete_gun()
{ {
if (const bool bDeleteGun = g.weapons.custom_weapon == CustomWeapon::DELETE_GUN; bDeleteGun && (!g.self.custom_weapon_stop || WEAPON::IS_PED_ARMED(self::ped, 4 | 2))) if (g.weapons.custom_weapon == CustomWeapon::DELETE_GUN && (!g.self.custom_weapon_stop || WEAPON::IS_PED_ARMED(self::ped, 4 | 2)))
{ {
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM))
{ {

View File

@ -1,5 +1,5 @@
#include "natives.hpp"
#include "backend/looped_command.hpp" #include "backend/looped_command.hpp"
#include "natives.hpp"
namespace big namespace big
{ {
@ -43,5 +43,5 @@ namespace big
} }
}; };
infinite_range g_infinite_range("infrange", "Infinite Range", "Kill anything at any distance.", g.weapons.infinite_range); infinite_range g_infinite_range("infrange", "Infinite Range", "Kill anything at any distance", g.weapons.infinite_range);
} }

View File

@ -8,7 +8,7 @@ namespace big
{ {
void looped::weapons_repair_gun() void looped::weapons_repair_gun()
{ {
if (const bool bRepairGun = g.weapons.custom_weapon == CustomWeapon::REPAIR_GUN; bRepairGun && (!g.self.custom_weapon_stop || WEAPON::IS_PED_ARMED(self::ped, 4 | 2))) if (g.weapons.custom_weapon == CustomWeapon::REPAIR_GUN && (!g.self.custom_weapon_stop || WEAPON::IS_PED_ARMED(self::ped, 4 | 2)))
{ {
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM))
{ {

View File

@ -9,8 +9,7 @@ namespace big
void looped::weapons_steal_vehicle_gun() void looped::weapons_steal_vehicle_gun()
{ {
if (const bool bStealVehicleGun = g.weapons.custom_weapon == CustomWeapon::STEAL_VEHICLE_GUN; if (g.weapons.custom_weapon == CustomWeapon::STEAL_VEHICLE_GUN && (!g.self.custom_weapon_stop || WEAPON::IS_PED_ARMED(self::ped, 4 | 2)))
bStealVehicleGun && (!g.self.custom_weapon_stop || WEAPON::IS_PED_ARMED(self::ped, 4 | 2)))
{ {
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM))
{ {

View File

@ -15,56 +15,45 @@ namespace big
{ {
static void init() static void init()
{ {
// Max Wanted Level // Restore max wanted level after menu unload
police::m_max_wanted_level = police::m_max_wanted_level =
memory::byte_patch::make(g_pointers->m_gta.m_max_wanted_level.add(5).rip().as<uint32_t*>(), 0).get(); memory::byte_patch::make(g_pointers->m_gta.m_max_wanted_level.add(5).rip().as<uint32_t*>(), 0).get();
police::m_max_wanted_level_2 = police::m_max_wanted_level_2 =
memory::byte_patch::make(g_pointers->m_gta.m_max_wanted_level.add(14).rip().as<uint32_t*>(), 0).get(); memory::byte_patch::make(g_pointers->m_gta.m_max_wanted_level.add(14).rip().as<uint32_t*>(), 0).get();
//Patch blocked explosions // Patch blocked explosions
toxic::explosion_anti_cheat_bypass::m_can_blame_others = toxic::explosion_anti_cheat_bypass::m_can_blame_others =
memory::byte_patch::make(g_pointers->m_gta.m_blame_explode.as<std::uint16_t*>(), 0xE990).get(); memory::byte_patch::make(g_pointers->m_gta.m_blame_explode.as<std::uint16_t*>(), 0xE990).get();
toxic::explosion_anti_cheat_bypass::m_can_use_blocked_explosions = toxic::explosion_anti_cheat_bypass::m_can_use_blocked_explosions =
memory::byte_patch::make(g_pointers->m_gta.m_explosion_patch.sub(12).as<uint16_t*>(), 0x9090).get(); memory::byte_patch::make(g_pointers->m_gta.m_explosion_patch.sub(12).as<uint16_t*>(), 0x9090).get();
// Is Matchmaking Session Valid // Skip matchmaking session validity checks
memory::byte_patch::make(g_pointers->m_gta.m_is_matchmaking_session_valid.as<void*>(), std::to_array({0xB0, 0x01, 0xC3})) memory::byte_patch::make(g_pointers->m_gta.m_is_matchmaking_session_valid.as<void*>(), std::to_array({0xB0, 0x01, 0xC3}))
->apply(); // has no observable side effects ->apply(); // has no observable side effects
// Broadcast Net Array Patch // Bypass netarray buffer cache when enabled
broadcast_net_array::m_patch = broadcast_net_array::m_patch =
memory::byte_patch::make(g_pointers->m_gta.m_broadcast_patch.as<uint8_t*>(), 0xEB).get(); memory::byte_patch::make(g_pointers->m_gta.m_broadcast_patch.as<uint8_t*>(), 0xEB).get();
// Creator Warp Cheat Triggered Patch // Disable cheat activated netevent when creator warping
memory::byte_patch::make(g_pointers->m_gta.m_creator_warp_cheat_triggered_patch.as<uint8_t*>(), 0xEB)->apply(); memory::byte_patch::make(g_pointers->m_gta.m_creator_warp_cheat_triggered_patch.as<uint8_t*>(), 0xEB)->apply();
// NTQVM Caller // PapiSysCallService VFT hook
memory::byte_patch::make(g_pointers->m_gta.m_ntqvm_caller.add(4).rip().sub(32).as<uint64_t*>(), (uint64_t)&hooks::nt_query_virtual_memory) memory::byte_patch::make(g_pointers->m_gta.m_ntqvm_caller.add(4).rip().sub(32).as<uint64_t*>(), (uint64_t)&hooks::nt_query_virtual_memory)
->apply(); ->apply();
// Sound Overload Detour // Setup inline hook for sound overload crash protection
g_sound_overload_ret_addr = g_pointers->m_gta.m_sound_overload_detour.add(13 + 15).as<decltype(g_sound_overload_ret_addr)>(); g_sound_overload_ret_addr = g_pointers->m_gta.m_sound_overload_detour.add(13 + 15).as<decltype(g_sound_overload_ret_addr)>();
std::vector<byte> bytes = {0xFF, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90}; // far jump opcode + a nop opcode std::vector<byte> bytes = {0xFF, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90}; // far jump opcode + a nop opcode
*(void**)(bytes.data() + 6) = sound_overload_detour; *(void**)(bytes.data() + 6) = sound_overload_detour;
memory::byte_patch::make(g_pointers->m_gta.m_sound_overload_detour.add(13).as<void*>(), bytes)->apply(); memory::byte_patch::make(g_pointers->m_gta.m_sound_overload_detour.add(13).as<void*>(), bytes)->apply();
// Disable Collision // Disable collision when enabled
vehicle::disable_collisions::m_patch = vehicle::disable_collisions::m_patch =
memory::byte_patch::make(g_pointers->m_gta.m_disable_collision.sub(2).as<uint8_t*>(), 0xEB).get(); memory::byte_patch::make(g_pointers->m_gta.m_disable_collision.sub(2).as<uint8_t*>(), 0xEB).get();
// Crash Trigger // Crash Trigger
memory::byte_patch::make(g_pointers->m_gta.m_crash_trigger.add(4).as<uint8_t*>(), 0x00)->apply(); memory::byte_patch::make(g_pointers->m_gta.m_crash_trigger.add(4).as<uint8_t*>(), 0x00)->apply();
// freemode_thread_restorer_through_vm_patch
memory::byte_patch::make(g_pointers->m_gta.freemode_thread_restorer_through_vm_patch_1.add(2).as<uint32_t*>(), 0xc9310272)
->apply();
memory::byte_patch::make(g_pointers->m_gta.freemode_thread_restorer_through_vm_patch_1.add(6).as<uint16_t*>(), 0x9090)
->apply();
memory::byte_patch::make(g_pointers->m_gta.freemode_thread_restorer_through_vm_patch_2.add(2).as<uint32_t*>(), 0xc9310272)
->apply();
memory::byte_patch::make(g_pointers->m_gta.freemode_thread_restorer_through_vm_patch_2.add(6).as<uint16_t*>(), 0x9090)
->apply();
} }
byte_patch_manager::byte_patch_manager() byte_patch_manager::byte_patch_manager()

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <vector> #include <unordered_set>
namespace big namespace big
{ {
const std::vector<std::uint64_t> admin_rids = {12435, 63457, 216820, 6597634, 9284553, 10552062, 10833148, 13934382, 14870763, 16395773, 16395782, 16395801, 16395840, 16395850, 16396080, 16396091, 16396096, 16396107, 16396118, 16396126, 16396133, 16396141, 16396148, 16396157, 16396170, 16417718, 16439132, 18965281, 20158751, 20158753, 20158757, 20158759, 21088063, 21765545, 22577121, 22577440, 22577458, 23659342, 23659351, 23659353, 23659354, 24037237, 24646485, 25667546, 25695975, 26658154, 27691740, 28776717, 28823614, 29454165, 31586721, 39573295, 41352312, 46469110, 49770174, 50850475, 53309582, 54445058, 54462116, 54468359, 54815152, 54815524, 56176623, 56321667, 56583239, 56778561, 57233573, 60331599, 61522786, 62409944, 62739248, 64074298, 64234321, 64499496, 64624133, 65428266, 67241866, 69079775, 69325516, 69991900, 70527952, 70703467, 70841434, 74716313, 75632221, 76384414, 76385407, 77205006, 78229643, 78934592, 80527019, 81691532, 85593421, 88047835, 88435236, 88435319, 88435362, 88435916, 88439202, 88440582, 89288299, 89705641, 89705672, 89705758, 89730037, 89730175, 89730345, 89797943, 90580674, 91003708, 91031119, 93759248, 93759254, 93759280, 93759401, 93759425, 93759462, 93800162, 93800269, 94028919, 99453882, 99922796, 100641297, 102519620, 103054099, 103318524, 103814653, 104041189, 104213911, 104432921, 105474714, 105919953, 106480467, 107713060, 107713114, 111262316, 111377226, 111439945, 112362134, 113097651, 114982881, 115641569, 115642993, 115643538, 115649691, 115670847, 115671687, 116815567, 117639172, 117639190, 119266383, 119958356, 121238364, 121397532, 121698158, 121708718, 121943600, 121970978, 123017343, 123849404, 124006884, 126156972, 126756566, 127403483, 127448079, 129159629, 130291511, 130291558, 130972490, 131037988, 131973478, 132258220, 132521200, 132826927, 133709045, 134385206, 134412628, 134933117, 134998109, 135811063, 136552330, 136553211, 136554213, 136554798, 137579070, 137601710, 137663665, 137667349, 137714280, 137851207, 138075198, 138097967, 138273823, 138302559, 138660450, 138831719, 139813495, 141594080, 141860986, 141884823, 142099256, 142536132, 142582982, 144372813, 146452200, 146999560, 147111499, 147405780, 147457094, 147604980, 149203647, 151018852, 151061557, 151158004, 151158634, 151159677, 151972200, 151975489, 152451452, 153034481, 153219155, 155527062, 156336742, 156436871, 156442381, 156575528, 159587479, 168226907, 170727774, 171093866, 171094021, 171480091, 171621041, 173200071, 173213117, 173229864, 173426004, 173709268, 173712102, 173717622, 174156763, 174194059, 174247774, 174607564, 174623904, 174623946, 174623951, 174624061, 174625194, 174625307, 174625407, 174625552, 174625647, 174626867, 174754789, 174875493, 176599903, 178440917, 179606757, 179607078, 179608067, 179654627, 179659205, 179848153, 179848203, 179848415, 179930265, 179936743, 179936852, 179942496, 179965835, 180015293, 180096359, 180096468, 182438142, 182516442, 182860908, 183314955, 183565013, 183746202, 183970446, 184269528, 184359255, 184360405, 185393703, 185405431, 186057650, 186058299, 186325468, 188498026, 192118902, 192796203, 193919365, 193947342, 193971479, 193971567, 193971908, 193972138, 193973221, 193975449, 194002589, 194003533, 194004216, 194060881, 194116470, 194125886, 194497396, 195246292, 195314410, 195404163, 195489237, 196222661, 196269807, 196270383, 196270581, 196271217, 196271907, 196524776, 196584699, 196588801, 197800858, 197872508, 197872817, 198439589, 198475036, 199788352, 199819506, 200121238, 200595661, 200613777, 201661227, 201663320, 201663467, 201664501, 201693153, 201693551, 201698392, 201701643, 201726181, 201727585, 201767917, 201983184, 201983223, 203209892, 203289934, 203294845, 203695911, 203720325, 203723447, 204061479, 204071275, 204339633, 204344395, 205005075, 205333914, 205904977, 205951017, 206624869, 207118252, 207819508, 208186004, 208206831, 208598427, 208854942, 208978576, 209191450, 209226460, 209260139, 209260714, 209260788, 209768906, 209842220, 209901120, 210340207, 210495239, 210495352, 210736452, 210993156, 210993185, 211136447, 211515349, 211532217, 211679972, 211680281, 211702584, 211750362, 212138766, 212464051, 212821044, 213182009, 213390165, 213498323, 213500078, 213550108, 213550783, 213560223, 213611914, 213612663, 213615794, 213616333, 214116086, 214250188, 214327469, 214516585, 214878420, 214921670, 215232482, 215629466, 216429141, 216753945, 217097347, 217254302, 217254350, 217255149, 217261805, 217353908, 217368373, 217858968, 217861358, 217861775, 217870124, 218035890, 218151680, 218152225, 218226925, 218308954, 218310715, 218487111, 218901089, 219365086, 219850254, 219850752, 219853753, 219855754, 219857662, 219857719, 219857745, 219866336, 220121187, 220143764, 220239069, 220506626, 220517406, 220538568, 220569666, 220591655, 220594438, 220930761, 221991933, 222524313, 222531414, 222549274, 222956471, 223787165, 223787707, 223843537, 223846253, 224166708, 224500725, 225107350}; const inline std::unordered_set<std::uint64_t> admin_rids = {12435, 63457, 216820, 6597634, 9284553, 10552062, 10833148, 13934382, 14870763, 16395773, 16395782, 16395801, 16395840, 16395850, 16396080, 16396091, 16396096, 16396107, 16396118, 16396126, 16396133, 16396141, 16396148, 16396157, 16396170, 16417718, 16439132, 18965281, 20158751, 20158753, 20158757, 20158759, 21088063, 21765545, 22577121, 22577440, 22577458, 23659342, 23659351, 23659353, 23659354, 24037237, 24646485, 25667546, 25695975, 26658154, 27691740, 28776717, 28823614, 29454165, 31586721, 39573295, 41352312, 46469110, 49770174, 50850475, 53309582, 54445058, 54462116, 54468359, 54815152, 54815524, 56176623, 56321667, 56583239, 56778561, 57233573, 60331599, 61522786, 62409944, 62739248, 64074298, 64234321, 64499496, 64624133, 65428266, 67241866, 69079775, 69325516, 69991900, 70527952, 70703467, 70841434, 74716313, 75632221, 76384414, 76385407, 77205006, 78229643, 78934592, 80527019, 81691532, 85593421, 88047835, 88435236, 88435319, 88435362, 88435916, 88439202, 88440582, 89288299, 89705641, 89705672, 89705758, 89730037, 89730175, 89730345, 89797943, 90580674, 91003708, 91031119, 93759248, 93759254, 93759280, 93759401, 93759425, 93759462, 93800162, 93800269, 94028919, 99453882, 99922796, 100641297, 102519620, 103054099, 103318524, 103814653, 104041189, 104213911, 104432921, 105474714, 105919953, 106480467, 107713060, 107713114, 111262316, 111377226, 111439945, 112362134, 113097651, 114982881, 115641569, 115642993, 115643538, 115649691, 115670847, 115671687, 116815567, 117639172, 117639190, 119266383, 119958356, 121238364, 121397532, 121698158, 121708718, 121943600, 121970978, 123017343, 123849404, 124006884, 126156972, 126756566, 127403483, 127448079, 129159629, 130291511, 130291558, 130972490, 131037988, 131973478, 132258220, 132521200, 132826927, 133709045, 134385206, 134412628, 134933117, 134998109, 135811063, 136552330, 136553211, 136554213, 136554798, 137579070, 137601710, 137663665, 137667349, 137714280, 137851207, 138075198, 138097967, 138273823, 138302559, 138660450, 138831719, 139813495, 141594080, 141860986, 141884823, 142099256, 142536132, 142582982, 144372813, 146452200, 146999560, 147111499, 147405780, 147457094, 147604980, 149203647, 151018852, 151061557, 151158004, 151158634, 151159677, 151972200, 151975489, 152451452, 153034481, 153219155, 155527062, 156336742, 156436871, 156442381, 156575528, 159587479, 168226907, 170727774, 171093866, 171094021, 171480091, 171621041, 173200071, 173213117, 173229864, 173426004, 173709268, 173712102, 173717622, 174156763, 174194059, 174247774, 174607564, 174623904, 174623946, 174623951, 174624061, 174625194, 174625307, 174625407, 174625552, 174625647, 174626867, 174754789, 174875493, 176599903, 178440917, 179606757, 179607078, 179608067, 179654627, 179659205, 179848153, 179848203, 179848415, 179930265, 179936743, 179936852, 179942496, 179965835, 180015293, 180096359, 180096468, 182438142, 182516442, 182860908, 183314955, 183565013, 183746202, 183970446, 184269528, 184359255, 184360405, 185393703, 185405431, 186057650, 186058299, 186325468, 188498026, 192118902, 192796203, 193919365, 193947342, 193971479, 193971567, 193971908, 193972138, 193973221, 193975449, 194002589, 194003533, 194004216, 194060881, 194116470, 194125886, 194497396, 195246292, 195314410, 195404163, 195489237, 196222661, 196269807, 196270383, 196270581, 196271217, 196271907, 196524776, 196584699, 196588801, 197800858, 197872508, 197872817, 198439589, 198475036, 199788352, 199819506, 200121238, 200595661, 200613777, 201661227, 201663320, 201663467, 201664501, 201693153, 201693551, 201698392, 201701643, 201726181, 201727585, 201767917, 201983184, 201983223, 203209892, 203289934, 203294845, 203695911, 203720325, 203723447, 204061479, 204071275, 204339633, 204344395, 205005075, 205333914, 205904977, 205951017, 206624869, 207118252, 207819508, 208186004, 208206831, 208598427, 208854942, 208978576, 209191450, 209226460, 209260139, 209260714, 209260788, 209768906, 209842220, 209901120, 210340207, 210495239, 210495352, 210736452, 210993156, 210993185, 211136447, 211515349, 211532217, 211679972, 211680281, 211702584, 211750362, 212138766, 212464051, 212821044, 213182009, 213390165, 213498323, 213500078, 213550108, 213550783, 213560223, 213611914, 213612663, 213615794, 213616333, 214116086, 214250188, 214327469, 214516585, 214878420, 214921670, 215232482, 215629466, 216429141, 216753945, 217097347, 217254302, 217254350, 217255149, 217261805, 217353908, 217368373, 217858968, 217861358, 217861775, 217870124, 218035890, 218151680, 218152225, 218226925, 218308954, 218310715, 218487111, 218901089, 219365086, 219850254, 219850752, 219853753, 219855754, 219857662, 219857719, 219857745, 219866336, 220121187, 220143764, 220239069, 220506626, 220517406, 220538568, 220569666, 220591655, 220594438, 220930761, 221991933, 222524313, 222531414, 222549274, 222956471, 223787165, 223787707, 223843537, 223846253, 224166708, 224500725, 225107350};
} }

View File

@ -0,0 +1,241 @@
#pragma once
namespace big
{
constexpr const static auto hud_colors = std::to_array({
"HUD_COLOUR_PURE_WHITE",
"HUD_COLOUR_WHITE",
"HUD_COLOUR_BLACK",
"HUD_COLOUR_GREY",
"HUD_COLOUR_GREYLIGHT",
"HUD_COLOUR_GREYDARK",
"HUD_COLOUR_RED",
"HUD_COLOUR_REDLIGHT",
"HUD_COLOUR_REDDARK",
"HUD_COLOUR_BLUE",
"HUD_COLOUR_BLUELIGHT",
"HUD_COLOUR_BLUEDARK",
"HUD_COLOUR_YELLOW",
"HUD_COLOUR_YELLOWLIGHT",
"HUD_COLOUR_YELLOWDARK",
"HUD_COLOUR_ORANGE",
"HUD_COLOUR_ORANGELIGHT",
"HUD_COLOUR_ORANGEDARK",
"HUD_COLOUR_GREEN",
"HUD_COLOUR_GREENLIGHT",
"HUD_COLOUR_GREENDARK",
"HUD_COLOUR_PURPLE",
"HUD_COLOUR_PURPLELIGHT",
"HUD_COLOUR_PURPLEDARK",
"HUD_COLOUR_PINK",
"HUD_COLOUR_RADAR_HEALTH",
"HUD_COLOUR_RADAR_ARMOUR",
"HUD_COLOUR_RADAR_DAMAGE",
"HUD_COLOUR_NET_PLAYER1",
"HUD_COLOUR_NET_PLAYER2",
"HUD_COLOUR_NET_PLAYER3",
"HUD_COLOUR_NET_PLAYER4",
"HUD_COLOUR_NET_PLAYER5",
"HUD_COLOUR_NET_PLAYER6",
"HUD_COLOUR_NET_PLAYER7",
"HUD_COLOUR_NET_PLAYER8",
"HUD_COLOUR_NET_PLAYER9",
"HUD_COLOUR_NET_PLAYER10",
"HUD_COLOUR_NET_PLAYER11",
"HUD_COLOUR_NET_PLAYER12",
"HUD_COLOUR_NET_PLAYER13",
"HUD_COLOUR_NET_PLAYER14",
"HUD_COLOUR_NET_PLAYER15",
"HUD_COLOUR_NET_PLAYER16",
"HUD_COLOUR_NET_PLAYER17",
"HUD_COLOUR_NET_PLAYER18",
"HUD_COLOUR_NET_PLAYER19",
"HUD_COLOUR_NET_PLAYER20",
"HUD_COLOUR_NET_PLAYER21",
"HUD_COLOUR_NET_PLAYER22",
"HUD_COLOUR_NET_PLAYER23",
"HUD_COLOUR_NET_PLAYER24",
"HUD_COLOUR_NET_PLAYER25",
"HUD_COLOUR_NET_PLAYER26",
"HUD_COLOUR_NET_PLAYER27",
"HUD_COLOUR_NET_PLAYER28",
"HUD_COLOUR_NET_PLAYER29",
"HUD_COLOUR_NET_PLAYER30",
"HUD_COLOUR_NET_PLAYER31",
"HUD_COLOUR_NET_PLAYER32",
"HUD_COLOUR_SIMPLEBLIP_DEFAULT",
"HUD_COLOUR_MENU_BLUE",
"HUD_COLOUR_MENU_GREY_LIGHT",
"HUD_COLOUR_MENU_BLUE_EXTRA_DARK",
"HUD_COLOUR_MENU_YELLOW",
"HUD_COLOUR_MENU_YELLOW_DARK",
"HUD_COLOUR_MENU_GREEN",
"HUD_COLOUR_MENU_GREY",
"HUD_COLOUR_MENU_GREY_DARK",
"HUD_COLOUR_MENU_HIGHLIGHT",
"HUD_COLOUR_MENU_STANDARD",
"HUD_COLOUR_MENU_DIMMED",
"HUD_COLOUR_MENU_EXTRA_DIMMED",
"HUD_COLOUR_BRIEF_TITLE",
"HUD_COLOUR_MID_GREY_MP",
"HUD_COLOUR_NET_PLAYER1_DARK",
"HUD_COLOUR_NET_PLAYER2_DARK",
"HUD_COLOUR_NET_PLAYER3_DARK",
"HUD_COLOUR_NET_PLAYER4_DARK",
"HUD_COLOUR_NET_PLAYER5_DARK",
"HUD_COLOUR_NET_PLAYER6_DARK",
"HUD_COLOUR_NET_PLAYER7_DARK",
"HUD_COLOUR_NET_PLAYER8_DARK",
"HUD_COLOUR_NET_PLAYER9_DARK",
"HUD_COLOUR_NET_PLAYER10_DARK",
"HUD_COLOUR_NET_PLAYER11_DARK",
"HUD_COLOUR_NET_PLAYER12_DARK",
"HUD_COLOUR_NET_PLAYER13_DARK",
"HUD_COLOUR_NET_PLAYER14_DARK",
"HUD_COLOUR_NET_PLAYER15_DARK",
"HUD_COLOUR_NET_PLAYER16_DARK",
"HUD_COLOUR_NET_PLAYER17_DARK",
"HUD_COLOUR_NET_PLAYER18_DARK",
"HUD_COLOUR_NET_PLAYER19_DARK",
"HUD_COLOUR_NET_PLAYER20_DARK",
"HUD_COLOUR_NET_PLAYER21_DARK",
"HUD_COLOUR_NET_PLAYER22_DARK",
"HUD_COLOUR_NET_PLAYER23_DARK",
"HUD_COLOUR_NET_PLAYER24_DARK",
"HUD_COLOUR_NET_PLAYER25_DARK",
"HUD_COLOUR_NET_PLAYER26_DARK",
"HUD_COLOUR_NET_PLAYER27_DARK",
"HUD_COLOUR_NET_PLAYER28_DARK",
"HUD_COLOUR_NET_PLAYER29_DARK",
"HUD_COLOUR_NET_PLAYER30_DARK",
"HUD_COLOUR_NET_PLAYER31_DARK",
"HUD_COLOUR_NET_PLAYER32_DARK",
"HUD_COLOUR_BRONZE",
"HUD_COLOUR_SILVER",
"HUD_COLOUR_GOLD",
"HUD_COLOUR_PLATINUM",
"HUD_COLOUR_GANG1",
"HUD_COLOUR_GANG2",
"HUD_COLOUR_GANG3",
"HUD_COLOUR_GANG4",
"HUD_COLOUR_SAME_CREW",
"HUD_COLOUR_FREEMODE",
"HUD_COLOUR_PAUSE_BG",
"HUD_COLOUR_FRIENDLY",
"HUD_COLOUR_ENEMY",
"HUD_COLOUR_LOCATION",
"HUD_COLOUR_PICKUP",
"HUD_COLOUR_PAUSE_SINGLEPLAYER",
"HUD_COLOUR_FREEMODE_DARK",
"HUD_COLOUR_INACTIVE_MISSION",
"HUD_COLOUR_DAMAGE",
"HUD_COLOUR_PINKLIGHT",
"HUD_COLOUR_PM_MITEM_HIGHLIGHT",
"HUD_COLOUR_SCRIPT_VARIABLE",
"HUD_COLOUR_YOGA",
"HUD_COLOUR_TENNIS",
"HUD_COLOUR_GOLF",
"HUD_COLOUR_SHOOTING_RANGE",
"HUD_COLOUR_FLIGHT_SCHOOL",
"HUD_COLOUR_NORTH_BLUE",
"HUD_COLOUR_SOCIAL_CLUB",
"HUD_COLOUR_PLATFORM_BLUE",
"HUD_COLOUR_PLATFORM_GREEN",
"HUD_COLOUR_PLATFORM_GREY",
"HUD_COLOUR_FACEBOOK_BLUE",
"HUD_COLOUR_INGAME_BG",
"HUD_COLOUR_DARTS",
"HUD_COLOUR_WAYPOINT",
"HUD_COLOUR_MICHAEL",
"HUD_COLOUR_FRANKLIN",
"HUD_COLOUR_TREVOR",
"HUD_COLOUR_GOLF_P1",
"HUD_COLOUR_GOLF_P2",
"HUD_COLOUR_GOLF_P3",
"HUD_COLOUR_GOLF_P4",
"HUD_COLOUR_WAYPOINTLIGHT",
"HUD_COLOUR_WAYPOINTDARK",
"HUD_COLOUR_PANEL_LIGHT",
"HUD_COLOUR_MICHAEL_DARK",
"HUD_COLOUR_FRANKLIN_DARK",
"HUD_COLOUR_TREVOR_DARK",
"HUD_COLOUR_OBJECTIVE_ROUTE",
"HUD_COLOUR_PAUSEMAP_TINT",
"HUD_COLOUR_PAUSE_DESELECT",
"HUD_COLOUR_PM_WEAPONS_PURCHASABLE",
"HUD_COLOUR_PM_WEAPONS_LOCKED",
"HUD_COLOUR_END_SCREEN_BG",
"HUD_COLOUR_CHOP",
"HUD_COLOUR_PAUSEMAP_TINT_HALF",
"HUD_COLOUR_NORTH_BLUE_OFFICIAL",
"HUD_COLOUR_SCRIPT_VARIABLE_2",
"HUD_COLOUR_H",
"HUD_COLOUR_HDARK",
"HUD_COLOUR_T",
"HUD_COLOUR_TDARK",
"HUD_COLOUR_HSHARD",
"HUD_COLOUR_CONTROLLER_MICHAEL",
"HUD_COLOUR_CONTROLLER_FRANKLIN",
"HUD_COLOUR_CONTROLLER_TREVOR",
"HUD_COLOUR_CONTROLLER_CHOP",
"HUD_COLOUR_VIDEO_EDITOR_VIDEO",
"HUD_COLOUR_VIDEO_EDITOR_AUDIO",
"HUD_COLOUR_VIDEO_EDITOR_TEXT",
"HUD_COLOUR_HB_BLUE",
"HUD_COLOUR_HB_YELLOW",
"HUD_COLOUR_VIDEO_EDITOR_SCORE",
"HUD_COLOUR_VIDEO_EDITOR_AUDIO_FADEOUT",
"HUD_COLOUR_VIDEO_EDITOR_TEXT_FADEOUT",
"HUD_COLOUR_VIDEO_EDITOR_SCORE_FADEOUT",
"HUD_COLOUR_HEIST_BACKGROUND",
"HUD_COLOUR_VIDEO_EDITOR_AMBIENT",
"HUD_COLOUR_VIDEO_EDITOR_AMBIENT_FADEOUT",
"HUD_COLOUR_VIDEO_EDITOR_AMBIENT_DARK",
"HUD_COLOUR_VIDEO_EDITOR_AMBIENT_LIGHT",
"HUD_COLOUR_VIDEO_EDITOR_AMBIENT_MID",
"HUD_COLOUR_LOW_FLOW",
"HUD_COLOUR_LOW_FLOW_DARK",
"HUD_COLOUR_G1",
"HUD_COLOUR_G2",
"HUD_COLOUR_G3",
"HUD_COLOUR_G4",
"HUD_COLOUR_G5",
"HUD_COLOUR_G6",
"HUD_COLOUR_G7",
"HUD_COLOUR_G8",
"HUD_COLOUR_G9",
"HUD_COLOUR_G10",
"HUD_COLOUR_G11",
"HUD_COLOUR_G12",
"HUD_COLOUR_G13",
"HUD_COLOUR_G14",
"HUD_COLOUR_G15",
"HUD_COLOUR_ADVERSARY",
"HUD_COLOUR_DEGEN_RED",
"HUD_COLOUR_DEGEN_YELLOW",
"HUD_COLOUR_DEGEN_GREEN",
"HUD_COLOUR_DEGEN_CYAN",
"HUD_COLOUR_DEGEN_BLUE",
"HUD_COLOUR_DEGEN_MAGENTA",
"HUD_COLOUR_STUNT_1",
"HUD_COLOUR_STUNT_2",
"HUD_COLOUR_SPECIAL_RACE_SERIES",
"HUD_COLOUR_SPECIAL_RACE_SERIES_DARK",
"HUD_COLOUR_CS",
"HUD_COLOUR_CS_DARK",
"HUD_COLOUR_TECH_GREEN",
"HUD_COLOUR_TECH_GREEN_DARK",
"HUD_COLOUR_TECH_RED",
"HUD_COLOUR_TECH_GREEN_VERY_DARK",
"HUD_COLOUR_PLACEHOLDER_01",
"HUD_COLOUR_PLACEHOLDER_02",
"HUD_COLOUR_PLACEHOLDER_03",
"HUD_COLOUR_PLACEHOLDER_04",
"HUD_COLOUR_PLACEHOLDER_05",
"HUD_COLOUR_PLACEHOLDER_06",
"HUD_COLOUR_PLACEHOLDER_07",
"HUD_COLOUR_PLACEHOLDER_08",
"HUD_COLOUR_PLACEHOLDER_09",
"HUD_COLOUR_PLACEHOLDER_10",
});
}

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "backend/reactions/interloper_reaction.hpp" #include "backend/reactions/interloper_reaction.hpp"
#include "backend/reactions/reaction.hpp" #include "backend/reactions/reaction.hpp"
#include "core/data/hud_colors.hpp"
#include "core/data/ptfx_effects.hpp" #include "core/data/ptfx_effects.hpp"
#include "enums.hpp" #include "enums.hpp"
#include "file_manager.hpp" #include "file_manager.hpp"
@ -21,6 +22,16 @@ namespace rage
namespace big namespace big
{ {
struct color
{
int r;
int g;
int b;
int a;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(color, r, g, b, a)
};
class menu_settings class menu_settings
{ {
public: public:
@ -189,11 +200,9 @@ namespace big
reaction report{"Report", "Blocked Report from %s", "%s tried to report me!"}; reaction report{"Report", "Blocked Report from %s", "%s tried to report me!"};
interloper_reaction breakup_others{"Breakup Kicks On Other Players", "%s is trying to breakup kick %s!", "%s is trying to breakup kick %s!", true, true}; // blockable only when host but we have no way to specify that atm interloper_reaction breakup_others{"Breakup Kicks On Other Players", "%s is trying to breakup kick %s!", "%s is trying to breakup kick %s!", true, true}; // blockable only when host but we have no way to specify that atm
reaction lost_connection_kick{"Lost Connection Kick", "Blocked Lost Connection Kick from %s", "%s tried to kick me out!"};
reaction gamer_instruction_kick{"Gamer Instruction Kick", "Blocked Gamer Instruction Kick from %s", "%s tried to kick me out!"}; reaction gamer_instruction_kick{"Gamer Instruction Kick", "Blocked Gamer Instruction Kick from %s", "%s tried to kick me out!"};
interloper_reaction lost_connection_kick_others{"Lost Connection Kick On Other Players", "%s is trying to lost connection kick %s!", "%s is trying to lost connection kick %s!", true, false};
NLOHMANN_DEFINE_TYPE_INTRUSIVE(reactions, bounty, ceo_money, ceo_kick, clear_wanted_level, crash, end_session_kick, fake_deposit, force_mission, force_teleport, gta_banner, kick_from_interior, mc_teleport, network_bail, personal_vehicle_destroyed, remote_off_radar, rotate_cam, send_to_cutscene, send_to_location, sound_spam, spectate_notification, give_collectible, transaction_error, tse_freeze, tse_sender_mismatch, vehicle_kick, teleport_to_warehouse, trigger_business_raid, start_activity, start_script, null_function_kick, destroy_personal_vehicle, clear_ped_tasks, turn_into_beast, remote_wanted_level, remote_wanted_level_others, remote_ragdoll, kick_vote, report_cash_spawn, modder_detection, request_control_event, report, breakup_others, gamer_instruction_kick, lost_connection_kick, lost_connection_kick_others) NLOHMANN_DEFINE_TYPE_INTRUSIVE(reactions, bounty, ceo_money, ceo_kick, clear_wanted_level, crash, end_session_kick, fake_deposit, force_mission, force_teleport, gta_banner, kick_from_interior, mc_teleport, network_bail, personal_vehicle_destroyed, remote_off_radar, rotate_cam, send_to_cutscene, send_to_location, sound_spam, spectate_notification, give_collectible, transaction_error, tse_freeze, tse_sender_mismatch, vehicle_kick, teleport_to_warehouse, trigger_business_raid, start_activity, start_script, null_function_kick, destroy_personal_vehicle, clear_ped_tasks, turn_into_beast, remote_wanted_level, remote_wanted_level_others, remote_ragdoll, kick_vote, report_cash_spawn, modder_detection, request_control_event, report, breakup_others, gamer_instruction_kick)
} reactions{}; } reactions{};
struct player struct player
@ -289,13 +298,11 @@ namespace big
bool custom_weapon_stop = true; bool custom_weapon_stop = true;
struct hud struct hud
{ {
bool hudcolor = false; bool color_override = false;
bool shcolor = false; bool color_override_initialized = false;
bool mtcolor = false; std::array<color, hud_colors.size()> hud_color_overrides = {};
bool mhcolor = false; std::array<color, hud_colors.size()> hud_color_defaults = {}; // don't save
int hcolor = 0;
int tcolor = 0;
int index, r, g, b, a;
bool hide_radar = false; bool hide_radar = false;
bool hide_ammo = false; bool hide_ammo = false;
int selected_hud_component = 1; int selected_hud_component = 1;
@ -303,7 +310,7 @@ namespace big
bool force_show_hud_element = false; bool force_show_hud_element = false;
bool force_show_hud = false; bool force_show_hud = false;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(hud, hudcolor, shcolor, mtcolor, mhcolor, hcolor, tcolor, index, r, g, b, a, hide_radar, hide_ammo, selected_hud_component, hud_components_states, force_show_hud_element, force_show_hud) NLOHMANN_DEFINE_TYPE_INTRUSIVE(hud, color_override, color_override_initialized, hud_color_overrides, hide_radar, hide_ammo, selected_hud_component, hud_components_states, force_show_hud_element, force_show_hud)
} hud{}; } hud{};
// do not save below entries // do not save below entries
bool dance_mode = false; bool dance_mode = false;
@ -559,8 +566,8 @@ namespace big
float x = .9f; float x = .9f;
float y = .72f; float y = .72f;
bool enabled = false; bool enabled = false;
bool left_side = false; bool left_side = false;
bool show_current_gear = true; bool show_current_gear = true;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(speedo_meter, x, y, enabled, left_side, show_current_gear) NLOHMANN_DEFINE_TYPE_INTRUSIVE(speedo_meter, x, y, enabled, left_side, show_current_gear)

View File

@ -1,6 +1,7 @@
#include "fidevice.hpp" #include "fidevice.hpp"
#include "pointers.hpp"
#include "hooking.hpp" #include "hooking.hpp"
#include "pointers.hpp"
namespace rage namespace rage
{ {
@ -264,4 +265,9 @@ namespace rage
{ {
return big::g_hooking->get_original<big::hooks::fipackfile_mount>()(this, mount_point); return big::g_hooking->get_original<big::hooks::fipackfile_mount>()(this, mount_point);
} }
void fiDevice::Unmount(const char* rootPath)
{
big::g_pointers->m_gta.m_fipackfile_unmount(rootPath);
}
} }

121
src/gta/pools.hpp Normal file
View File

@ -0,0 +1,121 @@
#pragma once
#include "natives.hpp"
#include "pointers.hpp"
// everything pasted from https://github.com/gta-chaos-mod/ChaosModV/blob/master/ChaosMod/Util/EntityIterator.h
// Thanks to menyoo for most of these!!
// Pool Interator class to iterate over pools. Has just enough operators defined to be able to be used in a for loop, not suitable for any other iterating.
template<typename T>
class pool_iterator
{
public:
T* pool = nullptr;
uint32_t index = 0;
explicit pool_iterator(T* pool, int32_t index = 0)
{
this->pool = pool;
this->index = index;
}
pool_iterator& operator++()
{
for (index++; index < pool->m_size; index++)
{
if (pool->is_valid(index))
{
return *this;
}
}
index = pool->m_size;
return *this;
}
rage::CEntity* operator*()
{
auto addr = pool->get_address(index);
return (rage::CEntity*)addr;
}
bool operator!=(const pool_iterator& other) const
{
return this->index != other.index;
}
};
// Common functions for VehiclePool and GenericPool
template<typename T>
class PoolUtils
{
public:
inline auto to_array()
{
std::vector<Entity> arr;
for (auto entity : *static_cast<T*>(this))
{
arr.push_back(big::g_pointers->m_gta.m_ptr_to_handle(entity));
}
return arr;
}
auto begin()
{
return ++pool_iterator<T>(static_cast<T*>(this), -1);
}
auto end()
{
return ++pool_iterator<T>(static_cast<T*>(this), static_cast<T*>(this)->m_size);
}
};
class VehiclePool : public PoolUtils<VehiclePool>
{
public:
UINT64* m_pool_address;
UINT32 m_size;
char _Padding2[36];
UINT32* m_bit_array;
char _Padding3[40];
UINT32 m_item_count;
inline bool is_valid(UINT32 i)
{
return (m_bit_array[i >> 5] >> (i & 0x1F)) & 1;
}
inline UINT64 get_address(UINT32 i)
{
return m_pool_address[i];
}
};
class GenericPool : public PoolUtils<GenericPool>
{
public:
UINT64 m_pool_address;
BYTE* m_bit_array;
UINT32 m_size;
UINT32 m_item_size;
inline bool is_valid(UINT32 i)
{
return mask(i) != 0;
}
inline UINT64 get_address(UINT32 i)
{
return mask(i) & (m_pool_address + i * m_item_size);
}
private:
inline long long mask(UINT32 i)
{
long long num1 = m_bit_array[i] & 0x80;
return ~((num1 | -num1) >> 63);
}
};

View File

@ -1,10 +1,10 @@
#pragma once #pragma once
#pragma pack(push, 4)
#include "base/CObject.hpp"
#include "common.hpp" #include "common.hpp"
#include "fwddec.hpp" #include "fwddec.hpp"
#include "base/CObject.hpp"
#pragma pack(push, 4)
namespace rage namespace rage
{ {
template<typename T = CDynamicEntity> template<typename T = CDynamicEntity>

View File

@ -1,10 +1,14 @@
#pragma once #pragma once
#include <memory/handle.hpp>
class CCommunications; class CCommunications;
class FriendRegistry; class FriendRegistry;
class CNetworkPlayerMgr; class CNetworkPlayerMgr;
class Network; class Network;
class ChatData; class ChatData;
class ScInfo;
class GenericPool;
class VehiclePool;
namespace rage namespace rage
{ {
@ -41,9 +45,6 @@ namespace big
memory::handle m_crash_trigger; memory::handle m_crash_trigger;
memory::handle freemode_thread_restorer_through_vm_patch_1;
memory::handle freemode_thread_restorer_through_vm_patch_2;
eGameState* m_game_state{}; eGameState* m_game_state{};
bool* m_is_session_started{}; bool* m_is_session_started{};
@ -140,8 +141,6 @@ namespace big
functions::reset_network_complaints m_reset_network_complaints{}; functions::reset_network_complaints m_reset_network_complaints{};
functions::fidevice_get_device m_fidevice_get_device{}; functions::fidevice_get_device m_fidevice_get_device{};
uintptr_t m_fidevices{};
uint16_t* m_fidevices_len{};
functions::fipackfile_ctor m_fipackfile_ctor{}; functions::fipackfile_ctor m_fipackfile_ctor{};
rage::fiPackfile** m_fipackfile_instances{}; rage::fiPackfile** m_fipackfile_instances{};
functions::fipackfile_open_archive m_fipackfile_open_archive{}; functions::fipackfile_open_archive m_fipackfile_open_archive{};
@ -255,6 +254,14 @@ namespace big
PVOID m_write_vehicle_proximity_migration_data_node{}; PVOID m_write_vehicle_proximity_migration_data_node{};
functions::migrate_object m_migrate_object{}; functions::migrate_object m_migrate_object{};
const char* m_game_version{};
const char* m_online_version{};
GenericPool** m_ped_pool{};
GenericPool** m_prop_pool{};
VehiclePool*** m_vehicle_pool{};
}; };
#pragma pack(pop) #pragma pack(pop)
static_assert(sizeof(gta_pointers) % 8 == 0, "Pointers are not properly aligned");
} }

View File

@ -1,7 +1,7 @@
#include "hooking.hpp"
#include "gta/fidevice.hpp" #include "gta/fidevice.hpp"
#include "services/gta_data/yim_fipackfile.hpp" #include "hooking.hpp"
#include "services/gta_data/gta_data_service.hpp" #include "services/gta_data/gta_data_service.hpp"
#include "services/gta_data/yim_fipackfile.hpp"
namespace big namespace big
{ {
@ -16,29 +16,17 @@ namespace big
if (g_gta_data_service->state() == eGtaDataUpdateState::ON_INIT_UPDATE_START) if (g_gta_data_service->state() == eGtaDataUpdateState::ON_INIT_UPDATE_START)
{ {
yim_fipackfile rpf_wrapper = yim_fipackfile(this_, mount_point); yim_fipackfile rpf_wrapper = yim_fipackfile(this_);
std::for_each(yim_fipackfile::m_wrapper_call_back.begin(), yim_fipackfile::m_wrapper_call_back.end(), [&rpf_wrapper](std::function<size_t(yim_fipackfile & rpf_wrapper)> cb) { std::for_each(yim_fipackfile::m_wrapper_call_back.begin(), yim_fipackfile::m_wrapper_call_back.end(), [&rpf_wrapper](std::function<size_t(yim_fipackfile & rpf_wrapper)> cb) {
cb(rpf_wrapper); cb(rpf_wrapper);
}); });
if (!stricmp(this_->GetName(), "BgScript.rpf")) if (!stricmp(this_->GetName(), "BgScript.rpf"))
{ {
auto names = yim_fipackfile::get_non_dlc_mounted_devices_names();
for (auto name : names)
{
auto device = rage::fiDevice::GetDevice(name.c_str(), true);
if (*(void**)this_ == *(void**)device) //make sure it's fipackfile
{
rpf_wrapper = yim_fipackfile((rage::fiPackfile*)device, name);
std::for_each(yim_fipackfile::m_wrapper_call_back.begin(), yim_fipackfile::m_wrapper_call_back.end(), [&rpf_wrapper](std::function<size_t(yim_fipackfile & rpf_wrapper)> cb) {
cb(rpf_wrapper);
});
}
}
g_gta_data_service->set_state(eGtaDataUpdateState::ON_INIT_UPDATE_END); g_gta_data_service->set_state(eGtaDataUpdateState::ON_INIT_UPDATE_END);
} }
} }
return result; return result;
} }
} }

View File

@ -48,12 +48,13 @@ namespace big
{ {
if (g.protections.admin_check) if (g.protections.admin_check)
{ {
auto found = std::find(admin_rids.begin(), admin_rids.end(), net_player_data->m_gamer_handle.m_rockstar_id); if (admin_rids.contains(net_player_data->m_gamer_handle.m_rockstar_id))
if (found != admin_rids.end())
{ {
g_notification_service->push_warning("POTENTIAL_ADMIN_FOUND"_T.data(), g_notification_service->push_warning("POTENTIAL_ADMIN_FOUND"_T.data(),
std::vformat("PLAYER_DETECTED_AS_ADMIN"_T, std::make_format_args(net_player_data->m_name))); std::vformat("PLAYER_DETECTED_AS_ADMIN"_T, std::make_format_args(net_player_data->m_name)));
LOG(WARNING) << net_player_data->m_name << " (" << net_player_data->m_gamer_handle.m_rockstar_id << ") has been detected as admin";
LOG(WARNING) << net_player_data->m_name << " (" << net_player_data->m_gamer_handle.m_rockstar_id << ") has been detected as an admin";
auto id = player->m_player_id; auto id = player->m_player_id;
if (auto plyr = g_player_service->get_by_id(id)) if (auto plyr = g_player_service->get_by_id(id))
plyr->is_admin = true; plyr->is_admin = true;
@ -97,14 +98,6 @@ namespace big
} }
} }
} }
if (auto snplyr = plyr->get_session_player())
{
packet msg{};
msg.write_message(rage::eNetMessage::MsgSessionEstablishedRequest);
msg.write<uint64_t>(gta_util::get_network()->m_game_session_ptr->m_rline_session.m_session_id, 64);
msg.send(snplyr->m_msg_id);
}
} }
}); });
} }

View File

@ -191,41 +191,6 @@ namespace big
break; break;
} }
case rage::eNetMessage::MsgLostConnectionToHost:
{
uint64_t session_id;
buffer.ReadQWord(&session_id, 64);
rage::rlGamerHandle handle;
gamer_handle_deserialize(handle, buffer);
auto self = g_player_service->get_self();
if (self->get_net_data() && self->get_net_data()->m_gamer_handle.m_rockstar_id == handle.m_rockstar_id)
{
session::add_infraction(player, Infraction::TRIED_KICK_PLAYER);
g.reactions.lost_connection_kick.process(player);
return true;
}
for (auto& [_, plyr] : g_player_service->players())
{
if (plyr->get_net_data() && plyr != player
&& plyr->get_net_data()->m_gamer_handle.m_rockstar_id == handle.m_rockstar_id)
{
session::add_infraction(player, Infraction::LOST_CONNECTION_KICK_DETECTED);
g.reactions.lost_connection_kick_others.process(player, plyr);
if (g.reactions.lost_connection_kick_others.block)
return true;
else
break;
}
}
if (player->get_net_data() && player->get_net_data()->m_gamer_handle.m_rockstar_id == handle.m_rockstar_id)
break;
else
return true;
}
case rage::eNetMessage::MsgNetComplaint: case rage::eNetMessage::MsgNetComplaint:
{ {
uint64_t host_token{}; uint64_t host_token{};
@ -242,7 +207,7 @@ namespace big
player->exposed_desync_protection = true; player->exposed_desync_protection = true;
} }
return true;// block desync kicks as host return true; // block desync kicks as host
} }
case rage::eNetMessage::MsgRequestObjectIds: case rage::eNetMessage::MsgRequestObjectIds:
{ {
@ -283,6 +248,7 @@ namespace big
} }
case rage::eNetMessage::MsgTransitionGamerInstruction: case rage::eNetMessage::MsgTransitionGamerInstruction:
{ {
// this kick is still a thing
if (is_kick_instruction(buffer)) if (is_kick_instruction(buffer))
{ {
g.reactions.gamer_instruction_kick.process(player); g.reactions.gamer_instruction_kick.process(player);
@ -292,90 +258,6 @@ namespace big
} }
} }
} }
else
{
switch (msgType)
{
case rage::eNetMessage::MsgLostConnectionToHost:
{
uint64_t session_id;
buffer.ReadQWord(&session_id, 64);
rage::rlGamerHandle handle;
gamer_handle_deserialize(handle, buffer);
auto self = g_player_service->get_self();
if (self->get_net_data() && self->get_net_data()->m_gamer_handle.m_rockstar_id == handle.m_rockstar_id)
{
g_notification_service->push_error("KICK"_T.data(), "REMOTE_KICK_LOST_CONNECTION"_T.data());
return true;
}
for (auto& [_, plyr] : g_player_service->players())
{
if (plyr->get_net_data() && plyr->get_net_data()->m_gamer_handle.m_rockstar_id == handle.m_rockstar_id)
{
g_notification_service->push_error("KICK"_T.data(), std::vformat("REMOTE_KICK_LOST_CONNECTION_PLAYER"_T, std::make_format_args(plyr->get_name())));
return true;
}
}
return true;
}
case rage::eNetMessage::MsgRemoveGamersFromSessionCmd:
{
if (!g_player_service->get_self()->is_host())
break;
player_ptr target;
uint64_t session_id;
buffer.ReadQWord(&session_id, 64);
uint32_t count;
buffer.ReadDword(&count, 6);
for (std::uint32_t i = 0; i < count; i++)
{
uint64_t peer_id;
buffer.ReadQWord(&peer_id, 64);
if (g_player_service->get_self()->get_net_data() && g_player_service->get_self()->get_net_data()->m_peer_id_2 == peer_id)
{
target = g_player_service->get_self();
}
else
{
for (std::uint32_t i = 0; i < gta_util::get_network()->m_game_session_ptr->m_peer_count; i++)
{
if (gta_util::get_network()->m_game_session_ptr->m_peers[i]->m_peer_data.m_peer_id_2 == peer_id)
{
target = g_player_service->get_by_host_token(
gta_util::get_network()->m_game_session_ptr->m_peers[i]->m_peer_data.m_host_token);
break;
}
}
}
}
if (target && count == 1 && frame->m_msg_id == -1)
{
if (target->id() == g_player_service->get_self()->id())
g_notification_service->push_error("KICK"_T.data(), "REMOTE_KICK_BREAKUP"_T.data());
else
g_notification_service->push_error("KICK"_T.data(),
std::vformat("REMOTE_KICK_BREAKUP_PLAYER"_T, std::make_format_args(target->get_name())));
}
return true;
}
case rage::eNetMessage::MsgTransitionGamerInstruction:
{
if (is_kick_instruction(buffer))
{
g_notification_service->push_error("KICK"_T.data(), "REMOTE_KICK_GAMER_INSTRUCTION"_T.data());
return true;
}
break;
}
}
}
if (g.debug.logs.packet_logs && msgType != rage::eNetMessage::MsgCloneSync && msgType != rage::eNetMessage::MsgPackedCloneSyncACKs && msgType != rage::eNetMessage::MsgPackedEvents && msgType != rage::eNetMessage::MsgPackedReliables && msgType != rage::eNetMessage::MsgPackedEventReliablesMsgs && msgType != rage::eNetMessage::MsgNetArrayMgrUpdate && msgType != rage::eNetMessage::MsgNetArrayMgrSplitUpdateAck && msgType != rage::eNetMessage::MsgNetArrayMgrUpdateAck && msgType != rage::eNetMessage::MsgScriptHandshakeAck && msgType != rage::eNetMessage::MsgScriptHandshake && msgType != rage::eNetMessage::MsgScriptJoin && msgType != rage::eNetMessage::MsgScriptJoinAck && msgType != rage::eNetMessage::MsgScriptJoinHostAck && msgType != rage::eNetMessage::MsgRequestObjectIds && msgType != rage::eNetMessage::MsgInformObjectIds && msgType != rage::eNetMessage::MsgNetTimeSync) if (g.debug.logs.packet_logs && msgType != rage::eNetMessage::MsgCloneSync && msgType != rage::eNetMessage::MsgPackedCloneSyncACKs && msgType != rage::eNetMessage::MsgPackedEvents && msgType != rage::eNetMessage::MsgPackedReliables && msgType != rage::eNetMessage::MsgPackedEventReliablesMsgs && msgType != rage::eNetMessage::MsgNetArrayMgrUpdate && msgType != rage::eNetMessage::MsgNetArrayMgrSplitUpdateAck && msgType != rage::eNetMessage::MsgNetArrayMgrUpdateAck && msgType != rage::eNetMessage::MsgScriptHandshakeAck && msgType != rage::eNetMessage::MsgScriptHandshake && msgType != rage::eNetMessage::MsgScriptJoin && msgType != rage::eNetMessage::MsgScriptJoinAck && msgType != rage::eNetMessage::MsgScriptJoinHostAck && msgType != rage::eNetMessage::MsgRequestObjectIds && msgType != rage::eNetMessage::MsgInformObjectIds && msgType != rage::eNetMessage::MsgNetTimeSync)
{ {

View File

@ -39,6 +39,11 @@ namespace memory
return m_loaded; return m_loaded;
} }
size_t module::size() const
{
return m_size;
}
bool module::wait_for_module(std::optional<std::chrono::high_resolution_clock::duration> time) bool module::wait_for_module(std::optional<std::chrono::high_resolution_clock::duration> time)
{ {
const auto giveup_time = time.has_value() ? std::make_optional(std::chrono::high_resolution_clock::now() + time.value()) : std::nullopt; const auto giveup_time = time.has_value() ? std::make_optional(std::chrono::high_resolution_clock::now() + time.value()) : std::nullopt;

View File

@ -17,6 +17,8 @@ namespace memory
memory::handle get_export(std::string_view symbol_name); memory::handle get_export(std::string_view symbol_name);
bool loaded() const; bool loaded() const;
size_t size() const;
/** /**
* @brief Waits till the given module is loaded. * @brief Waits till the given module is loaded.
* *

View File

@ -525,16 +525,6 @@ namespace big
g_pointers->m_gta.m_fidevice_get_device = ptr.sub(0x1F).as<functions::fidevice_get_device>(); g_pointers->m_gta.m_fidevice_get_device = ptr.sub(0x1F).as<functions::fidevice_get_device>();
} }
}, },
// fiDevices
{
"FDS",
"74 1B 48 8D 0D ? ? ? ? 41 8B D6",
[](memory::handle ptr)
{
g_pointers->m_gta.m_fidevices = ptr.add(5).rip().as<uintptr_t>();
g_pointers->m_gta.m_fidevices_len = ptr.add(5).rip().add(8).as<uint16_t*>();
}
},
// fiPackfile ctor // fiPackfile ctor
{ {
"FPFC", "FPFC",
@ -1222,6 +1212,43 @@ namespace big
g_pointers->m_gta.m_migrate_object = ptr.as<functions::migrate_object>(); g_pointers->m_gta.m_migrate_object = ptr.as<functions::migrate_object>();
} }
}, },
// Game Version + Online Version
{
"GVOV",
"8B C3 33 D2 C6 44 24 20",
[](memory::handle ptr)
{
g_pointers->m_gta.m_game_version = ptr.add(0x24).rip().as<const char*>();
g_pointers->m_gta.m_online_version = ptr.add(0x24).rip().add(0x20).as<const char*>();
}
},
// Ped Pool
{
"PEP",
"4C 8B 35 ? ? ? ? B8 ? ? ? ? 0F 57 F6 89 05 ? ? ? ? 49 63 76 10 4C 8B FE 85 F6 0F 84 ? ? ? ? 49 8B 46 08 49 FF CF FF CE 42 0F B6 0C 38",
[](memory::handle ptr)
{
g_pointers->m_gta.m_ped_pool = ptr.add(3).rip().as<GenericPool**>();
}
},
// Prop Pool
{
"PRP",
"48 8B 0D ? ? ? ? 49 8B D0 E8 ? ? ? ? 39 03 EB 19 41 80 78 ? ? 75 15 48 8B 0D ? ? ? ? 49 8B D0 E8 ? ? ? ? 39 43 04",
[](memory::handle ptr)
{
g_pointers->m_gta.m_prop_pool = ptr.add(3).rip().as<GenericPool**>();
}
},
// Vehicle Pool
{
"VEP",
"4C 8B 25 ? ? ? ? 8B 29 33 F6 49 8B 04 24 33 DB 4C 8D 71 08 44 8B 78 08 45 85 FF 0F 8E ? ? ? ? 4D 8B 0C 24 41 3B 59 08 7D 29 49 8B 51 30 44 8B C3 8B CB 49 C1 E8 05 83 E1 1F 44 8B D3 42 8B 04 82",
[](memory::handle ptr)
{
g_pointers->m_gta.m_vehicle_pool = ptr.add(3).rip().as<VehiclePool***>();
}
},
// Task Jump Constructor // Task Jump Constructor
{ {
"TJC", "TJC",
@ -1320,24 +1347,6 @@ namespace big
{ {
g_pointers->m_gta.m_crash_trigger = ptr; g_pointers->m_gta.m_crash_trigger = ptr;
} }
},
// freemode_thread_restorer_through_vm_patch 1
{
"FMVM1",
"3b 0a 0f 83 ? ? ? ? 48 ff c7",
[](memory::handle ptr)
{
g_pointers->m_gta.freemode_thread_restorer_through_vm_patch_1 = ptr;
}
},
// freemode_thread_restorer_through_vm_patch 2
{
"FMVM2",
"3b 0a 0f 83 ? ? ? ? 49 03 fa",
[](memory::handle ptr)
{
g_pointers->m_gta.freemode_thread_restorer_through_vm_patch_2 = ptr;
}
} }
>(); >();
@ -1422,7 +1431,7 @@ namespace big
} }
else else
{ {
LOG(FATAL) << "Just tried to load from cache a pointer supposedly within the gta 5 module range but wasnt!!! Offset from start of pointers instance: " << (reinterpret_cast<uintptr_t>(field_ptr) - reinterpret_cast<uintptr_t>(this)); LOG(FATAL) << "Just tried to load from cache a pointer supposedly within the gta 5 module range but isn't! Offset from start of pointers instance: " << (reinterpret_cast<uintptr_t>(field_ptr) - reinterpret_cast<uintptr_t>(this));
} }
field_ptr++; field_ptr++;
@ -1435,41 +1444,15 @@ namespace big
{ {
g_pointers = this; g_pointers = this;
// clang-format off
constexpr auto version_batch = memory::make_batch<
// game version + online version
{
"GVOV",
"8B C3 33 D2 C6 44 24 20",
[](memory::handle ptr)
{
g_pointers->m_game_version = ptr.add(0x24).rip().as<const char*>();
g_pointers->m_online_version = ptr.add(0x24).rip().add(0x20).as<const char*>();
g_pointers->m_game_version_uint32_t = std::strtoul(g_pointers->m_game_version, nullptr, 10);
g_pointers->m_online_version_float = std::strtof(g_pointers->m_online_version, nullptr);
}
}
>();
// clang-format on
const auto mem_region = memory::module("GTA5.exe"); const auto mem_region = memory::module("GTA5.exe");
const auto found_game_version = memory::batch_runner::run(version_batch.m_batch, mem_region);
if (!found_game_version)
{
LOG(WARNING) << "Failed to find version patterns. Can't utilize pointers cache.";
}
constexpr auto gta_batch_and_hash = pointers::get_gta_batch(); constexpr auto gta_batch_and_hash = pointers::get_gta_batch();
constexpr cstxpr_str gta_batch_name{"GTA5"}; constexpr cstxpr_str gta_batch_name{"GTA5"};
write_to_cache_or_read_from_cache<gta_batch_name, write_to_cache_or_read_from_cache<gta_batch_name,
gta_batch_and_hash.m_hash, gta_batch_and_hash.m_hash,
gta_pointers_layout_info::offset_of_cache_begin_field, gta_pointers_layout_info::offset_of_cache_begin_field,
gta_pointers_layout_info::offset_of_cache_end_field, gta_pointers_layout_info::offset_of_cache_end_field,
gta_batch_and_hash.m_batch>(m_gta_pointers_cache, mem_region, found_game_version); gta_batch_and_hash.m_batch>(m_gta_pointers_cache, mem_region);
auto sc_module = memory::module("socialclub.dll"); auto sc_module = memory::module("socialclub.dll");
if (sc_module.wait_for_module()) if (sc_module.wait_for_module())
@ -1480,7 +1463,7 @@ namespace big
sc_batch_and_hash.m_hash, sc_batch_and_hash.m_hash,
sc_pointers_layout_info::offset_of_cache_begin_field, sc_pointers_layout_info::offset_of_cache_begin_field,
sc_pointers_layout_info::offset_of_cache_end_field, sc_pointers_layout_info::offset_of_cache_end_field,
sc_batch_and_hash.m_batch>(m_sc_pointers_cache, sc_module, found_game_version); sc_batch_and_hash.m_batch>(m_sc_pointers_cache, sc_module);
} }
else else
LOG(WARNING) << "socialclub.dll module was not loaded within the time limit."; LOG(WARNING) << "socialclub.dll module was not loaded within the time limit.";

View File

@ -3,14 +3,14 @@
#include "function_types.hpp" #include "function_types.hpp"
#include "gta/fwddec.hpp" #include "gta/fwddec.hpp"
#include "gta/replay.hpp" #include "gta/replay.hpp"
#include "gta_pointers.hpp"
#include "memory/batch.hpp" #include "memory/batch.hpp"
#include "memory/byte_patch.hpp" #include "memory/byte_patch.hpp"
#include "memory/module.hpp" #include "memory/module.hpp"
#include "sc_pointers.hpp"
#include "services/gta_data/cache_file.hpp" #include "services/gta_data/cache_file.hpp"
#include "socialclub/ScInfo.hpp" #include "socialclub/ScInfo.hpp"
#include "util/compile_time_helpers.hpp" #include "util/compile_time_helpers.hpp"
#include "gta_pointers.hpp"
#include "sc_pointers.hpp"
namespace big namespace big
{ {
@ -18,7 +18,7 @@ namespace big
{ {
private: private:
template<cstxpr_str batch_name, auto batch_hash, size_t offset_of_cache_begin_field, size_t offset_of_cache_end_field, memory::batch batch> template<cstxpr_str batch_name, auto batch_hash, size_t offset_of_cache_begin_field, size_t offset_of_cache_end_field, memory::batch batch>
void write_to_cache_or_read_from_cache(cache_file& cache_file, const memory::module& mem_region, const bool found_version_cache) void write_to_cache_or_read_from_cache(cache_file& cache_file, const memory::module& mem_region)
{ {
static_assert(batch_hash > 0); static_assert(batch_hash > 0);
@ -26,7 +26,7 @@ namespace big
const uintptr_t pointer_to_cacheable_data_start = reinterpret_cast<uintptr_t>(this) + offset_of_cache_begin_field; const uintptr_t pointer_to_cacheable_data_start = reinterpret_cast<uintptr_t>(this) + offset_of_cache_begin_field;
if (!found_version_cache || !is_pointers_cache_up_to_date<batch_name>(cache_file, mem_region)) if (!is_pointers_cache_up_to_date<batch_name>(cache_file, mem_region))
{ {
run_batch<batch_name>(batch, mem_region); run_batch<batch_name>(batch, mem_region);
@ -68,7 +68,7 @@ namespace big
} }
else else
{ {
LOG(FATAL) << "Just tried to save to cache a pointer supposedly within the " << batch_name.str << " module range but wasnt !!!Offset from start of pointers instance : " << (field_ptr - reinterpret_cast<uintptr_t>(this)); LOG(FATAL) << "Just tried to save to cache a pointer supposedly within the " << batch_name.str << " module range but isn't! Offset from start of pointers instance: " << (field_ptr - reinterpret_cast<uintptr_t>(this));
} }
i++; i++;
@ -78,7 +78,7 @@ namespace big
cache_file.set_data(std::move(cache_data_ptr), data_size); cache_file.set_data(std::move(cache_data_ptr), data_size);
cache_file.set_header_version(m_game_version_uint32_t, m_online_version_float); cache_file.set_header_version(mem_region.size());
cache_file.write(); cache_file.write();
} }
@ -87,7 +87,7 @@ namespace big
{ {
cache_file.load(); cache_file.load();
if (cache_file.up_to_date(m_game_version_uint32_t, m_online_version_float)) if (cache_file.up_to_date(mem_region.size()))
{ {
LOG(INFO) << batch_name.str << " pointers cache is up to date, using it."; LOG(INFO) << batch_name.str << " pointers cache is up to date, using it.";
@ -124,16 +124,7 @@ namespace big
public: public:
HWND m_hwnd{}; HWND m_hwnd{};
// Those version pointers are not in the gta pointers struct due to always having to look for them in the binary
// (We use them as a way of checking if the cache needs to be updated or not on game updates)
const char* m_game_version;
const char* m_online_version;
uint32_t m_game_version_uint32_t;
float m_online_version_float;
gta_pointers m_gta; gta_pointers m_gta;
socialclub_pointers m_sc; socialclub_pointers m_sc;
}; };

View File

@ -12,4 +12,6 @@ namespace big
functions::start_get_presence_attributes m_start_get_presence_attributes; functions::start_get_presence_attributes m_start_get_presence_attributes;
}; };
#pragma pack(pop) #pragma pack(pop)
static_assert(sizeof(socialclub_pointers) % 8 == 0, "Pointers are not properly aligned");
} }

View File

@ -193,62 +193,52 @@ namespace big
void context_menu_service::get_entity_closest_to_screen_center() void context_menu_service::get_entity_closest_to_screen_center()
{ {
m_pointer = nullptr; m_pointer = nullptr;
if (const auto replay = *g_pointers->m_gta.m_replay_interface; replay) if (*g_pointers->m_gta.m_ped_pool && *g_pointers->m_gta.m_prop_pool && *g_pointers->m_gta.m_vehicle_pool
&& **g_pointers->m_gta.m_vehicle_pool)
{ {
const auto veh_interface = replay->m_vehicle_interface; double distance = 1;
const auto ped_interface = replay->m_ped_interface;
const auto obj_interface = replay->m_object_interface;
if (veh_interface && ped_interface && obj_interface) const auto get_closest_to_center = [this, &distance](auto entity_getter_func) -> auto
{ {
double distance = 1; rage::fvector2 screen_pos{};
bool got_an_entity = false;
const auto get_closest_to_center = [this, &distance](auto entity_list) -> auto for (const auto entity : entity_getter_func())
{ {
rage::fvector2 screen_pos{}; const auto temp_pointer = entity;
bool got_an_entity = false; if (!temp_pointer || !temp_pointer->m_navigation)
for (const auto entity : *entity_list) continue;
const auto temp_handle = g_pointers->m_gta.m_ptr_to_handle(temp_pointer);
const auto pos = temp_pointer->m_navigation->get_position();
HUD::GET_HUD_SCREEN_POSITION_FROM_WORLD_POSITION(pos->x, pos->y, pos->z, &screen_pos.x, &screen_pos.y);
const auto distance_from_middle = distance_to_middle_of_screen(screen_pos);
if (distance_from_middle < distance && ENTITY::HAS_ENTITY_CLEAR_LOS_TO_ENTITY(self::ped, temp_handle, 17) && temp_handle != self::ped)
{ {
const auto temp_pointer = entity.m_entity_ptr; m_handle = temp_handle;
if (!temp_pointer || !temp_pointer->m_navigation) m_pointer = temp_pointer;
continue; distance = distance_from_middle;
const auto temp_handle = g_pointers->m_gta.m_ptr_to_handle(temp_pointer); got_an_entity = true;
const auto pos = temp_pointer->m_navigation->get_position();
HUD::GET_HUD_SCREEN_POSITION_FROM_WORLD_POSITION(pos->x,
pos->y,
pos->z,
&screen_pos.x,
&screen_pos.y);
const auto distance_from_middle = distance_to_middle_of_screen(screen_pos);
if (distance_from_middle < distance && ENTITY::HAS_ENTITY_CLEAR_LOS_TO_ENTITY(self::ped, temp_handle, 17) && temp_handle != self::ped)
{
m_handle = temp_handle;
m_pointer = temp_pointer;
distance = distance_from_middle;
got_an_entity = true;
}
} }
return got_an_entity;
};
// I'm using bitwise OR instead or || to avoid compiler optimisation, all functions HAVE to execute
auto got_an_entity = get_closest_to_center(veh_interface->m_vehicle_list);
got_an_entity |= get_closest_to_center(ped_interface->m_ped_list);
got_an_entity |= get_closest_to_center(obj_interface->m_object_list);
if (got_an_entity)
{
// if the ped is driving a vehicle take their vehicle instead of the ped (aka. prevent jank)
if ((m_pointer->m_model_info->m_model_type == eModelType::Ped || m_pointer->m_model_info->m_model_type == eModelType::OnlineOnlyPed)
&& reinterpret_cast<CPed*>(m_pointer)->m_vehicle)
{
m_pointer = reinterpret_cast<CPed*>(m_pointer)->m_vehicle;
m_handle = g_pointers->m_gta.m_ptr_to_handle(m_pointer);
}
fill_model_bounding_box_screen_space();
} }
return got_an_entity;
};
// I'm using bitwise OR instead or || to avoid compiler optimisation, all functions HAVE to execute
auto got_an_entity = get_closest_to_center(pools::get_all_vehicles);
got_an_entity |= get_closest_to_center(pools::get_all_peds);
got_an_entity |= get_closest_to_center(pools::get_all_props);
if (got_an_entity)
{
// if the ped is driving a vehicle take their vehicle instead of the ped (aka. prevent jank)
if ((m_pointer->m_model_info->m_model_type == eModelType::Ped || m_pointer->m_model_info->m_model_type == eModelType::OnlineOnlyPed)
&& reinterpret_cast<CPed*>(m_pointer)->m_vehicle)
{
m_pointer = reinterpret_cast<CPed*>(m_pointer)->m_vehicle;
m_handle = g_pointers->m_gta.m_ptr_to_handle(m_pointer);
}
fill_model_bounding_box_screen_space();
} }
} }
} }

View File

@ -65,13 +65,12 @@ namespace big
return m_cache_header.m_data_size; return m_cache_header.m_data_size;
} }
bool cache_file::up_to_date(std::uint32_t game_version, float online_version) const bool cache_file::up_to_date(std::uint32_t file_version) const
{ {
if (!m_data) if (!m_data)
return false; return false;
return m_cache_version == m_cache_header.m_cache_version && game_version == m_cache_header.m_game_version return m_cache_version == m_cache_header.m_cache_version && file_version == m_cache_header.m_file_version;
&& online_version == m_cache_header.m_online_version;
} }
void cache_file::set_data(cache_data&& data, std::uint64_t data_size) void cache_file::set_data(cache_data&& data, std::uint64_t data_size)
@ -80,11 +79,10 @@ namespace big
m_cache_header.m_data_size = data_size; m_cache_header.m_data_size = data_size;
} }
void cache_file::set_header_version(std::uint32_t game_version, float online_version) void cache_file::set_header_version(std::uint32_t file_version)
{ {
m_cache_header.m_cache_version = m_cache_version; m_cache_header.m_cache_version = m_cache_version;
m_cache_header.m_game_version = game_version; m_cache_header.m_file_version = file_version;
m_cache_header.m_online_version = online_version;
} }
void cache_file::set_cache_version(std::uint32_t cache_version) void cache_file::set_cache_version(std::uint32_t cache_version)

View File

@ -7,8 +7,7 @@ namespace big
{ {
public: public:
std::uint32_t m_cache_version; std::uint32_t m_cache_version;
std::uint32_t m_game_version; std::uint32_t m_file_version;
float m_online_version;
std::uint64_t m_data_size; std::uint64_t m_data_size;
}; };
@ -55,7 +54,7 @@ namespace big
/// <param name="game_version">Current Game version</param> /// <param name="game_version">Current Game version</param>
/// <param name="online_version">Current Online version</param> /// <param name="online_version">Current Online version</param>
/// <returns>True if cache is up to date, false otherwise.</returns> /// <returns>True if cache is up to date, false otherwise.</returns>
bool up_to_date(std::uint32_t game_version, float online_version) const; bool up_to_date(std::uint32_t file_version) const;
void set_data(cache_data&& data, std::uint64_t data_size); void set_data(cache_data&& data, std::uint64_t data_size);
@ -64,7 +63,7 @@ namespace big
/// </summary> /// </summary>
/// <param name="game_version">Game Build</param> /// <param name="game_version">Game Build</param>
/// <param name="online_version">Online Version</param> /// <param name="online_version">Online Version</param>
void set_header_version(std::uint32_t game_version, float online_version); void set_header_version(std::uint32_t file_version);
void set_cache_version(std::uint32_t cache_version); void set_cache_version(std::uint32_t cache_version);

View File

@ -15,6 +15,11 @@
namespace big namespace big
{ {
inline bool is_crash_ped(rage::joaat_t hash)
{
return hash == RAGE_JOAAT("slod_human") || hash == RAGE_JOAAT("slod_small_quadped") || hash == RAGE_JOAAT("slod_large_quadped");
}
bool add_if_not_exists(string_vec& vec, std::string str) bool add_if_not_exists(string_vec& vec, std::string str)
{ {
if (std::find(vec.begin(), vec.end(), str) != vec.end()) if (std::find(vec.begin(), vec.end(), str) != vec.end())
@ -25,9 +30,9 @@ namespace big
} }
gta_data_service::gta_data_service() : gta_data_service::gta_data_service() :
m_peds_cache(g_file_manager->get_project_file("./cache/peds.bin"), 2), m_peds_cache(g_file_manager->get_project_file("./cache/peds.bin"), 3),
m_vehicles_cache(g_file_manager->get_project_file("./cache/vehicles.bin"), 1), m_vehicles_cache(g_file_manager->get_project_file("./cache/vehicles.bin"), 2),
m_weapons_cache(g_file_manager->get_project_file("./cache/weapons.bin"), 2), m_weapons_cache(g_file_manager->get_project_file("./cache/weapons.bin"), 3),
m_update_state(eGtaDataUpdateState::IDLE) m_update_state(eGtaDataUpdateState::IDLE)
{ {
if (!is_cache_up_to_date()) if (!is_cache_up_to_date())
@ -142,11 +147,9 @@ namespace big
m_vehicles_cache.load(); m_vehicles_cache.load();
m_weapons_cache.load(); m_weapons_cache.load();
const auto game_version = g_pointers->m_game_version_uint32_t; const auto file_version = memory::module("GTA5.exe").size();
const auto online_version = g_pointers->m_online_version_float;
return m_peds_cache.up_to_date(game_version, online_version) && m_vehicles_cache.up_to_date(game_version, online_version) return m_peds_cache.up_to_date(file_version) && m_vehicles_cache.up_to_date(file_version) && m_weapons_cache.up_to_date(file_version);
&& m_weapons_cache.up_to_date(game_version, online_version);
} }
void gta_data_service::load_data() void gta_data_service::load_data()
@ -223,6 +226,9 @@ namespace big
const auto name = item.child("Name").text().as_string(); const auto name = item.child("Name").text().as_string();
const auto hash = rage::joaat(name); const auto hash = rage::joaat(name);
if (is_crash_ped(hash))
continue;
if (std::find(mapped_peds.begin(), mapped_peds.end(), hash) != mapped_peds.end()) if (std::find(mapped_peds.begin(), mapped_peds.end(), hash) != mapped_peds.end())
continue; continue;
@ -411,6 +417,9 @@ namespace big
const auto name = file.stem().string(); const auto name = file.stem().string();
const auto hash = rage::joaat(name); const auto hash = rage::joaat(name);
if (is_crash_ped(hash))
continue;
if (std::find(mapped_peds.begin(), mapped_peds.end(), hash) != mapped_peds.end()) if (std::find(mapped_peds.begin(), mapped_peds.end(), hash) != mapped_peds.end())
continue; continue;
@ -484,15 +493,14 @@ namespace big
LOG(VERBOSE) << "Starting cache saving procedure..."; LOG(VERBOSE) << "Starting cache saving procedure...";
g_thread_pool->push([this, peds = std::move(peds), vehicles = std::move(vehicles), weapons = std::move(weapons)] { g_thread_pool->push([this, peds = std::move(peds), vehicles = std::move(vehicles), weapons = std::move(weapons)] {
const auto game_version = g_pointers->m_game_version_uint32_t; const auto file_version = memory::module("GTA5.exe").size();
const auto online_version = g_pointers->m_online_version_float;
{ {
const auto data_size = sizeof(ped_item) * peds.size(); const auto data_size = sizeof(ped_item) * peds.size();
m_peds_cache.set_data(std::make_unique<std::uint8_t[]>(data_size), data_size); m_peds_cache.set_data(std::make_unique<std::uint8_t[]>(data_size), data_size);
std::memcpy(m_peds_cache.data(), peds.data(), data_size); std::memcpy(m_peds_cache.data(), peds.data(), data_size);
m_peds_cache.set_header_version(game_version, online_version); m_peds_cache.set_header_version(file_version);
m_peds_cache.write(); m_peds_cache.write();
} }
@ -501,7 +509,7 @@ namespace big
m_vehicles_cache.set_data(std::make_unique<std::uint8_t[]>(data_size), data_size); m_vehicles_cache.set_data(std::make_unique<std::uint8_t[]>(data_size), data_size);
std::memcpy(m_vehicles_cache.data(), vehicles.data(), data_size); std::memcpy(m_vehicles_cache.data(), vehicles.data(), data_size);
m_vehicles_cache.set_header_version(game_version, online_version); m_vehicles_cache.set_header_version(file_version);
m_vehicles_cache.write(); m_vehicles_cache.write();
} }
@ -510,7 +518,7 @@ namespace big
m_weapons_cache.set_data(std::make_unique<std::uint8_t[]>(data_size), data_size); m_weapons_cache.set_data(std::make_unique<std::uint8_t[]>(data_size), data_size);
std::memcpy(m_weapons_cache.data(), weapons.data(), data_size); std::memcpy(m_weapons_cache.data(), weapons.data(), data_size);
m_weapons_cache.set_header_version(game_version, online_version); m_weapons_cache.set_header_version(file_version);
m_weapons_cache.write(); m_weapons_cache.write();
} }

View File

@ -6,35 +6,9 @@
namespace big namespace big
{ {
yim_fipackfile::yim_fipackfile(rage::fiPackfile* rpf, const std::string& mount_name) yim_fipackfile::yim_fipackfile(rage::fiPackfile* rpf)
{ {
this->rpf = rpf; this->rpf = rpf;
this->mount_name = mount_name;
}
std::vector<std::string> yim_fipackfile::get_non_dlc_mounted_devices_names()
{
std::vector<std::string> non_dlc_mounted_devices_names;
uint16_t mounted_devices_len = *g_pointers->m_gta.m_fidevices_len;
if (mounted_devices_len)
{
auto devices_arr = *(uint64_t*)g_pointers->m_gta.m_fidevices;
uint8_t** current_device_mount_name_ptr = *(unsigned __int8***)g_pointers->m_gta.m_fidevices;
auto device_i = 0;
while (true)
{
non_dlc_mounted_devices_names.push_back(*(const char**)current_device_mount_name_ptr);
++device_i;
current_device_mount_name_ptr += 4;
if (device_i >= mounted_devices_len)
break;
}
}
return non_dlc_mounted_devices_names;
} }
void yim_fipackfile::add_wrapper_call_back(std::function<size_t(yim_fipackfile& rpf_wrapper)> cb) void yim_fipackfile::add_wrapper_call_back(std::function<size_t(yim_fipackfile& rpf_wrapper)> cb)
@ -44,14 +18,6 @@ namespace big
void yim_fipackfile::for_each_fipackfile() void yim_fipackfile::for_each_fipackfile()
{ {
// the idea is to reuse existing mount points as much as possible because
// even when mounting / unmounting properly you'll get file errors
// and crashes if the rpf file was already mounted
// iterate the fidevice array which contains devices that are currently mounted
// the dlc devices are in another array
const auto non_dlc_mounted_devices_names = get_non_dlc_mounted_devices_names();
// for not hanging the game too much // for not hanging the game too much
constexpr auto yield_increment = 80; constexpr auto yield_increment = 80;
@ -66,57 +32,11 @@ namespace big
break; break;
} }
yim_fipackfile rpf_wrapper = yim_fipackfile(rpf, default_mount_name); yim_fipackfile rpf_wrapper = yim_fipackfile(rpf);
auto already_mounted = false; std::for_each(m_wrapper_call_back.begin(), m_wrapper_call_back.end(), [&rpf_wrapper](std::function<size_t(yim_fipackfile & rpf_wrapper)> cb) {
for (const auto& non_dlc_mounted_device_name : non_dlc_mounted_devices_names) cb(rpf_wrapper);
{ });
auto* non_dlc_mounted_device = rage::fiDevice::GetDevice(non_dlc_mounted_device_name.c_str(), true);
if (rpf == non_dlc_mounted_device)
{
rpf_wrapper.mount_name = non_dlc_mounted_device_name;
already_mounted = true;
}
}
if (!already_mounted)
{
size_t acc = 0;
static std::vector<std::string> mount_names = {"memory:/", "memory:", "dlc", "dlc:", "dlc:/", "dlcpacks:/", "common:/", "commoncrc:/", "update:/", "update2:/", "platform:/", "platformcrc:/", "gamecache:/"};
for (auto& mount_name : mount_names)
{
rpf_wrapper.mount_name = mount_name;
if (auto count = rpf_wrapper.get_file_paths().size())
{
acc += count;
std::for_each(m_wrapper_call_back.begin(), m_wrapper_call_back.end(), [&rpf_wrapper](std::function<size_t(yim_fipackfile & rpf_wrapper)> cb) {
cb(rpf_wrapper);
});
}
}
// if we got nothing with those mount points for this rpf, mount it
if (!acc)
{
rpf_wrapper.mount_name = default_mount_name;
rpf->Mount(default_mount_name);
std::for_each(m_wrapper_call_back.begin(), m_wrapper_call_back.end(), [&rpf_wrapper](std::function<size_t(yim_fipackfile & rpf_wrapper)> cb) {
cb(rpf_wrapper);
});
g_pointers->m_gta.m_fipackfile_unmount(default_mount_name);
}
}
else
{
std::for_each(m_wrapper_call_back.begin(), m_wrapper_call_back.end(), [&rpf_wrapper](std::function<size_t(yim_fipackfile & rpf_wrapper)> cb) {
cb(rpf_wrapper);
});
}
if (i % yield_increment == 0) if (i % yield_increment == 0)
script::get_current()->yield(); script::get_current()->yield();
@ -127,7 +47,7 @@ namespace big
{ {
std::vector<std::filesystem::path> file_paths; std::vector<std::filesystem::path> file_paths;
if (parent.empty()) if (parent.empty())
parent = mount_name; parent = "/";
std::vector<std::string> directories; std::vector<std::string> directories;
@ -137,7 +57,12 @@ namespace big
{ {
do do
{ {
std::string fn = std::string(parent.c_str()) + std::string("/") + std::string(findData.fileName); std::string fn;
if (parent == "/")
fn = std::string(parent.c_str()) + std::string(findData.fileName);
else
fn = std::string(parent.c_str()) + std::string("/") + std::string(findData.fileName);
if (findData.fileAttributes & FILE_ATTRIBUTE_DIRECTORY) if (findData.fileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{ {

View File

@ -4,15 +4,13 @@
namespace big namespace big
{ {
using file_contents_callback = std::function<void(const std::unique_ptr<std::uint8_t[]>& file_content, const int data_size)>; using file_contents_callback = std::function<void(const std::unique_ptr<std::uint8_t[]>& file_content, const int data_size)>;
class yim_fipackfile class yim_fipackfile
{ {
static constexpr auto default_mount_name = "yimM:/";
rage::fiPackfile* rpf; rage::fiPackfile* rpf;
std::string mount_name;
public: public:
explicit yim_fipackfile(rage::fiPackfile* rpf, const std::string& mount_name); explicit yim_fipackfile(rage::fiPackfile* rpf);
static std::vector<std::string> get_non_dlc_mounted_devices_names(); static std::vector<std::string> get_non_dlc_mounted_devices_names();
@ -29,7 +27,5 @@ namespace big
void read_file(const std::filesystem::path& path, file_contents_callback&& cb); void read_file(const std::filesystem::path& path, file_contents_callback&& cb);
void read_xml_file(const std::filesystem::path& path, std::function<void(pugi::xml_document& doc)> cb); void read_xml_file(const std::filesystem::path& path, std::function<void(pugi::xml_document& doc)> cb);
private:
}; };
} }

View File

@ -15,11 +15,11 @@ namespace big
register_hotkey("beastjump", g.settings.hotkeys.beastjump, RAGE_JOAAT("beastjump")); register_hotkey("beastjump", g.settings.hotkeys.beastjump, RAGE_JOAAT("beastjump"));
register_hotkey("bringpv", g.settings.hotkeys.bringvehicle, RAGE_JOAAT("bringpv")); register_hotkey("bringpv", g.settings.hotkeys.bringvehicle, RAGE_JOAAT("bringpv"));
register_hotkey("quicksearch", g.settings.hotkeys.cmd_excecutor, RAGE_JOAAT("cmdexecutor")); register_hotkey("quicksearch", g.settings.hotkeys.cmd_excecutor, RAGE_JOAAT("cmdexecutor"));
register_hotkey("fastrun", g.settings.hotkeys.teleport_waypoint, RAGE_JOAAT("fastrun")); register_hotkey("fastrun", g.settings.hotkeys.superrun, RAGE_JOAAT("fastrun"));
register_hotkey("fastquit", g.settings.hotkeys.fast_quit, RAGE_JOAAT("fastquit")); register_hotkey("fastquit", g.settings.hotkeys.fast_quit, RAGE_JOAAT("fastquit"));
register_hotkey("fillammo", g.settings.hotkeys.fill_ammo, RAGE_JOAAT("fillammo")); register_hotkey("fillammo", g.settings.hotkeys.fill_ammo, RAGE_JOAAT("fillammo"));
register_hotkey("fillsnacks", g.settings.hotkeys.fill_inventory, RAGE_JOAAT("fillsnacks")); register_hotkey("fillsnacks", g.settings.hotkeys.fill_inventory, RAGE_JOAAT("fillsnacks"));
register_hotkey("freecam", g.settings.hotkeys.teleport_waypoint, RAGE_JOAAT("freecam")); register_hotkey("freecam", g.settings.hotkeys.freecam, RAGE_JOAAT("freecam"));
register_hotkey("heal", g.settings.hotkeys.heal, RAGE_JOAAT("heal")); register_hotkey("heal", g.settings.hotkeys.heal, RAGE_JOAAT("heal"));
register_hotkey("invis", g.settings.hotkeys.invis, RAGE_JOAAT("invis")); register_hotkey("invis", g.settings.hotkeys.invis, RAGE_JOAAT("invis"));
register_hotkey("invisveh", g.settings.hotkeys.invisveh, RAGE_JOAAT("invisveh")); register_hotkey("invisveh", g.settings.hotkeys.invisveh, RAGE_JOAAT("invisveh"));

View File

@ -1,9 +1,9 @@
#include "locals_service.hpp" #include "locals_service.hpp"
#include "core/data/all_script_names.hpp" #include "core/data/all_script_names.hpp"
#include "fiber_pool.hpp"
#include "natives.hpp" #include "natives.hpp"
#include "pointers.hpp" #include "pointers.hpp"
#include "fiber_pool.hpp"
namespace big namespace big
{ {
@ -19,12 +19,13 @@ namespace big
bool locals_service::does_script_exist(std::string script_name) bool locals_service::does_script_exist(std::string script_name)
{ {
// TODO: find a better way to check script validity
for (auto s : all_script_names) for (auto s : all_script_names)
if (script_name == s) if (script_name == s)
return true; return true;
bool script_exists = false;
g_fiber_pool->queue_job([&] {script_exists = SCRIPT::DOES_SCRIPT_EXIST(script_name.data());}); return false;
return script_exists;
} }
std::filesystem::path locals_service::get_path() std::filesystem::path locals_service::get_path()

View File

@ -65,7 +65,7 @@ namespace big
{ {
script_local actual_local = script_local(m_script_thread, m_base_address); script_local actual_local = script_local(m_script_thread, m_base_address);
for (auto offset : m_offsets) for (auto& offset : m_offsets)
{ {
if (offset.m_size > 0) if (offset.m_size > 0)
actual_local = actual_local.at(offset.m_offset, offset.m_size); actual_local = actual_local.at(offset.m_offset, offset.m_size);

View File

@ -14,7 +14,7 @@
namespace big namespace big
{ {
bool_command g_orbital_drone("orbitaldrone", "Toggle orbital drone", "Enables/Disables the orbital drone.", bool_command g_orbital_drone("orbitaldrone", "Toggle Orbital Drone", "Enables/Disables the orbital drone",
g.world.orbital_drone.enabled); g.world.orbital_drone.enabled);
static bool nav_override; static bool nav_override;
@ -28,12 +28,10 @@ namespace big
return; return;
} }
if (*g_pointers->m_gta.m_is_session_started && gta_util::get_network_player_mgr()->m_local_net_player if (g_local_player)
&& gta_util::get_network_player_mgr()->m_local_net_player->m_player_info->m_ped)
{ {
scr_globals::globalplayer_bd.as<GlobalPlayerBD*>()->Entries[self::id].OrbitalBitset.Set(eOrbitalBitset::kOrbitalCannonActive); scr_globals::globalplayer_bd.as<GlobalPlayerBD*>()->Entries[self::id].OrbitalBitset.Set(eOrbitalBitset::kOrbitalCannonActive);
const auto player_pos = const auto player_pos = *g_local_player->get_position();
*gta_util::get_network_player_mgr()->m_local_net_player->m_player_info->m_ped->m_navigation->get_position();
m_start_pos = {player_pos.x, player_pos.y, player_pos.z}; m_start_pos = {player_pos.x, player_pos.y, player_pos.z};
@ -69,7 +67,7 @@ namespace big
{ {
m_initialized = false; m_initialized = false;
Entity self = PLAYER::PLAYER_PED_ID(); Entity self = self::ped;
if (PED::IS_PED_IN_ANY_VEHICLE(self, true)) if (PED::IS_PED_IN_ANY_VEHICLE(self, true))
self = PED::GET_VEHICLE_PED_IS_IN(self, false); self = PED::GET_VEHICLE_PED_IS_IN(self, false);
@ -102,7 +100,7 @@ namespace big
m_lock_ent = -1; m_lock_ent = -1;
m_lock = false; m_lock = false;
scr_globals::globalplayer_bd.as<GlobalPlayerBD*>()->Entries[PLAYER::PLAYER_ID()].OrbitalBitset.Clear(eOrbitalBitset::kOrbitalCannonActive); scr_globals::globalplayer_bd.as<GlobalPlayerBD*>()->Entries[self::id].OrbitalBitset.Clear(eOrbitalBitset::kOrbitalCannonActive);
m_should_tp = false; m_should_tp = false;
} }
@ -292,7 +290,7 @@ namespace big
m_lock_ent = entity::get_entity_closest_to_middle_of_screen(); m_lock_ent = entity::get_entity_closest_to_middle_of_screen();
m_lock = true; m_lock = true;
if (g.world.orbital_drone.detect_player) if (*g_pointers->m_gta.m_is_session_started && g.world.orbital_drone.detect_player)
detect_player(m_lock_ent); detect_player(m_lock_ent);
} }
@ -378,8 +376,8 @@ namespace big
Vector3 campos = CAM::GET_CAM_COORD(m_cam); Vector3 campos = CAM::GET_CAM_COORD(m_cam);
Vector3 entpos = ENTITY::GET_ENTITY_COORDS(entity::get_entity_closest_to_middle_of_screen(), 0); Vector3 entpos = ENTITY::GET_ENTITY_COORDS(entity::get_entity_closest_to_middle_of_screen(), 0);
if (g_player_service->get_selected()->is_valid() if (*g_pointers->m_gta.m_is_session_started && g_player_service->get_selected()->is_valid()
&&ENTITY::DOES_ENTITY_EXIST(g_pointers->m_gta.m_ptr_to_handle(g_player_service->get_selected()->get_ped()))) && ENTITY::DOES_ENTITY_EXIST(g_pointers->m_gta.m_ptr_to_handle(g_player_service->get_selected()->get_ped())))
{ {
toxic::blame_explode_coord(g_player_service->get_selected(), m_ground_pos, eExplosionTag::EXP_TAG_ORBITAL_CANNON, 1.f, TRUE, TRUE, 1.f); toxic::blame_explode_coord(g_player_service->get_selected(), m_ground_pos, eExplosionTag::EXP_TAG_ORBITAL_CANNON, 1.f, TRUE, TRUE, 1.f);
@ -388,9 +386,9 @@ namespace big
} }
else else
{ {
toxic::blame_explode_coord(g_player_service->get_self(), m_ground_pos, eExplosionTag::EXP_TAG_ORBITAL_CANNON, 1.f, TRUE, TRUE, 1.f); toxic::blame_explode_coord(*g_pointers->m_gta.m_is_session_started ? g_player_service->get_self() : nullptr, m_ground_pos, eExplosionTag::EXP_TAG_ORBITAL_CANNON, 1.f, TRUE, TRUE, 1.f);
if (MISC::GET_DISTANCE_BETWEEN_COORDS(campos.x, campos.y, campos.z, entpos.x, entpos.y, entpos.z, false) < 10) if (MISC::GET_DISTANCE_BETWEEN_COORDS(campos.x, campos.y, campos.z, entpos.x, entpos.y, entpos.z, false) < 10)
toxic::blame_explode_coord(g_player_service->get_self(), entpos, eExplosionTag::EXP_TAG_ORBITAL_CANNON, 1.f, TRUE, TRUE, 1.f); toxic::blame_explode_coord(*g_pointers->m_gta.m_is_session_started ? g_player_service->get_self() : nullptr, entpos, eExplosionTag::EXP_TAG_ORBITAL_CANNON, 1.f, TRUE, TRUE, 1.f);
} }

View File

@ -335,18 +335,11 @@ namespace big
nlohmann::json persist_car_service::get_model_attachments(Vehicle vehicle, bool is_towed_vehicle) nlohmann::json persist_car_service::get_model_attachments(Vehicle vehicle, bool is_towed_vehicle)
{ {
const auto replay_interface = *g_pointers->m_gta.m_replay_interface;
std::vector<nlohmann::json> attached_objects; std::vector<nlohmann::json> attached_objects;
const auto object_interface = replay_interface->m_object_interface; for (auto obj : pools::get_all_props())
for (int i = 0; i < object_interface->m_max_objects; i++)
{ {
const auto object_ptr = object_interface->get_object(i); const auto object = g_pointers->m_gta.m_ptr_to_handle(obj);
if (!object_ptr)
continue;
const auto object = g_pointers->m_gta.m_ptr_to_handle(object_ptr);
if (!object) if (!object)
break; break;
@ -354,7 +347,7 @@ namespace big
continue; continue;
// Don't save tow hook. // Don't save tow hook.
if (is_towed_vehicle && ENTITY::GET_ENTITY_MODEL(object) == 0xBC344305) if (is_towed_vehicle && ENTITY::GET_ENTITY_MODEL(object) == RAGE_JOAAT("prop_v_hook_s"))
continue; continue;
attached_objects.push_back(get_model_attachment(vehicle, object)); attached_objects.push_back(get_model_attachment(vehicle, object));
@ -365,22 +358,14 @@ namespace big
nlohmann::json persist_car_service::get_vehicle_attachents(Vehicle vehicle) nlohmann::json persist_car_service::get_vehicle_attachents(Vehicle vehicle)
{ {
const auto replay_interface = *g_pointers->m_gta.m_replay_interface;
const auto vehicle_interface = replay_interface->m_vehicle_interface;
std::vector<nlohmann::json> attached_vehicles; std::vector<nlohmann::json> attached_vehicles;
Vehicle trailer; Vehicle trailer;
VEHICLE::GET_VEHICLE_TRAILER_VEHICLE(vehicle, &trailer); VEHICLE::GET_VEHICLE_TRAILER_VEHICLE(vehicle, &trailer);
for (int i = 0; i < vehicle_interface->m_max_vehicles; i++) for (auto veh : pools::get_all_vehicles())
{ {
const auto vehicle_ptr = vehicle_interface->get_vehicle(i); const auto object = g_pointers->m_gta.m_ptr_to_handle(veh);
if (!vehicle_ptr)
continue;
const auto object = g_pointers->m_gta.m_ptr_to_handle(vehicle_ptr);
if (!object) if (!object)
break; break;

View File

@ -4,6 +4,7 @@
#include "gta_util.hpp" #include "gta_util.hpp"
#include "math.hpp" #include "math.hpp"
#include "natives.hpp" #include "natives.hpp"
#include "pools.hpp"
#include "script.hpp" #include "script.hpp"
namespace big::entity namespace big::entity
@ -101,48 +102,27 @@ namespace big::entity
{ {
std::vector<Entity> target_entities; std::vector<Entity> target_entities;
target_entities.clear(); target_entities.clear();
const auto replay_interface = *g_pointers->m_gta.m_replay_interface;
if (!replay_interface)
return target_entities;
if (vehicles) if (vehicles)
{ {
const auto vehicle_interface = replay_interface->m_vehicle_interface; for (auto vehicle : pools::get_all_vehicles())
for (int i = 0; i < vehicle_interface->m_max_vehicles; i++)
{ {
const auto vehicle_ptr = vehicle_interface->get_vehicle(i); if (vehicle == gta_util::get_local_vehicle())
if (!vehicle_ptr)
continue; continue;
if (vehicle_ptr == gta_util::get_local_vehicle()) target_entities.push_back(g_pointers->m_gta.m_ptr_to_handle(vehicle));
continue;
const auto veh = g_pointers->m_gta.m_ptr_to_handle(vehicle_ptr);
if (!veh)
break;
target_entities.push_back(veh);
} }
} }
if (peds) if (peds)
{ {
const auto ped_interface = replay_interface->m_ped_interface; for (auto ped : pools::get_all_peds())
for (int i = 0; i < ped_interface->m_max_peds; i++)
{ {
const auto ped_ptr = ped_interface->get_ped(i); // make sure to not include ourselves
if (!ped_ptr) if (ped == gta_util::get_local_ped())
continue; continue;
//make sure to don't include ourselves target_entities.push_back(g_pointers->m_gta.m_ptr_to_handle(ped));
if (ped_ptr == gta_util::get_local_ped())
continue;
const auto ped = g_pointers->m_gta.m_ptr_to_handle(ped_ptr);
if (!ped)
break;
target_entities.push_back(ped);
} }
} }
return target_entities; return target_entities;
@ -200,15 +180,13 @@ namespace big::entity
Entity closest_entity{}; Entity closest_entity{};
float distance = 1; float distance = 1;
auto replayInterface = *g_pointers->m_gta.m_replay_interface; auto replayInterface = *g_pointers->m_gta.m_replay_interface;
auto vehicleInterface = replayInterface->m_vehicle_interface;
auto pedInterface = replayInterface->m_ped_interface;
for (const auto veh : (*vehicleInterface->m_vehicle_list)) for (const auto veh : pools::get_all_vehicles())
{ {
if (veh.m_entity_ptr) if (veh)
{ {
Vehicle handle = g_pointers->m_gta.m_ptr_to_handle(veh.m_entity_ptr); Vehicle handle = g_pointers->m_gta.m_ptr_to_handle(veh);
Vector3 pos = ENTITY::GET_ENTITY_COORDS(handle, 1); Vector3 pos = ENTITY::GET_ENTITY_COORDS(handle, 1);
rage::fvector2 screenpos; rage::fvector2 screenpos;
HUD::GET_HUD_SCREEN_POSITION_FROM_WORLD_POSITION(pos.x, pos.y, pos.z, &screenpos.x, &screenpos.y); HUD::GET_HUD_SCREEN_POSITION_FROM_WORLD_POSITION(pos.x, pos.y, pos.z, &screenpos.x, &screenpos.y);
@ -221,11 +199,11 @@ namespace big::entity
} }
} }
for (auto ped : *pedInterface->m_ped_list) for (auto ped : pools::get_all_peds())
{ {
if (ped.m_entity_ptr) if (ped)
{ {
Vehicle handle = g_pointers->m_gta.m_ptr_to_handle(ped.m_entity_ptr); Vehicle handle = g_pointers->m_gta.m_ptr_to_handle(ped);
Vector3 pos = ENTITY::GET_ENTITY_COORDS(handle, 1); Vector3 pos = ENTITY::GET_ENTITY_COORDS(handle, 1);
rage::fvector2 screenpos; rage::fvector2 screenpos;
HUD::GET_HUD_SCREEN_POSITION_FROM_WORLD_POSITION(pos.x, pos.y, pos.z, &screenpos.x, &screenpos.y); HUD::GET_HUD_SCREEN_POSITION_FROM_WORLD_POSITION(pos.x, pos.y, pos.z, &screenpos.x, &screenpos.y);

View File

@ -70,6 +70,9 @@ namespace big::notify
{ {
int scaleform = GRAPHICS::REQUEST_SCALEFORM_MOVIE("MULTIPLAYER_CHAT"); int scaleform = GRAPHICS::REQUEST_SCALEFORM_MOVIE("MULTIPLAYER_CHAT");
while (!GRAPHICS::HAS_SCALEFORM_MOVIE_LOADED(scaleform))
script::get_current()->yield();
GRAPHICS::BEGIN_SCALEFORM_MOVIE_METHOD(scaleform, "ADD_MESSAGE"); GRAPHICS::BEGIN_SCALEFORM_MOVIE_METHOD(scaleform, "ADD_MESSAGE");
GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_PLAYER_NAME_STRING(player_name); // player name GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_PLAYER_NAME_STRING(player_name); // player name
GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_LITERAL_STRING(msg); // content GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_LITERAL_STRING(msg); // content
@ -88,7 +91,7 @@ namespace big::notify
GRAPHICS::DRAW_SCALEFORM_MOVIE_FULLSCREEN(scaleform, 255, 255, 255, 255, 0); GRAPHICS::DRAW_SCALEFORM_MOVIE_FULLSCREEN(scaleform, 255, 255, 255, 255, 0);
//fix broken scaleforms, when chat alrdy opened // fix broken scaleforms, when chat alrdy opened
if (const auto chat_data = *g_pointers->m_gta.m_chat_data; chat_data && (chat_data->m_chat_open || chat_data->m_timer_two)) if (const auto chat_data = *g_pointers->m_gta.m_chat_data; chat_data && (chat_data->m_chat_open || chat_data->m_timer_two))
HUD::CLOSE_MP_TEXT_CHAT(); HUD::CLOSE_MP_TEXT_CHAT();
} }

34
src/util/pools.hpp Normal file
View File

@ -0,0 +1,34 @@
#include "gta/pools.hpp"
namespace big::pools
{
inline auto& get_all_peds()
{
return **g_pointers->m_gta.m_ped_pool;
}
inline auto& get_all_vehicles()
{
return ***g_pointers->m_gta.m_vehicle_pool;
}
inline auto& get_all_props()
{
return **g_pointers->m_gta.m_prop_pool;
}
inline auto get_all_peds_array()
{
return get_all_peds().to_array();
}
inline auto get_all_vehicles_array()
{
return get_all_vehicles().to_array();
}
inline auto get_all_props_array()
{
return get_all_props().to_array();
}
};

View File

@ -28,7 +28,16 @@ namespace big::toxic
explosion_anti_cheat_bypass::m_can_blame_others->apply(); explosion_anti_cheat_bypass::m_can_blame_others->apply();
explosion_anti_cheat_bypass::m_can_use_blocked_explosions->apply(); explosion_anti_cheat_bypass::m_can_use_blocked_explosions->apply();
FIRE::ADD_OWNED_EXPLOSION(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(to_blame->id()), pos.x, pos.y, pos.z, (int)explosion_type, damage, is_audible, is_invisible, camera_shake); FIRE::ADD_OWNED_EXPLOSION(
(*g_pointers->m_gta.m_is_session_started && to_blame) ? PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(to_blame->id()) : 0,
pos.x,
pos.y,
pos.z,
(int)explosion_type,
damage,
is_audible,
is_invisible,
camera_shake);
explosion_anti_cheat_bypass::m_can_use_blocked_explosions->restore(); explosion_anti_cheat_bypass::m_can_use_blocked_explosions->restore();
explosion_anti_cheat_bypass::m_can_blame_others->restore(); explosion_anti_cheat_bypass::m_can_blame_others->restore();
@ -83,7 +92,7 @@ namespace big::toxic
peer, peer,
(*g_pointers->m_gta.m_network_time)->m_connection_identifier, (*g_pointers->m_gta.m_network_time)->m_connection_identifier,
&msg, &msg,
0x1000000);// repeatedly spamming the event will eventually cause certain bounds checks to disable for some reason 0x1000000); // repeatedly spamming the event will eventually cause certain bounds checks to disable for some reason
} }
return true; return true;

View File

@ -8,31 +8,12 @@
namespace big::train namespace big::train
{ {
inline auto get_all_vehicles()
{
std::vector<Vehicle> result;
rage::CReplayInterface* CReplayInterface_var = *g_pointers->m_gta.m_replay_interface;
for (int i = 0; i < 300; i++)
{
auto vehicle_ptr = CReplayInterface_var->m_vehicle_interface->get_vehicle(i);
if (vehicle_ptr)
{
Vehicle vehicle_handle = g_pointers->m_gta.m_ptr_to_handle(vehicle_ptr);
result.push_back(vehicle_handle);
}
}
return result;
};
inline int get_closest_train() inline int get_closest_train()
{ {
auto allVehicles = get_all_vehicles(); for (auto veh : pools::get_all_vehicles())
for (int i = 0; i < allVehicles.size(); i++)
{ {
if (ENTITY::GET_ENTITY_MODEL(allVehicles[i]) == 1030400667) if (veh->m_model_info->m_hash == RAGE_JOAAT("freight"))
return allVehicles[i]; return g_pointers->m_gta.m_ptr_to_handle(veh);
} }
return 0; return 0;
} }

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "core/scr_globals.hpp" #include "core/scr_globals.hpp"
#include "entity.hpp" #include "entity.hpp"
#include "gta/enums.hpp"
#include "gta/joaat.hpp" #include "gta/joaat.hpp"
#include "gta/vehicle_values.hpp" #include "gta/vehicle_values.hpp"
#include "math.hpp" #include "math.hpp"
@ -9,7 +10,6 @@
#include "script.hpp" #include "script.hpp"
#include "script_global.hpp" #include "script_global.hpp"
#include "services/vehicle_helper/vehicle_helper.hpp" #include "services/vehicle_helper/vehicle_helper.hpp"
#include "gta/enums.hpp"
namespace big::vehicle namespace big::vehicle
{ {
@ -105,43 +105,33 @@ namespace big::vehicle
inline Vehicle get_closest_to_location(Vector3 location, float range) inline Vehicle get_closest_to_location(Vector3 location, float range)
{ {
if (const auto replay = *g_pointers->m_gta.m_replay_interface; replay) float min_dist = FLT_MAX;
int32_t m_handle = 0;
for (const auto veh_entity : pools::get_all_vehicles())
{ {
if (const auto veh_interface = replay->m_vehicle_interface; veh_interface) const auto veh_ptr = veh_entity;
if (!veh_ptr || !veh_ptr->m_navigation)
continue;
auto veh_pos_arr = *veh_ptr->m_navigation->get_position();
Vector3 veh_pos(veh_pos_arr.x, veh_pos_arr.y, veh_pos_arr.z);
float dist = math::distance_between_vectors(veh_pos, location);
if (dist < min_dist)
{ {
const auto veh_interface_size = veh_interface->m_max_vehicles; int32_t tmp_handle = g_pointers->m_gta.m_ptr_to_handle(veh_ptr);
float min_dist = FLT_MAX; if (entity::take_control_of(tmp_handle))
int32_t m_handle = 0;
for (const auto veh_entity : *veh_interface->m_vehicle_list)
{ {
const auto veh_ptr = veh_entity.m_entity_ptr; min_dist = dist;
if (!veh_ptr || !veh_ptr->m_navigation) m_handle = tmp_handle;
continue;
auto veh_pos_arr = *veh_ptr->m_navigation->get_position();
Vector3 veh_pos(veh_pos_arr.x, veh_pos_arr.y, veh_pos_arr.z);
float dist = math::distance_between_vectors(veh_pos, location);
if (dist < min_dist)
{
int32_t tmp_handle = g_pointers->m_gta.m_ptr_to_handle(veh_ptr);
if (entity::take_control_of(tmp_handle))
{
min_dist = dist;
m_handle = tmp_handle;
}
}
} }
return m_handle;
} }
} }
return 0; return m_handle;
} }
inline bool set_plate(Vehicle veh, const char* plate) inline bool set_plate(Vehicle veh, const char* plate)
@ -331,7 +321,7 @@ namespace big::vehicle
owned_mods[MOD_TIRESMOKE_COL_R] = *vehicle_idx.at(62).as<int32_t*>(); owned_mods[MOD_TIRESMOKE_COL_R] = *vehicle_idx.at(62).as<int32_t*>();
owned_mods[MOD_TIRESMOKE_COL_G] = *vehicle_idx.at(63).as<int32_t*>(); owned_mods[MOD_TIRESMOKE_COL_G] = *vehicle_idx.at(63).as<int32_t*>();
owned_mods[MOD_TIRESMOKE_COL_B] = *vehicle_idx.at(64).as<int32_t*>(); owned_mods[MOD_TIRESMOKE_COL_B] = *vehicle_idx.at(64).as<int32_t*>();
owned_mods[MOD_TYRE_SMOKE] = !(owned_mods[MOD_TIRESMOKE_COL_R] == 255 && owned_mods[MOD_TIRESMOKE_COL_G] == 255 && owned_mods[MOD_TIRESMOKE_COL_B] == 255); owned_mods[MOD_TYRE_SMOKE] = !(owned_mods[MOD_TIRESMOKE_COL_R] == 255 && owned_mods[MOD_TIRESMOKE_COL_G] == 255 && owned_mods[MOD_TIRESMOKE_COL_B] == 255);
// XENON // XENON
@ -702,7 +692,7 @@ namespace big::vehicle
if (VEHICLE::GET_IS_DOOR_VALID(veh, (int)doorId)) if (VEHICLE::GET_IS_DOOR_VALID(veh, (int)doorId))
VEHICLE::SET_VEHICLE_INDIVIDUAL_DOORS_LOCKED(veh, (int)doorId, (int)state); VEHICLE::SET_VEHICLE_INDIVIDUAL_DOORS_LOCKED(veh, (int)doorId, (int)state);
return VEHICLE::GET_VEHICLE_INDIVIDUAL_DOOR_LOCK_STATUS(veh, (int) doorId) == (int)state; return VEHICLE::GET_VEHICLE_INDIVIDUAL_DOOR_LOCK_STATUS(veh, (int)doorId) == (int)state;
} }
} }
@ -715,10 +705,9 @@ namespace big::vehicle
*/ */
inline bool operate_vehicle_door(Vehicle veh, eDoorId doorId, bool open) inline bool operate_vehicle_door(Vehicle veh, eDoorId doorId, bool open)
{ {
bool success = false; bool success = false;
if (ENTITY::DOES_ENTITY_EXIST(veh)) if (ENTITY::DOES_ENTITY_EXIST(veh))
{ {
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
{ {
if (doorId == eDoorId::VEH_EXT_DOOR_INVALID_ID || (int)doorId == i) if (doorId == eDoorId::VEH_EXT_DOOR_INVALID_ID || (int)doorId == i)
@ -756,11 +745,10 @@ namespace big::vehicle
*/ */
inline bool operate_vehicle_neons(Vehicle veh, int index, bool toggle) inline bool operate_vehicle_neons(Vehicle veh, int index, bool toggle)
{ {
bool success = false; bool success = false;
if (ENTITY::DOES_ENTITY_EXIST(veh)) if (ENTITY::DOES_ENTITY_EXIST(veh))
{ {
VEHICLE::SET_VEHICLE_MOD_KIT(veh, 0); VEHICLE::SET_VEHICLE_MOD_KIT(veh, 0);
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
if (index == -1 || index == i) if (index == -1 || index == i)

View File

@ -26,6 +26,7 @@ namespace big
ImGui::Text(std::format("Players: {}/{}", network_player_mgr->m_player_count, network_player_mgr->m_player_limit) ImGui::Text(std::format("Players: {}/{}", network_player_mgr->m_player_count, network_player_mgr->m_player_limit)
.c_str()); .c_str());
// can't easily get used item count using pools, so keeping replay interface for now
if (auto replay_interface = *g_pointers->m_gta.m_replay_interface; g.window.ingame_overlay.show_replay_interface) if (auto replay_interface = *g_pointers->m_gta.m_replay_interface; g.window.ingame_overlay.show_replay_interface)
{ {
ImGui::Separator(); ImGui::Separator();
@ -52,8 +53,8 @@ namespace big
if (g.window.ingame_overlay.show_game_versions) if (g.window.ingame_overlay.show_game_versions)
{ {
ImGui::Separator(); ImGui::Separator();
ImGui::Text(std::format("Game Version: {}", g_pointers->m_game_version).c_str()); ImGui::Text(std::format("Game Version: {}", g_pointers->m_gta.m_game_version).c_str());
ImGui::Text(std::format("Online Version: {}", g_pointers->m_online_version).c_str()); ImGui::Text(std::format("Online Version: {}", g_pointers->m_gta.m_online_version).c_str());
} }
} }
ImGui::End(); ImGui::End();

View File

@ -33,7 +33,7 @@ namespace big
static int base_address = 0; static int base_address = 0;
static bool freeze = false; static bool freeze = false;
static char name[32] = ""; static char name[32] = "";
static int(*offsets)[2] = nullptr; static int offsets[10][2] = {};
static int offset_count = 0; static int offset_count = 0;
static int previous_offset_count = 0; static int previous_offset_count = 0;
@ -46,21 +46,7 @@ namespace big
ImGui::Text("DEBUG_GLOBAL_OFFSET_COUNT"_T.data()); ImGui::Text("DEBUG_GLOBAL_OFFSET_COUNT"_T.data());
ImGui::InputInt("##modal_offset_count", &offset_count); ImGui::InputInt("##modal_offset_count", &offset_count);
if (offset_count < 0) offset_count = std::clamp(offset_count, 0, 10);
offset_count = 0;
else if (offset_count > 10)
offset_count = 10;
if (offset_count != previous_offset_count)
{
int(*new_offsets)[2] = new int[offset_count][2]{0};
memcpy(new_offsets, offsets, sizeof(int) * std::min(offset_count, previous_offset_count) * 2);
delete[] offsets;
offsets = new_offsets;
previous_offset_count = offset_count;
}
ImGui::PushItemWidth(320.f); ImGui::PushItemWidth(320.f);
for (int i = 0; i < offset_count; i++) for (int i = 0; i < offset_count; i++)
@ -83,9 +69,7 @@ namespace big
if (components::button("CANCEL"_T)) if (components::button("CANCEL"_T))
{ {
strcpy(name, ""); strcpy(name, "");
freeze = false; freeze = false;
delete[] offsets;
offsets = nullptr;
offset_count = 0; offset_count = 0;
previous_offset_count = 0; previous_offset_count = 0;
@ -100,9 +84,7 @@ namespace big
g_globals_service->m_globals.push_back(new_global); g_globals_service->m_globals.push_back(new_global);
strcpy(name, ""); strcpy(name, "");
freeze = false; freeze = false;
delete[] offsets;
offsets = nullptr;
offset_count = 0; offset_count = 0;
previous_offset_count = 0; previous_offset_count = 0;

View File

@ -11,7 +11,7 @@ namespace big
static bool freeze = false; static bool freeze = false;
static char name[200] = ""; static char name[200] = "";
static char script_thread_name[200] = ""; static char script_thread_name[200] = "";
static int(*offsets)[2] = nullptr; static int offsets[10][2] = {};
static int offset_count = 0; static int offset_count = 0;
static int previous_offset_count = 0; static int previous_offset_count = 0;
components::input_text_with_hint("##local_name", "Name", name, sizeof(name)); components::input_text_with_hint("##local_name", "Name", name, sizeof(name));
@ -21,21 +21,7 @@ namespace big
ImGui::Text("Offsetcount"); ImGui::Text("Offsetcount");
ImGui::InputInt("##modal_offset_count", &offset_count); ImGui::InputInt("##modal_offset_count", &offset_count);
if (offset_count < 0) offset_count = std::clamp(offset_count, 0, 10);
offset_count = 0;
else if (offset_count > 10)
offset_count = 10;
if (offset_count != previous_offset_count)
{
int(*new_offsets)[2] = new int[offset_count][2]{0};
memcpy(new_offsets, offsets, sizeof(int) * std::min(offset_count, previous_offset_count) * 2);
delete[] offsets;
offsets = new_offsets;
previous_offset_count = offset_count;
}
ImGui::PushItemWidth(320.f); ImGui::PushItemWidth(320.f);
for (int i = 0; i < offset_count; i++) for (int i = 0; i < offset_count; i++)
@ -57,9 +43,7 @@ namespace big
static auto reset_values = []() -> void { static auto reset_values = []() -> void {
strcpy(name, ""); strcpy(name, "");
freeze = false; freeze = false;
delete[] offsets;
offsets = nullptr;
offset_count = 0; offset_count = 0;
previous_offset_count = 0; previous_offset_count = 0;
}; };
@ -99,7 +83,7 @@ namespace big
if (components::button("SAVE"_T)) if (components::button("SAVE"_T))
g_locals_service.save(); g_locals_service.save();
if (components::button("Add local")) if (components::button("Add Local"))
{ {
ImGui::OpenPopup("##addlocal"); ImGui::OpenPopup("##addlocal");
} }

View File

@ -1,10 +1,10 @@
#include "core/data/hud_component_names.hpp" #include "core/data/hud_component_names.hpp"
#include "core/data/ptfx_effects.hpp" #include "core/data/ptfx_effects.hpp"
#include "fiber_pool.hpp" #include "fiber_pool.hpp"
#include "services/orbital_drone/orbital_drone.hpp"
#include "util/entity.hpp" #include "util/entity.hpp"
#include "util/local_player.hpp" #include "util/local_player.hpp"
#include "util/scripts.hpp" #include "util/scripts.hpp"
#include "services/orbital_drone/orbital_drone.hpp"
#include "views/view.hpp" #include "views/view.hpp"
namespace big namespace big
@ -55,7 +55,7 @@ namespace big
components::command_checkbox<"invis">(); components::command_checkbox<"invis">();
if (g.self.invisibility) if (g.self.invisibility)
components::command_checkbox<"localvis">();// TODO: does nothing in SP components::command_checkbox<"localvis">(); // TODO: does nothing in SP
components::command_checkbox<"cleanloop">(); components::command_checkbox<"cleanloop">();
components::command_checkbox<"nocollision">(); components::command_checkbox<"nocollision">();
components::command_checkbox<"mobileradio">(); components::command_checkbox<"mobileradio">();
@ -77,9 +77,9 @@ namespace big
{ {
if (ImGui::Selectable(ptfx_named[i].friendly_name, ptfx_named[i].asset_name == g.self.ptfx_effects.asset)) if (ImGui::Selectable(ptfx_named[i].friendly_name, ptfx_named[i].asset_name == g.self.ptfx_effects.asset))
{ {
g.self.ptfx_effects.asset = ptfx_named[i].asset_name;// Update our asset name to be used g.self.ptfx_effects.asset = ptfx_named[i].asset_name; // Update our asset name to be used
g.self.ptfx_effects.select = i; g.self.ptfx_effects.select = i;
g.self.ptfx_effects.effect = ptfx_named[i].effect_names.at(0);// set the effect to the first instance in the vector g.self.ptfx_effects.effect = ptfx_named[i].effect_names.at(0); // set the effect to the first instance in the vector
} }
if (ptfx_named[i].asset_name == g.self.ptfx_effects.asset) if (ptfx_named[i].asset_name == g.self.ptfx_effects.asset)
@ -94,7 +94,7 @@ namespace big
for (const auto& ptfx_type : ptfx_named[g.self.ptfx_effects.select].effect_names) for (const auto& ptfx_type : ptfx_named[g.self.ptfx_effects.select].effect_names)
{ {
if (ImGui::Selectable(ptfx_type, ptfx_type == g.self.ptfx_effects.effect)) if (ImGui::Selectable(ptfx_type, ptfx_type == g.self.ptfx_effects.effect))
g.self.ptfx_effects.effect = ptfx_type;// Update our ptfx effect g.self.ptfx_effects.effect = ptfx_type; // Update our ptfx effect
if (ptfx_type == g.self.ptfx_effects.effect) if (ptfx_type == g.self.ptfx_effects.effect)
ImGui::SetItemDefaultFocus(); ImGui::SetItemDefaultFocus();
@ -210,9 +210,8 @@ namespace big
}); });
components::button("HIDE_ALL"_T, [] { components::button("HIDE_ALL"_T, [] {
g.self.hud.hide_radar = true; g.self.hud.hide_radar = true;
g.self.hud.hide_ammo = true; g.self.hud.hide_ammo = true;
for (int i = 0; i < (int)HudComponents::HUD_WEAPONS; i++) for (int i = 0; i < (int)HudComponents::HUD_WEAPONS; i++)
{ {
@ -221,9 +220,8 @@ namespace big
}); });
ImGui::SameLine(); ImGui::SameLine();
components::button("SHOW_ALL"_T, [] { components::button("SHOW_ALL"_T, [] {
g.self.hud.hide_radar = false; g.self.hud.hide_radar = false;
g.self.hud.hide_ammo = false; g.self.hud.hide_ammo = false;
for (int i = 0; i < (int)HudComponents::HUD_WEAPONS; i++) for (int i = 0; i < (int)HudComponents::HUD_WEAPONS; i++)
{ {
@ -237,20 +235,55 @@ namespace big
ImGui::EndGroup(); ImGui::EndGroup();
ImGui::BeginGroup();
components::command_checkbox<"hudcolor">(); components::command_checkbox<"hudcolor">();
static int color_select_index = 0;
ImGui::Checkbox("Override Hud Color Specify", &g.self.hud.shcolor); if (g.self.hud.color_override)
ImGui::InputInt("Hud Index", &g.self.hud.index);//need to display current val if not displayed {
ImGui::InputInt("Hud Red", &g.self.hud.r); ImGui::Combo("Color Index", &color_select_index, hud_colors.data(), hud_colors.size());
ImGui::InputInt("Hud Green", &g.self.hud.g);
ImGui::InputInt("Hud Blue", &g.self.hud.b);
ImGui::InputInt("Hud Alpha", &g.self.hud.a);
ImGui::Checkbox("Override Multiplayer Hud Color", &g.self.hud.mhcolor); auto& ovr_color = g.self.hud.hud_color_overrides[color_select_index];
ImGui::InputInt("Hud Color", &g.self.hud.hcolor);
ImGui::Checkbox("Override Multiplayer Text Off Index", &g.self.hud.mtcolor); float col[4]{};
ImGui::InputInt("Hud Text Color", &g.self.hud.tcolor); col[0] = ovr_color.r / 255.0f;
col[1] = ovr_color.g / 255.0f;
col[2] = ovr_color.b / 255.0f;
col[3] = ovr_color.a / 255.0f;
if (ImGui::ColorPicker4("Override Color", col))
{
ovr_color.r = (int)(col[0] * 255);
ovr_color.g = (int)(col[1] * 255);
ovr_color.b = (int)(col[2] * 255);
ovr_color.a = (int)(col[3] * 255);
g_fiber_pool->queue_job([] {
auto& col = g.self.hud.hud_color_overrides[color_select_index];
HUD::REPLACE_HUD_COLOUR_WITH_RGBA(color_select_index, col.r, col.g, col.b, col.a);
});
}
components::button("Restore Default Color", [] {
g.self.hud.hud_color_overrides[color_select_index] = g.self.hud.hud_color_defaults[color_select_index];
auto& col = g.self.hud.hud_color_defaults[color_select_index];
HUD::REPLACE_HUD_COLOUR_WITH_RGBA(color_select_index, col.r, col.g, col.b, col.a);
});
ImGui::SameLine();
components::button("Restore All Defaults", [] {
for (int i = 0; i < hud_colors.size(); i++)
{
auto& col = g.self.hud.hud_color_defaults[i];
g.self.hud.hud_color_overrides[i] = col;
HUD::REPLACE_HUD_COLOUR_WITH_RGBA(i, col.r, col.g, col.b, col.a);
}
});
}
ImGui::EndGroup();
g.self.proof_mask = 0; g.self.proof_mask = 0;
if (g.self.god_mode) if (g.self.god_mode)

View File

@ -99,9 +99,7 @@ namespace big
draw_reaction(g.reactions.report_cash_spawn); draw_reaction(g.reactions.report_cash_spawn);
draw_reaction(g.reactions.request_control_event); draw_reaction(g.reactions.request_control_event);
ImGui::Separator(); ImGui::Separator();
draw_reaction(g.reactions.lost_connection_kick);
draw_reaction(g.reactions.gamer_instruction_kick); draw_reaction(g.reactions.gamer_instruction_kick);
draw_interloper_reaction(g.reactions.lost_connection_kick_others);
draw_interloper_reaction(g.reactions.breakup_others); draw_interloper_reaction(g.reactions.breakup_others);
components::title("SETTINGS_NOTIFICATIONS"_T); components::title("SETTINGS_NOTIFICATIONS"_T);

View File

@ -35,25 +35,18 @@ namespace big
} }
else else
{ {
ImGui::TextWrapped("GAME_CACHE_SINGLE_PLAYER_DESCRIPTION"_T.data()); if (ImGui::Button("GAME_CACHE_UPDATE_CACHE"_T.data()))
if (ImGui::Button("GAME_CACHE_DONT_CARE"_T.data()))
{ {
g_gta_data_service->update_now(); g_gta_data_service->update_now();
} }
if (ImGui::Button("GAME_CACHE_GO_ONLINE"_T.data()))
{
g_gta_data_service->update_in_online();
}
if (*g_pointers->m_gta.m_game_state == eGameState::Respawn) if (*g_pointers->m_gta.m_game_state == eGameState::Respawn)
{ {
if (ImGui::Button("GAME_CACHE_ON_INIT"_T.data())) if (ImGui::Button("GAME_CACHE_ON_INIT"_T.data()))
{ {
g_gta_data_service->update_on_init(); g_gta_data_service->update_on_init();
} }
} }
} }
break; break;