GTA V Handling Replacement
==========================

A library that helps scripts change a vehicles' handling without affecting unrelated vehicles of the same model.

## Installation

Grand Theft Auto V (v1868+) required.
Extract HandlingReplacement.asi to GTA V's main folder. 

## Development

Check `HandlingReplacement.h` for the three functions. The asi loader should already have loaded and initialized things, so one can just start using it right away.

Usage example:

```cpp
void MyFeature::Update() {
    void* handlingDataOrig = nullptr;
    void* handlingDataReplace = nullptr;
    
    if (!HR_GetHandlingData(g_playerVehicle, &handlingDataOrig, &handlingDataReplace)) {
        HR_Enable(g_playerVehicle, &handlingDataReplace);
        return;
    }

    // Write whatever field is needed
    *(float*)((uint8_t*)handlingDataReplace + fInitialDriveForceOffset) = 1.0f;
}
```

## Acknowledgements

FiveM - On some bits on how to properly replace/clone subhandlingdata, and the rage alloc/free.

## Changelog

### 1.1.0

* Compatibility patch for game version v1.0.3095.0 and newer
  * Tested on v1.0.3337.0

Remarks:

This is a worse solution than 1.0.0:

* Leaks 1.5kB memory every instance (memory does not deallocate)
* SubHandlingData is NOT replaced anymore, the original instance is active

This is due prior method of re-using FiveM's usage of using GTA V's allocator not being functional anymore (after... 2802?), and me having not the slightest clue how to properly do this again. I just need a release out of the door to fix Manual Transmission crashing upon usage of dynamic AWD, and this (sloppily) fixes it.

If you know how GTA V's allocator can be used, I'd be happy to hear it and release a proper update. Check https://github.com/ikt32/GTAVHandlingReplacement for the source code.

### 1.0.0

* Initial release
