refactor(Restructure): Moved everything to their own class/struct to improve compile times and cleanup the code.

This commit is contained in:
Yimura
2021-02-05 02:38:56 +01:00
parent e9c3a93f56
commit 3af9c82ca2
72 changed files with 721 additions and 451 deletions
+17 -1
View File
@@ -49,9 +49,13 @@
#include <nlohmann/json.hpp>
#include "logger.hpp"
#include "settings.h"
#include "gta/ped_factory.hpp"
#include "structs/lists.hpp"
#include "structs/player.hpp"
#include "structs/temp.hpp"
namespace big
{
using namespace std::chrono_literals;
@@ -63,4 +67,16 @@ namespace big
inline HANDLE g_main_thread{};
inline DWORD g_main_thread_id{};
inline std::atomic_bool g_running{ true };
// Global Variables
inline player g_player;
inline player g_selectedPlayer;
inline std::unordered_map<Player, player> g_players;
inline CAutomobile* g_vehicle;
inline temp g_temp = temp{};
// screen width and height
inline int x, y;
}
+26 -39
View File
@@ -1,54 +1,41 @@
#include "features.hpp"
#include "logger.hpp"
#include "natives.hpp"
#include "features/custom_guns.hpp"
#include "features/protections.hpp"
#include "features/self.hpp"
#include "features/sys.hpp"
#include "features/tunables.hpp"
#include "features/util.hpp"
#include "features/vehicle.hpp"
#include "features/world.hpp"
#include "script.hpp"
namespace big
{
void features::run_tick()
{
g_playerId = PLAYER::PLAYER_ID();
// System
update_player_structs();
update_screen_sizes();
sys::loop();
// Custom Guns
cage_gun();
delete_gun();
gravity_gun();
money_gun();
repair_gun();
vehicle_gun();
// Tunable
disable_phone();
no_idle_kick();
// Self
god_mode();
never_wanted();
noclip();
no_ragdoll();
off_radar();
super_sprint();
spoof_rank();
// Vehicle
handling();
no_bike_fall();
speedo_meter();
sticky_tyres();
// World
population_modifiers();
// Util
spectate_player();
custom_guns::loop();
// Protections
replay_interface();
//version_mismatch();
protections::loop();
// Self
self::loop();
// Tunable
tunables::loop();
// Util
util::loop();
// Vehicle
vehicle::loop();
// World
world::loop();
}
void features::script_func()
-58
View File
@@ -1,69 +1,11 @@
#pragma once
#include "common.hpp"
#include "fiber_pool.hpp"
#include "gta/joaat.hpp"
#include "structs/lists.hpp"
#include "structs/player.hpp"
#include "structs/temp.hpp"
#include "features/functions.hpp"
#include "features/notify.hpp"
#include "features/stats.hpp"
#include "features/teleport.hpp"
#include "gta/ped_factory.hpp"
namespace big
{
inline Player g_playerId;
inline Player g_selectedPlayerId;
inline player g_currentPlayer;
inline player g_selectedPlayer;
inline player g_players[32];
// Temporary Variable struct
inline temp g_temp = temp{};
inline CAutomobile* g_vehicle;
inline bool g_in_vehicle = false;
inline bool g_handling_window = false;
// Screen Width & Height
inline int x, y;
namespace features
{
void run_tick();
void script_func();
void cage_gun();
void delete_gun();
void gravity_gun();
void money_gun();
void repair_gun();
void vehicle_gun();
void replay_interface();
void version_mismatch();
void disable_phone();
void god_mode();
void never_wanted();
void noclip();
void no_bike_fall();
void no_idle_kick();
void no_ragdoll();
void off_radar();
void population_modifiers();
void spectate_player();
void speedo_meter();
void spoof_rank();
void sticky_tyres();
void super_sprint();
void handling();
void update_screen_sizes();
void update_player_structs();
}
}
+26
View File
@@ -0,0 +1,26 @@
#include "custom_guns.hpp"
#include "fiber_pool.hpp"
#include "script.hpp"
namespace big
{
static bool busy = false;
void custom_guns::loop()
{
if (busy) return;
busy = true;
QUEUE_JOB_BEGIN_CLAUSE()
{
cage_gun();
delete_gun();
gravity_gun();
money_gun();
repair_gun();
vehicle_gun();
busy = false;
}QUEUE_JOB_END_CLAUSE
}
}
+25
View File
@@ -0,0 +1,25 @@
#pragma once
#include "common.hpp"
#include "functions.hpp"
#include "gta/joaat.hpp"
#include "natives.hpp"
namespace big
{
class custom_guns
{
public:
static void loop();
private:
static void cage_gun();
static void delete_gun();
static void gravity_gun();
static void money_gun();
static void repair_gun();
static void vehicle_gun();
};
}
+2 -2
View File
@@ -1,9 +1,9 @@
#include "functions.hpp"
#include "features.hpp"
#include "gta/joaat.hpp"
#include "gta/levels.hpp"
#include "pointers.hpp"
#include "natives.hpp"
#include "notify.hpp"
#include "script.hpp"
#include "script_global.hpp"
@@ -194,7 +194,7 @@ namespace big
}
if (!STREAMING::HAS_MODEL_LOADED(hash))
{
features::notify::above_map("~r~Failed to spawn model, did you give an incorrect model?");
notify::above_map("~r~Failed to spawn model, did you give an incorrect model?");
return -1;
}
+1
View File
@@ -1,4 +1,5 @@
#pragma once
#include "common.hpp"
#include "structs/session_type.hpp"
namespace big
@@ -1,23 +1,24 @@
#include "features.hpp"
#include "features/custom_guns.hpp"
#include "features/notify.hpp"
namespace big
{
static const int controls[] = { 14, 15, 24 };
void features::cage_gun()
void custom_guns::cage_gun()
{
bool bCageGun = g_settings.options["custom_gun"]["type"] == 5;
if (bCageGun)
{
Hash currWeapon;
WEAPON::GET_CURRENT_PED_WEAPON(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId), &currWeapon, 1);
WEAPON::GET_CURRENT_PED_WEAPON(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player.id), &currWeapon, 1);
if (currWeapon != RAGE_JOAAT("weapon_pistol") && currWeapon != RAGE_JOAAT("weapon_pistol_mk2")) return;
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 25))
{
PLAYER::DISABLE_PLAYER_FIRING(g_playerId, true);
PLAYER::DISABLE_PLAYER_FIRING(g_player.id, true);
for (int control : controls)
PAD::DISABLE_CONTROL_ACTION(0, control, true);
@@ -32,7 +33,7 @@ namespace big
func::cage_ped(entity);
}
}
else features::notify::above_map("No entity found.");
else notify::above_map("No entity found.");
}
}
}
@@ -1,23 +1,24 @@
#include "features.hpp"
#include "features/custom_guns.hpp"
#include "features/notify.hpp"
namespace big
{
static const int controls[] = { 14, 15, 24 };
void features::delete_gun()
void custom_guns::delete_gun()
{
bool bDeleteGun = g_settings.options["custom_gun"]["type"] == 1;
if (bDeleteGun)
{
Hash currWeapon;
WEAPON::GET_CURRENT_PED_WEAPON(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId), &currWeapon, 1);
WEAPON::GET_CURRENT_PED_WEAPON(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player.id), &currWeapon, 1);
if (currWeapon != RAGE_JOAAT("weapon_pistol") && currWeapon != RAGE_JOAAT("weapon_pistol_mk2")) return;
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 25))
{
PLAYER::DISABLE_PLAYER_FIRING(g_playerId, true);
PLAYER::DISABLE_PLAYER_FIRING(g_player.id, true);
for (int control : controls)
PAD::DISABLE_CONTROL_ACTION(0, control, true);
@@ -33,7 +34,7 @@ namespace big
}
else
{
Vector3 player = ENTITY::GET_ENTITY_COORDS(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId), true);
Vector3 player = ENTITY::GET_ENTITY_COORDS(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player.id), true);
Vector3 entLoc = ENTITY::GET_ENTITY_COORDS(entity, true);
double dist = func::distance_between_vectors(player, entLoc);
@@ -51,7 +52,7 @@ namespace big
}
}
}
else features::notify::above_map("No entity found.");
else notify::above_map("No entity found.");
}
}
}
@@ -1,4 +1,5 @@
#include "features.hpp"
#include "features/custom_guns.hpp"
#include "features/notify.hpp"
namespace big
{
@@ -10,7 +11,7 @@ namespace big
static const int scroll = 2;
static const int controls[] = { 14, 15, 24 };
void features::gravity_gun()
void custom_guns::gravity_gun()
{
bool bGravityGun = g_settings.options["custom_gun"]["type"] == 2;
double multiplier = g_settings.options["custom_gun"]["gravity_velocity_multiplier"];
@@ -18,18 +19,18 @@ namespace big
if (bGravityGun)
{
Hash currWeapon;
WEAPON::GET_CURRENT_PED_WEAPON(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId), &currWeapon, 1);
WEAPON::GET_CURRENT_PED_WEAPON(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player.id), &currWeapon, 1);
if (currWeapon != RAGE_JOAAT("weapon_pistol") && currWeapon != RAGE_JOAAT("weapon_pistol_mk2")) return;
// ZOOMED IN
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 25))
{
PLAYER::DISABLE_PLAYER_FIRING(g_playerId, true);
PLAYER::DISABLE_PLAYER_FIRING(g_player.id, true);
for (int control : controls)
PAD::DISABLE_CONTROL_ACTION(0, control, true);
location = ENTITY::GET_ENTITY_COORDS(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId), true);
location = ENTITY::GET_ENTITY_COORDS(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player.id), true);
// Attack RELEASED
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 24) && entity == 0)
@@ -59,7 +60,7 @@ namespace big
if (ENTITY::IS_ENTITY_A_PED(entity) && !PED::IS_PED_RAGDOLL(entity)) TASK::SET_HIGH_FALL_TASK(entity, 0, 0, 0);
features::notify::above_map("Selected entity at crosshair.");
notify::above_map("Selected entity at crosshair.");
}
}
}
@@ -67,7 +68,7 @@ namespace big
{
entity = 0;
features::notify::above_map("No entity found.");
notify::above_map("No entity found.");
}
}
@@ -108,7 +109,7 @@ namespace big
entity = 0;
features::notify::above_map("Released entity.");
notify::above_map("Released entity.");
}
}
}
@@ -1,4 +1,6 @@
#include "features.hpp"
#include "features/custom_guns.hpp"
#include "fiber_pool.hpp"
#include "script.hpp"
namespace big
{
@@ -7,13 +9,13 @@ namespace big
static bool busy = false;
static Entity entity = 0;
void features::money_gun()
void custom_guns::money_gun()
{
bool bMoneyGun = g_settings.options["custom_gun"]["type"] == 3;
if (bMoneyGun)
{
Ped player = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId);
Ped player = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player.id);
Hash currWeapon;
WEAPON::GET_CURRENT_PED_WEAPON(player, &currWeapon, 1);
@@ -22,7 +24,7 @@ namespace big
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 25))
{
PLAYER::DISABLE_PLAYER_FIRING(g_playerId, true);
PLAYER::DISABLE_PLAYER_FIRING(g_player.id, true);
for (int control : controls)
PAD::DISABLE_CONTROL_ACTION(0, control, true);
@@ -30,7 +32,7 @@ namespace big
{
busy = true;
QUEUE_JOB_BEGIN_CLAUSE(&)
g_fiber_pool->queue_job([&]
{
if (func::raycast_entity(&entity))
{
@@ -49,7 +51,7 @@ namespace big
busy = false;
}
}QUEUE_JOB_END_CLAUSE
});
}
}
}
@@ -1,46 +1,47 @@
#include "features.hpp"
namespace big
{
static const int controls[] = { 14, 15, 24 };
void features::repair_gun()
{
bool bRepairGun = g_settings.options["custom_gun"]["type"] == 6;
if (bRepairGun)
{
Hash currWeapon;
WEAPON::GET_CURRENT_PED_WEAPON(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId), &currWeapon, 1);
if (currWeapon != RAGE_JOAAT("weapon_pistol") && currWeapon != RAGE_JOAAT("weapon_pistol_mk2")) return;
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 25))
{
PLAYER::DISABLE_PLAYER_FIRING(g_playerId, true);
for (int control : controls)
PAD::DISABLE_CONTROL_ACTION(0, control, true);
if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, 24))
{
Entity entity;
if (func::raycast_entity(&entity))
{
if (ENTITY::IS_ENTITY_A_VEHICLE(entity))
{
VEHICLE::SET_VEHICLE_FIXED(entity);
VEHICLE::SET_VEHICLE_DEFORMATION_FIXED(entity);
VEHICLE::SET_VEHICLE_DIRT_LEVEL(entity, 0.f);
}
else
{
notify::above_map("Entity is not a vehicle.");
}
}
else notify::above_map("No entity found.");
}
}
}
}
#include "features/custom_guns.hpp"
#include "features/notify.hpp"
namespace big
{
static const int controls[] = { 14, 15, 24 };
void custom_guns::repair_gun()
{
bool bRepairGun = g_settings.options["custom_gun"]["type"] == 6;
if (bRepairGun)
{
Hash currWeapon;
WEAPON::GET_CURRENT_PED_WEAPON(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player.id), &currWeapon, 1);
if (currWeapon != RAGE_JOAAT("weapon_pistol") && currWeapon != RAGE_JOAAT("weapon_pistol_mk2")) return;
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 25))
{
PLAYER::DISABLE_PLAYER_FIRING(g_player.id, true);
for (int control : controls)
PAD::DISABLE_CONTROL_ACTION(0, control, true);
if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, 24))
{
Entity entity;
if (func::raycast_entity(&entity))
{
if (ENTITY::IS_ENTITY_A_VEHICLE(entity))
{
VEHICLE::SET_VEHICLE_FIXED(entity);
VEHICLE::SET_VEHICLE_DEFORMATION_FIXED(entity);
VEHICLE::SET_VEHICLE_DIRT_LEVEL(entity, 0.f);
}
else
{
notify::above_map("Entity is not a vehicle.");
}
}
else notify::above_map("No entity found.");
}
}
}
}
}
@@ -1,16 +1,16 @@
#include "features.hpp"
#include "features/custom_guns.hpp"
namespace big
{
static const int controls[] = { 14, 15, 24 };
void features::vehicle_gun()
void custom_guns::vehicle_gun()
{
bool bVehicleGun = g_settings.options["custom_gun"]["type"] == 4;
if (bVehicleGun)
{
Ped player = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId);
Ped player = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player.id);
Hash currWeapon;
WEAPON::GET_CURRENT_PED_WEAPON(player, &currWeapon, 1);
@@ -19,7 +19,7 @@ namespace big
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 25))
{
PLAYER::DISABLE_PLAYER_FIRING(g_playerId, true);
PLAYER::DISABLE_PLAYER_FIRING(g_player.id, true);
for (int control : controls)
PAD::DISABLE_CONTROL_ACTION(0, control, true);
@@ -44,8 +44,6 @@ namespace big
velocity.y = dist * sin(yaw) * cos(pitch);
velocity.z = dist * sin(pitch);
script::get_current()->yield();
ENTITY::SET_ENTITY_ROTATION(veh, rot.x, rot.y, rot.z, 2, 1);
ENTITY::SET_ENTITY_VELOCITY(veh, velocity.x, velocity.y, velocity.z);
}
@@ -1,10 +1,14 @@
#include "features.hpp"
#include "features/protections.hpp"
#include "features/functions.hpp"
#include "gta/joaat.hpp"
#include "gta/replay.hpp"
#include "pointers.hpp"
#include "natives.hpp"
#include "script.hpp"
namespace big
{
void features::replay_interface()
void protections::replay_interface()
{
Ped player = PLAYER::PLAYER_PED_ID();
@@ -32,6 +36,8 @@ namespace big
if (protections["cage"] && ENTITY::GET_ENTITY_MODEL(ent) == RAGE_JOAAT("prop_gold_cont_01"))
func::delete_entity(ent);
script::get_current()->yield();
}
}
}
@@ -1,11 +1,11 @@
#include "features.hpp"
#include "features/self.hpp"
#include "gta_util.hpp"
namespace big
{
static bool bLastGodMode = false;
void features::god_mode()
void self::god_mode()
{
bool bGodMode = g_settings.options["god_mode"].get<bool>();
@@ -15,7 +15,7 @@ namespace big
ped->m_godmode = bGodMode ? 0x1 : 0x0;
//ENTITY::SET_ENTITY_INVINCIBLE(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId), bGodMode);
//ENTITY::SET_ENTITY_INVINCIBLE(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player.id), bGodMode);
bLastGodMode = bGodMode;
}
@@ -1,26 +1,24 @@
#include "features.hpp"
#include "features/self.hpp"
#include "natives.hpp"
namespace big
{
static bool bLastNeverWanted = false;
void features::never_wanted()
void self::never_wanted()
{
QUEUE_JOB_BEGIN_CLAUSE()
bool bNeverWanted = g_settings.options["never_wanted"].get<bool>();
if (bNeverWanted && PLAYER::GET_PLAYER_WANTED_LEVEL(g_player.id) > 0)
{
bool bNeverWanted = g_settings.options["never_wanted"].get<bool>();
PLAYER::SET_PLAYER_WANTED_LEVEL(g_player.id, 0, true);
PLAYER::SET_MAX_WANTED_LEVEL(0);
}
else if (!bNeverWanted && bNeverWanted != bLastNeverWanted)
{
PLAYER::SET_MAX_WANTED_LEVEL(5);
}
if (bNeverWanted && PLAYER::GET_PLAYER_WANTED_LEVEL(g_playerId) > 0)
{
PLAYER::SET_PLAYER_WANTED_LEVEL(g_playerId, 0, true);
PLAYER::SET_MAX_WANTED_LEVEL(0);
}
else if (!bNeverWanted && bNeverWanted != bLastNeverWanted)
{
PLAYER::SET_MAX_WANTED_LEVEL(5);
}
bLastNeverWanted = bNeverWanted;
}QUEUE_JOB_END_CLAUSE
bLastNeverWanted = bNeverWanted;
}
}
@@ -1,25 +1,23 @@
#include "features.hpp"
#include "features/self.hpp"
#include "natives.hpp"
namespace big
{
static bool bLastNoRagdoll = false;
void features::no_ragdoll()
void self::no_ragdoll()
{
bool bNoRagdoll = g_settings.options["ragdoll"].get<bool>();
if (bNoRagdoll || (!bNoRagdoll && bNoRagdoll != bLastNoRagdoll))
{
QUEUE_JOB_BEGIN_CLAUSE(= )
{
Ped player = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId);
Ped player = PLAYER::PLAYER_PED_ID();
PED::SET_PED_CAN_RAGDOLL(player, !bNoRagdoll);
PED::SET_PED_CAN_RAGDOLL_FROM_PLAYER_IMPACT(player, !bNoRagdoll);
PED::SET_PED_RAGDOLL_ON_COLLISION(player, !bNoRagdoll);
}QUEUE_JOB_END_CLAUSE
PED::SET_PED_CAN_RAGDOLL(player, !bNoRagdoll);
PED::SET_PED_CAN_RAGDOLL_FROM_PLAYER_IMPACT(player, !bNoRagdoll);
PED::SET_PED_RAGDOLL_ON_COLLISION(player, !bNoRagdoll);
bLastNoRagdoll = bNoRagdoll;
bLastNoRagdoll = bNoRagdoll;
}
}
}
@@ -1,4 +1,6 @@
#include "features.hpp"
#include "features/self.hpp"
#include "features/functions.hpp"
#include "natives.hpp"
namespace big
{
@@ -8,13 +10,13 @@ namespace big
static bool bLastNoClip;
void features::noclip()
void self::noclip()
{
bool bNoclip = g_settings.options["noclip"]["enabled"];
float fHorizontal = g_settings.options["noclip"]["horizontal"];
float fVertical = g_settings.options["noclip"]["vertical"];
Entity ent = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId);
Entity ent = PLAYER::PLAYER_PED_ID();
bool inVehicle = PED::IS_PED_IN_ANY_VEHICLE(ent, true);
if (inVehicle) ent = PED::GET_VEHICLE_PED_IS_IN(ent, false);
@@ -1,20 +1,18 @@
#include "features.hpp"
#include "features/self.hpp"
#include "natives.hpp"
#include "script_global.hpp"
namespace big
{
void features::off_radar()
void self::off_radar()
{
if (g_settings.options["off_radar"].get<bool>())
{
QUEUE_JOB_BEGIN_CLAUSE()
if (PLAYER::IS_PLAYER_ONLINE())
{
if (PLAYER::IS_PLAYER_ONLINE())
{
*script_global(2425869).at(1 + (g_playerId * 443)).at(204).as<int*>() = 1;
*script_global(2440049).at(70).as<int*>() = NETWORK::GET_NETWORK_TIME() + 999;
}
}QUEUE_JOB_END_CLAUSE
*script_global(2425869).at(g_player.id, 443).at(204).as<int*>() = 1;
*script_global(2440049).at(70).as<int*>() = NETWORK::GET_NETWORK_TIME() + 999;
}
}
}
}
@@ -1,18 +1,14 @@
#include "features.hpp"
#include "features/self.hpp"
#include "features/functions.hpp"
#include "script_global.hpp"
namespace big
{
void features::spoof_rank()
void self::spoof_rank()
{
bool bSpoofRank = g_settings.options["spoof_rank"].get<bool>();
if (bSpoofRank)
{
QUEUE_JOB_BEGIN_CLAUSE()
{
func::spoof_rank(g_settings.options["rank"].get<int>());
}QUEUE_JOB_END_CLAUSE
}
func::spoof_rank(g_settings.options["rank"].get<int>());
}
}

Some files were not shown because too many files have changed in this diff Show More