Skip to content
Permalink
Browse files
Removed obsolete properties and functions
  • Loading branch information
crosire committed Jul 22, 2015
1 parent 0cfbf67 commit 1371e63bd7a4b7678a3586050961e5d658f76f09
@@ -289,16 +289,6 @@ namespace GTA

void HideNumber();
void ShowNumber(int number);
[System::ObsoleteAttribute("Blip.SetAsFriendly is obsolete, please use Blip.IsFriendly instead")]
void SetAsFriendly()
{
IsFriendly = true;
}
[System::ObsoleteAttribute("Blip.SetAsHostile is obsolete, please use Blip.IsFriendly instead")]
void SetAsHostile()
{
IsFriendly = false;
}

bool Exists();
void Remove();
@@ -35,31 +35,11 @@ namespace GTA
{
void set(float strength);
}
[System::ObsoleteAttribute("Camera.DOFStrength is obsolete, please use Camera.DepthOfFieldStrength instead")]
property float DOFStrength
{
void set(float strength)
{
DepthOfFieldStrength = strength;
}
}
property float FieldOfView
{
float get();
void set(float fov);
}
[System::ObsoleteAttribute("Camera.FOV is obsolete, please use Camera.FieldOfView instead")]
property float FOV
{
float get()
{
return FieldOfView;
}
void set(float fov)
{
FieldOfView = fov;
}
}
property float FarClip
{
float get();
@@ -70,18 +50,6 @@ namespace GTA
float get();
void set(float farDOF);
}
[System::ObsoleteAttribute("Camera.FarDOF is obsolete, please use Camera.FarDepthOfField instead")]
property float FarDOF
{
float get()
{
return FarDepthOfField;
}
void set(float farDOF)
{
FarDepthOfField = farDOF;
}
}
property bool IsActive
{
bool get();
@@ -109,14 +77,6 @@ namespace GTA
{
void set(float nearDOF);
}
[System::ObsoleteAttribute("Camera.NearDOF is obsolete, please use Camera.NearDepthOfField instead")]
property float NearDOF
{
void set(float nearDOF)
{
NearDepthOfField = nearDOF;
}
}
property Math::Vector3 Position
{
Math::Vector3 get();
@@ -12,14 +12,6 @@ namespace GTA
public:
Entity(int handle);

[System::ObsoleteAttribute("Entity.ID is obsolete, please use Entity.Handle instead.")]
property int ID
{
int get()
{
return Handle;
}
}
property int Handle
{
int get();
@@ -11,14 +11,6 @@ namespace GTA
{
float get();
}
[System::ObsoleteAttribute("GameplayCamera.FOV is obsolete, please use GameplayCamera.FieldOfView instead")]
static property float FOV
{
float get()
{
return FieldOfView;
}
}
static property bool IsAimCamActive
{
bool get();
@@ -17,11 +17,11 @@
#include "Native.hpp"
#include "ScriptDomain.hpp"

#include "Entity.hpp"
#include "Prop.hpp"
#include "Blip.hpp"
#include "Entity.hpp"
#include "Ped.hpp"
#include "Player.hpp"
#include "Prop.hpp"
#include "Vector2.hpp"
#include "Vector3.hpp"
#include "Vehicle.hpp"
@@ -153,7 +153,6 @@ namespace GTA
delete[] this->mStorage;
}


Object ^GetResult(Type ^type, PUINT64 value)
{
if (type == Boolean::typeid)
@@ -205,42 +204,44 @@ namespace GTA
return gcnew Math::Vector3(reinterpret_cast<NativeVector3 *>(value)->x, reinterpret_cast<NativeVector3 *>(value)->y, reinterpret_cast<NativeVector3 *>(value)->z);
}

if (type == Ped::typeid)
if (type == Blip::typeid)
{
return gcnew Ped(*reinterpret_cast<int *>(value));
return gcnew Blip(*reinterpret_cast<int *>(value));
}
if (type == Player::typeid)
if (type == Entity::typeid)
{
return gcnew Player(*reinterpret_cast<int *>(value));
const int handle = *reinterpret_cast<int *>(value);

if (Function::Call<bool>(Hash::DOES_ENTITY_EXIST, handle))
{
switch (Function::Call<int>(Hash::GET_ENTITY_TYPE, handle))
{
case 1:
return gcnew Ped(handle);
case 2:
return gcnew Vehicle(handle);
case 3:
return gcnew Prop(handle);
}
}

return nullptr;
}
if (type == Vehicle::typeid)
if (type == Ped::typeid)
{
return gcnew Vehicle(*reinterpret_cast<int *>(value));
return gcnew Ped(*reinterpret_cast<int *>(value));
}
if (type == Blip::typeid)
if (type == Player::typeid)
{
return gcnew Blip(*reinterpret_cast<int *>(value));
return gcnew Player(*reinterpret_cast<int *>(value));
}
if (type == Prop::typeid)
{
return gcnew Prop(*reinterpret_cast<int *>(value));
}
if (type == Entity::typeid)
if (type == Vehicle::typeid)
{
int handle = *reinterpret_cast<int *>(value);
if (Native::Function::Call<bool>(Native::Hash::DOES_ENTITY_EXIST, handle))
{
switch (Native::Function::Call<int>(Native::Hash::GET_ENTITY_TYPE, handle))
{
case 1:
return gcnew Ped(handle);
case 2:
return gcnew Vehicle(handle);
case 3:
return gcnew Prop(handle);
}
}
return nullptr;
return gcnew Vehicle(*reinterpret_cast<int *>(value));
}

throw gcnew InvalidCastException(String::Concat("Unable to cast native value to object of type '", type->FullName, "'"));
@@ -21,12 +21,13 @@

namespace GTA
{
ref class Blip;
ref class Entity;
value class Model;
ref class Ped;
ref class Player;
ref class Vehicle;
ref class Blip;
ref class Prop;
ref class Vehicle;

namespace Native
{
@@ -134,11 +135,9 @@ namespace GTA

unsigned char *mStorage;
};

public ref class InOutArgument : public OutputArgument
{
public:

InOutArgument(bool value);
InOutArgument(int value);
InOutArgument(float value);
@@ -150,16 +149,13 @@ namespace GTA
InOutArgument(Blip ^object);
InOutArgument(Prop ^object);
InOutArgument(Model model);

~InOutArgument()
{
this->!InOutArgument();
}

private:
protected:
!InOutArgument();


};

public ref class Function abstract sealed
@@ -5,6 +5,7 @@

namespace GTA
{
using namespace System;
using namespace System::Collections::Generic;

static MemoryAccess::MemoryAccess()
@@ -15,45 +16,36 @@ namespace GTA
sAddressEntityPool = reinterpret_cast<MemoryPool **>(*reinterpret_cast<int *>(patternAddress + 3) + patternAddress + 7);
}

int MemoryAccess::HandleToIndex(int Handle)
int MemoryAccess::HandleToIndex(int handle)
{
return Handle >> 8; // == Handle / 256
return handle >> 8; // == handle / 256
}

uintptr_t MemoryAccess::GetAddressOfEntity(int Handle)
uintptr_t MemoryAccess::GetAddressOfEntity(int handle)
{
return *reinterpret_cast<uintptr_t*>(GetAddressOfItemInPool(*sAddressEntityPool, Handle) + 8);
return *reinterpret_cast<const uintptr_t *>(GetAddressOfItemInPool(*sAddressEntityPool, handle) + 8);
}
array<int> ^MemoryAccess::GetEntityHandleList()
{
return GetListOfHandlesInPool(*sAddressEntityPool);
}
float MemoryAccess::GetVehicleRPM(int handle)
{
uintptr_t addr = GetAddressOfEntity(handle);
if (addr == 0)
{
return 0.0f;
}
return *(float*)(addr + 2004);
const uintptr_t address = GetAddressOfEntity(handle);

return address == 0 ? 0.0f : *reinterpret_cast<const float *>(address + 2004);
}
float MemoryAccess::GetVehicleAcceleration(int handle)
{
uintptr_t addr = GetAddressOfEntity(handle);
if (addr == 0)
{
return 0.0f;
}
return *(float*)(addr + 2020);
const uintptr_t address = GetAddressOfEntity(handle);

return address == 0 ? 0.0f : *reinterpret_cast<const float *>(address + 2020);
}
float MemoryAccess::GetVehicleSteering(int handle)
{
uintptr_t addr = GetAddressOfEntity(handle);
if (addr == 0)
{
return 0.0f;
}
return *(float*)(addr + 2212);
const uintptr_t address = GetAddressOfEntity(handle);

return address == 0 ? 0.0f : *reinterpret_cast<const float *>(address + 2212);
}

uintptr_t MemoryAccess::FindPattern(const char *pattern, const char *mask)
@@ -62,18 +54,18 @@ namespace GTA
GetModuleInformation(GetCurrentProcess(), GetModuleHandle(nullptr), &modInfo, sizeof(MODULEINFO));

const char *start_offset = reinterpret_cast<const char *>(modInfo.lpBaseOfDll);
const uintptr_t size = static_cast<uintptr_t>(modInfo.SizeOfImage);
const size_t size = static_cast<size_t>(modInfo.SizeOfImage);

intptr_t pos = 0;
const uintptr_t searchLen = static_cast<uintptr_t>(strlen(mask) - 1);
const size_t searchLen = static_cast<size_t>(strlen(mask) - 1);

for (const char *retAddress = start_offset; retAddress < start_offset + size; retAddress++)
{
if (*retAddress == pattern[pos] || mask[pos] == '?')
{
if (mask[pos + 1] == '\0')
{
return (reinterpret_cast<uintptr_t>(retAddress) - searchLen);
return reinterpret_cast<uintptr_t>(retAddress) - searchLen;
}

pos++;
@@ -94,16 +86,17 @@ namespace GTA
return 0;
}

const int index = HandleToIndex(Handle);
const int flag = PoolAddress->BoolAdr[index]; // flag should be equal to 2 if everything is ok
const int idx = HandleToIndex(Handle);
// Flag should be equal to 2 if everything is ok
const int flag = static_cast<int>(PoolAddress->BoolAddress[idx]);

// parity check? (taken from ScriptHookDotNet for IV
// Parity check (taken from ScriptHookDotNet for GTAIV)
if (flag & 0x80 || flag != (Handle & 0xFF))
{
return 0;
}

return (PoolAddress->ListAddr + index * PoolAddress->ItemSize);
return PoolAddress->ListAddress + idx * PoolAddress->ItemSize;
}
array<int> ^MemoryAccess::GetListOfHandlesInPool(MemoryPool *PoolAddress)
{
@@ -116,11 +109,12 @@ namespace GTA

for (int i = 0; i < PoolAddress->MaxCount; i++)
{
int val = static_cast<int>(PoolAddress->BoolAdr[i]); // parity value, important to cast it to int
int val = static_cast<int>(PoolAddress->BoolAddress[i]);

if ((val & 0x80) == 0)
{
val = (i << 8) | val;

handles->Add(val);
}
}
@@ -6,8 +6,8 @@ namespace GTA
{
private struct MemoryPool
{
uintptr_t ListAddr;
char *BoolAdr;
uintptr_t ListAddress;
char *BoolAddress;
int MaxCount;
int ItemSize;
};
@@ -16,9 +16,9 @@ namespace GTA
public:
static MemoryAccess();

static int HandleToIndex(int Handle);
static int HandleToIndex(int handle);

static uintptr_t GetAddressOfEntity(int Handle);
static uintptr_t GetAddressOfEntity(int handle);
static array<int> ^GetEntityHandleList();

static float GetVehicleRPM(int handle);

0 comments on commit 1371e63

Please sign in to comment.