Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6985,6 +6985,7 @@ void CClientGame::ResetWorldProperties(const ResetWorldPropsInfo& resetPropsInfo
g_pMultiplayer->ResetSunSize();
g_pMultiplayer->RestoreWindVelocity();
g_pMultiplayer->ResetColorFilter();
g_pMultiplayer->ResetGrassDrawDistance();

g_pGame->GetWeather()->ResetAmountOfRain();
}
Expand Down
13 changes: 13 additions & 0 deletions Client/mods/deathmatch/logic/CPacketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2544,6 +2544,19 @@ void CPacketHandler::Packet_MapInfo(NetBitStreamInterface& bitStream)
g_pMultiplayer->SetFogDistance(fFogDistance);
}

// Grass draw distance
bool bOverrideGrassDrawDistance = false;
float fGrassCloseDistance, fGrassFarDistance;
if (!bitStream.ReadBit(bOverrideGrassDrawDistance))
return;
if (bOverrideGrassDrawDistance)
{
if (!bitStream.Read(fGrassCloseDistance) || !bitStream.Read(fGrassFarDistance))
return;

g_pMultiplayer->SetGrassDrawDistance(fGrassCloseDistance, fGrassFarDistance);
}

// Aircraft max height
float fAircraftMaxHeight = 800;
if (!bitStream.Read(fAircraftMaxHeight))
Expand Down
26 changes: 25 additions & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ void CLuaWorldDefs::LoadFunctions()
{"isTimeFrozen", ArgumentParser<IsTimeFrozen>},
{"isVolumetricShadowsEnabled", ArgumentParser<IsVolumetricShadowsEnabled>},
{"isDynamicPedShadowsEnabled", ArgumentParser<IsDynamicPedShadowsEnabled>},
{"testSphereAgainstWorld", ArgumentParser<TestSphereAgainstWorld>}};
{"testSphereAgainstWorld", ArgumentParser<TestSphereAgainstWorld>},

// Grass draw distance functions
{"getGrassDrawDistance", ArgumentParser<GetGrassDrawDistance>},
{"setGrassDrawDistance", ArgumentParser<SetGrassDrawDistance>},
{"resetGrassDrawDistance", ArgumentParser<ResetGrassDrawDistance>}};

// Add functions
for (const auto& [name, func] : functions)
Expand Down Expand Up @@ -1818,6 +1823,25 @@ int CLuaWorldDefs::ResetFogDistance(lua_State* luaVM)
return 1;
}

CLuaMultiReturn<float, float> CLuaWorldDefs::GetGrassDrawDistance()
{
float fCloseDistance, fFarDistance;
g_pMultiplayer->GetGrassDrawDistance(fCloseDistance, fFarDistance);
return {fCloseDistance, fFarDistance};
}

bool CLuaWorldDefs::SetGrassDrawDistance(float closeDistance, float farDistance)
{
g_pMultiplayer->SetGrassDrawDistance(closeDistance, farDistance);
return true;
}

bool CLuaWorldDefs::ResetGrassDrawDistance()
{
g_pMultiplayer->ResetGrassDrawDistance();
return true;
}

int CLuaWorldDefs::GetSunColor(lua_State* luaVM)
{
unsigned char ucCoreRed, ucCoreGreen, ucCoreBlue, ucCoronaRed, ucCoronaGreen, ucCoronaBlue;
Expand Down
3 changes: 3 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ class CLuaWorldDefs : public CLuaDefs
LUA_DECLARE(GetFogDistance);
LUA_DECLARE(SetFogDistance);
LUA_DECLARE(ResetFogDistance);
static CLuaMultiReturn<float, float> GetGrassDrawDistance();
static bool SetGrassDrawDistance(float closeDistance, float farDistance);
static bool ResetGrassDrawDistance();
LUA_DECLARE(GetSunColor);
LUA_DECLARE(SetSunColor);
LUA_DECLARE(ResetSunColor);
Expand Down
18 changes: 18 additions & 0 deletions Client/mods/deathmatch/logic/rpc/CWorldRPCs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ void CWorldRPCs::LoadFunctions()
AddHandler(SET_WORLD_SPECIAL_PROPERTY, SetWorldSpecialPropertyEnabled, "SetWorldSpecialPropertyEnabled");

AddHandler(RESET_WORLD_PROPERTIES, ResetWorldProperties, "ResetWorldProperties");

AddHandler(SET_GRASS_DRAW_DISTANCE, SetGrassDrawDistance, "SetGrassDrawDistance");
AddHandler(RESET_GRASS_DRAW_DISTANCE, ResetGrassDrawDistance, "ResetGrassDrawDistance");
}

