Skip to content
Open
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 @@ -351,6 +351,7 @@ void CClientVariables::LoadDefaults()
DEFAULT("high_detail_peds", 0); // Disable rendering high detail peds all the time
DEFAULT("blur", 1); // Enable blur
DEFAULT("corona_reflections", 0); // Disable corona rain reflections
DEFAULT("ps2_scorched_vehicles", 0); // Disable PS2-style scorched destroyed vehicles
DEFAULT("dynamic_ped_shadows", 0); // Disable dynamic ped shadows
DEFAULT("fast_clothes_loading", 1); // 0-off 1-auto 2-on
DEFAULT("allow_screen_upload", 1); // 0-off 1-on
Expand Down
2 changes: 2 additions & 0 deletions Client/core/CCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,8 @@ void CCore::ApplyGameSettings()
pGameSettings->SetGrassEnabled(bVal);
CVARS_GET("heat_haze", bVal);
m_pMultiplayer->SetHeatHazeEnabled(bVal);
CVARS_GET("ps2_scorched_vehicles", bVal);
m_pMultiplayer->SetPs2ScorchedVehiclesEnabled(bVal);
CVARS_GET("fast_clothes_loading", iVal);
m_pMultiplayer->SetFastClothesLoading((CMultiplayer::EFastClothesLoading)iVal);
CVARS_GET("tyre_smoke_enabled", bVal);
Expand Down
16 changes: 16 additions & 0 deletions Client/core/CSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ void CSettings::ResetGuiPointers()
m_pCheckBoxHighDetailPeds = NULL;
m_pCheckBoxBlur = NULL;
m_pCheckBoxCoronaReflections = NULL;
m_pCheckBoxPs2ScorchedVehicles = nullptr;
m_pCheckBoxDynamicPedShadows = NULL;
m_pFieldOfViewLabel = NULL;
m_pFieldOfView = NULL;
Expand Down Expand Up @@ -1407,6 +1408,10 @@ void CSettings::CreateGUI()
m_pCheckBoxCoronaReflections->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 150.0f));
m_pCheckBoxCoronaReflections->AutoSize(nullptr, 20.0f);

m_pCheckBoxPs2ScorchedVehicles = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabVideo, _("PS2 scorched vehicles"), true));
m_pCheckBoxPs2ScorchedVehicles->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 170.0f));
m_pCheckBoxPs2ScorchedVehicles->AutoSize(nullptr, 20.0f);

float fPosY = vecTemp.fY;
m_pCheckBoxMinimize = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(pTabVideo, _("Full Screen Minimize"), true));
m_pCheckBoxMinimize->SetPosition(CVector2D(vecTemp.fX + 245.0f, fPosY + 30.0f));
Expand Down Expand Up @@ -2330,6 +2335,11 @@ void CSettings::UpdateVideoTab()
CVARS_GET("corona_reflections", bCoronaReflections);
m_pCheckBoxCoronaReflections->SetSelected(bCoronaReflections);

// PS2 scorched vehicles
bool bPs2ScorchedVehicles;
CVARS_GET("ps2_scorched_vehicles", bPs2ScorchedVehicles);
m_pCheckBoxPs2ScorchedVehicles->SetSelected(bPs2ScorchedVehicles);

// Dynamic ped shadows
bool bDynamicPedShadows;
CVARS_GET("dynamic_ped_shadows", bDynamicPedShadows);
Expand Down Expand Up @@ -2679,6 +2689,7 @@ bool CSettings::OnVideoDefaultClick(CGUIElement* pElement)
CVARS_SET("high_detail_peds", false);
CVARS_SET("blur", true);
CVARS_SET("corona_reflections", false);
CVARS_SET("ps2_scorched_vehicles", false);
CVARS_SET("dynamic_ped_shadows", false);
CVARS_SET("borderless_gamma_power", kBorderlessGammaDefault);
CVARS_SET("borderless_brightness_scale", kBorderlessBrightnessDefault);
Expand Down Expand Up @@ -4499,6 +4510,11 @@ void CSettings::SaveData()
CVARS_SET("corona_reflections", bCoronaReflections);
gameSettings->ResetCoronaReflectionsEnabled();

// PS2 scorched vehicles (client graphics preference)
bool bPs2ScorchedVehicles = m_pCheckBoxPs2ScorchedVehicles->GetSelected();
CVARS_SET("ps2_scorched_vehicles", bPs2ScorchedVehicles);
g_pCore->GetMultiplayer()->SetPs2ScorchedVehiclesEnabled(bPs2ScorchedVehicles);

// Dynamic ped shadows
bool bDynamicPedShadows = m_pCheckBoxDynamicPedShadows->GetSelected();
CVARS_SET("dynamic_ped_shadows", bDynamicPedShadows);
Expand Down
1 change: 1 addition & 0 deletions Client/core/CSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ class CSettings
CGUICheckBox* m_pCheckBoxHighDetailPeds;
CGUICheckBox* m_pCheckBoxBlur;
CGUICheckBox* m_pCheckBoxCoronaReflections;
CGUICheckBox* m_pCheckBoxPs2ScorchedVehicles;
CGUICheckBox* m_pCheckBoxDynamicPedShadows;
CGUILabel* m_pFieldOfViewLabel;
CGUIScrollBar* m_pFieldOfView;
Expand Down
13 changes: 13 additions & 0 deletions Client/multiplayer_sa/CMultiplayerSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1597,6 +1597,7 @@ void CMultiplayerSA::InitHooks()
InitHooks_Postprocess();
InitHooks_Explosions();
InitHooks_Tasks();
InitHooks_ScorchedVehicles();
}

