Skip to content

Commit 26751e6

Browse files
committed
Add new glich (vehicle_rapid_stop)
1 parent 527f873 commit 26751e6

File tree

11 files changed

+109
-0
lines changed

11 files changed

+109
-0
lines changed

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ CClientGame::CClientGame(bool bLocalPlay) : m_ServerInfo(new CServerInfo())
137137
m_Glitches[GLITCH_BADDRIVEBYHITBOX] = false;
138138
m_Glitches[GLITCH_QUICKSTAND] = false;
139139
m_Glitches[GLITCH_KICKOUTOFVEHICLE_ONMODELREPLACE] = false;
140+
m_Glitches[GLITCH_VEHICLE_RAPID_STOP] = false;
141+
g_pMultiplayer->SetRapidVehicleStopFixEnabled(true);
140142

141143
g_pMultiplayer->DisableBadDrivebyHitboxes(true);
142144

@@ -5992,6 +5994,8 @@ bool CClientGame::SetGlitchEnabled(unsigned char ucGlitch, bool bEnabled)
59925994
g_pMultiplayer->DisableQuickReload(!bEnabled);
59935995
if (ucGlitch == GLITCH_CLOSEDAMAGE)
59945996
g_pMultiplayer->DisableCloseRangeDamage(!bEnabled);
5997+
if (ucGlitch == GLITCH_VEHICLE_RAPID_STOP)
5998+
g_pMultiplayer->SetRapidVehicleStopFixEnabled(!bEnabled);
59955999
return true;
59966000
}
59976001
return false;

Client/mods/deathmatch/logic/CClientGame.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ class CClientGame
204204
GLITCH_BADDRIVEBYHITBOX,
205205
GLITCH_QUICKSTAND,
206206
GLITCH_KICKOUTOFVEHICLE_ONMODELREPLACE,
207+
GLITCH_VEHICLE_RAPID_STOP,
207208
NUM_GLITCHES
208209
};
209210

Client/mods/deathmatch/logic/CPacketHandler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,6 +2378,7 @@ void CPacketHandler::Packet_MapInfo(NetBitStreamInterface& bitStream)
23782378
g_pClientGame->SetGlitchEnabled(CClientGame::GLITCH_FASTSPRINT, funBugs.data3.bFastSprint);
23792379
g_pClientGame->SetGlitchEnabled(CClientGame::GLITCH_BADDRIVEBYHITBOX, funBugs.data4.bBadDrivebyHitboxes);
23802380
g_pClientGame->SetGlitchEnabled(CClientGame::GLITCH_QUICKSTAND, funBugs.data5.bQuickStand);
2381+
g_pClientGame->SetGlitchEnabled(CClientGame::GLITCH_VEHICLE_RAPID_STOP, funBugs.data6.vehicleRapidStop);
23812382

23822383
SWorldSpecialPropertiesStateSync wsProps;
23832384
if (bitStream.Can(eBitStreamVersion::WorldSpecialProperties))

Client/multiplayer_sa/CMultiplayerSA.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ class CMultiplayerSA : public CMultiplayer
336336
bool IsVehicleEngineAutoStartEnabled() const noexcept override;
337337
void SetVehicleEngineAutoStartEnabled(bool enabled) override;
338338

339+
bool IsRapidVehicleStopFixEnabled() const noexcept override { return isRapidVehicleStopFixEnabled; };
340+
void SetRapidVehicleStopFixEnabled(bool enabled) override;
341+
339342
void SetPedTargetingMarkerEnabled(bool bEnable);
340343
bool IsPedTargetingMarkerEnabled();
341344
bool IsConnected();
@@ -385,6 +388,8 @@ class CMultiplayerSA : public CMultiplayer
385388
DWORD m_dwLastAnimArrayAddress;
386389
float m_fShadowsOffset;
387390

391+
bool isRapidVehicleStopFixEnabled{false};
392+
388393
/* VOID SetPlayerShotVectors(CPlayerPed* player, Vector3D * vecTarget, Vector3D * vecStart);
389394
VOID SetPlayerCameraVectors(CPlayerPed* player, Vector3D * vecSource, Vector3D * vecFront);
390395
Vector3D * GetLocalShotOriginVector();*/

Client/multiplayer_sa/CMultiplayerSA_FrameRateFixes.cpp

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,77 @@ static void __declspec(naked) HOOK_CWeapon_Update()
619619
}
620620
}
621621