void CWorldRPCs::SetTime(NetBitStreamInterface& bitStream)
Expand Down Expand Up @@ -354,6 +357,16 @@ void CWorldRPCs::SetFogDistance(NetBitStreamInterface& bitStream)
}
}

void CWorldRPCs::SetGrassDrawDistance(NetBitStreamInterface& bitStream)
{
float fCloseDistance, fFarDistance;

if (bitStream.Read(fCloseDistance) && bitStream.Read(fFarDistance))
{
g_pMultiplayer->SetGrassDrawDistance(fCloseDistance, fFarDistance);
}
}

void CWorldRPCs::SetAircraftMaxHeight(NetBitStreamInterface& bitStream)
{
float fMaxHeight;
Expand Down Expand Up @@ -414,6 +427,11 @@ void CWorldRPCs::ResetFogDistance(NetBitStreamInterface& bitStream)
g_pMultiplayer->RestoreFogDistance();
}

void CWorldRPCs::ResetGrassDrawDistance(NetBitStreamInterface& bitStream)
{
g_pMultiplayer->ResetGrassDrawDistance();
}

void CWorldRPCs::SetWeaponProperty(NetBitStreamInterface& bitStream)
{
unsigned char ucWeapon = 0;
Expand Down
2 changes: 2 additions & 0 deletions Client/mods/deathmatch/logic/rpc/CWorldRPCs.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@ class CWorldRPCs : public CRPCFunctions
DECLARE_RPC(SetSyncIntervals);
DECLARE_RPC(SetWorldSpecialPropertyEnabled);
DECLARE_RPC(ResetWorldProperties);
DECLARE_RPC(SetGrassDrawDistance);
DECLARE_RPC(ResetGrassDrawDistance);
};
18 changes: 18 additions & 0 deletions Client/multiplayer_sa/CMultiplayerSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2064,6 +2064,24 @@ void CMultiplayerSA::RestoreFogDistance()
}
}

void CMultiplayerSA::SetGrassDrawDistance(float fCloseDistance, float fFarDistance)
{
MemPutFast<float>(0xC02DBC, fCloseDistance);
MemPutFast<float>(0x8D132C, fFarDistance);
}

void CMultiplayerSA::GetGrassDrawDistance(float& fCloseDistance, float& fFarDistance) const
{
fCloseDistance = *(float*)0xC02DBC;
fFarDistance = *(float*)0x8D132C;
}

void CMultiplayerSA::ResetGrassDrawDistance()
{
MemPutFast<float>(0xC02DBC, 3.0f);
MemPutFast<float>(0x8D132C, 60.0f);
}

