Added stuff for Allow All Weapons in Vehicle. (#122)

This commit is contained in:
gir489 2023-07-16 11:49:13 -04:00 committed by GitHub
parent 8559fe7a9e
commit 249d3ad290
14 changed files with 401 additions and 9 deletions

View File

@ -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"

View File

@ -4,9 +4,7 @@
#include <ostream>
#include <vector>
#include "sysMemAllocator.hpp"
#include "script/tlsContext.hpp"
namespace rage
{
@ -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) :
@ -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];
@ -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>())
@ -84,4 +225,4 @@ namespace rage
};
static_assert(sizeof(rage::atArray<std::uint32_t>) == 0x10, "rage::atArray is not properly sized");
#pragma pack(pop)
}
}

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -1,6 +1,7 @@
#pragma once
#include "../base/CBaseModelInfo.hpp"
#include "vehicle/CVehicleModelInfoLayout.hpp"
#include <cstdint>
@ -56,7 +57,8 @@ enum class eVehicleClass : std::uint8_t
class CVehicleModelInfo : public CBaseModelInfo
{
public:
char pad_00A4[72]; //0x00A4
CVehicleModelInfoLayout* m_vehicle_layout; //0x00B0
char pad_00B8[64]; //0x00B8
uint8_t m_primary_color_combinations[25]; //0x00F8
uint8_t m_secondary_color_combinations[25]; //0x0111
uint8_t m_unk_color_combos1[25]; //0x012A
@ -73,8 +75,11 @@ public:
char pad_02D9[103]; //0x02D9
eVehicleType m_vehicle_type; //0x0340
uint32_t m_unk_vehicle_type; //0x0344
uint32_t m_diffuse_tint; //0x0348
char pad_034C[20]; //0x034C
uint16_t m_diffuse_tint; //0x0348
int8_t m_max_seats; //0x034A
char pad_034B[5]; //0x034B
CVehicleLayoutMetaData* m_layout_metadata; //0x0350
char pad_0358[8]; //0x0358
rage::fvector3 m_first_person_driveby_ik_offset; //0x0360
char pad_036C[4]; //0x036C
rage::fvector3 m_first_person_driveby_unarmed_ik_offset; //0x0370

View File

@ -0,0 +1,15 @@
#include "CVehicleLayoutMetaData.hpp"
#pragma pack(push, 4)
class CVehicleModelInfoLayout
{
private:
char pad_0000[842]; //0x0000
public:
int8_t m_max_seats; //0x034A
private:
char pad_034B[5]; //0x034B
public:
class CVehicleLayoutMetaData* m_layout_metadata; //0x0350
}; //Size: 0x0358
#pragma pack(pop)

View File

@ -0,0 +1,13 @@
#include "CVehicleDriveByAnimInfo.hpp"
#pragma pack(push, 4)
class CVehicleSeatAnimInfo
{
public:
uint32_t name; //0x0000
private:
char pad_0004[4]; //0x0004
public:
class CVehicleDriveByAnimInfo* m_drive_by_info; //0x0008
}; //Size: 0x0010
#pragma pack(pop)

View File

@ -0,0 +1,23 @@
#include "CVehicleSeatAnimInfo.hpp"
#pragma pack(push, 4)
class CVehicleSeatAnimInfos
{
private:
char pad_0000[8]; //0x0000
public:
class CVehicleSeatAnimInfo* m_front_left; //0x0008
private:
char pad_0010[8]; //0x0010
public:
class CVehicleSeatAnimInfo* m_front_right; //0x0018
private:
char pad_0020[8]; //0x0020
public:
class CVehicleSeatAnimInfo* m_rear_left; //0x0028
private:
char pad_0030[8]; //0x0030
public:
class CVehicleSeatAnimInfo* m_rear_right; //0x0038
}; //Size: 0x0040
#pragma pack(pop)

View File

@ -0,0 +1,9 @@
#include "vehicle/CDriveBySeatDefault.hpp"
#pragma pack(push, 4)
class CVehicleSeatMetadataMgr
{
public:
class CDriveBySeatDefault* m_drive_by_seat_defaults; //0x0000
}; //Size: 0x0008
#pragma pack(pop)

Binary file not shown.