DK22Pac / plugin-sdk

An SDK for developing ASI/CLEO plugins for GTA San Andreas, GTA Vice City and GTA III
zlib License
431 stars 114 forks source link

Crash when calling CPlaceable::GetAtDirection() #159

Open japajoe opened 1 year ago

japajoe commented 1 year ago

The function call in this method is incorrect and causes my application to crash:

CVector CPlaceable::GetAtDirection()
{
    return ((CVector(__thiscall *)(CPlaceable *, ))0x50E420)(this);
}

Upon inspection I noticed the method takes in a float pointer as parameter, which is then assigned in the actual method. The return type is also incorrect as it still crashes because a CVector is not returned. With the following adjustments I have managed to get it to work:

CVector CPlaceable::GetAtDirection()
{
    CVector result;
    ((void(__thiscall *)(CPlaceable *, float *))0x50E420)(this, &result.x);
    return result;
}

Also, the following 2 methods suffer from the same issue:

CPlaceable::GetRightDirection() CPlaceable::GetTopDirection()