void CMultiplayerSA::GetSunColor(unsigned char& ucCoreRed, unsigned char& ucCoreGreen, unsigned char& ucCoreBlue, unsigned char& ucCoronaRed,
unsigned char& ucCoronaGreen, unsigned char& ucCoronaBlue)
{
Expand Down
3 changes: 3 additions & 0 deletions Client/multiplayer_sa/CMultiplayerSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ void InitHooks();
float GetFogDistance();
void SetFogDistance(float fDistance);
void RestoreFogDistance();
void SetGrassDrawDistance(float fCloseDistance, float fFarDistance);
void GetGrassDrawDistance(float& fCloseDistance, float& fFarDistance) const;
void ResetGrassDrawDistance();
void GetSunColor(unsigned char& ucCoreRed, unsigned char& ucCoreGreen, unsigned char& ucCoreBlue, unsigned char& ucCoronaRed, unsigned char& ucCoronaGreen,
unsigned char& ucCoronaBlue);
void SetSunColor(unsigned char ucCoreRed, unsigned char ucCoreGreen, unsigned char ucCoreBlue, unsigned char ucCoronaRed, unsigned char ucCoronaGreen,
Expand Down
3 changes: 3 additions & 0 deletions Client/sdk/multiplayer/CMultiplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ class CMultiplayer
virtual void SetFogDistance(float fDistance) = 0;
virtual float GetFogDistance() = 0;
virtual void RestoreFogDistance() = 0;
virtual void SetGrassDrawDistance(float fCloseDistance, float fFarDistance) = 0;
virtual void GetGrassDrawDistance(float& fCloseDistance, float& fFarDistance) const = 0;
virtual void ResetGrassDrawDistance() = 0;
virtual void GetSunColor(unsigned char& ucCoreRed, unsigned char& ucCoreGreen, unsigned char& ucCoreBlue, unsigned char& ucCoronaRed,
unsigned char& ucCoronaGreen, unsigned char& ucCoronaBlue) = 0;
virtual void SetSunColor(unsigned char ucCoreRed, unsigned char ucCoreGreen, unsigned char ucCoreBlue, unsigned char ucCoronaRed,
Expand Down
3 changes: 3 additions & 0 deletions Server/mods/deathmatch/logic/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ CGame::CGame() : m_FloodProtect(4, 30000, 30000) // Max of 4 connecti
m_bOverrideWindVelocity = false;
m_bOverrideFarClip = false;
m_bOverrideFogDistance = false;
m_bOverrideGrassDrawDistance = false;
m_fGrassCloseDistance = 3.0f;
m_fGrassFarDistance = 60.0f;
m_bOverrideMoonSize = false;

m_pASE = NULL;
Expand Down
18 changes: 18 additions & 0 deletions Server/mods/deathmatch/logic/CGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,20 @@ class CGame
float GetFogDistance() { return m_fFogDistance; }
void SetFogDistance(float& fFogDistance) { m_fFogDistance = fFogDistance; }

bool HasGrassDrawDistance() { return m_bOverrideGrassDrawDistance; }
void SetHasGrassDrawDistance(bool bOverrideGrassDrawDistance) { m_bOverrideGrassDrawDistance = bOverrideGrassDrawDistance; }

void GetGrassDrawDistance(float& fCloseDistance, float& fFarDistance)
{
fCloseDistance = m_fGrassCloseDistance;
fFarDistance = m_fGrassFarDistance;
}
void SetGrassDrawDistance(float fCloseDistance, float fFarDistance)
{
m_fGrassCloseDistance = fCloseDistance;
m_fGrassFarDistance = fFarDistance;
}

float GetAircraftMaxHeight() { return m_fAircraftMaxHeight; }
void SetAircraftMaxHeight(float fMaxHeight) { m_fAircraftMaxHeight = fMaxHeight; }

Expand Down Expand Up @@ -640,6 +654,10 @@ class CGame
bool m_bOverrideFogDistance;
float m_fFogDistance;

bool m_bOverrideGrassDrawDistance;
float m_fGrassCloseDistance;
float m_fGrassFarDistance;

SGarageStates m_bGarageStates;

// FPS statistics
Expand Down
8 changes: 7 additions & 1 deletion Server/mods/deathmatch/logic/CMapManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@ void CMapManager::OnPlayerJoin(CPlayer& Player)
bool bOverrideFogDistance = g_pGame->HasFogDistance();
float fFogDistance = g_pGame->GetFogDistance();

// Grass draw distance
bool bOverrideGrassDrawDistance = g_pGame->HasGrassDrawDistance();
float fGrassCloseDistance, fGrassFarDistance;
g_pGame->GetGrassDrawDistance(fGrassCloseDistance, fGrassFarDistance);

marker.Set("FirstBit");

// Send the packet to the given player
Expand All @@ -528,7 +533,8 @@ void CMapManager::OnPlayerJoin(CPlayer& Player)
fJetpackMaxHeight, bOverrideWaterColor, ucWaterRed, ucWaterGreen, ucWaterBlue, ucWaterAlpha, bInteriorSoundsEnabled,
bOverrideRainLevel, fRainLevel, bOverrideSunSize, fSunSize, bOverrideSunColor, ucCoreR, ucCoreG, ucCoreB, ucCoronaR, ucCoronaG,
ucCoronaB, bOverrideWindVelocity, fWindVelX, fWindVelY, fWindVelZ, bOverrideFarClipDistance, fFarClip, bOverrideFogDistance,
fFogDistance, fAircraftMaxHeight, fAircraftMaxVelocity, bOverrideMoonSize, iMoonSize));
fFogDistance, bOverrideGrassDrawDistance, fGrassCloseDistance, fGrassFarDistance, fAircraftMaxHeight, fAircraftMaxVelocity,
bOverrideMoonSize, iMoonSize));

