Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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/core/CClientVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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", 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
Expand Down
1 change: 1 addition & 0 deletions Client/core/CCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ void CCore::ApplyGameSettings()
pGameSettings->UpdateFieldOfViewFromSettings();
pGameSettings->ResetVehiclesLODDistance(false);
pGameSettings->ResetPedsLODDistance(false);
pGameSettings->ResetCoronaReflectionsEnabled();
pController->SetVerticalAimSensitivityRawValue(CVARS_GET_VALUE<float>("vertical_aim_sensitivity"));
CVARS_GET("mastervolume", fVal);
pGameSettings->SetRadioVolume(pGameSettings->GetRadioVolume() * fVal);
Expand Down
16 changes: 16 additions & 0 deletions Client/core/CSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,11 @@ void CSettings::CreateGUI()
fPosY -= 20.0f;
}
#endif

m_pCheckBoxCoronaReflections = reinterpret_cast<CGUICheckBox*>(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);
Expand Down Expand Up @@ -1557,6 +1562,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
Expand Down Expand Up @@ -1781,6 +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", 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);
Expand Down Expand Up @@ -3426,6 +3437,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())
{
Expand Down
1 change: 1 addition & 0 deletions Client/core/CSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions Client/core/Graphics/CRenderItemManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,7 @@ void CRenderItemManager::GetDxStatus(SDxStatus& outStatus)
outStatus.settings.fFieldOfView = 70;
outStatus.settings.bHighDetailVehicles = false;
outStatus.settings.bHighDetailPeds = false;
outStatus.settings.bCoronaReflections = false;

CVARS_GET("streaming_memory", outStatus.settings.iStreamingMemory);
CVARS_GET("volumetric_shadows", outStatus.settings.bVolumetricShadows);
Expand All @@ -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)
{
Expand Down
46 changes: 46 additions & 0 deletions Client/game_sa/CCoronasSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<BYTE>(0x6FB630, 0xC3);
}
else
{
// Enable corona rain reflections
// Re-enable CCoronas::RenderReflections()
MemPut<BYTE>(0x6FB630, 0xD9);
}

if (ucEnabled == 2)
{
// Force enable corona reflections (render even if there is no rain)
// Disable fWetGripScale check
MemPut<BYTE>(0x6FB645, 0xEB);

// Patch "fld fWetGripScale" to "fld fOne"
MemCpy((void*)0x6FB906, "\x24\x86\x85\x00", 4);
}
else
{
// Restore patched code
MemPut<BYTE>(0x6FB645, 0x7A);
MemCpy((void*)0x6FB906, "\x08\x13\xC8\x00", 4);
}
}

unsigned char CCoronasSA::GetCoronaReflectionsEnabled()
{
return m_ucCoronaReflectionsEnabled;
}
4 changes: 4 additions & 0 deletions Client/game_sa/CCoronasSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class CCoronasSA : public CCoronas
{
private:
CRegisteredCoronaSA* Coronas[MAX_CORONAS];
unsigned char m_ucCoronaReflectionsEnabled;

public:
CCoronasSA();
Expand All @@ -37,4 +38,7 @@ class CCoronasSA : public CCoronas
RwTexture* GetTexture(eCoronaType type);

void DisableSunAndMoon(bool bDisabled);

void SetCoronaReflectionsEnabled(unsigned char ucEnabled);
unsigned char GetCoronaReflectionsEnabled();
};
7 changes: 6 additions & 1 deletion Client/game_sa/CRegisteredCoronaSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()");
Expand All @@ -128,7 +133,7 @@ VOID CRegisteredCoronaSA::Init(DWORD Identifier)
internalInterface->Intensity = 255;
internalInterface->FadedIntensity = 255;
internalInterface->FlareType = 0;
internalInterface->ReflectionType = 1;
internalInterface->ReflectionType = 0;
internalInterface->JustCreated = 1;
internalInterface->RegisteredThisFrame = 1; // won't appear in-game without this
}
Expand Down
1 change: 1 addition & 0 deletions Client/game_sa/CRegisteredCoronaSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
24 changes: 24 additions & 0 deletions Client/game_sa/CSettingsSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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->GetGame()->GetCoronas()->SetCoronaReflectionsEnabled(bEnabled ? 1 : 0);
}

void CSettingsSA::SetCoronaReflectionsControlledByScript(bool bViaScript)
{
m_bCoronaReflectionsViaScript = bViaScript;
}

////////////////////////////////////////////////
//
// CSettingsSA::HasUnsafeResolutions
Expand Down
4 changes: 4 additions & 0 deletions Client/game_sa/CSettingsSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class CSettingsSA : public CGameSettings
eAspectRatio m_AspectRatio;
int m_iDesktopWidth;
int m_iDesktopHeight;
bool m_bCoronaReflectionsViaScript;

public:
CSettingsSA();
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion Client/mods/deathmatch/logic/CClientCorona.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
}
4 changes: 4 additions & 0 deletions Client/mods/deathmatch/logic/CClientCorona.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -53,5 +56,6 @@ class CClientCorona : public CClientMarkerCommon
bool m_bVisible;
float m_fSize;
SColor m_Color;
bool m_bReflectionEnabled;
CCoronas* m_pCoronas;
};
4 changes: 4 additions & 0 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5297,6 +5297,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();

Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CClientGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ class CClientGame
GLITCH_KICKOUTOFVEHICLE_ONMODELREPLACE,
NUM_GLITCHES
};

class CStoredWeaponSlot
{
public:
Expand Down
4 changes: 4 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaDrawingDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<lua_Number>(SharedUtil::GetWMITotalPhysicalMemory()) / 1024.0 / 1024.0);
lua_settable(luaVM, -3);
Expand Down
25 changes: 25 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*****************************************************************************/

#include "StdInc.h"
#include "lua/CLuaFunctionParser.h"

void CLuaMarkerDefs::LoadFunctions()
{
Expand All @@ -21,6 +22,9 @@ void CLuaMarkerDefs::LoadFunctions()

{"setMarkerType", SetMarkerType}, {"setMarkerSize", SetMarkerSize}, {"setMarkerColor", SetMarkerColor},
{"setMarkerTarget", SetMarkerTarget}, {"setMarkerIcon", SetMarkerIcon},

{"setCoronaReflectionEnabled", ArgumentParser<SetCoronaReflectionEnabled>},
{"isCoronaReflectionEnabled", ArgumentParser<IsCoronaReflectionEnabled>},
};

// Add functions
Expand All @@ -40,12 +44,14 @@ 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");
Expand Down Expand Up @@ -385,3 +391,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();
}
5 changes: 4 additions & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaMarkerDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ class CLuaMarkerDefs : public CLuaDefs
LUA_DECLARE(SetMarkerColor);
LUA_DECLARE(SetMarkerTarget);
LUA_DECLARE(SetMarkerIcon);
};

static bool SetCoronaReflectionEnabled(CClientMarker* pMarker, bool bEnabled);
static bool IsCoronaReflectionEnabled(CClientMarker* pMarker);
};
Loading