Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
FileEX committed Sep 9, 2024
1 parent 8b5af35 commit 4608737
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 23 deletions.
20 changes: 13 additions & 7 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5429,7 +5429,13 @@ void CClientGame::ResetMapInfo()
m_bHudAreaNameDisabled = false;

// Reset world special properties, world properties, weather properties etc
ResetWorldProperties(true, true, true, true, true);
ResetWorldPropsInfo desc;
desc.resetSpecialProperties = true;
desc.resetWorldProperties = true;
desc.resetWeatherProperties = true;
desc.resetLODs = true;
desc.resetSounds = true;
ResetWorldProperties(desc);

// Wanted-level
SetWanted(0);
Expand Down Expand Up @@ -6744,10 +6750,10 @@ void CClientGame::ReinitMarkers()
g_pGame->Get3DMarkers()->ReinitMarkers();
}

void CClientGame::ResetWorldProperties(bool resetSpecialProperties, bool resetWorldProperties, bool resetWeatherProperties, bool resetLODs, bool resetSounds)
void CClientGame::ResetWorldProperties(const ResetWorldPropsInfo& resetPropsInfo)
{
// Reset all setWorldSpecialPropertyEnabled to default
if (resetSpecialProperties)
if (resetPropsInfo.resetSpecialProperties)
{
g_pGame->SetCheatEnabled("hovercars", false);
g_pGame->SetCheatEnabled("aircars", false);
Expand All @@ -6769,7 +6775,7 @@ void CClientGame::ResetWorldProperties(bool resetSpecialProperties, bool resetWo
}

// Reset all setWorldProperty to default
if (resetWorldProperties)
if (resetPropsInfo.resetWorldProperties)
{
g_pMultiplayer->ResetAmbientColor();
g_pMultiplayer->ResetAmbientObjectColor();
Expand All @@ -6796,7 +6802,7 @@ void CClientGame::ResetWorldProperties(bool resetSpecialProperties, bool resetWo
}

// Reset all weather stuff like heat haze, wind velocity etc
if (resetWeatherProperties)
if (resetPropsInfo.resetWeatherProperties)
{
g_pMultiplayer->ResetHeatHaze();
g_pMultiplayer->RestoreFogDistance();
Expand All @@ -6811,14 +6817,14 @@ void CClientGame::ResetWorldProperties(bool resetSpecialProperties, bool resetWo
}

// Reset LODs
if (resetLODs)
if (resetPropsInfo.resetLODs)
{
g_pGame->GetSettings()->ResetVehiclesLODDistance(true);
g_pGame->GetSettings()->ResetPedsLODDistance(true);
}

// Reset & restore sounds
if (resetSounds)
if (resetPropsInfo.resetSounds)
{
g_pMultiplayer->SetInteriorSoundsEnabled(true);
g_pGame->GetAudioEngine()->ResetAmbientSounds();
Expand Down
11 changes: 10 additions & 1 deletion Client/mods/deathmatch/logic/CClientGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ struct SMiscGameSettings
bool bAllowShotgunDamageFix;
};

struct ResetWorldPropsInfo
{
bool resetSpecialProperties{};
bool resetWorldProperties{};
bool resetWeatherProperties{};
bool resetLODs{};
bool resetSounds{};
};

class CClientGame
{
friend class CPacketHandler;
Expand Down Expand Up @@ -410,7 +419,7 @@ class CClientGame
bool SetBirdsEnabled(bool bEnabled);
bool GetBirdsEnabled();

void ResetWorldProperties(bool resetSpecialWorldProperties, bool resetWorldProperties, bool resetWeatherProperties, bool resetLODs, bool resetSounds);
void ResetWorldProperties(const ResetWorldPropsInfo& resetPropsInfo);

CTransferBox* GetTransferBox() { return m_pTransferBox; };

Expand Down
2 changes: 1 addition & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2276,5 +2276,5 @@ bool CLuaWorldDefs::ResetVolumetricShadows() noexcept

void CLuaWorldDefs::ResetWorldProperties(std::optional<bool> resetSpecialWorldProperties, std::optional<bool> resetWorldProperties, std::optional<bool> resetWeatherProperties, std::optional<bool> resetLODs, std::optional<bool> resetSounds) noexcept
{
g_pClientGame->ResetWorldProperties(resetSpecialWorldProperties.value_or(true), resetWorldProperties.value_or(true), resetWeatherProperties.value_or(true), resetLODs.value_or(true), resetSounds.value_or(true));
g_pClientGame->ResetWorldProperties(ResetWorldPropsInfo{resetSpecialWorldProperties.value_or(true), resetWorldProperties.value_or(true), resetWeatherProperties.value_or(true), resetLODs.value_or(true), resetSounds.value_or(true)});
}
2 changes: 1 addition & 1 deletion Client/mods/deathmatch/logic/rpc/CWorldRPCs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,5 +654,5 @@ void CWorldRPCs::ResetWorldProperties(NetBitStreamInterface& bitStream)
bool resetLODs = bitStream.ReadBit();
bool resetSounds = bitStream.ReadBit();

g_pClientGame->ResetWorldProperties(resetSpecialProperties, resetWorldProperties, resetWeatherProperties, resetLODs, resetSounds);
g_pClientGame->ResetWorldProperties(ResetWorldPropsInfo{resetSpecialProperties, resetWorldProperties, resetWeatherProperties, resetLODs, resetSounds});
}
22 changes: 11 additions & 11 deletions Server/mods/deathmatch/logic/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4396,10 +4396,10 @@ void CGame::SetJetpackWeaponEnabled(eWeaponType weaponType, bool bEnabled)
}
}

void CGame::ResetWorldProperties(bool resetSpecialProperties, bool resetWorldProperties, bool resetWeatherProperties, bool resetLODs, bool resetSounds, bool resetGlitches, bool resetJetpackWeapons)
void CGame::ResetWorldProperties(const ResetWorldPropsInfo& resetPropsInfo)
{
// Reset all setWorldSpecialPropertyEnabled to default
if (resetSpecialProperties)
if (resetPropsInfo.resetSpecialProperties)
{
g_pGame->SetWorldSpecialPropertyEnabled(WorldSpecialProperty::HOVERCARS, false);
g_pGame->SetWorldSpecialPropertyEnabled(WorldSpecialProperty::AIRCARS, false);
Expand All @@ -4420,7 +4420,7 @@ void CGame::ResetWorldProperties(bool resetSpecialProperties, bool resetWorldPro
}

// Reset all weather stuff like heat haze, wind velocity etc
if (resetWeatherProperties)
if (resetPropsInfo.resetWeatherProperties)
{
g_pGame->SetHasHeatHaze(false);
g_pGame->SetHasFogDistance(false);
Expand All @@ -4436,18 +4436,18 @@ void CGame::ResetWorldProperties(bool resetSpecialProperties, bool resetWorldPro
}

// Restore interiors sounds
if (resetSounds)
if (resetPropsInfo.resetSounds)
g_pGame->SetInteriorSoundsEnabled(true);

// Disable all glitches
if (resetGlitches)
if (resetPropsInfo.resetGlitches)
{
for (const auto& iter : m_GlitchNames)
CStaticFunctionDefinitions::SetGlitchEnabled(iter.first, false);
}

// Reset jetpack weapons
if (resetJetpackWeapons)
if (resetPropsInfo.resetJetpackWeapons)
{
for (std::uint8_t i = 0; i < WEAPONTYPE_LAST_WEAPONTYPE; i++)
CStaticFunctionDefinitions::SetJetpackWeaponEnabled(static_cast<eWeaponType>(i), false);
Expand Down Expand Up @@ -4493,11 +4493,11 @@ void CGame::ResetWorldProperties(bool resetSpecialProperties, bool resetWorldPro

// Send it to everyone
CBitStream bitStream;
bitStream->WriteBit(resetSpecialProperties);
bitStream->WriteBit(resetWorldProperties);
bitStream->WriteBit(resetWeatherProperties);
bitStream->WriteBit(resetLODs);
bitStream->WriteBit(resetSounds);
bitStream->WriteBit(resetPropsInfo.resetSpecialProperties);
bitStream->WriteBit(resetPropsInfo.resetWorldProperties);
bitStream->WriteBit(resetPropsInfo.resetWeatherProperties);
bitStream->WriteBit(resetPropsInfo.resetLODs);
bitStream->WriteBit(resetPropsInfo.resetSounds);
m_pPlayerManager->BroadcastOnlyJoined(CLuaPacket(RESET_WORLD_PROPERTIES, *bitStream.pBitStream));
}

Expand Down
13 changes: 12 additions & 1 deletion Server/mods/deathmatch/logic/CGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ class CWeaponDamageCheckPacket;

typedef SFixedArray<bool, MAX_GARAGES> SGarageStates;

struct ResetWorldPropsInfo
{
bool resetSpecialProperties{};
bool resetWorldProperties{};
bool resetWeatherProperties{};
bool resetLODs{};
bool resetSounds{};
bool resetGlitches{};
bool resetJetpackWeapons{};
};

// CSendList - Can be used like a std::list of players for sending packets.
// Used to construct an optimized list of players for CGame::Broadcast
class CSendList : public std::multimap<ushort, CPlayer*>
Expand Down Expand Up @@ -432,7 +443,7 @@ class CGame
int GetMoonSize() { return m_iMoonSize; }
void SetMoonSize(int iMoonSize) { m_iMoonSize = iMoonSize; }

void ResetWorldProperties(bool resetSpecialWorldProperties, bool resetWorldProperties, bool resetWeatherProperties, bool resetLODs, bool resetSounds, bool resetGlitches, bool resetJetpackWeapons);
void ResetWorldProperties(const ResetWorldPropsInfo& resetPropsInfo);

void PrintLogOutputFromNetModule();
void StartOpenPortsTest();
Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1452,5 +1452,5 @@ int CLuaWorldDefs::getOcclusionsEnabled(lua_State* luaVM)

void CLuaWorldDefs::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
{
g_pGame->ResetWorldProperties(resetSpecialWorldProperties.value_or(true), resetWorldProperties.value_or(true), resetWeatherProperties.value_or(true), resetLODs.value_or(true), resetSounds.value_or(true), resetGlitches.value_or(true), resetJetpackWeapons.value_or(true));
g_pGame->ResetWorldProperties(ResetWorldPropsInfo{resetSpecialWorldProperties.value_or(true), resetWorldProperties.value_or(true), resetWeatherProperties.value_or(true), resetLODs.value_or(true), resetSounds.value_or(true), resetGlitches.value_or(true), resetJetpackWeapons.value_or(true)});
}

0 comments on commit 4608737

Please sign in to comment.