marker.Set("SendMapInfoPacket");

Expand Down
34 changes: 34 additions & 0 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10686,6 +10686,17 @@ bool CStaticFunctionDefinitions::GetFogDistance(float& fFogDist)
return false;
}

bool CStaticFunctionDefinitions::GetGrassDrawDistance(float& fCloseDistance, float& fFarDistance)
{
if (g_pGame->HasGrassDrawDistance())
{
g_pGame->GetGrassDrawDistance(fCloseDistance, fFarDistance);
return true;
}

return false;
}

bool CStaticFunctionDefinitions::GetAircraftMaxHeight(float& fMaxHeight)
{
fMaxHeight = g_pGame->GetAircraftMaxHeight();
Expand Down Expand Up @@ -10870,6 +10881,19 @@ bool CStaticFunctionDefinitions::SetFogDistance(float fFogDist)
return true;
}

bool CStaticFunctionDefinitions::SetGrassDrawDistance(float fCloseDistance, float fFarDistance)
{
g_pGame->SetGrassDrawDistance(fCloseDistance, fFarDistance);
g_pGame->SetHasGrassDrawDistance(true);

CBitStream BitStream;
BitStream.pBitStream->Write(fCloseDistance);
BitStream.pBitStream->Write(fFarDistance);
m_pPlayerManager->BroadcastOnlyJoined(CLuaPacket(SET_GRASS_DRAW_DISTANCE, *BitStream.pBitStream));

return true;
}

bool CStaticFunctionDefinitions::SetAircraftMaxHeight(float fMaxHeight)
{
g_pGame->SetAircraftMaxHeight(fMaxHeight);
Expand Down Expand Up @@ -10962,6 +10986,16 @@ bool CStaticFunctionDefinitions::ResetFogDistance()
return true;
}

bool CStaticFunctionDefinitions::ResetGrassDrawDistance()
{
g_pGame->SetHasGrassDrawDistance(false);

CBitStream BitStream;
m_pPlayerManager->BroadcastOnlyJoined(CLuaPacket(RESET_GRASS_DRAW_DISTANCE, *BitStream.pBitStream));

return true;
}

