Skip to content

Commit

Permalink
Added stuff for Allow All Weapons in Vehicle. (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
gir489returns authored Jul 16, 2023
1 parent 95dadd6 commit e565234
Show file tree
Hide file tree
Showing 14 changed files with 401 additions and 9 deletions.
2 changes: 2 additions & 0 deletions classes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@
#include "vehicle/CHandlingObject.hpp"
#include "vehicle/CVehicle.hpp"
#include "vehicle/CVehicleModelInfo.hpp"
#include "vehicle/CVehicleDriveByMetadataMgr.hpp"
#include "vehicle/CVehicleSeatMetadataMgr.hpp"
#include "weapon/CAmmoInfo.hpp"
#include "weapon/CAmmoProjectileInfo.hpp"
#include "weapon/CAmmoRocketInfo.hpp"
Expand Down
153 changes: 147 additions & 6 deletions rage/atArray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
#include <ostream>
#include <vector>

#include "sysMemAllocator.hpp"


#include "script/tlsContext.hpp"

namespace rage
{
Expand All @@ -20,7 +18,17 @@ namespace rage
m_size(0),
m_count(0)
{


}

#if _WIN32
atArray(const atArray& right)
{
m_count = right.m_count;
m_size = right.m_size;

m_data = (T*)tlsContext::get()->m_allocator->Allocate(m_size * sizeof(T), 16, 0);
std::uninitialized_copy(right.m_data, right.m_data + right.m_count, m_data);
}

atArray(void* data_ptr, std::uint16_t size, std::uint16_t count) :
Expand All @@ -31,6 +39,127 @@ namespace rage

}

void clear()
{
m_count = 0;
m_size = 0;

if (m_data)
{
tlsContext::get()->m_allocator->Free(m_data);

m_data = nullptr;
}
}

bool append(atArray<T> value_array)
{
auto value_array_size = value_array.size();
auto old_capacity = m_count;

if ((value_array_size + m_count) > std::numeric_limits<uint16_t>::max())
return false;

auto size = (uint16_t)value_array_size;
expand(m_count + size);
m_size += size;

auto i = old_capacity;
for (auto iter_value : value_array)
{
m_data[i] = iter_value;
i++;
}
return true;
}

bool append(std::vector<T> value_array)
{
auto value_array_size = value_array.size();
auto old_capacity = m_count;

if ((value_array_size + m_count) > std::numeric_limits<uint16_t>::max())
return false;

auto size = (uint16_t)value_array_size;
expand(m_count + size);
m_size += size;

auto i = old_capacity;
for (auto iter_value : value_array)
{
m_data[i] = iter_value;
i++;
}
return true;
}

bool append(const std::initializer_list<T> value_array)
{
auto value_array_size = value_array.size();
auto old_capacity = m_count;

if ((value_array_size + m_count) > std::numeric_limits<uint16_t>::max())
return false;

auto size = (uint16_t)value_array_size;
expand(m_count + size);
m_size += size;

auto i = old_capacity;
for (const T* it = value_array.begin(); it != value_array.end(); ++it)
{
m_data[i] = *it;
i++;
}
return true;
}

void set(uint16_t offset, const T& value)
{
if (offset >= m_count)
{
expand(offset + 1);
}

if (offset >= m_size)
{
m_size = offset + 1;
}

m_data[offset] = value;
}

void expand(uint16_t newSize)
{
if (m_count >= newSize)
{
return;
}

T* newOffset = (T*)tlsContext::get()->m_allocator->Allocate(newSize * sizeof(T), 16, 0);


// initialize the new entries
std::uninitialized_fill(newOffset, newOffset + newSize, T());

// copy the existing entries
if (m_data)
{
std::copy(m_data, m_data + m_size, newOffset);
tlsContext::get()->m_allocator->Free(m_data);
}

m_data = newOffset;
m_count = newSize;
}
#endif

void append(T value)
{
set(m_count, value);
}

T* begin() const
{
return &m_data[0];
Expand Down Expand Up @@ -61,10 +190,22 @@ namespace rage
return m_data[index];
}

bool contains(T comparator)
{
for (auto iter_value : this)
{
if (iter_value == comparator)
{
return true;
}
}
return false;
}

friend std::ostream& operator<<(std::ostream& o, const atArray<T>& j)
{
o << "Array Size: " << j.size() << std::endl;
for(int i = 0; i < j.size(); i++)
for (int i = 0; i < j.size(); i++)
{
T item = j[i];
if (std::is_pointer<T>())
Expand All @@ -84,4 +225,4 @@ namespace rage
};
static_assert(sizeof(rage::atArray<std::uint32_t>) == 0x10, "rage::atArray is not properly sized");
#pragma pack(pop)
}
}
14 changes: 14 additions & 0 deletions vehicle/CDriveBySeatDefault.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "CVehicleDriveByAnimInfo.hpp"

