Skip to content

Commit 360e379

Browse files
committed
Requested changes & fixes
1 parent 8c9b6d6 commit 360e379

File tree

13 files changed

+70
-71
lines changed

13 files changed

+70
-71
lines changed

Client/mods/deathmatch/logic/CPacketHandler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2550,15 +2550,15 @@ void CPacketHandler::Packet_MapInfo(NetBitStreamInterface& bitStream)
25502550

25512551
// Grass draw distance
25522552
bool bOverrideGrassDrawDistance = false;
2553-
float fGrassCloseDistance, fGrassFarDistance;
2553+
float grassCloseDistance, grassFarDistance;
25542554
if (!bitStream.ReadBit(bOverrideGrassDrawDistance))
25552555
return;
25562556
if (bOverrideGrassDrawDistance)
25572557
{
2558-
if (!bitStream.Read(fGrassCloseDistance) || !bitStream.Read(fGrassFarDistance))
2558+
if (!bitStream.Read(grassCloseDistance) || !bitStream.Read(grassFarDistance))
25592559
return;
25602560

2561-
g_pMultiplayer->SetGrassDrawDistance(fGrassCloseDistance, fGrassFarDistance);
2561+
g_pMultiplayer->SetGrassDrawDistance(grassCloseDistance, grassFarDistance);
25622562
}
25632563

25642564
// Aircraft max height

Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,21 +1825,19 @@ int CLuaWorldDefs::ResetFogDistance(lua_State* luaVM)
18251825

18261826
CLuaMultiReturn<float, float> CLuaWorldDefs::GetGrassDrawDistance()
18271827
{
1828-
float fCloseDistance, fFarDistance;
1829-
g_pMultiplayer->GetGrassDrawDistance(fCloseDistance, fFarDistance);
1830-
return {fCloseDistance, fFarDistance};
1828+
float closeDistance, farDistance;
1829+
g_pMultiplayer->GetGrassDrawDistance(closeDistance, farDistance);
1830+
return {closeDistance, farDistance};
18311831
}
18321832

1833-
bool CLuaWorldDefs::SetGrassDrawDistance(float closeDistance, float farDistance)
1833+
void CLuaWorldDefs::SetGrassDrawDistance(float closeDistance, float farDistance)
18341834
{
18351835
g_pMultiplayer->SetGrassDrawDistance(closeDistance, farDistance);
1836-
return true;
18371836
}
18381837

1839-
bool CLuaWorldDefs::ResetGrassDrawDistance()
1838+
void CLuaWorldDefs::ResetGrassDrawDistance()
18401839
{
18411840
g_pMultiplayer->ResetGrassDrawDistance();
1842-
return true;
18431841
}
18441842

18451843
int CLuaWorldDefs::GetSunColor(lua_State* luaVM)

Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ class CLuaWorldDefs : public CLuaDefs
9191
LUA_DECLARE(SetFogDistance);
9292
LUA_DECLARE(ResetFogDistance);
9393
static CLuaMultiReturn<float, float> GetGrassDrawDistance();
94-
static bool SetGrassDrawDistance(float closeDistance, float farDistance);
95-
static bool ResetGrassDrawDistance();
94+
static void SetGrassDrawDistance(float closeDistance, float farDistance);
95+
static void ResetGrassDrawDistance();
9696
LUA_DECLARE(GetSunColor);
9797
LUA_DECLARE(SetSunColor);
9898
LUA_DECLARE(ResetSunColor);

Client/mods/deathmatch/logic/rpc/CWorldRPCs.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,11 @@ void CWorldRPCs::SetFogDistance(NetBitStreamInterface& bitStream)
359359

360360
void CWorldRPCs::SetGrassDrawDistance(NetBitStreamInterface& bitStream)
361361
{
362-
float fCloseDistance, fFarDistance;
362+
float closeDistance, farDistance;
363363

364-
if (bitStream.Read(fCloseDistance) && bitStream.Read(fFarDistance))
364+
if (bitStream.Read(closeDistance) && bitStream.Read(farDistance))
365365
{
366-
g_pMultiplayer->SetGrassDrawDistance(fCloseDistance, fFarDistance);
366+
g_pMultiplayer->SetGrassDrawDistance(closeDistance, farDistance);
367367
}
368368
}
369369