bool CStaticFunctionDefinitions::RemoveWorldModel(unsigned short usModel, float fRadius, const CVector& vecPosition, char cInterior)
{
g_pGame->GetBuildingRemovalManager()->CreateBuildingRemoval(usModel, fRadius, vecPosition, cInterior);
Expand Down
3 changes: 3 additions & 0 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ class CStaticFunctionDefinitions
static bool GetWindVelocity(float& fVelX, float& fVelY, float& fVelZ);
static bool GetFarClipDistance(float& fFarClip);
static bool GetFogDistance(float& fFogDist);
static bool GetGrassDrawDistance(float& fCloseDistance, float& fFarDistance);
static bool GetAircraftMaxHeight(float& fMaxHeight);
static bool GetOcclusionsEnabled(bool& bEnabled);
static bool GetMoonSize(int& iSize);
Expand Down Expand Up @@ -644,6 +645,7 @@ class CStaticFunctionDefinitions
static bool SetWindVelocity(float fVelX, float fVelY, float fVelZ);
static bool SetFarClipDistance(float fFarClip);
static bool SetFogDistance(float fFogDist);
static bool SetGrassDrawDistance(float fCloseDistance, float fFarDistance);
static bool SetAircraftMaxHeight(float fMaxHeight);
static bool SetAircraftMaxVelocity(float fVelocity);
static bool SetOcclusionsEnabled(bool bEnabled);
Expand All @@ -653,6 +655,7 @@ class CStaticFunctionDefinitions
static bool ResetWindVelocity();
static bool ResetFarClipDistance();
static bool ResetFogDistance();
static bool ResetGrassDrawDistance();
static bool RemoveWorldModel(unsigned short usModel, float fRadius, const CVector& vecPosition, char cInterior);
static bool RestoreWorldModel(unsigned short usModel, float fRadius, const CVector& vecPosition, char cInterior);
static bool RestoreAllWorldModels();
Expand Down
28 changes: 27 additions & 1 deletion Server/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ void CLuaWorldDefs::LoadFunctions()
{"isGarageOpen", isGarageOpen},
{"isGlitchEnabled", isGlitchEnabled},
{"isWorldSpecialPropertyEnabled", ArgumentParserWarn<false, isWorldSpecialPropertyEnabled>},
{"areTrafficLightsLocked", areTrafficLightsLocked}};
{"areTrafficLightsLocked", areTrafficLightsLocked},

// Grass draw distance functions
{"getGrassDrawDistance", ArgumentParser<GetGrassDrawDistance>},
{"setGrassDrawDistance", ArgumentParser<SetGrassDrawDistance>},
{"resetGrassDrawDistance", ArgumentParser<ResetGrassDrawDistance>}};

// Add functions
for (const auto& [name, func] : functions)
Expand Down Expand Up @@ -797,6 +802,17 @@ int CLuaWorldDefs::getFogDistance(lua_State* luaVM)
return 1;
}

std::variant<CLuaMultiReturn<float, float>, bool> CLuaWorldDefs::GetGrassDrawDistance()
{
float fCloseDistance, fFarDistance;
bool bSuccess = CStaticFunctionDefinitions::GetGrassDrawDistance(fCloseDistance, fFarDistance);

if (bSuccess)
return std::make_tuple(fCloseDistance, fFarDistance);

return false;
}

int CLuaWorldDefs::setInteriorSoundsEnabled(lua_State* luaVM)
{
CScriptArgReader argStream(luaVM);
Expand Down Expand Up @@ -983,6 +999,11 @@ int CLuaWorldDefs::setFogDistance(lua_State* luaVM)
return 1;
}

bool CLuaWorldDefs::SetGrassDrawDistance(float closeDistance, float farDistance)
{
return CStaticFunctionDefinitions::SetGrassDrawDistance(closeDistance, farDistance);
}

int CLuaWorldDefs::resetRainLevel(lua_State* luaVM)
{
if (CStaticFunctionDefinitions::ResetRainLevel())
Expand Down Expand Up @@ -1060,6 +1081,11 @@ int CLuaWorldDefs::resetFogDistance(lua_State* luaVM)
return 1;
}

bool CLuaWorldDefs::ResetGrassDrawDistance()
{
return CStaticFunctionDefinitions::ResetGrassDrawDistance();
}

int CLuaWorldDefs::RemoveWorldModel(lua_State* luaVM)
{
CScriptArgReader argStream(luaVM);
Expand Down
4 changes: 4 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,8 @@ class CLuaWorldDefs : public CLuaDefs
LUA_DECLARE(resetMoonSize);

static void ResetWorldProperties(std::optional<bool> resetSpecialWorldProperties, std::optional<bool> resetWorldProperties, std::optional<bool> resetWeatherProperties, std::optional<bool> resetLODs, std::optional<bool> resetSounds, std::optional<bool> resetGlitches, std::optional<bool> resetJetpackWeapons) noexcept;

static bool SetGrassDrawDistance(float closeDistance, float farDistance);
static std::variant<CLuaMultiReturn<float, float>, bool> GetGrassDrawDistance();
static bool ResetGrassDrawDistance();
};
Loading