#pragma pack(push, 4)
class CDriveBySeatDefault
{
private:
char pad_0000[320]; //0x0000
public:
class CVehicleDriveByAnimInfo* m_driveby_standard_front_left; //0x0140
class CVehicleDriveByAnimInfo* m_driveby_standard_front_right; //0x0148
class CVehicleDriveByAnimInfo* m_driveby_standard_rear_left; //0x0150
class CVehicleDriveByAnimInfo* m_driveby_standard_rear_right; //0x0158
}; //Size: 0x0160
#pragma pack(pop)
105 changes: 105 additions & 0 deletions vehicle/CDriveByWeaponGroupDefault.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#include "../rage/atArray.hpp"
#include "script/types.hpp"

class CDriveByWeaponGroupDefault
{
public:
Hash m_driveby_default_unarmed; //0x0000
private:
char pad_0004[4]; //0x0004
public:
rage::atArray<Hash> m_driveby_default_unarmed_weapon_group_names; //0x0008
rage::atArray<Hash> m_driveby_default_unarmed_weapon_type_names; //0x0018
private:
char pad_0028[8]; //0x0028
public:
Hash m_driveby_default_one_handed; //0x0030
private:
char pad_0034[4]; //0x0034
public:
rage::atArray<Hash> m_driveby_default_one_handed_weapon_group_names; //0x0038
rage::atArray<Hash> m_driveby_default_one_handed_weapon_type_names; //0x0048
private:
char pad_0058[8]; //0x0058
public:
Hash m_driveby_default_two_handed; //0x0060
private:
char pad_0064[4]; //0x0064
public:
rage::atArray<Hash> m_driveby_default_two_handed_weapon_group_names; //0x0068
rage::atArray<Hash> m_driveby_default_two_handed_weapon_type_names; //0x0078
private:
char pad_0088[8]; //0x0088
public:
Hash m_driveby_heli_two_handed; //0x0090
private:
char pad_0094[4]; //0x0094
public:
rage::atArray<Hash> m_driveby_heli_two_handed_weapon_group_names; //0x0098
rage::atArray<Hash> m_driveby_heli_two_handed_weapon_type_names; //0x00A8
private:
char pad_00B8[56]; //0x00B8
public:
Hash m_driveby_heli_rpg; //0x00F0
private:
char pad_00F4[4]; //0x00F4
public:
rage::atArray<Hash> m_driveby_heli_rpg_weapon_group_names; //0x00F8
rage::atArray<Hash> m_driveby_heli_rpg_weapon_type_names; //0x0108
private:
char pad_0118[8]; //0x0118
public:
Hash m_driveby_default_rear_one_handed; //0x0120
private:
char pad_0124[4]; //0x0124
public:
rage::atArray<Hash> m_driveby_default_rear_one_handed_weapon_group_names; //0x0128
rage::atArray<Hash> m_driveby_default_rear_one_handed_weapon_type_names; //0x0138
private:
char pad_0148[8]; //0x0148
public:
Hash m_driveby_bike_one_handed; //0x0150
private:
char pad_0154[4]; //0x0154
public:
rage::atArray<Hash> m_driveby_bike_one_handed_weapon_group_names; //0x0158
rage::atArray<Hash> m_driveby_bike_one_handed_weapon_type_names; //0x0168
private:
char pad_0178[56]; //0x0178
public:
Hash m_driveby_bike_melee; //0x01B0
private:
char pad_01B4[4]; //0x01B4
public:
rage::atArray<Hash> m_driveby_bike_melee_weapon_group_names; //0x01B8
rage::atArray<Hash> m_driveby_bike_melee_weapon_type_names; //0x01C8
private:
char pad_01D8[56]; //0x01D8
public:
Hash m_driveby_mounted_throw; //0x0210
private:
char pad_0214[4]; //0x0214
public:
rage::atArray<Hash> m_driveby_mounted_throw_weapon_group_names; //0x0218
rage::atArray<Hash> m_driveby_mounted_throw_weapon_type_names; //0x0228
private:
char pad_0238[8]; //0x0238
public:
Hash m_driveby_throw; //0x0240
private:
char pad_0244[4]; //0x0244
public:
rage::atArray<Hash> m_driveby_throw_weapon_group_names; //0x0248
rage::atArray<Hash> m_driveby_throw_weapon_type_names; //0x0258
private:
char pad_0268[8]; //0x0268
public:
Hash m_driveby_vehicle_weapon_group; //0x0270
private:
char pad_0274[4]; //0x0274
public:
rage::atArray<Hash> m_driveby_vehicle_weapon_group_weapon_group_names; //0x0278
rage::atArray<Hash> m_driveby_vehicle_weapon_group_weapon_type_names; //0x0288
private:
char pad_0298[8]; //0x0298
}; //Size: 0x02A0
9 changes: 9 additions & 0 deletions vehicle/CDrivebyWeaponGroups.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "CDriveByWeaponGroupDefault.hpp"

