Skip to content

Commit 0d5e2e9

Browse files
authored
Merge branch 'master' into 230724_Add_getLoadedFiles
2 parents df5275e + 5ac6c8a commit 0d5e2e9

Some content is hidden

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

46 files changed

+1983
-1980
lines changed

Client/core/CCommands.cpp

Lines changed: 9 additions & 2 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,13 +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);
137+
138+
wasHandled = true;
136139
}
137140
}
138141

139142
// Recompose the original command text
140143
std::string val = std::string(szCommand) + " " + std::string(szParameters ? szParameters : "");
141144

142145
// Is it a cvar? (syntax: cvar[ = value])
146+
if (!wasHandled)
143147
{
144148
// Check to see if '=' exists
145149
unsigned int nOpIndex = val.find('=');
@@ -187,7 +191,7 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool
187191

188192
// HACK: if its a 'nick' command, save it here
189193
bool bIsNickCommand = !stricmp(szCommand, "nick");
190-
if (bIsNickCommand && szParameters && !bIsScriptedBind)
194+
if (!wasHandled && bIsNickCommand && szParameters && !bIsScriptedBind)
191195
{
192196
if (CCore::GetSingleton().IsValidNick(szParameters))
193197
{
@@ -208,10 +212,13 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool
208212
if (m_pfnExecuteHandler)
209213
{
210214
bool bAllowScriptedBind = (!pEntry || pEntry->bAllowScriptedBind);
211-
if (m_pfnExecuteHandler(szCommand, szParameters, bHandleRemotely, (pEntry != NULL), bIsScriptedBind, 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/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);
Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*****************************************************************************
22
*
3-
* PROJECT: Multi Theft Auto v1.0
3+
* PROJECT: Multi Theft Auto
44
* LICENSE: See LICENSE in the top level directory
5-
* FILE: game_sa/CHandlingEntrySA.cpp
5+
* FILE: Client/game_sa/CHandlingEntrySA.cpp
66
* PURPOSE: Vehicle handling data entry
77
*
8-
* Multi Theft Auto is available from http://www.multitheftauto.com/
8+
* Multi Theft Auto is available from https://multitheftauto.com/
99
*
1010
*****************************************************************************/
1111

@@ -22,91 +22,89 @@ CHandlingEntrySA::CHandlingEntrySA()
2222
m_pHandlingSA = new tHandlingDataSA;
2323
memset(m_pHandlingSA, 0, sizeof(tHandlingDataSA));
2424
m_bDeleteInterface = true;
25-
26-
// We have no original data
27-
m_pOriginalData = NULL;
28-
m_bChanged = true;
2925
}
3026

3127
CHandlingEntrySA::CHandlingEntrySA(tHandlingDataSA* pOriginal)
3228
{
3329
// Store gta's pointer
34-
m_pHandlingSA = NULL;
35-
m_pOriginalData = NULL;
30+
m_pHandlingSA = nullptr;
3631
m_bDeleteInterface = false;
3732
memcpy(&m_Handling, pOriginal, sizeof(tHandlingDataSA));
38-
m_bChanged = true;
3933
}
4034

4135
CHandlingEntrySA::~CHandlingEntrySA()
4236
{
43-
if (m_bChanged)
44-
{
45-
pGame->GetHandlingManager()->RemoveChangedVehicle();
46-
}
4737
if (m_bDeleteInterface)
4838
{
49-
delete m_pHandlingSA;
39+
SAFE_DELETE(m_pHandlingSA);
5040
}
5141
}
5242

5343
// Apply the handlingdata from another data
54-
void CHandlingEntrySA::Assign(const CHandlingEntry* pData)
44+
void CHandlingEntrySA::Assign(const CHandlingEntry* pEntry)
5545
{
46+
if (!pEntry)
47+
return;
48+
5649
// Copy the data
57-
const CHandlingEntrySA* pEntrySA = static_cast<const CHandlingEntrySA*>(pData);
50+
const CHandlingEntrySA* pEntrySA = static_cast<const CHandlingEntrySA*>(pEntry);
5851
m_Handling = pEntrySA->m_Handling;
59-
if (m_bChanged)
60-
{
61-
pGame->GetHandlingManager()->RemoveChangedVehicle();
62-
}
63-
pGame->GetHandlingManager()->CheckSuspensionChanges(this);
6452
}
6553

66-
void CHandlingEntrySA::Recalculate(unsigned short usModel)
54+
void CHandlingEntrySA::Recalculate()
6755
{
6856
// Real GTA class?
69-
if (m_pHandlingSA)
70-
{
71-
// Copy our stored field to GTA's
72-
memcpy(m_pHandlingSA, &m_Handling, sizeof(m_Handling));
73-
((void(_stdcall*)(tHandlingDataSA*))FUNC_HandlingDataMgr_ConvertDataToGameUnits)(m_pHandlingSA);
74-
}
57+
if (!m_pHandlingSA)
58+
return;
59+
60+
// Copy our stored field to GTA's
61+
memcpy(m_pHandlingSA, &m_Handling, sizeof(m_Handling));
62+
((void(_stdcall*)(tHandlingDataSA*))FUNC_HandlingDataMgr_ConvertDataToGameUnits)(m_pHandlingSA);
7563
}
7664

77-
// Moved to cpp to check suspension changes against default values to make sure the handling hasn't changed.
78-
void CHandlingEntrySA::SetSuspensionForceLevel(float fForce)
65+
void CHandlingEntrySA::SetSuspensionForceLevel(float fForce) noexcept
7966
{
67+
CheckSuspensionChanges();
8068
m_Handling.fSuspensionForceLevel = fForce;
81-
pGame->GetHandlingManager()->CheckSuspensionChanges(this);
8269
}
83-
void CHandlingEntrySA::SetSuspensionDamping(float fDamping)
70+
71+
void CHandlingEntrySA::SetSuspensionDamping(float fDamping) noexcept
8472
{
73+
CheckSuspensionChanges();
8574
m_Handling.fSuspensionDamping = fDamping;
86-
pGame->GetHandlingManager()->CheckSuspensionChanges(this);
8775
}
88-
void CHandlingEntrySA::SetSuspensionHighSpeedDamping(float fDamping)
76+
77+
void CHandlingEntrySA::SetSuspensionHighSpeedDamping(float fDamping) noexcept
8978
{
79+
CheckSuspensionChanges();
9080
m_Handling.fSuspensionHighSpdDamping = fDamping;
91-
pGame->GetHandlingManager()->CheckSuspensionChanges(this);
9281
}
93-
void CHandlingEntrySA::SetSuspensionUpperLimit(float fUpperLimit)
82+
83+
void CHandlingEntrySA::SetSuspensionUpperLimit(float fUpperLimit) noexcept
9484
{
85+
CheckSuspensionChanges();
9586
m_Handling.fSuspensionUpperLimit = fUpperLimit;
96-
pGame->GetHandlingManager()->CheckSuspensionChanges(this);
9787
}
98-
void CHandlingEntrySA::SetSuspensionLowerLimit(float fLowerLimit)
88+
89+
void CHandlingEntrySA::SetSuspensionLowerLimit(float fLowerLimit) noexcept
9990
{
91+
CheckSuspensionChanges();
10092
m_Handling.fSuspensionLowerLimit = fLowerLimit;
101-
pGame->GetHandlingManager()->CheckSuspensionChanges(this);
10293
}
103-
void CHandlingEntrySA::SetSuspensionFrontRearBias(float fBias)
94+
95+
void CHandlingEntrySA::SetSuspensionFrontRearBias(float fBias) noexcept
10496
{
97+
CheckSuspensionChanges();
10598
m_Handling.fSuspensionFrontRearBias = fBias;
106-
pGame->GetHandlingManager()->CheckSuspensionChanges(this);
10799
}
108-
void CHandlingEntrySA::SetSuspensionAntiDiveMultiplier(float fAntidive)
100+
101+
void CHandlingEntrySA::SetSuspensionAntiDiveMultiplier(float fAntidive) noexcept
109102
{
103+
CheckSuspensionChanges();
110104
m_Handling.fSuspensionAntiDiveMultiplier = fAntidive;
105+
}
106+
107+
void CHandlingEntrySA::CheckSuspensionChanges() noexcept
108+
{
111109
pGame->GetHandlingManager()->CheckSuspensionChanges(this);
112110
}

0 commit comments

Comments
 (0)