622+
#define HOOKPOS_CPhysical__ApplyAirResistance 0x544D29
623+
#define HOOKSIZE_CPhysical__ApplyAirResistance 5
624+
static const unsigned int RETURN_CPhysical__ApplyAirResistance = 0x544D4D;
625+
static void _declspec(naked) HOOK_CPhysical__ApplyAirResistance()
626+
{
627+
_asm {
628+
fld ds:[0x862CD0] // 0.99000001f
629+
fld ds:[0xB7CB5C] // CTimer::ms_fTimeStep
630+
fdiv kOriginalTimeStep // 1.666f
631+
mov eax, 0x822130 // powf
632+
call eax
633+
634+
fld st(0)
635+
fmul [esi+0x50]
636+
fstp [esi+0x50]
637+
638+
fld st(0)
639+
fmul [esi+0x54]
640+
fstp [esi+0x54]
641+
642+
fmul [esi+0x58]
643+
fstp [esi+0x58]
644+
jmp RETURN_CPhysical__ApplyAirResistance
645+
}
646+
}
647+
648+
template <unsigned int returnAddress>
649+
static void _declspec(naked) HOOK_VehicleRapidStopFix()
650+
{
651+
static unsigned int RETURN_VehicleRapidStopFix = returnAddress;
652+
_asm {
653+
fld ds:[0xC2B9CC] // mod_HandlingManager.m_fWheelFriction
654+
fmul ds:[0xB7CB5C] // CTimer::ms_fTimeStep
655+
fdiv kOriginalTimeStep // 1.666f
656+
jmp RETURN_VehicleRapidStopFix
657+
}
658+
}
659+
660+
void CMultiplayerSA::SetRapidVehicleStopFixEnabled(bool enabled)
661+
{
662+
if (isRapidVehicleStopFixEnabled == enabled)
663+
return;
664+
665+
if (enabled)
666+
{
667+
EZHookInstall(CPhysical__ApplyAirResistance);
668+
669+
// CVehicle::ProcessWheel
670+
HookInstall(0x6D6E69, (DWORD)HOOK_VehicleRapidStopFix<0x6D6E6F>, 6);
671+
HookInstall(0x6D6EA8, (DWORD)HOOK_VehicleRapidStopFix<0x6D6EAE>, 6);
672+
673+
// CVehicle::ProcessBikeWheel
674+
HookInstall(0x6D767F, (DWORD)HOOK_VehicleRapidStopFix<0x6D7685>, 6);
675+
HookInstall(0x6D76AB, (DWORD)HOOK_VehicleRapidStopFix<0x6D76B1>, 6);
676+
HookInstall(0x6D76CD, (DWORD)HOOK_VehicleRapidStopFix<0x6D76D3>, 6);
677+
}
678+
else
679+
{
680+
MemCpy((void*)HOOKPOS_CPhysical__ApplyAirResistance, "\xD9\x46\x50\xD8\x0D", 5);
681+
682+
MemCpy((void*)0x6D6E69, "\xD9\x05\xCC\xB9\xC2\x00", 6);
683+
MemCpy((void*)0x6D6EA8, "\xD9\x05\xCC\xB9\xC2\x00", 6);
684+
685+
MemCpy((void*)0x6D767F, "\xD9\x05\xCC\xB9\xC2\x00", 6);
686+
MemCpy((void*)0x6D76AB, "\xD9\x05\xCC\xB9\xC2\x00", 6);
687+
MemCpy((void*)0x6D76CD, "\xD9\x05\xCC\xB9\xC2\x00", 6);
688+
}
689+
690+
isRapidVehicleStopFixEnabled = enabled;
691+
}
692+
622693
void CMultiplayerSA::InitHooks_FrameRateFixes()
623694
{
624695
EZHookInstall(CTaskSimpleUseGun__SetMoveAnim);

Client/sdk/multiplayer/CMultiplayer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ class CMultiplayer
447447
virtual bool IsVehicleEngineAutoStartEnabled() const noexcept = 0;
448448
virtual void SetVehicleEngineAutoStartEnabled(bool enabled) = 0;
449449

450+
virtual bool IsRapidVehicleStopFixEnabled() const noexcept = 0;
451+
virtual void SetRapidVehicleStopFixEnabled(bool enabled) = 0;
452+
450453
virtual void SetPedTargetingMarkerEnabled(bool bEnabled) = 0;
451454
virtual bool IsPedTargetingMarkerEnabled() = 0;
452455

Server/mods/deathmatch/logic/CGame.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ CGame::CGame() : m_FloodProtect(4, 30000, 30000) // Max of 4 connecti
240240
m_Glitches[GLITCH_BADDRIVEBYHITBOX] = false;
241241
m_Glitches[GLITCH_QUICKSTAND] = false;
242242
m_Glitches[GLITCH_KICKOUTOFVEHICLE_ONMODELREPLACE] = false;
243+
m_Glitches[GLITCH_VEHICLE_RAPID_STOP] = false;
243244
for (int i = 0; i < WEAPONTYPE_LAST_WEAPONTYPE; i++)
244245
m_JetpackWeapons[i] = false;
245246

@@ -279,6 +280,7 @@ CGame::CGame() : m_FloodProtect(4, 30000, 30000) // Max of 4 connecti
279280
m_GlitchNames["baddrivebyhitbox"] = GLITCH_BADDRIVEBYHITBOX;
280281
m_GlitchNames["quickstand"] = GLITCH_QUICKSTAND;
281282
m_GlitchNames["kickoutofvehicle_onmodelreplace"] = GLITCH_KICKOUTOFVEHICLE_ONMODELREPLACE;
283+
m_GlitchNames["vehicle_rapid_stop"] = GLITCH_VEHICLE_RAPID_STOP;
282284

283285
m_bCloudsEnabled = true;
284286

Server/mods/deathmatch/logic/CGame.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ class CGame
196196
GLITCH_BADDRIVEBYHITBOX,
197197
GLITCH_QUICKSTAND,
198198
GLITCH_KICKOUTOFVEHICLE_ONMODELREPLACE,
199+
GLITCH_VEHICLE_RAPID_STOP,
199200
NUM_GLITCHES
200201
};
201202

