Skip to content

Commit 132bd64

Browse files
committed
Merge remote-tracking branch 'origin/master' into feature/underwater-effect
2 parents b4c5104 + 615b9b6 commit 132bd64

File tree

508 files changed

+6130
-6676
lines changed

Some content is hidden

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

508 files changed

+6130
-6676
lines changed

Client/game_sa/CGameSA.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ void CGameSA::SetCoronaZTestEnabled(bool isEnabled)
664664
m_isCoronaZTestEnabled = isEnabled;
665665
}
666666

667-
void CGameSA::SetWaterCreaturesEnabled(bool isEnabled)
667+
void CGameSA::SetWaterCreaturesEnabled(bool isEnabled)
668668
{
669669
if (isEnabled == m_areWaterCreaturesEnabled)
670670
return;
@@ -684,6 +684,29 @@ void CGameSA::SetWaterCreaturesEnabled(bool isEnabled)
684684
m_areWaterCreaturesEnabled = isEnabled;
685685
}
686686

687+
void CGameSA::SetTunnelWeatherBlendEnabled(bool isEnabled)
688+
{
689+
if (isEnabled == m_isTunnelWeatherBlendEnabled)
690+
return;
691+
// CWeather::UpdateInTunnelness
692+
DWORD functionAddress = 0x72B630;
693+
if (isEnabled)
694+
{
695+
// Restore original bytes: 83 EC 20
696+
MemPut<BYTE>(functionAddress, 0x83); // Restore 83
697+
MemPut<BYTE>(functionAddress + 1, 0xEC); // Restore EC
698+
MemPut<BYTE>(functionAddress + 2, 0x20); // Restore 20
699+
}
700+
else
701+
{
702+
// Patch CWeather::UpdateInTunnelness (Found By AlexTMjugador)
703+
MemPut<BYTE>(functionAddress, 0xC3); // Write C3 (RET)
704+
MemPut<BYTE>(functionAddress + 1, 0x90); // Write 90 (NOP)
705+
MemPut<BYTE>(functionAddress + 2, 0x90); // Write 90 (NOP)
706+
}
707+
m_isTunnelWeatherBlendEnabled = isEnabled;
708+
}
709+
687710
void CGameSA::SetBurnFlippedCarsEnabled(bool isEnabled)
688711
{
689712
if (isEnabled == m_isBurnFlippedCarsEnabled)

Client/game_sa/CGameSA.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ class CGameSA : public CGame
244244
bool IsRoadSignsTextEnabled() const noexcept override { return m_isRoadSignsTextEnabled; }
245245
void SetRoadSignsTextEnabled(bool isEnabled) override;
246246

247+
bool IsTunnelWeatherBlendEnabled() const noexcept override { return m_isTunnelWeatherBlendEnabled; }
248+
void SetTunnelWeatherBlendEnabled(bool isEnabled) override;
249+
250+
247251
unsigned long GetMinuteDuration();
248252
void SetMinuteDuration(unsigned long ulTime);
249253

@@ -363,6 +367,7 @@ class CGameSA : public CGame
363367
int m_iCheckStatus;
364368
bool m_bUnderworldWarp;
365369
bool m_isCoronaZTestEnabled{true};
370+
bool m_isTunnelWeatherBlendEnabled{true};
366371
bool m_areWaterCreaturesEnabled{true};
367372
bool m_isBurnFlippedCarsEnabled{true};
368373
bool m_isFireballDestructEnabled{true};

Client/game_sa/CPedSA.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,3 +1108,34 @@ void CPedSA::StaticSetHooks()
11081108
EZHookInstall(CPed_PreRenderAfterTest);
11091109
EZHookInstall(CPed_PreRenderAfterTest_Mid);
11101110
}
1111+
1112+
void CPedSA::GetAttachedSatchels(std::vector<SSatchelsData>& satchelsList) const
1113+
{
1114+
// Array of projectiles objects
1115+
CProjectileSAInterface** projectilesArray = (CProjectileSAInterface**)ARRAY_CProjectile;
1116+
CProjectileSAInterface* pProjectileInterface;
1117+
1118+
// Array of projectiles infos
1119+
CProjectileInfoSAInterface* projectilesInfoArray = (CProjectileInfoSAInterface*)ARRAY_CProjectileInfo;
1120+
CProjectileInfoSAInterface* pProjectileInfoInterface;
1121+
1122+
// Loop through all projectiles
1123+
for (size_t i = 0; i < PROJECTILE_COUNT; i++)
1124+
{
1125+
pProjectileInterface = projectilesArray[i];
1126+
1127+
// is attached to our ped?
1128+
if (!pProjectileInterface || pProjectileInterface->m_pAttachedEntity != m_pInterface)
1129+
continue;
1130+
1131+
// index is always the same for both arrays
1132+
pProjectileInfoInterface = &projectilesInfoArray[i];
1133+
1134+
// We are only interested in satchels
1135+
if (!pProjectileInfoInterface || pProjectileInfoInterface->dwProjectileType != eWeaponType::WEAPONTYPE_REMOTE_SATCHEL_CHARGE)
1136+
continue;
1137+
1138+
// Push satchel into the array. There is no need to check the counter because for satchels it restarts until the player detonates the charges
1139+
satchelsList.push_back({pProjectileInterface, &pProjectileInterface->m_vecAttachedOffset, &pProjectileInterface->m_vecAttachedRotation});
1140+
}
1141+
}