Client/multiplayer_sa/CMultiplayerSA.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,22 +2064,22 @@ void CMultiplayerSA::RestoreFogDistance()
20642064
}
20652065
}
20662066

2067-
void CMultiplayerSA::SetGrassDrawDistance(float fCloseDistance, float fFarDistance)
2067+
void CMultiplayerSA::SetGrassDrawDistance(float closeDistance, float farDistance)
20682068
{
2069-
MemPutFast<float>(0xC02DBC, fCloseDistance);
2070-
MemPutFast<float>(0x8D132C, fFarDistance);
2069+
MemPutFast<float>(VAR_CGrassCloseDist, closeDistance);
2070+
MemPutFast<float>(VAR_CGrassFarDist, farDistance);
20712071
}
20722072

2073-
void CMultiplayerSA::GetGrassDrawDistance(float& fCloseDistance, float& fFarDistance) const
2073+
void CMultiplayerSA::GetGrassDrawDistance(float& closeDistance, float& farDistance) const
20742074
{
2075-
fCloseDistance = *(float*)0xC02DBC;
2076-
fFarDistance = *(float*)0x8D132C;
2075+
closeDistance = *(float*)VAR_CGrassCloseDist;
2076+
farDistance = *(float*)VAR_CGrassFarDist;
20772077
}
20782078

20792079
void CMultiplayerSA::ResetGrassDrawDistance()
20802080
{
2081-
MemPutFast<float>(0xC02DBC, 3.0f);
2082-
MemPutFast<float>(0x8D132C, 60.0f);
2081+
MemPutFast<float>(VAR_CGrassCloseDist, DEFAULT_GRASS_CLOSE_DISTANCE);
2082+
MemPutFast<float>(VAR_CGrassFarDist, DEFAULT_GRASS_FAR_DISTANCE);
20832083
}
20842084

