Skip to content

Commit

Permalink
support strHandlingFlags entry 0x2000000
Browse files Browse the repository at this point in the history
this was added in the mpbiker update, and apparently disables traction control for bikes.

default vehicles using it include the hakuchou2 and sanctus.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=647f0d6622ef3b35bdc43b5b66e0ac5a805afd7c
  • Loading branch information
blattersturm committed Apr 16, 2017
1 parent 17f40de commit acaae1a
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions components/gta-core-five/src/PatchHandlingFlag25.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "StdInc.h"
#include "Hooking.h"

static HookFunction hookFunction([]()
{
static struct : jitasm::Frontend
{
void InternalMain() override
{
// test whether or not we have to skip
mov(rax, qword_ptr[rdi + 0x830]); // rax = rdi+_CVehicle.handling
test(dword_ptr[rax + 0x120], 0x2000000); // if (rax+_CHandlingData.strHandlingFlags & 0x2000000)
jnz("skip_entirely"); // goto skip_entirely

// run original code
cmp(ebx, dword_ptr[rdi + 0xA98]); // original code we overwrote
ret(); // return;

// skipping label
L("skip_entirely"); // skip_entirely:
mov(rax, qword_ptr[rsp]); // rax = _ReturnAddress()
add(rax, 0x3E - 5); // rax += (0x3E - 5)
// difference between end of CALL and the ending of the branch

mov(qword_ptr[rsp], rax); // *_AddressOfReturnAddress() = rax
ret(); // return;
}
} tractionControlSkipStub;

auto location = hook::get_pattern("73 69 3B 9F ? ? 00 00 7D 0D", 0x6B);
hook::nop(location, 6);
hook::call(location, tractionControlSkipStub.GetCode());
});

0 comments on commit acaae1a

Please sign in to comment.