From 45529f04c0bbec418bf67de1985c3465a87f0185 Mon Sep 17 00:00:00 2001 From: lopezloo Date: Tue, 7 Sep 2021 05:27:07 +0200 Subject: [PATCH 01/13] Fix corona rain reflections aren't rendering (#2345) --- Client/multiplayer_sa/CMultiplayerSA.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Client/multiplayer_sa/CMultiplayerSA.cpp b/Client/multiplayer_sa/CMultiplayerSA.cpp index 61764d2b838..3a192bcaabd 100644 --- a/Client/multiplayer_sa/CMultiplayerSA.cpp +++ b/Client/multiplayer_sa/CMultiplayerSA.cpp @@ -1521,6 +1521,10 @@ void CMultiplayerSA::InitHooks() for (auto uiAddr : shadowAddr) MemPut(uiAddr, &m_fShadowsOffset); + // Fix corona rain reflections aren't rendering (#2345) + // By using zBufferFar instead of zBufferNear for corona position + MemSet((void*)0x6FB9A0, 0x1C, 1); + InitHooks_CrashFixHacks(); // Init our 1.3 hooks. From 3cc3fd326cab7c3c64919033f5091f36ace1b15a Mon Sep 17 00:00:00 2001 From: lopezloo Date: Tue, 7 Sep 2021 19:48:07 +0200 Subject: [PATCH 02/13] Disable rain reflections for custom created coronas --- Client/game_sa/CRegisteredCoronaSA.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Client/game_sa/CRegisteredCoronaSA.cpp b/Client/game_sa/CRegisteredCoronaSA.cpp index 277da2eb0a7..8ba70fd03fa 100644 --- a/Client/game_sa/CRegisteredCoronaSA.cpp +++ b/Client/game_sa/CRegisteredCoronaSA.cpp @@ -128,7 +128,10 @@ VOID CRegisteredCoronaSA::Init(DWORD Identifier) internalInterface->Intensity = 255; internalInterface->FadedIntensity = 255; internalInterface->FlareType = 0; - internalInterface->ReflectionType = 1; + + // Disable corona rain reflection + internalInterface->ReflectionType = 0; + internalInterface->JustCreated = 1; internalInterface->RegisteredThisFrame = 1; // won't appear in-game without this } From 817e0bc23f2a88c990239bd2e35d00edde9450bb Mon Sep 17 00:00:00 2001 From: lopezloo Date: Sat, 11 Sep 2021 15:40:28 +0200 Subject: [PATCH 03/13] Add "coronareflections" property to setWorldSpecialPropertyEnabled (true by default) --- Client/game_sa/CGameSA.cpp | 29 ++++++++++++++++++++++++ Client/game_sa/CGameSA.h | 5 ++++ Client/multiplayer_sa/CMultiplayerSA.cpp | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Client/game_sa/CGameSA.cpp b/Client/game_sa/CGameSA.cpp index 631b7b329f1..bf5e8a4f16b 100644 --- a/Client/game_sa/CGameSA.cpp +++ b/Client/game_sa/CGameSA.cpp @@ -603,6 +603,9 @@ bool CGameSA::IsCheatEnabled(const char* szCheatName) if (!strcmp(szCheatName, PROP_UNDERWORLD_WARP)) return IsUnderWorldWarpEnabled(); + if (!strcmp(szCheatName, PROP_CORONA_REFLECTIONS)) + return IsCoronaReflectionsEnabled(); + std::map::iterator it = m_Cheats.find(szCheatName); if (it == m_Cheats.end()) return false; @@ -635,6 +638,12 @@ bool CGameSA::SetCheatEnabled(const char* szCheatName, bool bEnable) return true; } + if (!strcmp(szCheatName, PROP_CORONA_REFLECTIONS)) + { + SetCoronaReflectionsEnabled(bEnable); + return true; + } + std::map::iterator it = m_Cheats.find(szCheatName); if (it == m_Cheats.end()) return false; @@ -651,6 +660,7 @@ void CGameSA::ResetCheats() SetMoonEasterEggEnabled(false); SetExtraAirResistanceEnabled(true); SetUnderWorldWarpEnabled(true); + SetCoronaReflectionsEnabled(true); std::map::iterator it; for (it = m_Cheats.begin(); it != m_Cheats.end(); it++) @@ -707,6 +717,25 @@ bool CGameSA::IsUnderWorldWarpEnabled() return !m_bUnderworldWarp; } +void CGameSA::SetCoronaReflectionsEnabled(bool bEnabled) +{ + // Restore or disable calls to CCoronas::RenderReflections + if(bEnabled) { + MemCpy((void*)0x53DFD8, "\xE8\x53\xD6\x1B\x00", 5); + MemCpy((void*)0x53DCAC, "\xE8\x7F\xD9\x1B\x00", 5); + } + else { + MemSet((void*)0x53DFD8, 0x90, 5); + MemSet((void*)0x53DCAC, 0x90, 5); + } + m_bCoronaReflections = bEnabled; +} + +bool CGameSA::IsCoronaReflectionsEnabled() +{ + return m_bCoronaReflections; +} + bool CGameSA::GetJetpackWeaponEnabled(eWeaponType weaponType) { if (weaponType >= WEAPONTYPE_BRASSKNUCKLE && weaponType < WEAPONTYPE_LAST_WEAPONTYPE) diff --git a/Client/game_sa/CGameSA.h b/Client/game_sa/CGameSA.h index 6a2c04d49be..189fdd4e25b 100644 --- a/Client/game_sa/CGameSA.h +++ b/Client/game_sa/CGameSA.h @@ -85,6 +85,7 @@ extern unsigned int OBJECTDYNAMICINFO_MAX; // default: 160 #define PROP_SNIPER_MOON "snipermoon" #define PROP_EXTRA_AIR_RESISTANCE "extraairresistance" #define PROP_UNDERWORLD_WARP "underworldwarp" +#define PROP_CORONA_REFLECTIONS "coronareflections" struct SCheatSA { @@ -409,6 +410,9 @@ class CGameSA : public CGame bool IsUnderWorldWarpEnabled(); void SetUnderWorldWarpEnabled(bool bEnable); + bool IsCoronaReflectionsEnabled(); + void SetCoronaReflectionsEnabled(bool bEnabled); + bool VerifySADataFileNames(); bool PerformChecks(); int& GetCheckStatus() { return m_iCheckStatus; } @@ -505,6 +509,7 @@ class CGameSA : public CGame bool m_bASyncLoadingSuspended; int m_iCheckStatus; bool m_bUnderworldWarp; + bool m_bCoronaReflections; static unsigned int& ClumpOffset; static unsigned long* VAR_SystemTime; diff --git a/Client/multiplayer_sa/CMultiplayerSA.cpp b/Client/multiplayer_sa/CMultiplayerSA.cpp index 3a192bcaabd..47572f7c316 100644 --- a/Client/multiplayer_sa/CMultiplayerSA.cpp +++ b/Client/multiplayer_sa/CMultiplayerSA.cpp @@ -1523,7 +1523,7 @@ void CMultiplayerSA::InitHooks() // Fix corona rain reflections aren't rendering (#2345) // By using zBufferFar instead of zBufferNear for corona position - MemSet((void*)0x6FB9A0, 0x1C, 1); + MemPut(0x6FB9A0, 0x1C); InitHooks_CrashFixHacks(); From be59195116288e524b548d78e9065867cd6e86b2 Mon Sep 17 00:00:00 2001 From: lopezloo Date: Wed, 15 Sep 2021 22:24:44 +0200 Subject: [PATCH 04/13] Revert "Add "coronareflections" property to setWorldSpecialPropertyEnabled" This reverts commit 817e0bc23f2a88c990239bd2e35d00edde9450bb. --- Client/game_sa/CGameSA.cpp | 29 ------------------------ Client/game_sa/CGameSA.h | 5 ---- Client/multiplayer_sa/CMultiplayerSA.cpp | 2 +- 3 files changed, 1 insertion(+), 35 deletions(-) diff --git a/Client/game_sa/CGameSA.cpp b/Client/game_sa/CGameSA.cpp index bf5e8a4f16b..631b7b329f1 100644 --- a/Client/game_sa/CGameSA.cpp +++ b/Client/game_sa/CGameSA.cpp @@ -603,9 +603,6 @@ bool CGameSA::IsCheatEnabled(const char* szCheatName) if (!strcmp(szCheatName, PROP_UNDERWORLD_WARP)) return IsUnderWorldWarpEnabled(); - if (!strcmp(szCheatName, PROP_CORONA_REFLECTIONS)) - return IsCoronaReflectionsEnabled(); - std::map::iterator it = m_Cheats.find(szCheatName); if (it == m_Cheats.end()) return false; @@ -638,12 +635,6 @@ bool CGameSA::SetCheatEnabled(const char* szCheatName, bool bEnable) return true; } - if (!strcmp(szCheatName, PROP_CORONA_REFLECTIONS)) - { - SetCoronaReflectionsEnabled(bEnable); - return true; - } - std::map::iterator it = m_Cheats.find(szCheatName); if (it == m_Cheats.end()) return false; @@ -660,7 +651,6 @@ void CGameSA::ResetCheats() SetMoonEasterEggEnabled(false); SetExtraAirResistanceEnabled(true); SetUnderWorldWarpEnabled(true); - SetCoronaReflectionsEnabled(true); std::map::iterator it; for (it = m_Cheats.begin(); it != m_Cheats.end(); it++) @@ -717,25 +707,6 @@ bool CGameSA::IsUnderWorldWarpEnabled() return !m_bUnderworldWarp; } -void CGameSA::SetCoronaReflectionsEnabled(bool bEnabled) -{ - // Restore or disable calls to CCoronas::RenderReflections - if(bEnabled) { - MemCpy((void*)0x53DFD8, "\xE8\x53\xD6\x1B\x00", 5); - MemCpy((void*)0x53DCAC, "\xE8\x7F\xD9\x1B\x00", 5); - } - else { - MemSet((void*)0x53DFD8, 0x90, 5); - MemSet((void*)0x53DCAC, 0x90, 5); - } - m_bCoronaReflections = bEnabled; -} - -bool CGameSA::IsCoronaReflectionsEnabled() -{ - return m_bCoronaReflections; -} - bool CGameSA::GetJetpackWeaponEnabled(eWeaponType weaponType) { if (weaponType >= WEAPONTYPE_BRASSKNUCKLE && weaponType < WEAPONTYPE_LAST_WEAPONTYPE) diff --git a/Client/game_sa/CGameSA.h b/Client/game_sa/CGameSA.h index 189fdd4e25b..6a2c04d49be 100644 --- a/Client/game_sa/CGameSA.h +++ b/Client/game_sa/CGameSA.h @@ -85,7 +85,6 @@ extern unsigned int OBJECTDYNAMICINFO_MAX; // default: 160 #define PROP_SNIPER_MOON "snipermoon" #define PROP_EXTRA_AIR_RESISTANCE "extraairresistance" #define PROP_UNDERWORLD_WARP "underworldwarp" -#define PROP_CORONA_REFLECTIONS "coronareflections" struct SCheatSA { @@ -410,9 +409,6 @@ class CGameSA : public CGame bool IsUnderWorldWarpEnabled(); void SetUnderWorldWarpEnabled(bool bEnable); - bool IsCoronaReflectionsEnabled(); - void SetCoronaReflectionsEnabled(bool bEnabled); - bool VerifySADataFileNames(); bool PerformChecks(); int& GetCheckStatus() { return m_iCheckStatus; } @@ -509,7 +505,6 @@ class CGameSA : public CGame bool m_bASyncLoadingSuspended; int m_iCheckStatus; bool m_bUnderworldWarp; - bool m_bCoronaReflections; static unsigned int& ClumpOffset; static unsigned long* VAR_SystemTime; diff --git a/Client/multiplayer_sa/CMultiplayerSA.cpp b/Client/multiplayer_sa/CMultiplayerSA.cpp index 47572f7c316..3a192bcaabd 100644 --- a/Client/multiplayer_sa/CMultiplayerSA.cpp +++ b/Client/multiplayer_sa/CMultiplayerSA.cpp @@ -1523,7 +1523,7 @@ void CMultiplayerSA::InitHooks() // Fix corona rain reflections aren't rendering (#2345) // By using zBufferFar instead of zBufferNear for corona position - MemPut(0x6FB9A0, 0x1C); + MemSet((void*)0x6FB9A0, 0x1C, 1); InitHooks_CrashFixHacks(); From 4dac2a11be6a1eff0ab3ec63e13b3f08109b8c52 Mon Sep 17 00:00:00 2001 From: lopezloo Date: Thu, 16 Sep 2021 00:31:45 +0200 Subject: [PATCH 05/13] Add get/setCoronaReflectionsEnabled --- Client/mods/deathmatch/logic/CClientGame.cpp | 17 ++++++++ Client/mods/deathmatch/logic/CClientGame.h | 13 +++++++ .../logic/luadefs/CLuaWorldDefs.cpp | 12 ++++++ .../deathmatch/logic/luadefs/CLuaWorldDefs.h | 3 ++ Client/multiplayer_sa/CMultiplayerSA.cpp | 39 ++++++++++++++++++- Client/multiplayer_sa/CMultiplayerSA.h | 1 + Client/sdk/multiplayer/CMultiplayer.h | 1 + 7 files changed, 85 insertions(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index 8871c130c7b..b976463d5f2 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -5358,6 +5358,8 @@ void CClientGame::ResetMapInfo() g_pGame->SetBlurLevel(DEFAULT_BLUR_LEVEL); #endif + g_pClientGame->SetCoronaReflectionsEnabled(CORONA_REFLECTIONS_ON); + // Close all garages CGarage* pGarage = NULL; CGarages* pGarages = g_pCore->GetGame()->GetGarages(); @@ -5878,6 +5880,21 @@ bool CClientGame::GetBirdsEnabled() return m_bBirdsEnabled; } +bool CClientGame::SetCoronaReflectionsEnabled(uchar ucEnabled) +{ + if(ucEnabled > 2) { + return false; + } + m_ucCoronaReflectionsEnabled = ucEnabled; + g_pMultiplayer->SetCoronaReflectionsEnabled(ucEnabled); + return true; +} + +uchar CClientGame::GetCoronaReflectionsEnabled() +{ + return m_ucCoronaReflectionsEnabled; +} + #pragma code_seg(".text") bool CClientGame::VerifySADataFiles(int iEnableClientChecks) { diff --git a/Client/mods/deathmatch/logic/CClientGame.h b/Client/mods/deathmatch/logic/CClientGame.h index 7633479508e..620243ea596 100644 --- a/Client/mods/deathmatch/logic/CClientGame.h +++ b/Client/mods/deathmatch/logic/CClientGame.h @@ -193,6 +193,14 @@ class CClientGame GLITCH_KICKOUTOFVEHICLE_ONMODELREPLACE, NUM_GLITCHES }; + + enum eCoronaReflectionsEnabled : uchar + { + CORONA_REFLECTIONS_OFF, + CORONA_REFLECTIONS_ON, + CORONA_REFLECTIONS_FORCED + }; + class CStoredWeaponSlot { public: @@ -403,6 +411,9 @@ class CClientGame bool SetBirdsEnabled(bool bEnabled); bool GetBirdsEnabled(); + bool SetCoronaReflectionsEnabled(uchar ucEnabled); + uchar GetCoronaReflectionsEnabled(); + CTransferBox* GetTransferBox() { return m_pTransferBox; }; void ChangeVehicleWeapon(bool bNext); @@ -752,6 +763,8 @@ class CClientGame // Birds Enabled bool m_bBirdsEnabled; + uchar m_ucCoronaReflectionsEnabled; + unsigned long m_ulMinuteDuration; CClientGUIElement* m_pClickedGUIElement; diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp index 65553eec9b2..1475ba046ba 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp @@ -52,6 +52,7 @@ void CLuaWorldDefs::LoadFunctions() {"getMoonSize", GetMoonSize}, {"getFPSLimit", GetFPSLimit}, {"getBirdsEnabled", GetBirdsEnabled}, + {"getCoronaReflectionsEnabled", ArgumentParser}, // World set funcs {"setTime", SetTime}, @@ -89,6 +90,7 @@ void CLuaWorldDefs::LoadFunctions() {"setPedTargetingMarkerEnabled", SetPedTargetingMarkerEnabled}, {"setMoonSize", SetMoonSize}, {"setFPSLimit", SetFPSLimit}, + {"setCoronaReflectionsEnabled", ArgumentParser}, {"removeWorldModel", RemoveWorldBuilding}, {"restoreAllWorldModels", RestoreWorldBuildings}, {"restoreWorldModel", RestoreWorldBuilding}, @@ -1992,3 +1994,13 @@ bool CLuaWorldDefs::SetColorFilter(uchar ucPass0Red, uchar ucPass0Green, uchar u g_pMultiplayer->SetColorFilter(ulColor0, ulColor1); return true; } + +bool CLuaWorldDefs::SetCoronaReflectionsEnabled(uchar ucEnabled) +{ + return g_pClientGame->SetCoronaReflectionsEnabled(ucEnabled); +} + +uchar CLuaWorldDefs::GetCoronaReflectionsEnabled() +{ + return g_pClientGame->GetCoronaReflectionsEnabled(); +} diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h index 91881b7b05a..db9fcc98e7e 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h @@ -116,4 +116,7 @@ class CLuaWorldDefs : public CLuaDefs static bool ResetColorFilter(); static bool SetColorFilter(uchar ucPass0Red, uchar ucPass0Green, uchar ucPass0Blue, uchar ucPass0Alpha, uchar ucPass1Red, uchar ucPass1Green, uchar ucPass1Blue, uchar ucPass1Alpha); + + static bool SetCoronaReflectionsEnabled(uchar ucEnabled); + static uchar GetCoronaReflectionsEnabled(); }; diff --git a/Client/multiplayer_sa/CMultiplayerSA.cpp b/Client/multiplayer_sa/CMultiplayerSA.cpp index 3a192bcaabd..f0ee8cb39ff 100644 --- a/Client/multiplayer_sa/CMultiplayerSA.cpp +++ b/Client/multiplayer_sa/CMultiplayerSA.cpp @@ -1523,7 +1523,7 @@ void CMultiplayerSA::InitHooks() // Fix corona rain reflections aren't rendering (#2345) // By using zBufferFar instead of zBufferNear for corona position - MemSet((void*)0x6FB9A0, 0x1C, 1); + MemPut(0x6FB9A0, 0x1C); InitHooks_CrashFixHacks(); @@ -2204,6 +2204,43 @@ void CMultiplayerSA::ResetWater() MemPut(0x7051D7, 184); } +void CMultiplayerSA::SetCoronaReflectionsEnabled(unsigned char ucEnabled) +{ + /* + ucEnabled: + 0 - corona rain reflections disabled + 1 - enabled + 2 - force enabled (render even if there is no rain) + */ + + if(ucEnabled == 0) { + // Disable corona rain reflections + // Disable calls to CCoronas::RenderReflections + MemSet((void*)0x53DFD8, 0x90, 5); + MemSet((void*)0x53DCAC, 0x90, 5); + } + else { + // Enable corona rain reflections + // Restore calls to CCoronas::RenderReflections + MemCpy((void*)0x53DFD8, "\xE8\x53\xD6\x1B\x00", 5); + MemCpy((void*)0x53DCAC, "\xE8\x7F\xD9\x1B\x00", 5); + } + + if(ucEnabled == 2) { + // Force enable corona reflections (render even if there is no rain) + // Disable fWetGripScale check + MemPut(0x6FB645, 0xEB); + + // Patch "fld fWetGripScale" to "fld fOne" + MemCpy((void*)0x6FB906, "\x24\x86\x85\x00", 4); + } + else { + // Restore patched stuff + MemPut(0x6FB645, 0x7A); + MemCpy((void*)0x6FB906, "\x08\x13\xC8\x00", 4); + } +} + bool CMultiplayerSA::GetExplosionsDisabled() { return m_bExplosionsDisabled; diff --git a/Client/multiplayer_sa/CMultiplayerSA.h b/Client/multiplayer_sa/CMultiplayerSA.h index 8458a398fe7..ff1cfde559d 100644 --- a/Client/multiplayer_sa/CMultiplayerSA.h +++ b/Client/multiplayer_sa/CMultiplayerSA.h @@ -161,6 +161,7 @@ class CMultiplayerSA : public CMultiplayer void GetWaterColor(float& fWaterRed, float& fWaterGreen, float& fWaterBlue, float& fWaterAlpha); void SetWaterColor(float fWaterRed, float fWaterGreen, float fWaterBlue, float fWaterAlpha); void ResetWater(); + void SetCoronaReflectionsEnabled(unsigned char ucEnabled); void SetCloudsEnabled(bool bDisabled); void RebuildMultiplayerPlayer(CPed* player); bool GetInteriorSoundsEnabled(); diff --git a/Client/sdk/multiplayer/CMultiplayer.h b/Client/sdk/multiplayer/CMultiplayer.h index 964a5dfd56c..5218847f3a0 100644 --- a/Client/sdk/multiplayer/CMultiplayer.h +++ b/Client/sdk/multiplayer/CMultiplayer.h @@ -265,6 +265,7 @@ class CMultiplayer virtual void SetWaterColor(float fWaterRed, float fWaterGreen, float fWaterBlue, float fWaterAlpha) = 0; virtual void ResetWater() = 0; virtual void SetCloudsEnabled(bool bDisabled) = 0; + virtual void SetCoronaReflectionsEnabled(unsigned char ucEnabled) = 0; virtual bool GetInteriorSoundsEnabled() = 0; virtual void SetInteriorSoundsEnabled(bool bEnabled) = 0; virtual bool GetInteriorFurnitureEnabled(char cRoomId) = 0; From a5a63354c8fe0c22b8f3aba67e4f082bc27b1f31 Mon Sep 17 00:00:00 2001 From: lopezloo Date: Thu, 16 Sep 2021 01:14:00 +0200 Subject: [PATCH 06/13] Addendum to 4dac2a11b --- Client/mods/deathmatch/logic/CClientGame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index b976463d5f2..a1c78786203 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -5358,7 +5358,7 @@ void CClientGame::ResetMapInfo() g_pGame->SetBlurLevel(DEFAULT_BLUR_LEVEL); #endif - g_pClientGame->SetCoronaReflectionsEnabled(CORONA_REFLECTIONS_ON); + SetCoronaReflectionsEnabled(CORONA_REFLECTIONS_ON); // Close all garages CGarage* pGarage = NULL; From 1fc8b6b6d8eb594f125fe9fb906485f6c2afb6bb Mon Sep 17 00:00:00 2001 From: lopezloo Date: Mon, 8 Nov 2021 16:06:16 +0100 Subject: [PATCH 07/13] Add is/setCoronaReflectionEnabled --- Client/game_sa/CRegisteredCoronaSA.cpp | 8 ++++--- Client/game_sa/CRegisteredCoronaSA.h | 1 + .../mods/deathmatch/logic/CClientCorona.cpp | 4 +++- Client/mods/deathmatch/logic/CClientCorona.h | 4 ++++ .../logic/luadefs/CLuaMarkerDefs.cpp | 24 +++++++++++++++++++ .../deathmatch/logic/luadefs/CLuaMarkerDefs.h | 5 +++- Client/sdk/game/CRegisteredCorona.h | 1 + 7 files changed, 42 insertions(+), 5 deletions(-) diff --git a/Client/game_sa/CRegisteredCoronaSA.cpp b/Client/game_sa/CRegisteredCoronaSA.cpp index 8ba70fd03fa..6c28efa93b1 100644 --- a/Client/game_sa/CRegisteredCoronaSA.cpp +++ b/Client/game_sa/CRegisteredCoronaSA.cpp @@ -106,6 +106,11 @@ VOID CRegisteredCoronaSA::SetFlareType(BYTE fFlareType) internalInterface->FlareType = fFlareType; } +VOID CRegisteredCoronaSA::SetReflectionType(BYTE reflectionType) +{ + internalInterface->ReflectionType = reflectionType; +} + DWORD CRegisteredCoronaSA::GetID() { DEBUG_TRACE("DWORD CRegisteredCoronaSA::GetID()"); @@ -128,10 +133,7 @@ VOID CRegisteredCoronaSA::Init(DWORD Identifier) internalInterface->Intensity = 255; internalInterface->FadedIntensity = 255; internalInterface->FlareType = 0; - - // Disable corona rain reflection internalInterface->ReflectionType = 0; - internalInterface->JustCreated = 1; internalInterface->RegisteredThisFrame = 1; // won't appear in-game without this } diff --git a/Client/game_sa/CRegisteredCoronaSA.h b/Client/game_sa/CRegisteredCoronaSA.h index 9da812b9e05..32c58a11442 100644 --- a/Client/game_sa/CRegisteredCoronaSA.h +++ b/Client/game_sa/CRegisteredCoronaSA.h @@ -72,6 +72,7 @@ class CRegisteredCoronaSA : public CRegisteredCorona VOID SetTexture(eCoronaType texture); BYTE GetFlareType(); VOID SetFlareType(BYTE fFlareType); + VOID SetReflectionType(BYTE reflectionType); DWORD GetIdentifier() { return internalInterface->Identifier; } DWORD GetID(); VOID Init(DWORD Identifier); diff --git a/Client/mods/deathmatch/logic/CClientCorona.cpp b/Client/mods/deathmatch/logic/CClientCorona.cpp index 6597a888b2e..4632a644cd4 100644 --- a/Client/mods/deathmatch/logic/CClientCorona.cpp +++ b/Client/mods/deathmatch/logic/CClientCorona.cpp @@ -21,6 +21,7 @@ CClientCorona::CClientCorona(CClientMarker* pThis) m_Color = SColorRGBA(255, 0, 0, 255); m_fSize = 4.0f; m_pCoronas = g_pGame->GetCoronas(); + m_bReflectionEnabled = false; // Pick an unique identifier static unsigned long ulIdentifier = 0xFFFFFFFF; @@ -75,9 +76,10 @@ void CClientCorona::DoPulse() color.A = 0; pCorona->SetColor(color.R, color.G, color.B, color.A); pCorona->SetSize(m_fSize); + pCorona->SetReflectionType(m_bReflectionEnabled); } else { pCorona->Disable(); } -} \ No newline at end of file +} diff --git a/Client/mods/deathmatch/logic/CClientCorona.h b/Client/mods/deathmatch/logic/CClientCorona.h index 641cee4fd49..ed1977cadb9 100644 --- a/Client/mods/deathmatch/logic/CClientCorona.h +++ b/Client/mods/deathmatch/logic/CClientCorona.h @@ -38,6 +38,9 @@ class CClientCorona : public CClientMarkerCommon float GetSize() const { return m_fSize; }; void SetSize(float fSize) { m_fSize = fSize; }; + void SetReflectionEnabled(bool bEnabled) { m_bReflectionEnabled = bEnabled; }; + bool IsReflectionEnabled() const { return m_bReflectionEnabled; }; + protected: bool IsStreamedIn() { return m_bStreamedIn; }; void StreamIn(); @@ -53,5 +56,6 @@ class CClientCorona : public CClientMarkerCommon bool m_bVisible; float m_fSize; SColor m_Color; + bool m_bReflectionEnabled; CCoronas* m_pCoronas; }; diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.cpp index 9064fbe1520..e45be4fbb31 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.cpp @@ -10,6 +10,7 @@ *****************************************************************************/ #include "StdInc.h" +#include "lua/CLuaFunctionParser.h" void CLuaMarkerDefs::LoadFunctions() { @@ -21,6 +22,9 @@ void CLuaMarkerDefs::LoadFunctions() {"setMarkerType", SetMarkerType}, {"setMarkerSize", SetMarkerSize}, {"setMarkerColor", SetMarkerColor}, {"setMarkerTarget", SetMarkerTarget}, {"setMarkerIcon", SetMarkerIcon}, + + {"setCoronaReflectionEnabled", ArgumentParser}, + {"isCoronaReflectionEnabled", ArgumentParser}, }; // Add functions @@ -50,6 +54,7 @@ void CLuaMarkerDefs::AddClass(lua_State* luaVM) lua_classvariable(luaVM, "markerType", "setMarkerType", "getMarkerType"); lua_classvariable(luaVM, "icon", "setMarkerIcon", "getMarkerIcon"); lua_classvariable(luaVM, "size", "setMarkerSize", "getMarkerSize"); + lua_classvariable(luaVM, "reflectionEnabled", "setCoronaReflectionEnabled", "isCoronaReflectionEnabled"); lua_classvariable(luaVM, "target", SetMarkerTarget, OOP_GetMarkerTarget); @@ -385,3 +390,22 @@ int CLuaMarkerDefs::SetMarkerIcon(lua_State* luaVM) lua_pushboolean(luaVM, false); return 1; } + +bool CLuaMarkerDefs::SetCoronaReflectionEnabled(CClientMarker* pMarker, bool bEnabled) +{ + CClientCorona* pCorona = pMarker->GetCorona(); + if (!pCorona) + return false; + + pCorona->SetReflectionEnabled(bEnabled); + return true; +} + +bool CLuaMarkerDefs::IsCoronaReflectionEnabled(CClientMarker* pMarker) +{ + CClientCorona* pCorona = pMarker->GetCorona(); + if (!pCorona) + return false; + + return pCorona->IsReflectionEnabled(); +} diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.h index d470a47268c..6f0c1c0abbb 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.h @@ -32,4 +32,7 @@ class CLuaMarkerDefs : public CLuaDefs LUA_DECLARE(SetMarkerColor); LUA_DECLARE(SetMarkerTarget); LUA_DECLARE(SetMarkerIcon); -}; \ No newline at end of file + + static bool SetCoronaReflectionEnabled(CClientMarker* pMarker, bool bEnabled); + static bool IsCoronaReflectionEnabled(CClientMarker* pMarker); +}; diff --git a/Client/sdk/game/CRegisteredCorona.h b/Client/sdk/game/CRegisteredCorona.h index 07ce647ba58..23a7252d226 100644 --- a/Client/sdk/game/CRegisteredCorona.h +++ b/Client/sdk/game/CRegisteredCorona.h @@ -33,6 +33,7 @@ class CRegisteredCorona virtual VOID SetTexture(eCoronaType texture) = 0; virtual BYTE GetFlareType() = 0; virtual VOID SetFlareType(BYTE fFlareType) = 0; + virtual VOID SetReflectionType(BYTE reflectionType) = 0; virtual DWORD GetIdentifier() = 0; virtual DWORD GetID() = 0; virtual VOID Refresh() = 0; From 74d79ba2193519ff03f2d1fbe7da5d92499547fa Mon Sep 17 00:00:00 2001 From: lopezloo Date: Wed, 12 Jan 2022 18:20:29 +0100 Subject: [PATCH 08/13] Add corona reflections video option --- Client/core/CClientVariables.cpp | 1 + Client/core/CCore.cpp | 1 + Client/core/CSettings.cpp | 16 +++++++++++++ Client/core/CSettings.h | 1 + Client/core/Graphics/CRenderItemManager.cpp | 2 ++ Client/game_sa/CSettingsSA.cpp | 24 +++++++++++++++++++ Client/game_sa/CSettingsSA.h | 4 ++++ Client/mods/deathmatch/logic/CClientGame.cpp | 21 ++++------------ Client/mods/deathmatch/logic/CClientGame.h | 12 ---------- .../logic/luadefs/CLuaDrawingDefs.cpp | 4 ++++ .../logic/luadefs/CLuaWorldDefs.cpp | 17 +++++++++++-- .../deathmatch/logic/luadefs/CLuaWorldDefs.h | 1 + Client/multiplayer_sa/CMultiplayerSA.cpp | 6 +++++ Client/multiplayer_sa/CMultiplayerSA.h | 2 ++ Client/sdk/core/CRenderItemManagerInterface.h | 1 + Client/sdk/game/CSettings.h | 3 +++ Client/sdk/multiplayer/CMultiplayer.h | 1 + 17 files changed, 86 insertions(+), 31 deletions(-) diff --git a/Client/core/CClientVariables.cpp b/Client/core/CClientVariables.cpp index 2ebb5f7418e..9635d226632 100644 --- a/Client/core/CClientVariables.cpp +++ b/Client/core/CClientVariables.cpp @@ -329,6 +329,7 @@ void CClientVariables::LoadDefaults() DEFAULT("tyre_smoke_enabled", 1); // Enable tyre smoke DEFAULT("high_detail_vehicles", 0); // Disable rendering high detail vehicles all the time DEFAULT("high_detail_peds", 0); // Disable rendering high detail peds all the time + DEFAULT("corona_reflections", 1); // Enable corona rain reflections DEFAULT("fast_clothes_loading", 1); // 0-off 1-auto 2-on DEFAULT("allow_screen_upload", 1); // 0-off 1-on DEFAULT("allow_external_sounds", 1); // 0-off 1-on diff --git a/Client/core/CCore.cpp b/Client/core/CCore.cpp index d650e7bffd9..6c867ef358e 100644 --- a/Client/core/CCore.cpp +++ b/Client/core/CCore.cpp @@ -579,6 +579,7 @@ void CCore::ApplyGameSettings() pGameSettings->UpdateFieldOfViewFromSettings(); pGameSettings->ResetVehiclesLODDistance(false); pGameSettings->ResetPedsLODDistance(false); + pGameSettings->ResetCoronaReflectionsEnabled(); pController->SetVerticalAimSensitivityRawValue(CVARS_GET_VALUE("vertical_aim_sensitivity")); CVARS_GET("mastervolume", fVal); pGameSettings->SetRadioVolume(pGameSettings->GetRadioVolume() * fVal); diff --git a/Client/core/CSettings.cpp b/Client/core/CSettings.cpp index 0efff2cf593..cad8c9b1fe5 100644 --- a/Client/core/CSettings.cpp +++ b/Client/core/CSettings.cpp @@ -851,6 +851,11 @@ void CSettings::CreateGUI() fPosY -= 20.0f; } #endif + + m_pCheckBoxCoronaReflections = reinterpret_cast(pManager->CreateCheckBox(pTabVideo, _("Corona rain reflections"), true)); + m_pCheckBoxCoronaReflections->SetPosition(CVector2D(vecTemp.fX + 245.0f, fPosY + 90.0f)); + m_pCheckBoxCoronaReflections->AutoSize(NULL, 20.0f); + vecTemp.fY += 10; m_pTabs->GetSize(vecTemp); @@ -1539,6 +1544,11 @@ void CSettings::UpdateVideoTab() CVARS_GET("high_detail_peds", bHighDetailPeds); m_pCheckBoxHighDetailPeds->SetSelected(bHighDetailPeds); + // Corona rain reflections + bool bCoronaReflections; + CVARS_GET("corona_reflections", bCoronaReflections); + m_pCheckBoxCoronaReflections->SetSelected(bCoronaReflections); + PopulateResolutionComboBox(); // Fullscreen style @@ -1763,6 +1773,7 @@ bool CSettings::OnVideoDefaultClick(CGUIElement* pElement) CVARS_SET("tyre_smoke_enabled", true); CVARS_SET("high_detail_vehicles", false); CVARS_SET("high_detail_peds", false); + CVARS_SET("corona_reflections", true); gameSettings->UpdateFieldOfViewFromSettings(); gameSettings->SetDrawDistance(1.19625f); // All values taken from a default SA install, no gta_sa.set or coreconfig.xml modifications. gameSettings->SetBrightness(253); @@ -3389,6 +3400,11 @@ void CSettings::SaveData() CVARS_SET("high_detail_peds", bHighDetailPeds); gameSettings->ResetPedsLODDistance(false); + // Corona rain reflections + bool bCoronaReflections = m_pCheckBoxCoronaReflections->GetSelected(); + CVARS_SET("corona_reflections", bCoronaReflections); + gameSettings->ResetCoronaReflectionsEnabled(); + // Fast clothes loading if (CGUIListItem* pSelected = m_pFastClothesCombo->GetSelectedItem()) { diff --git a/Client/core/CSettings.h b/Client/core/CSettings.h index b57167eca18..5ce94b9fe2d 100644 --- a/Client/core/CSettings.h +++ b/Client/core/CSettings.h @@ -160,6 +160,7 @@ class CSettings CGUICheckBox* m_pCheckBoxTyreSmokeParticles; CGUICheckBox* m_pCheckBoxHighDetailVehicles; CGUICheckBox* m_pCheckBoxHighDetailPeds; + CGUICheckBox* m_pCheckBoxCoronaReflections; CGUILabel* m_pFieldOfViewLabel; CGUIScrollBar* m_pFieldOfView; CGUILabel* m_pFieldOfViewValueLabel; diff --git a/Client/core/Graphics/CRenderItemManager.cpp b/Client/core/Graphics/CRenderItemManager.cpp index 9e7b77e8734..ef4d380daf3 100644 --- a/Client/core/Graphics/CRenderItemManager.cpp +++ b/Client/core/Graphics/CRenderItemManager.cpp @@ -782,6 +782,7 @@ void CRenderItemManager::GetDxStatus(SDxStatus& outStatus) outStatus.settings.fFieldOfView = 70; outStatus.settings.bHighDetailVehicles = false; outStatus.settings.bHighDetailPeds = false; + outStatus.settings.bCoronaReflections = true; CVARS_GET("streaming_memory", outStatus.settings.iStreamingMemory); CVARS_GET("volumetric_shadows", outStatus.settings.bVolumetricShadows); @@ -793,6 +794,7 @@ void CRenderItemManager::GetDxStatus(SDxStatus& outStatus) CVARS_GET("fov", outStatus.settings.fFieldOfView); CVARS_GET("high_detail_vehicles", outStatus.settings.bHighDetailVehicles); CVARS_GET("high_detail_peds", outStatus.settings.bHighDetailPeds); + CVARS_GET("corona_reflections", outStatus.settings.bCoronaReflections); if (outStatus.settings.iFXQuality == 0) { diff --git a/Client/game_sa/CSettingsSA.cpp b/Client/game_sa/CSettingsSA.cpp index 6ad24ffe351..c543e329da0 100644 --- a/Client/game_sa/CSettingsSA.cpp +++ b/Client/game_sa/CSettingsSA.cpp @@ -43,6 +43,7 @@ CSettingsSA::CSettingsSA() m_pInterface->bFrameLimiter = false; m_bVolumetricShadowsEnabled = false; m_bVolumetricShadowsSuspended = false; + m_bCoronaReflectionsViaScript = false; SetAspectRatio(ASPECT_RATIO_4_3); HookInstall(HOOKPOS_GetFxQuality, (DWORD)HOOK_GetFxQuality, 5); HookInstall(HOOKPOS_StoreShadowForVehicle, (DWORD)HOOK_StoreShadowForVehicle, 9); @@ -698,6 +699,29 @@ float CSettingsSA::GetPedsLODDistance() return ms_fPedsLODDistance; } +//////////////////////////////////////////////// +// +// Corona rain reflections +// +// When corona reflections are controlled by script changing this option +// in settings doesn't produce any effect +// +//////////////////////////////////////////////// +void CSettingsSA::ResetCoronaReflectionsEnabled() +{ + if (m_bCoronaReflectionsViaScript) + return; + + bool bEnabled; + g_pCore->GetCVars()->Get("corona_reflections", bEnabled); + g_pCore->GetMultiplayer()->SetCoronaReflectionsEnabled(bEnabled ? 1 : 0); +} + +void CSettingsSA::SetCoronaReflectionsControlledByScript(bool bViaScript) +{ + m_bCoronaReflectionsViaScript = bViaScript; +} + //////////////////////////////////////////////// // // CSettingsSA::HasUnsafeResolutions diff --git a/Client/game_sa/CSettingsSA.h b/Client/game_sa/CSettingsSA.h index 4f75c95a258..8226a1321f7 100644 --- a/Client/game_sa/CSettingsSA.h +++ b/Client/game_sa/CSettingsSA.h @@ -89,6 +89,7 @@ class CSettingsSA : public CGameSettings eAspectRatio m_AspectRatio; int m_iDesktopWidth; int m_iDesktopHeight; + bool m_bCoronaReflectionsViaScript; public: CSettingsSA(); @@ -163,6 +164,9 @@ class CSettingsSA : public CGameSettings void ResetVehiclesLODDistanceFromScript(); void GetVehiclesLODDistance(float& fVehiclesLODDistance, float& fTrainsPlanesLODDistance); + void ResetCoronaReflectionsEnabled(); + void SetCoronaReflectionsControlledByScript(bool bViaScript); + void Save(); void SetPedsLODDistance(float fPedsLODDistance, bool bFromScript); diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index 13fbc597cdd..7f42b88bacd 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -5291,6 +5291,10 @@ void CClientGame::ResetMapInfo() // Peds LOD distance g_pGame->GetSettings()->ResetPedsLODDistanceFromScript(); + // Corona rain reflections + g_pGame->GetSettings()->SetCoronaReflectionsControlledByScript(false); + g_pGame->GetSettings()->ResetCoronaReflectionsEnabled(); + // Sun color g_pMultiplayer->ResetSunColor(); @@ -5357,8 +5361,6 @@ void CClientGame::ResetMapInfo() g_pGame->SetBlurLevel(DEFAULT_BLUR_LEVEL); #endif - SetCoronaReflectionsEnabled(CORONA_REFLECTIONS_ON); - // Close all garages CGarage* pGarage = NULL; CGarages* pGarages = g_pCore->GetGame()->GetGarages(); @@ -5879,21 +5881,6 @@ bool CClientGame::GetBirdsEnabled() return m_bBirdsEnabled; } -bool CClientGame::SetCoronaReflectionsEnabled(uchar ucEnabled) -{ - if(ucEnabled > 2) { - return false; - } - m_ucCoronaReflectionsEnabled = ucEnabled; - g_pMultiplayer->SetCoronaReflectionsEnabled(ucEnabled); - return true; -} - -uchar CClientGame::GetCoronaReflectionsEnabled() -{ - return m_ucCoronaReflectionsEnabled; -} - #pragma code_seg(".text") bool CClientGame::VerifySADataFiles(int iEnableClientChecks) { diff --git a/Client/mods/deathmatch/logic/CClientGame.h b/Client/mods/deathmatch/logic/CClientGame.h index c307f9b32cd..b9a36479af6 100644 --- a/Client/mods/deathmatch/logic/CClientGame.h +++ b/Client/mods/deathmatch/logic/CClientGame.h @@ -194,13 +194,6 @@ class CClientGame NUM_GLITCHES }; - enum eCoronaReflectionsEnabled : uchar - { - CORONA_REFLECTIONS_OFF, - CORONA_REFLECTIONS_ON, - CORONA_REFLECTIONS_FORCED - }; - class CStoredWeaponSlot { public: @@ -411,9 +404,6 @@ class CClientGame bool SetBirdsEnabled(bool bEnabled); bool GetBirdsEnabled(); - bool SetCoronaReflectionsEnabled(uchar ucEnabled); - uchar GetCoronaReflectionsEnabled(); - CTransferBox* GetTransferBox() { return m_pTransferBox; }; void ChangeVehicleWeapon(bool bNext); @@ -763,8 +753,6 @@ class CClientGame // Birds Enabled bool m_bBirdsEnabled; - uchar m_ucCoronaReflectionsEnabled; - unsigned long m_ulMinuteDuration; CClientGUIElement* m_pClickedGUIElement; diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaDrawingDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaDrawingDefs.cpp index efc4a429c97..dc0f422efeb 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaDrawingDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaDrawingDefs.cpp @@ -1712,6 +1712,10 @@ int CLuaDrawingDefs::DxGetStatus(lua_State* luaVM) lua_pushboolean(luaVM, dxStatus.settings.bHighDetailPeds); lua_settable(luaVM, -3); + lua_pushstring(luaVM, "SettingCoronaReflections"); + lua_pushboolean(luaVM, dxStatus.settings.bCoronaReflections); + lua_settable(luaVM, -3); + lua_pushstring(luaVM, "TotalPhysicalMemory"); lua_pushnumber(luaVM, static_cast(SharedUtil::GetWMITotalPhysicalMemory()) / 1024.0 / 1024.0); lua_settable(luaVM, -3); diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp index c95fec859fb..7d6799dd5ec 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp @@ -100,6 +100,7 @@ void CLuaWorldDefs::LoadFunctions() // World reset funcs {"resetColorFilter", ArgumentParser}, + {"resetCoronaReflectionsEnabled", ArgumentParser}, {"resetSkyGradient", ResetSkyGradient}, {"resetHeatHaze", ResetHeatHaze}, {"resetWindVelocity", ResetWindVelocity}, @@ -1995,10 +1996,22 @@ bool CLuaWorldDefs::SetColorFilter(uchar ucPass0Red, uchar ucPass0Green, uchar u bool CLuaWorldDefs::SetCoronaReflectionsEnabled(uchar ucEnabled) { - return g_pClientGame->SetCoronaReflectionsEnabled(ucEnabled); + if(ucEnabled > 2) + return false; + + g_pGame->GetSettings()->SetCoronaReflectionsControlledByScript(true); + g_pMultiplayer->SetCoronaReflectionsEnabled(ucEnabled); + return true; } uchar CLuaWorldDefs::GetCoronaReflectionsEnabled() { - return g_pClientGame->GetCoronaReflectionsEnabled(); + return g_pMultiplayer->GetCoronaReflectionsEnabled(); +} + +bool CLuaWorldDefs::ResetCoronaReflectionsEnabled() +{ + g_pGame->GetSettings()->SetCoronaReflectionsControlledByScript(false); + g_pGame->GetSettings()->ResetCoronaReflectionsEnabled(); + return true; } diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h index aeedc18b574..19fe94a3a32 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h @@ -119,4 +119,5 @@ class CLuaWorldDefs : public CLuaDefs static bool SetCoronaReflectionsEnabled(uchar ucEnabled); static uchar GetCoronaReflectionsEnabled(); + static bool ResetCoronaReflectionsEnabled(); }; diff --git a/Client/multiplayer_sa/CMultiplayerSA.cpp b/Client/multiplayer_sa/CMultiplayerSA.cpp index 1c02b0f41c9..08a33c2b756 100644 --- a/Client/multiplayer_sa/CMultiplayerSA.cpp +++ b/Client/multiplayer_sa/CMultiplayerSA.cpp @@ -2211,6 +2211,7 @@ void CMultiplayerSA::SetCoronaReflectionsEnabled(unsigned char ucEnabled) 1 - enabled 2 - force enabled (render even if there is no rain) */ + m_ucCoronaReflectionsEnabled = ucEnabled; if(ucEnabled == 0) { // Disable corona rain reflections @@ -2240,6 +2241,11 @@ void CMultiplayerSA::SetCoronaReflectionsEnabled(unsigned char ucEnabled) } } +unsigned char CMultiplayerSA::GetCoronaReflectionsEnabled() +{ + return m_ucCoronaReflectionsEnabled; +} + bool CMultiplayerSA::GetExplosionsDisabled() { return m_bExplosionsDisabled; diff --git a/Client/multiplayer_sa/CMultiplayerSA.h b/Client/multiplayer_sa/CMultiplayerSA.h index 46480d38922..1ad42dee008 100644 --- a/Client/multiplayer_sa/CMultiplayerSA.h +++ b/Client/multiplayer_sa/CMultiplayerSA.h @@ -162,6 +162,7 @@ class CMultiplayerSA : public CMultiplayer void SetWaterColor(float fWaterRed, float fWaterGreen, float fWaterBlue, float fWaterAlpha); void ResetWater(); void SetCoronaReflectionsEnabled(unsigned char ucEnabled); + unsigned char GetCoronaReflectionsEnabled(); void SetCloudsEnabled(bool bDisabled); void RebuildMultiplayerPlayer(CPed* player); bool GetInteriorSoundsEnabled(); @@ -319,6 +320,7 @@ class CMultiplayerSA : public CMultiplayer eAnimID m_dwLastStaticAnimID; DWORD m_dwLastAnimArrayAddress; float m_fShadowsOffset; + unsigned char m_ucCoronaReflectionsEnabled; /* VOID SetPlayerShotVectors(CPlayerPed* player, Vector3D * vecTarget, Vector3D * vecStart); VOID SetPlayerCameraVectors(CPlayerPed* player, Vector3D * vecSource, Vector3D * vecFront); diff --git a/Client/sdk/core/CRenderItemManagerInterface.h b/Client/sdk/core/CRenderItemManagerInterface.h index 59cc62ddb89..db59fc25456 100644 --- a/Client/sdk/core/CRenderItemManagerInterface.h +++ b/Client/sdk/core/CRenderItemManagerInterface.h @@ -128,6 +128,7 @@ struct SDxStatus float fFieldOfView; bool bHighDetailVehicles; bool bHighDetailPeds; + bool bCoronaReflections; } settings; }; diff --git a/Client/sdk/game/CSettings.h b/Client/sdk/game/CSettings.h index d51125ae6f0..acaa15d81dc 100644 --- a/Client/sdk/game/CSettings.h +++ b/Client/sdk/game/CSettings.h @@ -166,5 +166,8 @@ class CGameSettings virtual void ResetPedsLODDistanceFromScript() = 0; virtual float GetPedsLODDistance() = 0; + virtual void ResetCoronaReflectionsEnabled() = 0; + virtual void SetCoronaReflectionsControlledByScript(bool bViaScript) = 0; + virtual void Save() = 0; }; diff --git a/Client/sdk/multiplayer/CMultiplayer.h b/Client/sdk/multiplayer/CMultiplayer.h index 357bf8dac37..bc32c883b99 100644 --- a/Client/sdk/multiplayer/CMultiplayer.h +++ b/Client/sdk/multiplayer/CMultiplayer.h @@ -266,6 +266,7 @@ class CMultiplayer virtual void ResetWater() = 0; virtual void SetCloudsEnabled(bool bDisabled) = 0; virtual void SetCoronaReflectionsEnabled(unsigned char ucEnabled) = 0; + virtual unsigned char GetCoronaReflectionsEnabled() = 0; virtual bool GetInteriorSoundsEnabled() = 0; virtual void SetInteriorSoundsEnabled(bool bEnabled) = 0; virtual bool GetInteriorFurnitureEnabled(char cRoomId) = 0; From 49cc4b9d7d462979a37a6399a2e8d490b9f012a0 Mon Sep 17 00:00:00 2001 From: lopezloo Date: Wed, 12 Jan 2022 18:32:48 +0100 Subject: [PATCH 09/13] Rename Marker reflectionEnabled property to coronaReflectionEnabled --- Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.cpp index e45be4fbb31..862fc43b1b4 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.cpp @@ -54,7 +54,7 @@ void CLuaMarkerDefs::AddClass(lua_State* luaVM) lua_classvariable(luaVM, "markerType", "setMarkerType", "getMarkerType"); lua_classvariable(luaVM, "icon", "setMarkerIcon", "getMarkerIcon"); lua_classvariable(luaVM, "size", "setMarkerSize", "getMarkerSize"); - lua_classvariable(luaVM, "reflectionEnabled", "setCoronaReflectionEnabled", "isCoronaReflectionEnabled"); + lua_classvariable(luaVM, "coronaReflectionEnabled", "setCoronaReflectionEnabled", "isCoronaReflectionEnabled"); lua_classvariable(luaVM, "target", SetMarkerTarget, OOP_GetMarkerTarget); From 0a3f72011e833b3525310f66addf00f0c6b65132 Mon Sep 17 00:00:00 2001 From: lopezloo Date: Wed, 9 Feb 2022 20:43:28 +0100 Subject: [PATCH 10/13] Move some code to CCoronasSA.cpp --- Client/game_sa/CCoronasSA.cpp | 46 +++++++++++++++++++ Client/game_sa/CCoronasSA.h | 4 ++ Client/game_sa/CSettingsSA.cpp | 2 +- .../logic/luadefs/CLuaWorldDefs.cpp | 4 +- Client/multiplayer_sa/CMultiplayerSA.cpp | 43 ----------------- Client/sdk/game/CCoronas.h | 2 + Client/sdk/multiplayer/CMultiplayer.h | 2 - 7 files changed, 55 insertions(+), 48 deletions(-) diff --git a/Client/game_sa/CCoronasSA.cpp b/Client/game_sa/CCoronasSA.cpp index 1d19e761536..3d02f3e10e7 100644 --- a/Client/game_sa/CCoronasSA.cpp +++ b/Client/game_sa/CCoronasSA.cpp @@ -108,3 +108,49 @@ void CCoronasSA::DisableSunAndMoon(bool bDisabled) byteOriginal = 0; } } + +/* + Enable or disable corona rain reflections. + ucEnabled: + 0 - disabled + 1 - enabled + 2 - force enabled (render even if there is no rain) +*/ +void CCoronasSA::SetCoronaReflectionsEnabled(unsigned char ucEnabled) +{ + m_ucCoronaReflectionsEnabled = ucEnabled; + + if (ucEnabled == 0) + { + // Disable corona rain reflections + // Return out CCoronas::RenderReflections() + MemPut(0x6FB630, 0xC3); + } + else + { + // Enable corona rain reflections + // Re-enable CCoronas::RenderReflections() + MemPut(0x6FB630, 0xD9); + } + + if (ucEnabled == 2) + { + // Force enable corona reflections (render even if there is no rain) + // Disable fWetGripScale check + MemPut(0x6FB645, 0xEB); + + // Patch "fld fWetGripScale" to "fld fOne" + MemCpy((void*)0x6FB906, "\x24\x86\x85\x00", 4); + } + else + { + // Restore patched code + MemPut(0x6FB645, 0x7A); + MemCpy((void*)0x6FB906, "\x08\x13\xC8\x00", 4); + } +} + +unsigned char CCoronasSA::GetCoronaReflectionsEnabled() +{ + return m_ucCoronaReflectionsEnabled; +} diff --git a/Client/game_sa/CCoronasSA.h b/Client/game_sa/CCoronasSA.h index 989c8aedf55..ffa9e097006 100644 --- a/Client/game_sa/CCoronasSA.h +++ b/Client/game_sa/CCoronasSA.h @@ -25,6 +25,7 @@ class CCoronasSA : public CCoronas { private: CRegisteredCoronaSA* Coronas[MAX_CORONAS]; + unsigned char m_ucCoronaReflectionsEnabled; public: CCoronasSA(); @@ -37,4 +38,7 @@ class CCoronasSA : public CCoronas RwTexture* GetTexture(eCoronaType type); void DisableSunAndMoon(bool bDisabled); + + void SetCoronaReflectionsEnabled(unsigned char ucEnabled); + unsigned char GetCoronaReflectionsEnabled(); }; diff --git a/Client/game_sa/CSettingsSA.cpp b/Client/game_sa/CSettingsSA.cpp index c543e329da0..cb608846597 100644 --- a/Client/game_sa/CSettingsSA.cpp +++ b/Client/game_sa/CSettingsSA.cpp @@ -714,7 +714,7 @@ void CSettingsSA::ResetCoronaReflectionsEnabled() bool bEnabled; g_pCore->GetCVars()->Get("corona_reflections", bEnabled); - g_pCore->GetMultiplayer()->SetCoronaReflectionsEnabled(bEnabled ? 1 : 0); + g_pCore->GetGame()->GetCoronas()->SetCoronaReflectionsEnabled(bEnabled ? 1 : 0); } void CSettingsSA::SetCoronaReflectionsControlledByScript(bool bViaScript) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp index 7d6799dd5ec..fe356321ceb 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp @@ -2000,13 +2000,13 @@ bool CLuaWorldDefs::SetCoronaReflectionsEnabled(uchar ucEnabled) return false; g_pGame->GetSettings()->SetCoronaReflectionsControlledByScript(true); - g_pMultiplayer->SetCoronaReflectionsEnabled(ucEnabled); + g_pGame->GetCoronas()->SetCoronaReflectionsEnabled(ucEnabled); return true; } uchar CLuaWorldDefs::GetCoronaReflectionsEnabled() { - return g_pMultiplayer->GetCoronaReflectionsEnabled(); + return g_pGame->GetCoronas()->GetCoronaReflectionsEnabled(); } bool CLuaWorldDefs::ResetCoronaReflectionsEnabled() diff --git a/Client/multiplayer_sa/CMultiplayerSA.cpp b/Client/multiplayer_sa/CMultiplayerSA.cpp index 08a33c2b756..493a04962b2 100644 --- a/Client/multiplayer_sa/CMultiplayerSA.cpp +++ b/Client/multiplayer_sa/CMultiplayerSA.cpp @@ -2203,49 +2203,6 @@ void CMultiplayerSA::ResetWater() MemPut(0x7051D7, 184); } -void CMultiplayerSA::SetCoronaReflectionsEnabled(unsigned char ucEnabled) -{ - /* - ucEnabled: - 0 - corona rain reflections disabled - 1 - enabled - 2 - force enabled (render even if there is no rain) - */ - m_ucCoronaReflectionsEnabled = ucEnabled; - - if(ucEnabled == 0) { - // Disable corona rain reflections - // Disable calls to CCoronas::RenderReflections - MemSet((void*)0x53DFD8, 0x90, 5); - MemSet((void*)0x53DCAC, 0x90, 5); - } - else { - // Enable corona rain reflections - // Restore calls to CCoronas::RenderReflections - MemCpy((void*)0x53DFD8, "\xE8\x53\xD6\x1B\x00", 5); - MemCpy((void*)0x53DCAC, "\xE8\x7F\xD9\x1B\x00", 5); - } - - if(ucEnabled == 2) { - // Force enable corona reflections (render even if there is no rain) - // Disable fWetGripScale check - MemPut(0x6FB645, 0xEB); - - // Patch "fld fWetGripScale" to "fld fOne" - MemCpy((void*)0x6FB906, "\x24\x86\x85\x00", 4); - } - else { - // Restore patched stuff - MemPut(0x6FB645, 0x7A); - MemCpy((void*)0x6FB906, "\x08\x13\xC8\x00", 4); - } -} - -unsigned char CMultiplayerSA::GetCoronaReflectionsEnabled() -{ - return m_ucCoronaReflectionsEnabled; -} - bool CMultiplayerSA::GetExplosionsDisabled() { return m_bExplosionsDisabled; diff --git a/Client/sdk/game/CCoronas.h b/Client/sdk/game/CCoronas.h index afc318647fb..87b6f6f44d0 100644 --- a/Client/sdk/game/CCoronas.h +++ b/Client/sdk/game/CCoronas.h @@ -28,4 +28,6 @@ class CCoronas virtual CRegisteredCorona* FindFreeCorona() = 0; virtual CRegisteredCorona* FindCorona(DWORD Identifier) = 0; virtual void DisableSunAndMoon(bool bDisabled) = 0; + virtual void SetCoronaReflectionsEnabled(unsigned char ucEnabled) = 0; + virtual unsigned char GetCoronaReflectionsEnabled() = 0; }; diff --git a/Client/sdk/multiplayer/CMultiplayer.h b/Client/sdk/multiplayer/CMultiplayer.h index bc32c883b99..ac9746d5c6d 100644 --- a/Client/sdk/multiplayer/CMultiplayer.h +++ b/Client/sdk/multiplayer/CMultiplayer.h @@ -265,8 +265,6 @@ class CMultiplayer virtual void SetWaterColor(float fWaterRed, float fWaterGreen, float fWaterBlue, float fWaterAlpha) = 0; virtual void ResetWater() = 0; virtual void SetCloudsEnabled(bool bDisabled) = 0; - virtual void SetCoronaReflectionsEnabled(unsigned char ucEnabled) = 0; - virtual unsigned char GetCoronaReflectionsEnabled() = 0; virtual bool GetInteriorSoundsEnabled() = 0; virtual void SetInteriorSoundsEnabled(bool bEnabled) = 0; virtual bool GetInteriorFurnitureEnabled(char cRoomId) = 0; From 0a489be16735167f64d36a07ef9c44bea82fa293 Mon Sep 17 00:00:00 2001 From: lopezloo Date: Wed, 9 Feb 2022 20:45:36 +0100 Subject: [PATCH 11/13] Change Marker coronaReflectionEnabled OOP property to is/setCoronaReflectionEnabled method --- Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.cpp index 862fc43b1b4..1348d16c179 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.cpp @@ -44,17 +44,18 @@ void CLuaMarkerDefs::AddClass(lua_State* luaVM) lua_classfunction(luaVM, "getSize", "getMarkerSize"); lua_classfunction(luaVM, "getTarget", OOP_GetMarkerTarget); lua_classfunction(luaVM, "getColor", "getMarkerColor"); + lua_classfunction(luaVM, "isCoronaReflectionEnabled", "isCoronaReflectionEnabled"); lua_classfunction(luaVM, "setType", "setMarkerType"); lua_classfunction(luaVM, "setIcon", "setMarkerIcon"); lua_classfunction(luaVM, "setSize", "setMarkerSize"); lua_classfunction(luaVM, "setTarget", "setMarkerTarget"); lua_classfunction(luaVM, "setColor", "setMarkerColor"); + lua_classfunction(luaVM, "setCoronaReflectionEnabled", "setCoronaReflectionEnabled"); lua_classvariable(luaVM, "markerType", "setMarkerType", "getMarkerType"); lua_classvariable(luaVM, "icon", "setMarkerIcon", "getMarkerIcon"); lua_classvariable(luaVM, "size", "setMarkerSize", "getMarkerSize"); - lua_classvariable(luaVM, "coronaReflectionEnabled", "setCoronaReflectionEnabled", "isCoronaReflectionEnabled"); lua_classvariable(luaVM, "target", SetMarkerTarget, OOP_GetMarkerTarget); From aff2ccaeda405d53c3c509ca029ae2aed0a5fb77 Mon Sep 17 00:00:00 2001 From: lopezloo Date: Wed, 9 Feb 2022 20:51:38 +0100 Subject: [PATCH 12/13] Addendum to 0a3f720 --- Client/multiplayer_sa/CMultiplayerSA.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/Client/multiplayer_sa/CMultiplayerSA.h b/Client/multiplayer_sa/CMultiplayerSA.h index 1ad42dee008..b280e30dc00 100644 --- a/Client/multiplayer_sa/CMultiplayerSA.h +++ b/Client/multiplayer_sa/CMultiplayerSA.h @@ -161,8 +161,6 @@ class CMultiplayerSA : public CMultiplayer void GetWaterColor(float& fWaterRed, float& fWaterGreen, float& fWaterBlue, float& fWaterAlpha); void SetWaterColor(float fWaterRed, float fWaterGreen, float fWaterBlue, float fWaterAlpha); void ResetWater(); - void SetCoronaReflectionsEnabled(unsigned char ucEnabled); - unsigned char GetCoronaReflectionsEnabled(); void SetCloudsEnabled(bool bDisabled); void RebuildMultiplayerPlayer(CPed* player); bool GetInteriorSoundsEnabled(); @@ -320,7 +318,6 @@ class CMultiplayerSA : public CMultiplayer eAnimID m_dwLastStaticAnimID; DWORD m_dwLastAnimArrayAddress; float m_fShadowsOffset; - unsigned char m_ucCoronaReflectionsEnabled; /* VOID SetPlayerShotVectors(CPlayerPed* player, Vector3D * vecTarget, Vector3D * vecStart); VOID SetPlayerCameraVectors(CPlayerPed* player, Vector3D * vecSource, Vector3D * vecFront); From c9f44630f7c5f1fda2466e1a749c139a0e44dd3b Mon Sep 17 00:00:00 2001 From: lopezloo Date: Sun, 12 Jun 2022 04:41:12 +0200 Subject: [PATCH 13/13] Disable corona rain reflections by default --- Client/core/CClientVariables.cpp | 2 +- Client/core/CSettings.cpp | 2 +- Client/core/Graphics/CRenderItemManager.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Client/core/CClientVariables.cpp b/Client/core/CClientVariables.cpp index 9635d226632..7a46f3242e6 100644 --- a/Client/core/CClientVariables.cpp +++ b/Client/core/CClientVariables.cpp @@ -329,7 +329,7 @@ void CClientVariables::LoadDefaults() DEFAULT("tyre_smoke_enabled", 1); // Enable tyre smoke DEFAULT("high_detail_vehicles", 0); // Disable rendering high detail vehicles all the time DEFAULT("high_detail_peds", 0); // Disable rendering high detail peds all the time - DEFAULT("corona_reflections", 1); // Enable corona rain reflections + DEFAULT("corona_reflections", 0); // Disable corona rain reflections DEFAULT("fast_clothes_loading", 1); // 0-off 1-auto 2-on DEFAULT("allow_screen_upload", 1); // 0-off 1-on DEFAULT("allow_external_sounds", 1); // 0-off 1-on diff --git a/Client/core/CSettings.cpp b/Client/core/CSettings.cpp index f55fa071edb..566ed82eae6 100644 --- a/Client/core/CSettings.cpp +++ b/Client/core/CSettings.cpp @@ -1791,7 +1791,7 @@ bool CSettings::OnVideoDefaultClick(CGUIElement* pElement) CVARS_SET("tyre_smoke_enabled", true); CVARS_SET("high_detail_vehicles", false); CVARS_SET("high_detail_peds", false); - CVARS_SET("corona_reflections", true); + CVARS_SET("corona_reflections", false); gameSettings->UpdateFieldOfViewFromSettings(); gameSettings->SetDrawDistance(1.19625f); // All values taken from a default SA install, no gta_sa.set or coreconfig.xml modifications. gameSettings->SetBrightness(253); diff --git a/Client/core/Graphics/CRenderItemManager.cpp b/Client/core/Graphics/CRenderItemManager.cpp index ef4d380daf3..10ca9cd3351 100644 --- a/Client/core/Graphics/CRenderItemManager.cpp +++ b/Client/core/Graphics/CRenderItemManager.cpp @@ -782,7 +782,7 @@ void CRenderItemManager::GetDxStatus(SDxStatus& outStatus) outStatus.settings.fFieldOfView = 70; outStatus.settings.bHighDetailVehicles = false; outStatus.settings.bHighDetailPeds = false; - outStatus.settings.bCoronaReflections = true; + outStatus.settings.bCoronaReflections = false; CVARS_GET("streaming_memory", outStatus.settings.iStreamingMemory); CVARS_GET("volumetric_shadows", outStatus.settings.bVolumetricShadows);