Skip to content

Commit d7d3ff9

Browse files
Merge branch 'master' into fix-dildo-vibrator-names
2 parents 82e85c0 + 527f873 commit d7d3ff9

File tree

18 files changed

+2087
-1955
lines changed

18 files changed

+2087
-1955
lines changed

Client/core/CMessageLoopHook.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,13 @@ LRESULT CALLBACK CMessageLoopHook::ProcessMessage(HWND hwnd, UINT uMsg, WPARAM w
518518
return true;
519519
}
520520

521+
// Process ALT + F4
522+
if (uMsg == WM_SYSKEYDOWN && wParam == VK_F4)
523+
{
524+
// Tell windows to handle this message.
525+
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
526+
}
527+
521528
// If we handled mouse steering, don't let GTA.
522529
// if ( !CCore::GetSingleton ().GetMouseControl()->ProcessMouseMove ( uMsg, wParam, lParam ) )
523530
// Call GTA's window procedure.

Client/game_sa/CVehicleSA.cpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
*****************************************************************************/
1111

1212
#include "StdInc.h"
13+
#include <core/CCoreInterface.h>
14+
#include <multiplayer/CMultiplayer.h>
1315
#include "CAutomobileSA.h"
1416
#include "CBikeSA.h"
1517
#include "CCameraSA.h"
@@ -28,7 +30,8 @@
2830
#include "gamesa_renderware.h"
2931
#include "CFireManagerSA.h"
3032

31-
extern CGameSA* pGame;
33+
extern CCoreInterface* g_pCore;
34+
extern CGameSA* pGame;
3235

3336
static BOOL m_bVehicleSunGlare = false;
3437
_declspec(naked) void DoVehicleSunGlare(void* this_)
@@ -54,13 +57,39 @@ void _declspec(naked) HOOK_Vehicle_PreRender(void)
5457
}
5558
}
5659

60+
static float& fTimeStep = *(float*)(0xB7CB5C);
5761
static bool __fastcall CanProcessFlyingCarStuff(CAutomobileSAInterface* vehicleInterface)
5862
{
5963
SClientEntity<CVehicleSA>* vehicle = pGame->GetPools()->GetVehicle((DWORD*)vehicleInterface);
6064
if (!vehicle || !vehicle->pEntity)
6165
return true;
6266

63-
return vehicle->pEntity->GetVehicleRotorState();
67+
if (vehicle->pEntity->GetVehicleRotorState())
68+
{
69+
if (g_pCore->GetMultiplayer()->IsVehicleEngineAutoStartEnabled()) // keep default behavior
70+
return true;
71+
72+
if (vehicle->pEntity->GetEntityStatus() != eEntityStatus::STATUS_PHYSICS && !vehicle->pEntity->IsBeingDriven())
73+
{
74+
vehicle->pEntity->SetEntityStatus(eEntityStatus::STATUS_PHYSICS); // this will make rotors spin without driver when engine is on
75+
return false;
76+
}
77+
if (!vehicle->pEntity->IsEngineOn())
78+
{
79+
// Smoothly change rotors speed to 0
80+
float speed = vehicle->pEntity->GetHeliRotorSpeed();
81+
if (speed > 0)
82+
vehicle->pEntity->SetHeliRotorSpeed(std::max(0.0f, speed - fTimeStep * 0.00055f)); // 0x6C4EB7
83+
84+
speed = vehicle->pEntity->GetPlaneRotorSpeed();
85+
if (speed > 0)
86+
vehicle->pEntity->SetPlaneRotorSpeed(std::max(0.0f, speed - fTimeStep * 0.003f)); // 0x6CC145
87+
88+
return false;
89+
}
90+
return true;
91+
}
92+
return false;
6493
}
6594

6695
static constexpr DWORD CONTINUE_CHeli_ProcessFlyingCarStuff = 0x6C4E82;

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6057,6 +6057,9 @@ bool CClientGame::SetWorldSpecialProperty(const WorldSpecialProperty property, c
60576057
case WorldSpecialProperty::VEHICLEBURNEXPLOSIONS:
60586058
g_pGame->SetVehicleBurnExplosionsEnabled(enabled);
60596059
break;
6060+
case WorldSpecialProperty::VEHICLE_ENGINE_AUTOSTART:
6061+
SetVehicleEngineAutoStartEnabled(enabled);
6062+
break;
60606063
default:
60616064
return false;
60626065
}
@@ -6103,6 +6106,8 @@ bool CClientGame::IsWorldSpecialProperty(const WorldSpecialProperty property)
61036106
return m_pVehicleManager->IsSpawnFlyingComponentEnabled();
61046107
case WorldSpecialProperty::VEHICLEBURNEXPLOSIONS:
61056108
return g_pGame->IsVehicleBurnExplosionsEnabled();
6109+
case WorldSpecialProperty::VEHICLE_ENGINE_AUTOSTART:
6110+
return IsVehicleEngineAutoStartEnabled();
61066111
}
61076112

61086113
return false;
@@ -6138,6 +6143,20 @@ bool CClientGame::IsWeaponRenderEnabled() const
61386143
return g_pGame->IsWeaponRenderEnabled();
61396144
}
61406145

6146+
void CClientGame::SetVehicleEngineAutoStartEnabled(bool enabled)
6147+
{
6148+
if (enabled == g_pMultiplayer->IsVehicleEngineAutoStartEnabled())
6149+
return;
6150+
6151+
g_pMultiplayer->SetVehicleEngineAutoStartEnabled(enabled);
6152+
m_pVehicleManager->ResetNotControlledRotors(enabled);
6153+
}
6154+
6155+
bool CClientGame::IsVehicleEngineAutoStartEnabled() const
6156+
{
6157+
return g_pMultiplayer->IsVehicleEngineAutoStartEnabled();
6158+
}
6159+
61416160
#pragma code_seg(".text")
61426161
bool CClientGame::VerifySADataFiles(int iEnableClientChecks)
61436162
{
@@ -6823,6 +6842,7 @@ void CClientGame::ResetWorldProperties(const ResetWorldPropsInfo& resetPropsInfo
68236842
g_pGame->SetIgnoreFireStateEnabled(false);
68246843
m_pVehicleManager->SetSpawnFlyingComponentEnabled(true);
68256844
g_pGame->SetVehicleBurnExplosionsEnabled(true);
6845+
SetVehicleEngineAutoStartEnabled(true);
68266846
}
68276847

68286848
// Reset all setWorldProperty to default

Client/mods/deathmatch/logic/CClientGame.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,9 @@ class CClientGame
426426
void SetWeaponRenderEnabled(bool enabled);
427427
bool IsWeaponRenderEnabled() const;
428428

429+
void SetVehicleEngineAutoStartEnabled(bool enabled);
430+
bool IsVehicleEngineAutoStartEnabled() const;
431+
429432
void ResetWorldProperties(const ResetWorldPropsInfo& resetPropsInfo);
430433

431434
CTransferBox* GetTransferBox() { return m_pTransferBox; };

Client/mods/deathmatch/logic/CClientVehicleManager.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,3 +791,20 @@ void CClientVehicleManager::RestreamVehicleUpgrades(unsigned short usModel)
791791
pVehicle->GetUpgrades()->RestreamVehicleUpgrades(usModel);
792792
}
793793
}
794+
795+
void CClientVehicleManager::ResetNotControlledRotors(bool engineAutoStart)
796+
{
797+
// Reset rotors to original or custom state for loaded vehicles without controller
798+
// Custom state allows rotors to spin without driver inside (if engine is on)
799+
eEntityStatus status = engineAutoStart ? eEntityStatus::STATUS_ABANDONED : eEntityStatus::STATUS_PHYSICS;
800+
for (auto& pVehicle : m_List)
801+
{
802+
if (pVehicle->GetGameEntity() && pVehicle->GetVehicleRotorState() && !pVehicle->IsDriven())
803+
{
804+
float speed = (!engineAutoStart && pVehicle->IsEngineOn()) ? 0.001f : 0.0f;
805+
pVehicle->GetGameEntity()->SetEntityStatus(status);
806+
pVehicle->SetHeliRotorSpeed(speed);
807+
pVehicle->SetPlaneRotorSpeed(speed);
808+
}
809+
}
810+
}

Client/mods/deathmatch/logic/CClientVehicleManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class CClientVehicleManager
7373
bool IsSpawnFlyingComponentEnabled() const noexcept { return m_spawnFlyingComponentsDuringRecreate; }
7474
void SetSpawnFlyingComponentEnabled(bool isEnabled) noexcept { m_spawnFlyingComponentsDuringRecreate = isEnabled; }
7575

76+
void ResetNotControlledRotors(bool engineAutoStart);
77+
7678
protected:
7779
CClientManager* m_pManager;
7880
bool m_bCanRemoveFromList;

Client/mods/deathmatch/logic/CPacketHandler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,6 +2402,7 @@ void CPacketHandler::Packet_MapInfo(NetBitStreamInterface& bitStream)
24022402
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::IGNOREFIRESTATE, wsProps.data6.ignoreFireState);
24032403
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::FLYINGCOMPONENTS, wsProps.data7.flyingcomponents);
24042404
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::VEHICLEBURNEXPLOSIONS, wsProps.data8.vehicleburnexplosions);
2405+
g_pClientGame->SetWorldSpecialProperty(WorldSpecialProperty::VEHICLE_ENGINE_AUTOSTART, wsProps.data9.vehicleEngineAutoStart);
24052406

24062407
float fJetpackMaxHeight = 100;
24072408
if (!bitStream.Read(fJetpackMaxHeight))

Client/multiplayer_sa/CMultiplayerSA.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6634,6 +6634,25 @@ void CMultiplayerSA::SetAutomaticVehicleStartupOnPedEnter(bool bSet)
66346634
MemSet((char*)0x64BC0D, 0x90, 6);
66356635
}
66366636

6637+
bool CMultiplayerSA::IsVehicleEngineAutoStartEnabled() const noexcept
6638+
{
6639+
return *(unsigned char*)0x64BC03 == 0x75;
6640+
}
6641+
6642+
void CMultiplayerSA::SetVehicleEngineAutoStartEnabled(bool enabled)
6643+
{
6644+
if (enabled)
6645+
{
6646+
MemCpy((void*)0x64BC03, "\x75\x05\x80\xC9\x10", 5);
6647+
MemCpy((void*)0x6C4EA9, "\x8A\x86\x28\x04", 4);
6648+
}
6649+
else
6650+
{
6651+
MemSet((void*)0x64BC03, 0x90, 5); // prevent vehicle engine from turning on (driver enter)
6652+
MemCpy((void*)0x6C4EA9, "\xE9\x15\x03\x00", 4); // prevent aircraft engine from turning off (driver exit)
6653+
}
6654+
}
6655+
66376656
// Storage
66386657
CVehicleSAInterface* pHeliKiller = NULL;
66396658
CEntitySAInterface* pHitByHeli = NULL;

Client/multiplayer_sa/CMultiplayerSA.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@ class CMultiplayerSA : public CMultiplayer
333333

334334
void SetAutomaticVehicleStartupOnPedEnter(bool bSet);
335335

336+
bool IsVehicleEngineAutoStartEnabled() const noexcept override;
337+
void SetVehicleEngineAutoStartEnabled(bool enabled) override;
338+
336339
void SetPedTargetingMarkerEnabled(bool bEnable);
337340
bool IsPedTargetingMarkerEnabled();
338341
bool IsConnected();

Client/sdk/multiplayer/CMultiplayer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,9 @@ class CMultiplayer
444444

445445
virtual void SetAutomaticVehicleStartupOnPedEnter(bool bSet) = 0;
446446

447+
virtual bool IsVehicleEngineAutoStartEnabled() const noexcept = 0;
448+
virtual void SetVehicleEngineAutoStartEnabled(bool enabled) = 0;
449+
447450
virtual void SetPedTargetingMarkerEnabled(bool bEnabled) = 0;
448451
virtual bool IsPedTargetingMarkerEnabled() = 0;
449452

0 commit comments

Comments
 (0)