Server/mods/deathmatch/logic/packets/CMapInfoPacket.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ bool CMapInfoPacket::Write(NetBitStreamInterface& BitStream) const
170170
funBugs.data3.bFastSprint = g_pGame->IsGlitchEnabled(CGame::GLITCH_FASTSPRINT);
171171
funBugs.data4.bBadDrivebyHitboxes = g_pGame->IsGlitchEnabled(CGame::GLITCH_BADDRIVEBYHITBOX);
172172
funBugs.data5.bQuickStand = g_pGame->IsGlitchEnabled(CGame::GLITCH_QUICKSTAND);
173+
funBugs.data6.vehicleRapidStop = g_pGame->IsGlitchEnabled(CGame::GLITCH_VEHICLE_RAPID_STOP);
173174
BitStream.Write(&funBugs);
174175

175176
// Write world special properties states

Shared/sdk/net/SyncStructures.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,6 +1964,10 @@ struct SFunBugsStateSync : public ISyncStructure
19641964
{
19651965
BITCOUNT5 = 1
19661966
};
1967+
enum
1968+
{
1969+
BITCOUNT6 = 1
1970+
};
19671971

19681972
bool Read(NetBitStreamInterface& bitStream)
19691973
{
@@ -1984,6 +1988,10 @@ struct SFunBugsStateSync : public ISyncStructure
19841988
bOk &= bitStream.ReadBits(reinterpret_cast<char*>(&data5), BITCOUNT5);
19851989
else
19861990
data5.bQuickStand = 0;
1991+
if (bitStream.Can(eBitStreamVersion::Glitch_VehicleRapidStop))
1992+
bOk &= bitStream.ReadBits(reinterpret_cast<char*>(&data6), BITCOUNT6);
1993+
else
1994+
data6.vehicleRapidStop = 0;
19871995

19881996
//// Example for adding item:
19891997
// if ( bitStream.Version() >= 0x999 )
@@ -2004,6 +2012,8 @@ struct SFunBugsStateSync : public ISyncStructure
20042012
bitStream.WriteBits(reinterpret_cast<const char*>(&data4), BITCOUNT4);
20052013
if (bitStream.Can(eBitStreamVersion::QuickStandGlitch))
20062014
bitStream.WriteBits(reinterpret_cast<const char*>(&data5), BITCOUNT5);
2015+
if (bitStream.Can(eBitStreamVersion::Glitch_VehicleRapidStop))
2016+
bitStream.WriteBits(reinterpret_cast<const char*>(&data6), BITCOUNT6);
20072017

20082018
//// Example for adding item:
20092019
// if (bitStream.Can(eBitStreamVersion::YourGlitch))
@@ -2042,6 +2052,12 @@ struct SFunBugsStateSync : public ISyncStructure
20422052
{
20432053
bool bQuickStand : 1;
20442054
} data5;
2055+
2056+
// Add new ones in separate structs
2057+
struct
2058+
{
2059+
bool vehicleRapidStop : 1;
2060+
} data6;
20452061
};
20462062

20472063
//////////////////////////////////////////

0 commit comments

Comments
 (0)