Client/game_sa/CPedSA.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,4 +408,6 @@ class CPedSA : public virtual CPed, public virtual CPhysicalSA
408408
void* GetPedNodeInterface(std::int32_t nodeId) { return reinterpret_cast<CPedSAInterface*>(m_pInterface)->pedNodes[nodeId]; }
409409
std::unique_ptr<CPedIK> GetPedIK() { return std::make_unique<CPedIKSA>(GetPedIKInterface()); }
410410
static void StaticSetHooks();
411+
412+
void GetAttachedSatchels(std::vector<SSatchelsData> &satchelsList) const override;
411413
};

Client/game_sa/CVehicleSA.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "StdInc.h"
1313
#include "CAutomobileSA.h"
14+
#include "CBikeSA.h"
1415
#include "CCameraSA.h"
1516
#include "CColModelSA.h"
1617
#include "CFxManagerSA.h"
@@ -494,6 +495,37 @@ void CVehicleSA::SetPlaneRotorSpeed(float fSpeed)
494495
pInterface->m_fPropSpeed = fSpeed;
495496
}
496497

498+
bool CVehicleSA::SetVehicleWheelRotation(float fWheelRot1, float fWheelRot2, float fWheelRot3, float fWheelRot4) noexcept
499+
{
500+
VehicleClass m_eVehicleType = static_cast<VehicleClass>(GetVehicleInterface()->m_vehicleSubClass);
501+
switch (m_eVehicleType)
502+
{
503+
case VehicleClass::AUTOMOBILE:
504+
case VehicleClass::MONSTER_TRUCK:
505+
case VehicleClass::QUAD:
506+
case VehicleClass::TRAILER:
507+
{
508+
auto pInterface = static_cast<CAutomobileSAInterface*>(GetInterface());
509+
pInterface->m_wheelRotation[0] = fWheelRot1;
510+
pInterface->m_wheelRotation[1] = fWheelRot2;
511+
pInterface->m_wheelRotation[2] = fWheelRot3;
512+
pInterface->m_wheelRotation[3] = fWheelRot4;
513+
return true;
514+
}
515+
case VehicleClass::BIKE:
516+
case VehicleClass::BMX:
517+
{
518+
auto pInterface = static_cast<CBikeSAInterface*>(GetInterface());
519+
pInterface->m_afWheelRotationX[0] = fWheelRot1;
520+
pInterface->m_afWheelRotationX[1] = fWheelRot2;
521+
return true;
522+
}
523+
default:
524+
return false;
525+
}
526+
return false;
527+
}
528+
497529
float CVehicleSA::GetPlaneRotorSpeed()
498530
{
499531
auto pInterface = static_cast<CPlaneSAInterface*>(GetInterface());

Client/game_sa/CVehicleSA.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ class CVehicleSA : public virtual CVehicle, public virtual CPhysicalSA
568568
};
569569
void SetHeliRotorSpeed(float fSpeed) { *reinterpret_cast<float*>(reinterpret_cast<unsigned int>(m_pInterface) + 2124) = fSpeed; };
570570
void SetPlaneRotorSpeed(float fSpeed);
571+
bool SetVehicleWheelRotation(float fWheelRot1, float fWheelRot2, float fWheelRot3, float fWheelRot4) noexcept;
571572
void SetExplodeTime(unsigned long ulTime) { *reinterpret_cast<unsigned long*>(reinterpret_cast<unsigned int>(m_pInterface) + 1240) = ulTime; };
572573
void SetRadioStatus(bool bStatus) { *reinterpret_cast<unsigned char*>(reinterpret_cast<unsigned int>(m_pInterface) + 0x1D3) = bStatus; };
573574

