Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5035b7f

Browse files
Kamil Marciniakqaisjp
Kamil Marciniak
authored andcommitted
Fix changing handling max gear to lower than current one crashing client (#778)
* Fix changing max number of gears resulting in crash * Match CTransmission with db * fix typos
1 parent 23aef88 commit 5035b7f

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

‎Client/game_sa/CVehicleSA.h‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,29 @@ struct CTrainFlags
315315
unsigned char unknown7 : 8;
316316
};
317317

318+
struct CTransmissionGear
319+
{
320+
float maxGearVelocity;
321+
float changeUpVelocity;
322+
float changeDownVelocity;
323+
};
324+
325+
struct CTransmission
326+
{
327+
CTransmissionGear gears[6];
328+
byte driveType;
329+
byte engineType;
330+
byte numOfGears;
331+
byte pad;
332+
DWORD handlingFlags;
333+
float engineAcceleration;
334+
float engineInertia;
335+
float maxGearVelocity;
336+
byte pad2[4];
337+
float minGearVelocity;
338+
float curSpeed;
339+
};
340+
318341
class CAutoPilot
319342
{
320343
BYTE pad[56];

‎Client/multiplayer_sa/CMultiplayerSA.cpp‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ DWORD RETURN_VehColCB = 0x04C83AA;
186186
#define HOOKPOS_VehCol 0x06D6603
187187
DWORD RETURN_VehCol = 0x06D660C;
188188

189+
#define HOOKPOS_Transmission_CalculateDriveAcceleration 0x6D05E0
190+
DWORD RETURN_Transmission_CalculateDriveAcceleration = 0x6D05E6;
189191
// Handling fix - driveType is per model
190192
#define HOOKPOS_CHandlingData_isNotRWD 0x6A048C
191193
DWORD RETURN_CHandlingData_isNotRWD = 0x6A0493;
@@ -450,6 +452,7 @@ void HOOK_CrashFix_Misc24();
450452
void HOOK_CheckAnimMatrix();
451453
void HOOK_VehColCB();
452454
void HOOK_VehCol();
455+
void HOOK_Transmission_CalculateDriveAcceleration();
453456
void HOOK_isVehDriveTypeNotRWD();
454457
void HOOK_isVehDriveTypeNotFWD();
455458
void HOOK_PreFxRender();
@@ -658,6 +661,8 @@ void CMultiplayerSA::InitHooks()
658661
HookInstall(HOOKPOS_PreHUDRender, (DWORD)HOOK_PreHUDRender, 5);
659662
HookInstall(HOOKPOS_CAutomobile__ProcessSwingingDoor, (DWORD)HOOK_CAutomobile__ProcessSwingingDoor, 7);
660663

664+
HookInstall(HOOKPOS_Transmission_CalculateDriveAcceleration, (DWORD)HOOK_Transmission_CalculateDriveAcceleration, 5);
665+
661666
HookInstall(HOOKPOS_CHandlingData_isNotRWD, (DWORD)HOOK_isVehDriveTypeNotRWD, 7);
662667
HookInstall(HOOKPOS_CHandlingData_isNotFWD, (DWORD)HOOK_isVehDriveTypeNotFWD, 7);
663668

@@ -4069,6 +4074,40 @@ void GetVehicleDriveType()
40694074
ucDriveType = static_cast<unsigned char>(pHandlingDriveTypeVeh->m_pVehicle->GetHandlingData()->GetCarDriveType());
40704075
}
40714076

4077+
static CTransmission* pCurTransmission = nullptr;
4078+
static byte* pCurGear = nullptr;
4079+
4080+
void CheckVehicleMaxGear()
4081+
{
4082+
if (*pCurGear > pCurTransmission->numOfGears)
4083+
{
4084+
*pCurGear = pCurTransmission->numOfGears;
4085+
}
4086+
}
4087+
4088+
void _declspec(naked) HOOK_Transmission_CalculateDriveAcceleration()
4089+
{
4090+
_asm
4091+
{
4092+
push eax
4093+
mov pCurTransmission, ecx
4094+
mov eax, [esp+0xC]
4095+
mov pCurGear, eax
4096+
pop eax
4097+
pushad
4098+
}
4099+
4100+
CheckVehicleMaxGear();
4101+
4102+
_asm
4103+
{
4104+
popad
4105+
mov eax, [esp+0x10]
4106+
mov edx, [eax]
4107+
jmp RETURN_Transmission_CalculateDriveAcceleration
4108+
}
4109+
}
4110+
40724111
void _declspec(naked) HOOK_isVehDriveTypeNotRWD()
40734112
{
40744113
// Get the Vehicle interface from esi

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /