Skip to content

Commit

Permalink
Merge branch 'master' into TheNormalnij/aggresive_restream
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNormalnij authored Jul 22, 2024
2 parents 5dd0aa0 + f474b4d commit 2583067
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 11 deletions.
15 changes: 15 additions & 0 deletions Client/game_sa/CCameraSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,3 +443,18 @@ float CCameraSA::GetShakeForce()
CCameraSAInterface* pCameraInterface = GetInterface();
return pCameraInterface->m_fCamShakeForce;
}

void CCameraSA::ShakeCamera(float radius, float x, float y, float z) noexcept
{
DWORD dwFunc = FUNC_ShakeCam;
CCameraSAInterface* cameraInterface = GetInterface();
_asm
{
mov ecx, cameraInterface
push z
push y
push x
push radius
call dwFunc
}
}
3 changes: 3 additions & 0 deletions Client/game_sa/CCameraSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define FUNC_GetFading 0x50ADE0
#define FUNC_Fade 0x50AC20
#define FUNC_SetFadeColour 0x50BF00
#define FUNC_ShakeCam 0x50A9F0

#define VAR_CameraRotation 0xB6F178 // used for controling where the player faces
#define VAR_VehicleCameraView 0xB6F0DC
Expand Down Expand Up @@ -426,4 +427,6 @@ class CCameraSA : public CCamera
void RestoreLastGoodState();
void SetShakeForce(float fShakeForce);
float GetShakeForce();

void ShakeCamera(float radius, float x, float y, float z) noexcept override;
};
5 changes: 5 additions & 0 deletions Client/mods/deathmatch/logic/CClientCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,3 +634,8 @@ void CClientCamera::SetGtaMatrix(const CMatrix& matInNew, CCam* pCam) const
*pCam->GetFront() = matNew.vFront;
*pCam->GetSource() = matNew.vPos;
}

void CClientCamera::ShakeCamera(float radius, float x, float y, float z) noexcept
{
m_pCamera->ShakeCamera(radius, x, y, z);
}
2 changes: 2 additions & 0 deletions Client/mods/deathmatch/logic/CClientCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class CClientCamera final : public CClientEntity
void SetFocusToLocalPlayer();
void Reset();

void ShakeCamera(float radius, float x, float y, float z) noexcept;

void SetCameraVehicleViewMode(eVehicleCamMode eMode);
void SetCameraPedViewMode(ePedCamMode eMode);
eVehicleCamMode GetCameraVehicleViewMode();
Expand Down
18 changes: 18 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ void CLuaCameraDefs::LoadFunctions()
{"setCameraViewMode", ArgumentParserWarn<false, SetCameraViewMode>},
{"setCameraGoggleEffect", SetCameraGoggleEffect},
{"setCameraDrunkLevel", ArgumentParserWarn<false, SetCameraDrunkLevel>},

{"shakeCamera", ArgumentParser<ShakeCamera>},
};

// Add functions
Expand Down Expand Up @@ -543,3 +545,19 @@ const SString& CLuaCameraDefs::GetElementType()
{
return m_pManager->GetCamera()->GetTypeName();
}

bool CLuaCameraDefs::ShakeCamera(float radius, std::optional<float> x, std::optional<float> y, std::optional<float> z) noexcept
{
if (!x || !y || !z)
{
const auto* player = CStaticFunctionDefinitions::GetLocalPlayer();
CVector out;
player->GetPosition(out);
x = out.fX;
y = out.fY;
z = out.fZ;
}
m_pManager->GetCamera()->ShakeCamera(radius, *x, *y, *z);

return true;
}
3 changes: 3 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class CLuaCameraDefs : public CLuaDefs
LUA_DECLARE(SetCameraGoggleEffect);
static bool SetCameraDrunkLevel(short drunkLevel);

// Cam do funcs
static bool ShakeCamera(float radius, std::optional<float> x, std::optional<float> y, std::optional<float> z) noexcept;

// For OOP only
LUA_DECLARE(OOP_GetCameraPosition);
LUA_DECLARE(OOP_SetCameraPosition);
Expand Down
2 changes: 1 addition & 1 deletion Client/multiplayer_sa/CMultiplayerSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,7 @@ void CMultiplayerSA::InitHooks()
MemSetFast((void*)0x60D86F, 0x90, 19);

// Fix invisible vehicle windows when lights are on (#2936)
MemPut<BYTE>(0x6E1425, 0);
MemPut<BYTE>(0x6E1425, 1);

InitHooks_CrashFixHacks();

Expand Down
16 changes: 6 additions & 10 deletions Client/multiplayer_sa/CMultiplayerSA_CrashFixHacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2070,26 +2070,22 @@ static void _declspec(naked) HOOK_FxPrim_c__Enable()
////////////////////////////////////////////////////////////////////////
#define HOOKPOS_CFire_ProcessFire 0x53A6FC
#define HOOKSIZE_CFire_ProcessFire 9
static DWORD CONTINUE_CFire_ProcessFire = 0x53A705;
static constexpr DWORD CONTINUE_CFire_ProcessFire = 0x53A705;
static constexpr DWORD SKIP_CFire_ProcessFire = 0x53A69C;
static void _declspec(naked) HOOK_CFire_ProcessFire()
{
_asm
{
test byte ptr [esi], 4
// If the beingExtinguished flag has been set, we skip processing this fire instance
jnz skip
test byte ptr [esi], 1 // If the "active" flag has been set to 0, we skip processing attached entities
jz skip

mov ecx, [esi+10h]
mov eax, [ecx+590h]
jmp CONTINUE_CFire_ProcessFire

skip:
pop edi
pop esi
pop ebp
pop ebx
add esp, 2Ch
retn
mov ecx, esi
jmp SKIP_CFire_ProcessFire
}
}

Expand Down
2 changes: 2 additions & 0 deletions Client/sdk/game/CCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,6 @@ class CCamera
virtual BYTE GetCameraPedViewMode() = 0;
virtual void SetShakeForce(float fShakeForce) = 0;
virtual float GetShakeForce() = 0;

virtual void ShakeCamera(float radius, float x, float y, float z) noexcept = 0;
};

0 comments on commit 2583067

Please sign in to comment.