mirror of
https://github.com/YimMenu/RDR-Classes.git
synced 2024-12-22 14:37:30 +08:00
Improved Node Classes & More (#33)
This commit is contained in:
parent
ec19493aed
commit
ad824270b9
10
classes.cpp
10
classes.cpp
@ -3,10 +3,13 @@
|
|||||||
#include "base/fwRefAwareBase.hpp"
|
#include "base/fwRefAwareBase.hpp"
|
||||||
#include "base/fwRefAwareBaseImpl.hpp"
|
#include "base/fwRefAwareBaseImpl.hpp"
|
||||||
#include "base/pgBase.hpp"
|
#include "base/pgBase.hpp"
|
||||||
|
#include "entity/CDynamicEntity.hpp"
|
||||||
|
#include "entity/CEntity.hpp"
|
||||||
#include "entity/fwEntity.hpp"
|
#include "entity/fwEntity.hpp"
|
||||||
#include "event/CEvent.hpp"
|
#include "event/CEvent.hpp"
|
||||||
#include "event/CEventGroup.hpp"
|
#include "event/CEventGroup.hpp"
|
||||||
#include "event/CEventInventoryItemPickedUp.hpp"
|
#include "event/CEventInventoryItemPickedUp.hpp"
|
||||||
|
#include "network/CFriend.hpp"
|
||||||
#include "network/CNetGamePlayer.hpp"
|
#include "network/CNetGamePlayer.hpp"
|
||||||
#include "network/CNetworkPlayerMgr.hpp"
|
#include "network/CNetworkPlayerMgr.hpp"
|
||||||
#include "network/CNetworkScObjMgr.hpp"
|
#include "network/CNetworkScObjMgr.hpp"
|
||||||
@ -37,6 +40,7 @@
|
|||||||
#include "network/sync/netSyncDataNode.hpp"
|
#include "network/sync/netSyncDataNode.hpp"
|
||||||
#include "network/sync/netSyncNodeBase.hpp"
|
#include "network/sync/netSyncNodeBase.hpp"
|
||||||
#include "network/sync/netSyncTree.hpp"
|
#include "network/sync/netSyncTree.hpp"
|
||||||
|
#include "network/sync/animal/CAnimalCreationData.hpp"
|
||||||
#include "network/sync/object/CObjectCreationData.hpp"
|
#include "network/sync/object/CObjectCreationData.hpp"
|
||||||
#include "network/sync/ped/CPedAttachData.hpp"
|
#include "network/sync/ped/CPedAttachData.hpp"
|
||||||
#include "network/sync/ped/CPedCreationData.hpp"
|
#include "network/sync/ped/CPedCreationData.hpp"
|
||||||
@ -44,11 +48,17 @@
|
|||||||
#include "network/sync/physical/CPhysicalAttachData.hpp"
|
#include "network/sync/physical/CPhysicalAttachData.hpp"
|
||||||
#include "network/sync/pickup/CPickupCreationData.hpp"
|
#include "network/sync/pickup/CPickupCreationData.hpp"
|
||||||
#include "network/sync/player/CPlayerAppearanceData.hpp"
|
#include "network/sync/player/CPlayerAppearanceData.hpp"
|
||||||
|
#include "network/sync/player/CPlayerCameraUncommonData.hpp"
|
||||||
|
#include "network/sync/player/CPlayerCreationData.hpp"
|
||||||
|
#include "network/sync/player/CPlayerGameStateUncommonData.hpp"
|
||||||
#include "network/sync/player/CPlayerHealthData.hpp"
|
#include "network/sync/player/CPlayerHealthData.hpp"
|
||||||
|
#include "network/sync/projectile/CProjectileCreationData.hpp"
|
||||||
|
#include "network/sync/propset/CPropSetCreationData.hpp"
|
||||||
#include "network/sync/vehicle/CVehicleCreationData.hpp"
|
#include "network/sync/vehicle/CVehicleCreationData.hpp"
|
||||||
#include "network/sync/vehicle/CVehicleGadgetData.hpp"
|
#include "network/sync/vehicle/CVehicleGadgetData.hpp"
|
||||||
#include "network/sync/vehicle/CVehicleProximityMigrationData.hpp"
|
#include "network/sync/vehicle/CVehicleProximityMigrationData.hpp"
|
||||||
#include "ped/CPed.hpp"
|
#include "ped/CPed.hpp"
|
||||||
|
#include "physical/CPhysical.hpp"
|
||||||
#include "player/CPlayerInfo.hpp"
|
#include "player/CPlayerInfo.hpp"
|
||||||
#include "rage/Guid.hpp"
|
#include "rage/Guid.hpp"
|
||||||
#include "rage/atArray.hpp"
|
#include "rage/atArray.hpp"
|
||||||
|
21
entity/CDynamicEntity.hpp
Normal file
21
entity/CDynamicEntity.hpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "entity/CEntity.hpp"
|
||||||
|
|
||||||
|
class CPortalTracker
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~CPortalTracker() = default;
|
||||||
|
|
||||||
|
char m_Pad[0x90]; // 0x0008
|
||||||
|
};
|
||||||
|
static_assert(sizeof(CPortalTracker) == 0x98); // TODO: confirm
|
||||||
|
|
||||||
|
class CDynamicEntity : public CEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
class rage::netObject* m_NetObject; // 0x00E0
|
||||||
|
char m_Pad3[0x28]; // 0x00E8
|
||||||
|
CPortalTracker m_PortalTracker; // 0x0110
|
||||||
|
char m_Pad4[8]; // 0x01A8
|
||||||
|
};
|
||||||
|
static_assert(sizeof(CDynamicEntity) == 0x1B0);
|
9
entity/CEntity.hpp
Normal file
9
entity/CEntity.hpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "entity/fwEntity.hpp"
|
||||||
|
|
||||||
|
class CEntity : public rage::fwEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
char m_Pad2[0x30]; // 0xB0
|
||||||
|
};
|
||||||
|
static_assert(sizeof(CEntity) == 0xE0);
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include "../base/fwExtensibleBase.hpp"
|
#include "../base/fwExtensibleBase.hpp"
|
||||||
|
#include "rage/vector.hpp"
|
||||||
|
|
||||||
class CMoveObjectPooledObject;
|
class CMoveObjectPooledObject;
|
||||||
class CNavigation;
|
class CNavigation;
|
||||||
@ -21,16 +22,16 @@ namespace rage
|
|||||||
class CBaseModelInfo* m_ModelInfo; // 0x0020
|
class CBaseModelInfo* m_ModelInfo; // 0x0020
|
||||||
void* m_Unk; // 0x0028
|
void* m_Unk; // 0x0028
|
||||||
uint8_t m_EntityType; // 0x0030
|
uint8_t m_EntityType; // 0x0030
|
||||||
char m_Pad1[0x64]; // 0x0038
|
char m_Pad1[0x38]; // 0x0038
|
||||||
uint32_t m_EntityPoolSlot; // 0x009C
|
rage::vector3 m_Position; // 0x0070
|
||||||
char m_Pad2[0x40]; // 0x00A0
|
char m_Pad0080[0x1C]; // 0x0080
|
||||||
// TODO: move these out of rage::fwEntity
|
uint32_t m_ComponentIndex; // 0x009C
|
||||||
class rage::netObject* m_NetObject; // 0x00E0
|
char m_Pad2[0x10]; // 0x00A0
|
||||||
|
|
||||||
uint32_t GetEntityPoolSlot()
|
uint32_t GetComponentIndex() const
|
||||||
{
|
{
|
||||||
return (m_EntityPoolSlot & 0x1FFFFu);
|
return (m_ComponentIndex & 0x1FFFFu);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
static_assert(sizeof(fwEntity) == 0xE8);
|
static_assert(sizeof(fwEntity) == 0xB0);
|
||||||
}
|
}
|
||||||
|
10
network/CFriend.hpp
Normal file
10
network/CFriend.hpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
class CFriend
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::uint64_t m_RockstarId;
|
||||||
|
char m_Pad[0x8];
|
||||||
|
char m_Name[24];
|
||||||
|
};
|
@ -16,6 +16,8 @@ namespace rage
|
|||||||
uint8_t m_OwnerId; // 0x45
|
uint8_t m_OwnerId; // 0x45
|
||||||
uint8_t m_MigratingOwnerId; // 0x46
|
uint8_t m_MigratingOwnerId; // 0x46
|
||||||
bool m_IsRemotelyControlled; // 0x47
|
bool m_IsRemotelyControlled; // 0x47
|
||||||
|
char m_Pad2[0xA8]; // 0x48
|
||||||
|
int m_OwnershipToken; // 0xF0
|
||||||
};
|
};
|
||||||
static_assert(sizeof(rage::netObject) == 0x48);
|
static_assert(sizeof(rage::netObject) == 0xF8);
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ bool rage::rlGamerHandle::Serialize(rage::datBitBuffer& buf) const
|
|||||||
buf.Write<int>(m_Platform, 8);
|
buf.Write<int>(m_Platform, 8);
|
||||||
if (m_Platform != 3)
|
if (m_Platform != 3)
|
||||||
return false;
|
return false;
|
||||||
buf.Write<std::uint64_t>(m_RockstarId, 64);
|
buf.Write<std::int64_t>(m_RockstarId, 64, true);
|
||||||
buf.Write<std::uint16_t>(m_UnkData, 16);
|
buf.Write<std::uint16_t>(m_UnkData, 16);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -16,7 +16,7 @@ bool rage::rlGamerHandle::Deserialize(rage::datBitBuffer& buf)
|
|||||||
m_Platform = buf.Read<int>(8);
|
m_Platform = buf.Read<int>(8);
|
||||||
if (m_Platform != 3)
|
if (m_Platform != 3)
|
||||||
return false;
|
return false;
|
||||||
m_RockstarId = buf.Read<std::uint64_t>(64);
|
m_RockstarId = buf.Read<std::int64_t>(64, true);
|
||||||
m_UnkData = buf.Read<std::uint16_t>(16);
|
m_UnkData = buf.Read<std::uint16_t>(16);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,13 @@ namespace rage
|
|||||||
class rlGamerHandle
|
class rlGamerHandle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
uint64_t m_RockstarId; // 0x00
|
int64_t m_RockstarId; // 0x00
|
||||||
uint16_t m_UnkData; // 0x08
|
uint16_t m_UnkData; // 0x08
|
||||||
uint8_t m_Platform; // 0x0A
|
uint8_t m_Platform; // 0x0A
|
||||||
|
|
||||||
inline rlGamerHandle() = default;
|
inline rlGamerHandle() = default;
|
||||||
|
|
||||||
inline rlGamerHandle(uint64_t rockstar_id) :
|
inline rlGamerHandle(int64_t rockstar_id) :
|
||||||
m_RockstarId(rockstar_id),
|
m_RockstarId(rockstar_id),
|
||||||
m_Platform(3),
|
m_Platform(3),
|
||||||
m_UnkData(0)
|
m_UnkData(0)
|
||||||
|
15
network/sync/animal/CAnimalCreationData.hpp
Normal file
15
network/sync/animal/CAnimalCreationData.hpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
// TODO, CPedBaseCreationData
|
||||||
|
class CAnimalCreationData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
char pad_0000[4]; //0x0000
|
||||||
|
uint32_t m_PopulationType; //0x0004
|
||||||
|
uint32_t m_ModelHash; //0x0008
|
||||||
|
char pad_000C[18]; //0x000C
|
||||||
|
bool m_BannedPed; //0x001E
|
||||||
|
char pad_001F[5]; //0x001F
|
||||||
|
}; //Size: 0x0024
|
||||||
|
static_assert(sizeof(CAnimalCreationData) == 0x24);
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
// TODO
|
// TODO, CPedBaseCreationData
|
||||||
class CPedCreationData
|
class CPedCreationData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -5,14 +5,17 @@ class CPedTaskData
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
uint32_t m_TaskType; //0x0000
|
uint32_t m_TaskType; //0x0000
|
||||||
char pad_0004[16]; //0x0004
|
uint32_t m_TaskUnk1; //0x0004
|
||||||
|
uint32_t m_TaskTreeType; //0x0008
|
||||||
|
uint32_t m_TaskSequenceId; //0x000C
|
||||||
|
uint32_t m_TaskTreeDepth; //0x0010
|
||||||
}; //Size: 0x0014
|
}; //Size: 0x0014
|
||||||
static_assert(sizeof(CPedTaskData) == 0x14);
|
static_assert(sizeof(CPedTaskData) == 0x14);
|
||||||
|
|
||||||
class CPedTaskTree
|
class CPedTaskTree
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
uint32_t m_TreeType; //0x0000
|
uint32_t m_TreeType; //0x0000 not serialized
|
||||||
char pad_0004[4]; //0x0004 unused
|
char pad_0004[4]; //0x0004 unused
|
||||||
uint32_t m_NumTasks; //0x0008
|
uint32_t m_NumTasks; //0x0008
|
||||||
bool m_SequenceTree; //0x000C
|
bool m_SequenceTree; //0x000C
|
||||||
@ -21,6 +24,7 @@ public:
|
|||||||
}; //Size: 0x0110
|
}; //Size: 0x0110
|
||||||
static_assert(sizeof(CPedTaskTree) == 0x110);
|
static_assert(sizeof(CPedTaskTree) == 0x110);
|
||||||
|
|
||||||
|
// TODO: incorrect name
|
||||||
class CPedTaskTreeData
|
class CPedTaskTreeData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
16
network/sync/player/CPlayerCameraUncommonData.hpp
Normal file
16
network/sync/player/CPlayerCameraUncommonData.hpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include "rage/vector.hpp"
|
||||||
|
|
||||||
|
#pragma pack(push, 8)
|
||||||
|
class CPlayerCameraUncommonData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
rage::vector3 m_UnkCameraOffset; // 0x0
|
||||||
|
char m_Pad[8]; // 0x10
|
||||||
|
bool m_IsSpectating; // 0x18
|
||||||
|
private:
|
||||||
|
char m_Pad2[7]; // 0x19
|
||||||
|
}; //Size: 0x0010
|
||||||
|
static_assert(sizeof(CPlayerCameraUncommonData) == 0x20);
|
||||||
|
#pragma pack(pop)
|
10
network/sync/player/CPlayerCreationData.hpp
Normal file
10
network/sync/player/CPlayerCreationData.hpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
class CPlayerCreationData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint32_t m_Hash; // 0x0000
|
||||||
|
char m_Pad[20]; // 0x0004
|
||||||
|
}; //Size: 0x18
|
||||||
|
static_assert(sizeof(CPlayerCreationData) == 0x18);
|
22
network/sync/player/CPlayerGameStateUncommonData.hpp
Normal file
22
network/sync/player/CPlayerGameStateUncommonData.hpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include "rage/vector.hpp"
|
||||||
|
|
||||||
|
#pragma pack(push, 8)
|
||||||
|
class CPlayerGameStateUncommonData
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
char m_Pad[0x78];
|
||||||
|
public:
|
||||||
|
std::uint16_t m_SpectatorId; // 0x78
|
||||||
|
alignas(8) rage::vector3 m_SpectatePos; // 0x80
|
||||||
|
private:
|
||||||
|
char m_Pad2[0x4]; // 0x90
|
||||||
|
public:
|
||||||
|
bool m_IsSpectating; // 0x94
|
||||||
|
bool m_IsSpectatingStaticPos; // 0x95
|
||||||
|
private:
|
||||||
|
char m_Pad3[0xA]; // 0x96
|
||||||
|
}; //Size: 0x0010
|
||||||
|
static_assert(sizeof(CPlayerGameStateUncommonData) == 0xA0);
|
||||||
|
#pragma pack(pop)
|
30
network/sync/projectile/CProjectileCreationData.hpp
Normal file
30
network/sync/projectile/CProjectileCreationData.hpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include "rage/vector.hpp"
|
||||||
|
|
||||||
|
struct CProjectileCreationData
|
||||||
|
{
|
||||||
|
uint16_t unk_0000;
|
||||||
|
uint16_t m_OwnerObjectId;
|
||||||
|
uint32_t m_AmmoHash;
|
||||||
|
uint32_t m_WeaponHash;
|
||||||
|
uint32_t unk_000C;
|
||||||
|
rage::vector3 m_Vector;
|
||||||
|
uint32_t unk_0020;
|
||||||
|
uint16_t m_ObjectId2;
|
||||||
|
char pad_0026[2];
|
||||||
|
bool unk_0028;
|
||||||
|
char pad_0029[3];
|
||||||
|
uint32_t unk_002C;
|
||||||
|
bool pad_0030;
|
||||||
|
bool unk_0031;
|
||||||
|
char pad_0032[2];
|
||||||
|
float unk_0034;
|
||||||
|
bool unk_0038;
|
||||||
|
bool unk_0039;
|
||||||
|
bool unk_003A;
|
||||||
|
bool unk_003B;
|
||||||
|
char pad_003C[4];
|
||||||
|
rage::matrix34 m_Matrix;
|
||||||
|
};
|
||||||
|
static_assert(sizeof(CProjectileCreationData) == 0x80);
|
13
network/sync/propset/CPropSetCreationData.hpp
Normal file
13
network/sync/propset/CPropSetCreationData.hpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
class CPropSetCreationData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
char m_Pad[16]; // 0x0000
|
||||||
|
uint32_t m_Hash; // 0x0010
|
||||||
|
char m_Pad1[8]; // 0x0014
|
||||||
|
int32_t m_Type; // 0x001C
|
||||||
|
char m_Pad2[544]; // 0x0020
|
||||||
|
}; //Size: 0x240
|
||||||
|
static_assert(sizeof(CPropSetCreationData) == 0x240);
|
@ -14,7 +14,9 @@ public:
|
|||||||
uint32_t m_Timestamp; //0x0044
|
uint32_t m_Timestamp; //0x0044
|
||||||
bool m_HasPositionData; //0x0048
|
bool m_HasPositionData; //0x0048
|
||||||
alignas(16) rage::fvector3 m_Position; //0x0050
|
alignas(16) rage::fvector3 m_Position; //0x0050
|
||||||
rage::vector3<int> m_Velocity; //0x0060
|
int m_VelocityX;
|
||||||
|
int m_VelocityY;
|
||||||
|
int m_VelocityZ;
|
||||||
uint32_t m_UnkAmount; //0x006C
|
uint32_t m_UnkAmount; //0x006C
|
||||||
}; //Size: 0x0070
|
}; //Size: 0x0070
|
||||||
static_assert(sizeof(CVehicleProximityMigrationData) == 0x70);
|
static_assert(sizeof(CVehicleProximityMigrationData) == 0x70);
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "entity/fwEntity.hpp"
|
#include "physical/CPhysical.hpp"
|
||||||
|
|
||||||
// TODO
|
class CPed : public CPhysical
|
||||||
class CPed : public rage::fwEntity
|
|
||||||
{
|
{
|
||||||
};
|
char m_Pad6[0x18]; // 0x0368
|
||||||
|
};
|
||||||
|
static_assert(sizeof(CPed) == 0x380);
|
9
physical/CPhysical.hpp
Normal file
9
physical/CPhysical.hpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "entity/CDynamicEntity.hpp"
|
||||||
|
|
||||||
|
class CPhysical : public CDynamicEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
char m_Pad5[0x1B8]; // 0x01B0
|
||||||
|
};
|
||||||
|
static_assert(sizeof(CPhysical) == 0x368);
|
@ -159,24 +159,58 @@ namespace rage
|
|||||||
return WriteDword(low, 32) && WriteDword(high, size - 32);
|
return WriteDword(low, 32) && WriteDword(high, size - 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool ReadInt64(int64_t* value, int size)
|
||||||
|
{
|
||||||
|
unsigned int last_bit{};
|
||||||
|
uint64_t rest{};
|
||||||
|
|
||||||
|
if (!ReadQword((uint64_t*)&last_bit, 1) || ReadQword(&rest, size - 1))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
*value = ((uint64_t)last_bit << 63) | rest ^ -(int64_t)last_bit;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool WriteInt64(int64_t value, int size)
|
||||||
|
{
|
||||||
|
auto last_bit = value >> 63;
|
||||||
|
if (!WriteQword(last_bit, 1) || !WriteQword((uint64_t)value ^ -(__int64)(unsigned int)last_bit, size - 1))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// unsigned
|
// unsigned
|
||||||
|
// TODO: signed likely only works for 64 bit values!
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T Read(int size)
|
T Read(int size, bool _signed = false)
|
||||||
{
|
{
|
||||||
static_assert(sizeof(T) <= 8);
|
static_assert(sizeof(T) <= 8);
|
||||||
|
|
||||||
uint64_t data{};
|
uint64_t data{};
|
||||||
ReadQword(&data, size);
|
int64_t data_signed{};
|
||||||
return T(data);
|
if (_signed)
|
||||||
|
ReadInt64(&data_signed, size);
|
||||||
|
else
|
||||||
|
ReadQword(&data, size);
|
||||||
|
|
||||||
|
if (_signed)
|
||||||
|
return T(data_signed);
|
||||||
|
else
|
||||||
|
return T(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// unsigned
|
// unsigned
|
||||||
|
// TODO: signed likely only works for 64 bit values!
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void Write(T data, int size)
|
void Write(T data, int size, bool _signed = false)
|
||||||
{
|
{
|
||||||
static_assert(sizeof(T) <= 8);
|
static_assert(sizeof(T) <= 8);
|
||||||
|
|
||||||
WriteQword(uint64_t(data), size);
|
if (_signed)
|
||||||
|
WriteInt64(int64_t(data), size);
|
||||||
|
else
|
||||||
|
WriteQword(uint64_t(data), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -10,10 +10,10 @@ namespace rage
|
|||||||
class tlsContext
|
class tlsContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
char pad[0x410]; // 0x0000
|
char pad[0x600]; // 0x0000
|
||||||
int m_SyncThreadIndex; // 0x0410
|
int m_SyncThreadIndex; // 0x0600
|
||||||
char pad2[0x12EC]; // 0x0414
|
char pad2[0x12EC]; // 0x0604
|
||||||
bool m_RunningScript; // 0x1700
|
bool m_RunningScript; // 0x18F0
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
static tlsContext* Get()
|
static tlsContext* Get()
|
||||||
@ -24,5 +24,5 @@ namespace rage
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
static_assert(sizeof(rage::tlsContext) == 0x1704);
|
static_assert(sizeof(rage::tlsContext) == 0x18F4);
|
||||||
}
|
}
|
147
rage/vector.hpp
147
rage/vector.hpp
@ -4,13 +4,13 @@
|
|||||||
#pragma pack(push, 0x10)
|
#pragma pack(push, 0x10)
|
||||||
namespace rage
|
namespace rage
|
||||||
{
|
{
|
||||||
template<typename T>
|
// atVector<float, 2>?
|
||||||
class vector2
|
class vector2
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
T x, y;
|
float x, y;
|
||||||
|
|
||||||
constexpr vector2(T x, T y) :
|
constexpr vector2(float x, float y) :
|
||||||
x(x),
|
x(x),
|
||||||
y(y)
|
y(y)
|
||||||
{
|
{
|
||||||
@ -23,13 +23,16 @@ namespace rage
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
// atVector<float, 3>?
|
||||||
class vector3
|
class vector3
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
T x, y, z;
|
float x, y, z;
|
||||||
|
private:
|
||||||
|
int _PAD; // because alignof doesn't work
|
||||||
|
public:
|
||||||
|
|
||||||
constexpr vector3(T x, T y, T z) :
|
constexpr vector3(float x, float y, float z) :
|
||||||
x(x),
|
x(x),
|
||||||
y(y),
|
y(y),
|
||||||
z(z)
|
z(z)
|
||||||
@ -43,26 +46,72 @@ namespace rage
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
bool operator==(const vector3& other) const
|
||||||
bool operator==(const vector3<T>& other) const
|
|
||||||
{
|
{
|
||||||
return this->x == other.x && this->y == other.y && this->z == other.z;
|
return this->x == other.x && this->y == other.y && this->z == other.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool operator!=(const vector3<T>& other) const
|
bool operator!=(const vector3& other) const
|
||||||
{
|
{
|
||||||
return this->x != other.x || this->y != other.y || this->z != other.z;
|
return this->x != other.x || this->y != other.y || this->z != other.z;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
vector3 operator+(const vector3& other) const
|
||||||
|
{
|
||||||
|
vector3 vec;
|
||||||
|
vec.x = this->x + other.x;
|
||||||
|
vec.y = this->y + other.y;
|
||||||
|
vec.z = this->z + other.z;
|
||||||
|
return vec;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector3 operator-(const vector3& other) const
|
||||||
|
{
|
||||||
|
vector3 vec;
|
||||||
|
vec.x = this->x - other.x;
|
||||||
|
vec.y = this->y - other.y;
|
||||||
|
vec.z = this->z - other.z;
|
||||||
|
return vec;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector3 operator*(const vector3& other) const
|
||||||
|
{
|
||||||
|
vector3 vec;
|
||||||
|
vec.x = this->x * other.x;
|
||||||
|
vec.y = this->y * other.y;
|
||||||
|
vec.z = this->z * other.z;
|
||||||
|
return vec;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector3 operator*(const float& other) const
|
||||||
|
{
|
||||||
|
vector3 vec;
|
||||||
|
vec.x = this->x * other;
|
||||||
|
vec.y = this->y * other;
|
||||||
|
vec.z = this->z * other;
|
||||||
|
return vec;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float GetMagnitude() const
|
||||||
|
{
|
||||||
|
return sqrt(x * x + y * y + z * z);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float GetDistance(const vector3& other) const
|
||||||
|
{
|
||||||
|
return (*this - other).GetMagnitude();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
static_assert(sizeof(rage::vector3) == 0x10);
|
||||||
|
|
||||||
|
// atVector<float, 4>?
|
||||||
class vector4
|
class vector4
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
T x, y, z, w;
|
float x, y, z, w;
|
||||||
|
|
||||||
constexpr vector4(T x, T y, T z, T w) :
|
constexpr vector4(float x, float y, float z, float w) :
|
||||||
x(x),
|
x(x),
|
||||||
y(y),
|
y(y),
|
||||||
z(z),
|
z(z),
|
||||||
@ -79,75 +128,23 @@ namespace rage
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
union matrix34
|
union matrix34
|
||||||
{
|
{
|
||||||
T data[3][4];
|
float data[4][4]; // yes, the underlying representation is 4x4
|
||||||
struct { struct { T x, y, z, w; } rows[3]; };
|
struct { struct { float x, y, z, w; } rows[3]; };
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
union matrix44
|
union matrix44
|
||||||
{
|
{
|
||||||
T data[4][4];
|
float data[4][4];
|
||||||
struct { struct { T x, y, z, w; } rows[4]; };
|
struct { struct { float x, y, z, w; } rows[4]; };
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef vector2<float> fvector2;
|
|
||||||
typedef vector4<float> fvector4;
|
|
||||||
typedef matrix34<float> fmatrix34;
|
|
||||||
typedef matrix44<float> fmatrix44;
|
|
||||||
|
|
||||||
class fvector3 : public vector3<float>
|
// backwards compatibility
|
||||||
{
|
// TODO: remove these!
|
||||||
public:
|
using fvector2 = vector2;
|
||||||
using vector3::vector3;
|
using fvector3 = vector3;
|
||||||
|
using fvector4 = vector4;
|
||||||
fvector3 operator+(const fvector3& other) const
|
};
|
||||||
{
|
|
||||||
fvector3 vec;
|
|
||||||
vec.x = this->x + other.x;
|
|
||||||
vec.y = this->y + other.y;
|
|
||||||
vec.z = this->z + other.z;
|
|
||||||
return vec;
|
|
||||||
}
|
|
||||||
|
|
||||||
fvector3 operator-(const fvector3& other) const
|
|
||||||
{
|
|
||||||
fvector3 vec;
|
|
||||||
vec.x = this->x - other.x;
|
|
||||||
vec.y = this->y - other.y;
|
|
||||||
vec.z = this->z - other.z;
|
|
||||||
return vec;
|
|
||||||
}
|
|
||||||
|
|
||||||
fvector3 operator*(const fvector3& other) const
|
|
||||||
{
|
|
||||||
fvector3 vec;
|
|
||||||
vec.x = this->x * other.x;
|
|
||||||
vec.y = this->y * other.y;
|
|
||||||
vec.z = this->z * other.z;
|
|
||||||
return vec;
|
|
||||||
}
|
|
||||||
|
|
||||||
fvector3 operator*(const float& other) const
|
|
||||||
{
|
|
||||||
fvector3 vec;
|
|
||||||
vec.x = this->x * other;
|
|
||||||
vec.y = this->y * other;
|
|
||||||
vec.z = this->z * other;
|
|
||||||
return vec;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline float GetMagnitude() const
|
|
||||||
{
|
|
||||||
return std::sqrt(x * x + y * y + z * z);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline float GetDistance(const rage::fvector3& other) const
|
|
||||||
{
|
|
||||||
return (*this - other).GetMagnitude();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
Loading…
Reference in New Issue
Block a user