Skip to content

Commit fbad125

Browse files
committed
Merge remote-tracking branch 'upstream/master' into shadow
2 parents 60e29ed + bca4dff commit fbad125

Some content is hidden

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

70 files changed

+2782
-2317
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/CCameraSA.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -446,15 +446,15 @@ float CCameraSA::GetShakeForce()
446446

447447
void CCameraSA::ShakeCamera(float radius, float x, float y, float z) noexcept
448448
{
449-
DWORD dwFunc = FUNC_ShakeCam;
450-
CCameraSAInterface* cameraInterface = GetInterface();
451-
_asm
452-
{
453-
mov ecx, cameraInterface
454-
push z
455-
push y
456-
push x
457-
push radius
458-
call dwFunc
459-
}
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;
460460
}

Client/game_sa/CCameraSA.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,4 +429,5 @@ class CCameraSA : public CCamera
429429
float GetShakeForce();
430430

431431
void ShakeCamera(float radius, float x, float y, float z) noexcept override;
432+
void ResetShakeCamera() noexcept override;
432433
};

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/CClockSA.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,19 @@ void CClockSA::Get(BYTE* bHour, BYTE* bMinute)
3030
*bMinute = *(BYTE*)VAR_TimeMinutes;
3131
*bHour = *(BYTE*)VAR_TimeHours;
3232
}
33+
34+
bool CClockSA::SetTimeFrozen(bool value) noexcept
35+
{
36+
if (value)
37+
MemSet((void*)0x53BFBD, 0x90, 5);
38+
else
39+
MemCpy((void*)0x53BFBD, "\xE8\x4E\x0F\xFF\xFF", 5);
40+
41+
m_bTimeCycleFrozen = value;
42+
return true;
43+
}
44+
45+
bool CClockSA::ResetTimeFrozen() noexcept
46+
{
47+
return SetTimeFrozen(false);
48+
}

Client/game_sa/CClockSA.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,11 @@ class CClockSA : public CClock
2222
public:
2323
void Set(BYTE bHour, BYTE bMinute);
2424
void Get(BYTE* bHour, BYTE* bMinute);
25+
26+
bool SetTimeFrozen(bool value) noexcept;
27+
bool IsTimeFrozen() const noexcept { return m_bTimeCycleFrozen; };
28+
bool ResetTimeFrozen() noexcept;
29+
30+
private:
31+
bool m_bTimeCycleFrozen;
2532
};

Client/game_sa/CGameSA.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,18 +1005,14 @@ void CGameSA::GetShaderReplacementStats(SShaderReplacementStats& outStats)
10051005
m_pRenderWare->GetShaderReplacementStats(outStats);
10061006
}
10071007

1008-
void CGameSA::RemoveAllBuildings(bool clearBuildingRemoval)
1008+
void CGameSA::RemoveAllBuildings()
10091009
{
10101010
m_pIplStore->SetDynamicIplStreamingEnabled(false);
10111011

10121012
m_pPools->GetDummyPool().RemoveAllBuildingLods();
10131013
m_pPools->GetBuildingsPool().RemoveAllBuildings();
10141014

10151015
auto pBuildingRemoval = static_cast<CBuildingRemovalSA*>(m_pBuildingRemoval);
1016-
if (clearBuildingRemoval)
1017-
{
1018-
pBuildingRemoval->ClearRemovedBuildingLists();
1019-
}
10201016
pBuildingRemoval->DropCaches();
10211017

10221018
m_isBuildingsRemoved = true;
@@ -1036,7 +1032,7 @@ bool CGameSA::SetBuildingPoolSize(size_t size)
10361032
const bool shouldRemoveBuilding = !m_isBuildingsRemoved;
10371033
if (shouldRemoveBuilding)
10381034
{
1039-
RemoveAllBuildings(false);
1035+
RemoveAllBuildings();
10401036
}
10411037
else
10421038
{

Client/game_sa/CGameSA.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ class CGameSA : public CGame
303303
PostWeaponFireHandler* m_pPostWeaponFireHandler;
304304
TaskSimpleBeHitHandler* m_pTaskSimpleBeHitHandler;
305305

306-
void RemoveAllBuildings(bool clearBuildingRemoval = true);
306+
void RemoveAllBuildings();
307307
void RestoreGameBuildings();
308308

309309
bool SetBuildingPoolSize(size_t size);

0 commit comments

Comments
 (0)