#pragma pack(push, 4)
class CDrivebyWeaponGroups
{
public:
class CDriveByWeaponGroupDefault* m_drive_by_default; //0x0000
}; //Size: 0x0008
#pragma pack(pop)
36 changes: 36 additions & 0 deletions vehicle/CVehicleDriveByAnimInfo.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "../rage/atArray.hpp"

#pragma once

#pragma pack(push, 4)
class CVehicleDriveByAnimInfo
{
public:
uint32_t m_name; //0x0000
float m_min_aim_sweep_heading_angle_degs; //0x0004
float m_max_aim_sweep_heading_angle_degs; //0x0008
float m_first_person_min_aim_sweep_heading_angle_degs; //0x000C
float m_first_person_max_aim_sweep_heading_angle_degs; //0x0010
float m_first_person_unarmed_min_aim_sweep_heading_angle_degs; //0x0014
float m_first_person_unarmed_max_aim_sweep_heading_angle_degs; //0x0018
uint64_t m_unk1; //0x001C
float m_min_restricted_aim_sweep_heading_angle_degs; //0x0024
float m_max_restricted_aim_sweep_heading_angle_degs; //0x0028
float m_min_smash_window_angle_degs; //0x002C
float m_max_smash_window_angle_degs; //0x0030
float m_min_smash_window_angle_first_person_degs; //0x0034
float m_max_smash_window_angle_first_person_degs; //0x0038
float m_max_speed_param; //0x003C
float m_max_longitudinal_lean_blend_weight_delta; //0x0040
float m_max_lateral_lean_blend_weight_delta; //0x0044
float m_approach_speed_to_within_max_blend_delta; //0x0048
float m_spine_additive_blend_in_delay; //0x004C
float m_spine_additive_blend_in_duration_still; //0x0050
float m_spine_additive_blend_in_duration; //0x0054
float m_spine_additive_blend_out_delay; //0x0058
float m_spine_additive_blend_out_duration; //0x005C
float m_min_unarmed_driveby_yaw_if_window_rolled_up; //0x0060
float m_max_unarmed_driveby_yaw_if_window_rolled_up; //0x0064
rage::atArray<const Hash*> m_drive_by_anim_infos; //0x0068
}; //Size: 0x0078
#pragma pack(pop)
9 changes: 9 additions & 0 deletions vehicle/CVehicleDriveByMetadataMgr.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "CDrivebyWeaponGroups.hpp"

#pragma pack(push, 4)
class CVehicleDriveByMetadataMgr
{
public:
class CDrivebyWeaponGroups* m_drive_by_weapon_groups; //0x0000
}; //Size: 0x0008
#pragma pack(pop)
11 changes: 11 additions & 0 deletions vehicle/CVehicleLayoutMetaData.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "CVehicleSeatAnimInfos.hpp"

#pragma pack(push, 4)
class CVehicleLayoutMetaData
{
private:
char pad_0000[8]; //0x0000
public:
class CVehicleSeatAnimInfos* m_seat_info; //0x0008
}; //Size: 0x0010
#pragma pack(pop)
Loading

0 comments on commit e565234

Please sign in to comment.