Skip to content

Commit 95280d6

Browse files
authored
Merge branch 'master' into attach
2 parents 4047184 + eb66fa2 commit 95280d6

File tree

154 files changed

+4722
-2960
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+4722
-2960
lines changed

Client/core/CCommands.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool
125125

126126
// Grab the command
127127
tagCOMMANDENTRY* pEntry = Get(szCommand);
128+
bool wasHandled = false;
128129
if (pEntry)
129130
{
130131
// If its a core command, or if its enabled
@@ -133,14 +134,16 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool
133134
// Execute it
134135
if (!bIsScriptedBind || pEntry->bAllowScriptedBind)
135136
ExecuteHandler(pEntry->pfnCmdFunc, szParameters);
136-
return true;
137+
138+
wasHandled = true;
137139
}
138140
}
139141

140142
// Recompose the original command text
141143
std::string val = std::string(szCommand) + " " + std::string(szParameters ? szParameters : "");
142144

143145
// Is it a cvar? (syntax: cvar[ = value])
146+
if (!wasHandled)
144147
{
145148
// Check to see if '=' exists
146149
unsigned int nOpIndex = val.find('=');
@@ -188,7 +191,7 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool
188191

189192
// HACK: if its a 'nick' command, save it here
190193
bool bIsNickCommand = !stricmp(szCommand, "nick");
191-
if (bIsNickCommand && szParameters && !bIsScriptedBind)
194+
if (!wasHandled && bIsNickCommand && szParameters && !bIsScriptedBind)
192195
{
193196
if (CCore::GetSingleton().IsValidNick(szParameters))
194197
{
@@ -208,10 +211,14 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool
208211
// Try to execute the handler
209212
if (m_pfnExecuteHandler)
210213
{
211-
if (m_pfnExecuteHandler(szCommand, szParameters, bHandleRemotely, (pEntry != NULL), bIsScriptedBind))
214+
bool bAllowScriptedBind = (!pEntry || pEntry->bAllowScriptedBind);
215+
if (m_pfnExecuteHandler(szCommand, szParameters, bHandleRemotely, wasHandled, bIsScriptedBind, bAllowScriptedBind))
212216
return true;
213217
}
214218

219+
if (wasHandled)
220+
return true;
221+
215222
// Unknown command
216223
val = _("Unknown command or cvar: ") + szCommand;
217224
if (!bIsScriptedBind && !bIsNickCommand && pEntry == nullptr)

Client/core/CKeyBinds.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,8 @@ CCommandBind* CKeyBinds::FindCommandMatch(const char* szKey, const char* szComma
841841
NullEmptyStrings(szKey, szArguments, szResource, szOriginalScriptKey);
842842

843843
std::string arguments = szArguments ? szArguments : "";
844-
szArguments = SharedUtil::Trim(arguments.data());
844+
if (!arguments.empty())
845+
szArguments = SharedUtil::Trim(arguments.data());
845846

846847
for (KeyBindPtr& bind : m_binds)
847848
{

Client/game_sa/CBuildingRemovalSA.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,4 +716,10 @@ void CBuildingRemovalSA::DropCaches()
716716

717717
m_pBinaryBuildings->clear();
718718
m_pDataBuildings->clear();
719+
720+
for (auto &pRemoval : *m_pBuildingRemovals)
721+
{
722+
pRemoval.second->m_pDataRemoveList->clear();
723+
pRemoval.second->m_pBinaryRemoveList->clear();
724+
}
719725
}

Client/game_sa/CCameraSA.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,3 +443,18 @@ float CCameraSA::GetShakeForce()
443443
CCameraSAInterface* pCameraInterface = GetInterface();
444444
return pCameraInterface->m_fCamShakeForce;
445445
}
446+
447+
void CCameraSA::ShakeCamera(float radius, float x, float y, float z) noexcept
448+
{
449+
static CCameraSAInterface* cameraInterface = GetInterface();
450+
if (radius <= 0.0f)
451+
return ResetShakeCamera();
452+
453+
using ShakeCamera_t = void(__thiscall*)(CCameraSAInterface*, float radius, float x, float y, float z);
454+
((ShakeCamera_t)FUNC_ShakeCam)(cameraInterface, radius, x, y, z);
455+
}
456+
457+
void CCameraSA::ResetShakeCamera() noexcept
458+
{
459+
GetInterface()->m_fCamShakeForce = 0.0f;
460+
}

Client/game_sa/CCameraSA.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define FUNC_GetFading 0x50ADE0
2828
#define FUNC_Fade 0x50AC20
2929
#define FUNC_SetFadeColour 0x50BF00
30+
#define FUNC_ShakeCam 0x50A9F0
3031

3132
#define VAR_CameraRotation 0xB6F178 // used for controling where the player faces
3233
#define VAR_VehicleCameraView 0xB6F0DC
@@ -426,4 +427,7 @@ class CCameraSA : public CCamera
426427
void RestoreLastGoodState();
427428
void SetShakeForce(float fShakeForce);
428429
float GetShakeForce();
430+
431+
void ShakeCamera(float radius, float x, float y, float z) noexcept override;
432+
void ResetShakeCamera() noexcept override;
429433
};

Client/game_sa/CCarEnterExitSA.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@ bool CCarEnterExitSA::GetNearestCarPassengerDoor(CPed* pPed, CVehicle* pVehicle,
7878
return bReturn;
7979
}
8080

81+
void CCarEnterExitSA::GetPositionToOpenCarDoor(CVector& position, CVehicle* vehicle, std::uint32_t door) const noexcept
82+
{
83+
CVehicleSA* vehicleSA = dynamic_cast<CVehicleSA*>(vehicle);
84+
85+
if (!vehicleSA)
86+
return;
87+
88+
CVehicleSAInterface* vehicleInterface = vehicleSA->GetVehicleInterface();
89+
90+
auto CCarEnterExit_GetPositionToOpenCarDoor = (void(__cdecl*)(CVector&, CVehicleSAInterface*, int))FUNC_GetPositionToOpenCarDoor;
91+
CCarEnterExit_GetPositionToOpenCarDoor(position, vehicleInterface, door);
92+
}
93+
8194
int CCarEnterExitSA::ComputeTargetDoorToExit(CPed* pPed, CVehicle* pVehicle)
8295
{
8396
DWORD dwFunc = FUNC_ComputeTargetDoorToExit;

Client/game_sa/CCarEnterExitSA.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
#define FUNC_GetNearestCarPassengerDoor 0x650BB0
1818
#define FUNC_ComputeTargetDoorToExit 0x64F110
1919
#define FUNC_IsRoomForPedToLeaveCar 0x6504C0
20+
#define FUNC_GetPositionToOpenCarDoor 0x64E740
2021

2122
class CCarEnterExitSA : public CCarEnterExit
2223
{
2324
public:
2425
bool GetNearestCarDoor(CPed* pPed, CVehicle* pVehicle, CVector* pVector, int* pDoor);
2526
bool GetNearestCarPassengerDoor(CPed* pPed, CVehicle* pVehicle, CVector* pVector, int* pDoor, bool bUnknown, bool bUnknown2, bool bCheckIfRoomToGetIn);
27+
void GetPositionToOpenCarDoor(CVector& position, CVehicle* vehicle, std::uint32_t door) const noexcept;
2628
int ComputeTargetDoorToExit(CPed* pPed, CVehicle* pVehicle);
2729
bool IsRoomForPedToLeaveCar(CVehicle* pVehicle, int iDoor, CVector* pUnknown = 0);
2830
};

Client/game_sa/CCheckpointSA.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#include "C3DMarkerSA.h"
1414
#include "C3DMarkersSA.h"
1515
#include "CCheckpointSA.h"
16+
#include "CCheckpointsSA.h"
17+
#include "CGameSA.h"
18+
19+
extern CGameSA* pGame;
1620

1721
void CCheckpointSA::SetPosition(CVector* vecPosition)
1822
{
@@ -132,3 +136,39 @@ void CCheckpointSA::Remove()
132136
GetInterface()->m_nType = 257;
133137
GetInterface()->rwColour = 0;
134138
}
139+
140+
void CCheckpointSA::SetTargetArrowData(const SColor color, float size) noexcept
141+
{
142+
m_targetArrowColor = color;
143+
m_targetArrowSize = size;
144+
}
145+
146+
static void __cdecl RenderTargetArrow(CCheckpointSAInterface* pCheckpoint)
147+
{
148+
CCheckpoint* checkpoint = pGame->GetCheckpoints()->FindMarker(pCheckpoint->m_nIdentifier);
149+
if (!checkpoint)
150+
return;
151+
152+
CVector* position = checkpoint->GetPosition();
153+
CVector* direction = checkpoint->GetPointDirection();
154+
SColor color = checkpoint->GetTargetArrowColor();
155+
156+
((void(__cdecl*)(float, float, float, float, std::uint8_t, std::uint8_t, std::uint8_t, std::uint8_t, float, float, float))C3dMarkers_DirectionArrowSet)(position->fX, position->fY, position->fZ, checkpoint->GetTargetArrowSize(), color.R, color.G, color.B, color.A, -direction->fX, -direction->fY, -direction->fZ);
157+
}
158+
159+
static void _declspec(naked) HOOK_CCheckpoint__Render()
160+
{
161+
_asm {
162+
pushad
163+
push esi
164+
call RenderTargetArrow
165+
add esp, 4
166+
popad
167+
jmp RETURN_CCheckpoint__Render
168+
}
169+
}
170+
171+
void CCheckpointSA::StaticSetHooks()
172+
{
173+
EZHookInstall(CCheckpoint__Render);
174+
}

Client/game_sa/CCheckpointSA.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
#include <CVector.h>
1515
#include <game/CCheckpoint.h>
1616

17+
#define HOOKPOS_CCheckpoint__Render 0x725E56
18+
#define HOOKSIZE_CCheckpoint__Render 0x5
19+
static constexpr std::uint32_t RETURN_CCheckpoint__Render = 0x725E5B;
20+
21+
#define C3dMarkers_DirectionArrowSet 0x721140
22+
1723
class CCheckpointSAInterface
1824
{
1925
public:
@@ -36,12 +42,16 @@ class CCheckpointSA : public CCheckpoint
3642
{
3743
private:
3844
CCheckpointSAInterface* internalInterface;
45+
SColor m_targetArrowColor{0xFFFF4040};
46+
float m_targetArrowSize{0.625f};
3947

4048
public:
4149
CCheckpointSA(CCheckpointSAInterface* checkpointInterface) { internalInterface = checkpointInterface; };
4250

4351
CCheckpointSAInterface* GetInterface() { return internalInterface; }
4452

53+
static void StaticSetHooks();
54+
4555
void SetPosition(CVector* vecPosition);
4656
CVector* GetPosition();
4757
void SetPointDirection(CVector* vecPointDirection);
@@ -62,4 +72,7 @@ class CCheckpointSA : public CCheckpoint
6272
void SetPulseFraction(float fPulseFraction); // doesn't work propperly (not virtualed)
6373
float GetPulseFraction();
6474
void Remove();
75+
SColor GetTargetArrowColor() const noexcept override { return m_targetArrowColor; };
76+
float GetTargetArrowSize() const noexcept override { return m_targetArrowSize; };
77+
void SetTargetArrowData(const SColor color, float size) noexcept;
6578
};

Client/game_sa/CCheckpointsSA.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,14 @@ CCheckpoint* CCheckpointsSA::FindFreeMarker()
6666
}
6767
return NULL;
6868
}
69+
70+
CCheckpoint* CCheckpointsSA::FindMarker(DWORD identifier)
71+
{
72+
for (CCheckpointSA* checkpoint : Checkpoints)
73+
{
74+
if (checkpoint->GetIdentifier() == identifier)
75+
return checkpoint;
76+
}
77+
78+
return nullptr;
79+
}

0 commit comments

Comments
 (0)