20852085
void CMultiplayerSA::GetSunColor(unsigned char& ucCoreRed, unsigned char& ucCoreGreen, unsigned char& ucCoreBlue, unsigned char& ucCoronaRed,

Client/multiplayer_sa/CMultiplayerSA.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
class CRemoteDataSA;
2222
#define DEFAULT_NEAR_CLIP_DISTANCE ( 0.3f )
2323
#define DEFAULT_SHADOWS_OFFSET ( 0.013f ) // GTA default = 0.06f
24+
#define DEFAULT_GRASS_CLOSE_DISTANCE ( 3.0f )
25+
#define DEFAULT_GRASS_FAR_DISTANCE ( 60.0f )
26+
27+
#define VAR_CGrassCloseDist 0xC02DBC
28+
#define VAR_CGrassFarDist 0x8D132C
2429

2530
enum eRadioStationID
2631
{
@@ -192,9 +197,9 @@ void InitHooks();
192197
float GetFogDistance();
193198
void SetFogDistance(float fDistance);
194199
void RestoreFogDistance();
195-
void SetGrassDrawDistance(float fCloseDistance, float fFarDistance);
196-
void GetGrassDrawDistance(float& fCloseDistance, float& fFarDistance) const;
197-
void ResetGrassDrawDistance();
200+
void SetGrassDrawDistance(float closeDistance, float farDistance) override;
201+
void GetGrassDrawDistance(float& closeDistance, float& farDistance) const override;
202+
void ResetGrassDrawDistance() override;
198203
void GetSunColor(unsigned char& ucCoreRed, unsigned char& ucCoreGreen, unsigned char& ucCoreBlue, unsigned char& ucCoronaRed, unsigned char& ucCoronaGreen,
199204
unsigned char& ucCoronaBlue);
200205
void SetSunColor(unsigned char ucCoreRed, unsigned char ucCoreGreen, unsigned char ucCoreBlue, unsigned char ucCoronaRed, unsigned char ucCoronaGreen,

Client/sdk/multiplayer/CMultiplayer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ class CMultiplayer
299299
virtual void SetFogDistance(float fDistance) = 0;
300300
virtual float GetFogDistance() = 0;
301301
virtual void RestoreFogDistance() = 0;
302-
virtual void SetGrassDrawDistance(float fCloseDistance, float fFarDistance) = 0;
303-
virtual void GetGrassDrawDistance(float& fCloseDistance, float& fFarDistance) const = 0;
302+
virtual void SetGrassDrawDistance(float closeDistance, float farDistance) = 0;
303+
virtual void GetGrassDrawDistance(float& closeDistance, float& farDistance) const = 0;
304304
virtual void ResetGrassDrawDistance() = 0;
305305
virtual void GetSunColor(unsigned char& ucCoreRed, unsigned char& ucCoreGreen, unsigned char& ucCoreBlue, unsigned char& ucCoronaRed,
306306
unsigned char& ucCoronaGreen, unsigned char& ucCoronaBlue) = 0;

Server/mods/deathmatch/logic/CGame.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -404,18 +404,18 @@ class CGame
404404
float GetFogDistance() { return m_fFogDistance; }
405405
void SetFogDistance(float& fFogDistance) { m_fFogDistance = fFogDistance; }
406406

407-
bool HasGrassDrawDistance() { return m_bOverrideGrassDrawDistance; }
408-
void SetHasGrassDrawDistance(bool bOverrideGrassDrawDistance) { m_bOverrideGrassDrawDistance = bOverrideGrassDrawDistance; }
407+
bool HasGrassDrawDistance() const noexcept { return m_bOverrideGrassDrawDistance; }
408+
void SetHasGrassDrawDistance(bool bOverrideGrassDrawDistance) noexcept { m_bOverrideGrassDrawDistance = bOverrideGrassDrawDistance; }
409409

410-
void GetGrassDrawDistance(float& fCloseDistance, float& fFarDistance)
410+
void GetGrassDrawDistance(float& closeDistance, float& farDistance) const noexcept
411411
{
412-
fCloseDistance = m_fGrassCloseDistance;
413-
fFarDistance = m_fGrassFarDistance;
412+
closeDistance = m_fGrassCloseDistance;
413+
farDistance = m_fGrassFarDistance;
414414
}
415-
void SetGrassDrawDistance(float fCloseDistance, float fFarDistance)
415+
void SetGrassDrawDistance(float closeDistance, float farDistance) noexcept
416416
{
417-
m_fGrassCloseDistance = fCloseDistance;
418-
m_fGrassFarDistance = fFarDistance;
417+
m_fGrassCloseDistance = closeDistance;
418+
m_fGrassFarDistance = farDistance;
419419
}
420420

421421
float GetAircraftMaxHeight() { return m_fAircraftMaxHeight; }

Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10686,11 +10686,11 @@ bool CStaticFunctionDefinitions::GetFogDistance(float& fFogDist)
1068610686
return false;
1068710687
}
1068810688

10689-
bool CStaticFunctionDefinitions::GetGrassDrawDistance(float& fCloseDistance, float& fFarDistance)
10689+
bool CStaticFunctionDefinitions::GetGrassDrawDistance(float& closeDistance, float& farDistance)
1069010690
{
1069110691
if (g_pGame->HasGrassDrawDistance())
1069210692
{
10693-
g_pGame->GetGrassDrawDistance(fCloseDistance, fFarDistance);
10693+
g_pGame->GetGrassDrawDistance(closeDistance, farDistance);
1069410694
return true;
1069510695
}
1069610696

@@ -10881,17 +10881,15 @@ bool CStaticFunctionDefinitions::SetFogDistance(float fFogDist)
1088110881
return true;
1088210882
}
1088310883

10884-
bool CStaticFunctionDefinitions::SetGrassDrawDistance(float fCloseDistance, float fFarDistance)
10884+
void CStaticFunctionDefinitions::SetGrassDrawDistance(float closeDistance, float farDistance)
1088510885
{
10886-
g_pGame->SetGrassDrawDistance(fCloseDistance, fFarDistance);
10886+
g_pGame->SetGrassDrawDistance(closeDistance, farDistance);
1088710887
g_pGame->SetHasGrassDrawDistance(true);
1088810888

1088910889
CBitStream BitStream;
10890-
BitStream.pBitStream->Write(fCloseDistance);
10891-
BitStream.pBitStream->Write(fFarDistance);
10890+
BitStream.pBitStream->Write(closeDistance);
10891+
BitStream.pBitStream->Write(farDistance);
1089210892
m_pPlayerManager->BroadcastOnlyJoined(CLuaPacket(SET_GRASS_DRAW_DISTANCE, *BitStream.pBitStream));
10893-
10894-
return true;
1089510893
}
1089610894

1089710895
bool CStaticFunctionDefinitions::SetAircraftMaxHeight(float fMaxHeight)
@@ -10986,14 +10984,12 @@ bool CStaticFunctionDefinitions::ResetFogDistance()
1098610984
return true;
1098710985
}
1098810986

10989-
bool CStaticFunctionDefinitions::ResetGrassDrawDistance()
10987+
void CStaticFunctionDefinitions::ResetGrassDrawDistance()
1099010988
{
1099110989
g_pGame->SetHasGrassDrawDistance(false);
1099210990

1099310991
CBitStream BitStream;
1099410992
m_pPlayerManager->BroadcastOnlyJoined(CLuaPacket(RESET_GRASS_DRAW_DISTANCE, *BitStream.pBitStream));
10995-
10996-
return true;
1099710993
}
1099810994

1099910995
bool CStaticFunctionDefinitions::RemoveWorldModel(unsigned short usModel, float fRadius, const CVector& vecPosition, char cInterior)

Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ class CStaticFunctionDefinitions
605605
static bool GetWindVelocity(float& fVelX, float& fVelY, float& fVelZ);
606606
static bool GetFarClipDistance(float& fFarClip);
607607
static bool GetFogDistance(float& fFogDist);
608-
static bool GetGrassDrawDistance(float& fCloseDistance, float& fFarDistance);
608+
static bool GetGrassDrawDistance(float& closeDistance, float& farDistance);
609609
static bool GetAircraftMaxHeight(float& fMaxHeight);
610610
static bool GetOcclusionsEnabled(bool& bEnabled);
611611
static bool GetMoonSize(int& iSize);
@@ -645,7 +645,7 @@ class CStaticFunctionDefinitions
645645
static bool SetWindVelocity(float fVelX, float fVelY, float fVelZ);
646646
static bool SetFarClipDistance(float fFarClip);
647647
static bool SetFogDistance(float fFogDist);
648-
static bool SetGrassDrawDistance(float fCloseDistance, float fFarDistance);
648+
static void SetGrassDrawDistance(float closeDistance, float farDistance);
649649
static bool SetAircraftMaxHeight(float fMaxHeight);
650650
static bool SetAircraftMaxVelocity(float fVelocity);
651651
static bool SetOcclusionsEnabled(bool bEnabled);
@@ -655,7 +655,7 @@ class CStaticFunctionDefinitions
655655
static bool ResetWindVelocity();
656656
static bool ResetFarClipDistance();
657657
static bool ResetFogDistance();
658-
static bool ResetGrassDrawDistance();
658+
static void ResetGrassDrawDistance();
659659
static bool RemoveWorldModel(unsigned short usModel, float fRadius, const CVector& vecPosition, char cInterior);
660660
static bool RestoreWorldModel(unsigned short usModel, float fRadius, const CVector& vecPosition, char cInterior);
661661
static bool RestoreAllWorldModels();

0 commit comments

Comments
 (0)