// Used to store copied pointers for explosions in the FxSystem
Expand Down Expand Up @@ -6510,6 +6511,18 @@ void _cdecl SaveVehColors(DWORD dwThis)
if (pVehicle)
{
pVehicle->GetColor(&vehColors[0], &vehColors[1], &vehColors[2], &vehColors[3], true);

// Darken blown vehicle colours
if (pMultiplayer->IsPs2ScorchedVehiclesEnabled() && pVehicle->GetHealth() <= 0.0f)
{
constexpr float darkFactor = 0.08f;
for (auto& color : vehColors)
{
color.R = static_cast<unsigned char>(color.R * darkFactor);
color.G = static_cast<unsigned char>(color.G * darkFactor);
color.B = static_cast<unsigned char>(color.B * darkFactor);
}
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions Client/multiplayer_sa/CMultiplayerSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class CMultiplayerSA : public CMultiplayer
void InitHooks_DeviceSelection();
void InitHooks_Explosions();
void InitHooks_Tasks();
void InitHooks_ScorchedVehicles();
CRemoteDataStorage* CreateRemoteDataStorage();
void DestroyRemoteDataStorage(CRemoteDataStorage* pData);
void AddRemoteDataStorage(CPlayerPed* pPed, CRemoteDataStorage* pData);
Expand Down Expand Up @@ -341,6 +342,9 @@ class CMultiplayerSA : public CMultiplayer
bool IsVehicleEngineAutoStartEnabled() const noexcept override;
void SetVehicleEngineAutoStartEnabled(bool enabled) override;

bool IsPs2ScorchedVehiclesEnabled() const noexcept override;
void SetPs2ScorchedVehiclesEnabled(bool enabled) noexcept override;

bool IsRapidVehicleStopFixEnabled() const noexcept override { return m_isRapidVehicleStopFixEnabled; };
void SetRapidVehicleStopFixEnabled(bool enabled) override;

Expand Down
45 changes: 45 additions & 0 deletions Client/multiplayer_sa/CMultiplayerSA_ScorchedVehicles.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto
* LICENSE: See LICENSE in the top level directory
* FILE: multiplayer_sa/CMultiplayerSA_ScorchedVehicles.cpp
*
* Multi Theft Auto is available from https://www.multitheftauto.com/
*
*****************************************************************************/

#include "StdInc.h"

namespace
{
constexpr float SCORCHED_VEHICLE_LIGHTING_PS2 = 0.0f;

bool ms_bPs2ScorchedVehiclesEnabled = false;

using WorldReplaceNormalLightsWithScorched_t = void(__cdecl*)(RpWorld* world, float lighting);

void __cdecl WorldReplaceNormalLightsWithScorched_MTA(RpWorld* world, float lighting)
{
if (ms_bPs2ScorchedVehiclesEnabled)
lighting = SCORCHED_VEHICLE_LIGHTING_PS2;

// Call WorldReplaceNormalLightsWithScorched
reinterpret_cast<WorldReplaceNormalLightsWithScorched_t>(0x7357E0)(world, lighting);
Comment thread
FileEX marked this conversation as resolved.
}
} // namespace

bool CMultiplayerSA::IsPs2ScorchedVehiclesEnabled() const noexcept
{
return ms_bPs2ScorchedVehiclesEnabled;
}

void CMultiplayerSA::SetPs2ScorchedVehiclesEnabled(bool enabled) noexcept
{
ms_bPs2ScorchedVehiclesEnabled = enabled;
}

void CMultiplayerSA::InitHooks_ScorchedVehicles()
{
HookInstallCall(0x553E6A, reinterpret_cast<DWORD>(WorldReplaceNormalLightsWithScorched_MTA)); // CRenderer::SetupLightingForEntity
HookInstallCall(0x554FB7, reinterpret_cast<DWORD>(WorldReplaceNormalLightsWithScorched_MTA)); // CObject::SetupLighting
}
3 changes: 3 additions & 0 deletions Client/sdk/multiplayer/CMultiplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ class CMultiplayer
virtual bool IsVehicleEngineAutoStartEnabled() const noexcept = 0;
virtual void SetVehicleEngineAutoStartEnabled(bool enabled) = 0;

virtual bool IsPs2ScorchedVehiclesEnabled() const noexcept = 0;
virtual void SetPs2ScorchedVehiclesEnabled(bool enabled) noexcept = 0;

virtual bool IsRapidVehicleStopFixEnabled() const noexcept = 0;
virtual void SetRapidVehicleStopFixEnabled(bool enabled) = 0;

Expand Down
Loading