Client/game_sa/CWeatherSA.cpp

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,169 @@ void CWeatherSA::ResetAmountOfRain()
6262
MemCpy((LPVOID)0x72BC92, &originalFstp1, 6);
6363
MemCpy((LPVOID)0x72C686, &originalFstp2, 6);
6464
}
65+
66+
float CWeatherSA::GetWetRoads() const
67+
{
68+
return *(float*)0xC81308;
69+
}
70+
71+
bool CWeatherSA::SetWetRoads(float fAmount)
72+
{
73+
MemSet((LPVOID)(0x72BB9F + 2), 0x90, 3);
74+
MemSet((LPVOID)(0x72BBB7 + 2), 0x90, 3);
75+
MemSet((LPVOID)(0x72BBD0 + 1), 0x90, 3);
76+
MemSet((LPVOID)(0x72BBD7 + 2), 0x90, 3);
77+
78+
MemPutFast<float>(0xC81308, fAmount);
79+
return true;
80+
}
81+
82+
bool CWeatherSA::ResetWetRoads()
83+
{
84+
BYTE originalCodes[3] = {0x08, 0x13, 0xC8};
85+
MemCpy((LPVOID)(0x72BB9F + 2), &originalCodes, 3);
86+
MemCpy((LPVOID)(0x72BBB7 + 2), &originalCodes, 3);
87+
MemCpy((LPVOID)(0x72BBD0 + 1), &originalCodes, 3);
88+
MemCpy((LPVOID)(0x72BBD7 + 2), &originalCodes, 3);
89+
return true;
90+
}
91+
92+
float CWeatherSA::GetFoggyness() const
93+
{
94+
return *(float*)0xC81300;
95+
}
96+
97+
bool CWeatherSA::SetFoggyness(float fAmount)
98+
{
99+
MemSet((LPVOID)(0x72BDF5 + 2), 0x90, 3);
100+
MemSet((LPVOID)(0x72BDDD + 2), 0x90, 3);
101+
MemSet((LPVOID)(0x72BE13 + 2), 0x90, 3);
102+
103+
MemPutFast<float>(0xC81300, fAmount);
104+
return true;
105+
}
106+
107+
bool CWeatherSA::ResetFoggyness()
108+
{
109+
BYTE originalCodes[3] = {0x00, 0x13, 0xC8};
110+
MemCpy((LPVOID)(0x72BDF5 + 2), &originalCodes, 3);
111+
MemCpy((LPVOID)(0x72BDDD + 2), &originalCodes, 3);
112+
MemCpy((LPVOID)(0x72BE13 + 2), &originalCodes, 3);
113+
return true;
114+
}
115+
116+
float CWeatherSA::GetFog() const
117+
{
118+
return *(float*)0xC812FC;
119+
}
120+
121+
bool CWeatherSA::SetFog(float fAmount)
122+
{
123+
MemSet((LPVOID)(0x72BE37 + 2), 0x90, 3);
124+
MemSet((LPVOID)(0x72BE1F + 2), 0x90, 3);
125+
MemSet((LPVOID)(0x72BE4F + 2), 0x90, 3);
126+
127+
MemPutFast<float>(0xC812FC, fAmount);
128+
return true;
129+
}
130+
131+
bool CWeatherSA::ResetFog()
132+
{
133+
BYTE originalCodes[3] = {0xFC, 0x12, 0xC8};
134+
MemCpy((LPVOID)(0x72BE37 + 2), &originalCodes, 3);
135+
MemCpy((LPVOID)(0x72BE1F + 2), &originalCodes, 3);
136+
MemCpy((LPVOID)(0x72BE4F + 2), &originalCodes, 3);
137+
return true;
138+
}
139+
140+
float CWeatherSA::GetRainFog() const
141+
{
142+
return *(float*)0xC81410;
143+
}
144+
145+
bool CWeatherSA::SetRainFog(float fAmount)
146+
{
147+
MemSet((LPVOID)(0x72ADD8 + 2), 0x90, 3);
148+
MemSet((LPVOID)(0x72ADE4 + 2), 0x90, 3);
149+
150+
MemPutFast<float>(0xC81410, fAmount);
151+
return true;
152+
}
153+
154+
bool CWeatherSA::ResetRainFog()
155+
{
156+
BYTE originalCodes[3] = {0x10, 0x14, 0xC8};
157+
MemCpy((LPVOID)(0x72ADD8 + 2), &originalCodes, 3);
158+
MemCpy((LPVOID)(0x72ADE4 + 2), &originalCodes, 3);
159+
return true;
160+
}
161+
162+
float CWeatherSA::GetWaterFog() const
163+
{
164+
return *(float*)0xC81338;
165+
}
166+
167+
bool CWeatherSA::SetWaterFog(float fAmount)
168+
{
169+
MemSet((LPVOID)(0x72C35C + 2), 0x90, 3);
170+
MemSet((LPVOID)(0x72C38E + 2), 0x90, 3);
171+
MemSet((LPVOID)(0x72C36F + 2), 0x90, 3);
172+
173+
MemPutFast<float>(0xC81338, fAmount);
174+
return true;
175+
}
176+
177+
bool CWeatherSA::ResetWaterFog()
178+
{
179+
BYTE originalCodes[3] = {0x38, 0x13, 0xC8};
180+
MemCpy((LPVOID)(0x72C35C + 2), &originalCodes, 3);
181+
MemCpy((LPVOID)(0x72C38E + 2), &originalCodes, 3);
182+
MemCpy((LPVOID)(0x72C36F + 2), &originalCodes, 3);
183+
return true;
184+
}
185+
186+
float CWeatherSA::GetSandstorm() const
187+
{
188+
return *(float*)0xC812F4;
189+
}
190+
191+
bool CWeatherSA::SetSandstorm(float fAmount)
192+
{
193+
MemSet((LPVOID)(0x72A4B6 + 1), 0x90, 3);
194+
MemSet((LPVOID)(0x72BCEB + 1), 0x90, 3);
195+
MemSet((LPVOID)(0x72BD0B + 2), 0x90, 3);
196+
197+
MemPutFast<float>(0xC812F4, fAmount);
198+
return true;
199+
}
200+
201+
bool CWeatherSA::ResetSandstorm()
202+
{
203+
BYTE originalCodes[3] = {0xF4, 0x12, 0xC8};
204+
MemCpy((LPVOID)(0x72A4B6 + 1), &originalCodes, 3);
205+
MemCpy((LPVOID)(0x72BCEB + 1), &originalCodes, 3);
206+
MemCpy((LPVOID)(0x72BD0B + 2), &originalCodes, 3);
207+
return true;
208+
}
209+
210+
float CWeatherSA::GetRainbow() const
211+
{
212+
return *(float*)0xC812E4;
213+
}
214+
215+
bool CWeatherSA::SetRainbow(float fAmount)
216+
{
217+
MemSet((LPVOID)(0x72BF51 + 2), 0x90, 3);
218+
MemSet((LPVOID)(0x72BF59 + 2), 0x90, 3);
219+
220+
MemPutFast<float>(0xC812E4, fAmount);
221+
return true;
222+
}
223+
224+
bool CWeatherSA::ResetRainbow()
225+
{
226+
BYTE originalCodes[3] = {0xE4, 0x12, 0xC8};
227+
MemCpy((LPVOID)(0x72BF51 + 2), &originalCodes, 3);
228+
MemCpy((LPVOID)(0x72BF59 + 2), &originalCodes, 3);
229+
return true;
230+
}

Client/game_sa/CWeatherSA.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,39 @@ class CWeatherSA : public CWeather
2626
float GetAmountOfRain();
2727
void SetAmountOfRain(float fAmount);
2828
void ResetAmountOfRain();
29+
30+
float GetWetRoads() const;
31+
bool SetWetRoads(float fAmount);
32+
bool ResetWetRoads();
33+
34+
float GetFoggyness() const;
35+
bool SetFoggyness(float fAmount);
36+
bool ResetFoggyness();
37+
38+
float GetFog() const;
39+
bool SetFog(float fAmount);
40+
bool ResetFog();
41+
42+
float GetRainFog() const;
43+
bool SetRainFog(float fAmount);
44+
bool ResetRainFog();
45+
46+
float GetWaterFog() const;
47+
bool SetWaterFog(float fAmount);
48+
bool ResetWaterFog();
49+
50+
float GetSandstorm() const;
51+
bool SetSandstorm(float fAmount);
52+
bool ResetSandstorm();
53+
54+
float GetRainbow() const;
55+
bool SetRainbow(float fAmount);
56+
bool ResetRainbow();
57+
58+
private:
59+
static unsigned char* VAR_CWeather__ForcedWeatherType;
60+
static unsigned char* VAR_CWeather__OldWeatherType;
61+
static unsigned char* VAR_CWeather__NewWeatherType;
62+
static float* VAR_CWeather__Rain;
63+
2964
};

0 commit comments

Comments
 (0)