Skip to content

Commit

Permalink
Merge branch 'master' into add-vehicle-sirens
Browse files Browse the repository at this point in the history
  • Loading branch information
Proxy-99 authored Nov 2, 2024
2 parents 2538362 + 2c9f48c commit 9d1bc82
Show file tree
Hide file tree
Showing 30 changed files with 411 additions and 241 deletions.
7 changes: 7 additions & 0 deletions Client/cefweb/CWebApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ CefRefPtr<CefResourceHandler> CWebApp::HandleError(const SString& strError, unsi

void CWebApp::OnBeforeCommandLineProcessing(const CefString& process_type, CefRefPtr<CefCommandLine> command_line)
{
CWebCore* pWebCore = static_cast<CWebCore*>(g_pCore->GetWebCore());

if (!pWebCore->GetGPUEnabled())
command_line->AppendSwitch("disable-gpu");

command_line->AppendSwitch("disable-gpu-compositing"); // always disable this, causes issues with official builds

// command_line->AppendSwitch("disable-d3d11");
command_line->AppendSwitch("enable-begin-frame-scheduling");

Expand Down
10 changes: 9 additions & 1 deletion Client/cefweb/CWebCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ CWebCore::~CWebCore()
delete m_pXmlConfig;
}

bool CWebCore::Initialise()
bool CWebCore::Initialise(bool gpuEnabled)
{
CefMainArgs mainArgs;
void* sandboxInfo = nullptr;

m_bGPUEnabled = gpuEnabled;

CefRefPtr<CWebApp> app(new CWebApp);

#ifdef CEF_ENABLE_SANDBOX
Expand Down Expand Up @@ -869,3 +872,8 @@ void CWebCore::StaticFetchBlacklistFinished(const SHttpDownloadResult& result)
OutputDebugLine("Updated browser blacklist!");
#endif
}

bool CWebCore::GetGPUEnabled() const noexcept
{
return m_bGPUEnabled;
}
7 changes: 6 additions & 1 deletion Client/cefweb/CWebCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CWebCore : public CWebCoreInterface
public:
CWebCore();
~CWebCore();
bool Initialise() override;
bool Initialise(bool gpuEnabled) override;

CWebViewInterface* CreateWebView(unsigned int uiWidth, unsigned int uiHeight, bool bIsLocal, CWebBrowserItem* pWebBrowserRenderItem, bool bTransparent);
void DestroyWebView(CWebViewInterface* pWebViewInterface);
Expand Down Expand Up @@ -108,6 +108,8 @@ class CWebCore : public CWebCoreInterface
static void StaticFetchWhitelistFinished(const SHttpDownloadResult& result);
static void StaticFetchBlacklistFinished(const SHttpDownloadResult& result);

bool GetGPUEnabled() const noexcept;

private:
typedef std::pair<bool, eWebFilterType> WebFilterPair;

Expand All @@ -129,4 +131,7 @@ class CWebCore : public CWebCoreInterface
CXMLFile* m_pXmlConfig;
int m_iWhitelistRevision;
int m_iBlacklistRevision;

// Shouldn't be changed after init
bool m_bGPUEnabled;
};
1 change: 1 addition & 0 deletions Client/core/CClientVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ void CClientVariables::LoadDefaults()
DEFAULT("discord_rpc_share_data", false); // Consistent Rich Presence data sharing
DEFAULT("discord_rpc_share_data_firsttime", false); // Display the user data sharing consent dialog box - for the first time
DEFAULT("_beta_qc_rightclick_command", _S("reconnect")); // Command to run when right clicking quick connect (beta - can be removed at any time)
DEFAULT("browser_enable_gpu", true); // Enable GPU in CEF? (allows stuff like WebGL to function)

if (!Exists("locale"))
{
Expand Down
6 changes: 5 additions & 1 deletion Client/core/CCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1155,8 +1155,12 @@ CWebCoreInterface* CCore::GetWebCore()
{
if (m_pWebCore == nullptr)
{
bool gpuEnabled;
auto cvars = g_pCore->GetCVars();
cvars->Get("browser_enable_gpu", gpuEnabled);

m_pWebCore = CreateModule<CWebCoreInterface>(m_WebCoreModule, "CefWeb", "cefweb", "InitWebCoreInterface", this);
m_pWebCore->Initialise();
m_pWebCore->Initialise(gpuEnabled);
}
return m_pWebCore;
}
Expand Down
22 changes: 14 additions & 8 deletions Client/core/CGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,15 @@ CLocalGUI::~CLocalGUI()

void CLocalGUI::SetSkin(const char* szName)
{
CVector2D consolePos, consoleSize;

bool guiWasLoaded = m_pMainMenu != NULL;
if (guiWasLoaded)
{
consolePos = m_pConsole->GetPosition();
consoleSize = m_pConsole->GetSize();
DestroyWindows();
}

std::string error;

Expand Down Expand Up @@ -93,7 +99,11 @@ void CLocalGUI::SetSkin(const char* szName)
m_LastSettingsRevision = cvars->GetRevision();

if (guiWasLoaded)
{
CreateWindows(guiWasLoaded);
m_pConsole->SetPosition(consolePos);
m_pConsole->SetSize(consoleSize);
}

if (CCore::GetSingleton().GetConsole() && !error.empty())
CCore::GetSingleton().GetConsole()->Echo(error.c_str());
Expand All @@ -104,8 +114,8 @@ void CLocalGUI::ChangeLocale(const char* szName)
bool guiWasLoaded = m_pMainMenu != NULL;
assert(guiWasLoaded);

CVector2D vPos = m_pConsole->GetPosition();
CVector2D vSize = m_pConsole->GetSize();
CVector2D consolePos = m_pConsole->GetPosition();
CVector2D consoleSize = m_pConsole->GetSize();

if (guiWasLoaded)
DestroyWindows();
Expand All @@ -119,12 +129,8 @@ void CLocalGUI::ChangeLocale(const char* szName)
if (guiWasLoaded)
{
CreateWindows(guiWasLoaded);

if (m_pConsole != nullptr)
{
m_pConsole->SetPosition(vPos);
m_pConsole->SetSize(vSize);
}
m_pConsole->SetPosition(consolePos);
m_pConsole->SetSize(consoleSize);
}
}

Expand Down
15 changes: 14 additions & 1 deletion Client/core/CSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,10 @@ void CSettings::CreateGUI()
m_pCheckBoxRemoteJavascript->GetPosition(vecTemp);
m_pCheckBoxRemoteJavascript->AutoSize(NULL, 20.0f);

m_pCheckBoxBrowserGPUEnabled = reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(m_pTabBrowser, _("Enable GPU rendering"), true));
m_pCheckBoxBrowserGPUEnabled->SetPosition(CVector2D(vecTemp.fX + 300.0f, vecTemp.fY - 25.0f));
m_pCheckBoxBrowserGPUEnabled->AutoSize(NULL, 20.0f);

m_pLabelBrowserCustomBlacklist = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(m_pTabBrowser, _("Custom blacklist")));
m_pLabelBrowserCustomBlacklist->SetPosition(CVector2D(vecTemp.fX, vecTemp.fY + 30.0f));
m_pLabelBrowserCustomBlacklist->GetPosition(vecTemp);
Expand Down Expand Up @@ -3287,6 +3291,8 @@ void CSettings::LoadData()
m_pCheckBoxRemoteBrowser->SetSelected(bVar);
CVARS_GET("browser_remote_javascript", bVar);
m_pCheckBoxRemoteJavascript->SetSelected(bVar);
CVARS_GET("browser_enable_gpu", bVar);
m_pCheckBoxBrowserGPUEnabled->SetSelected(bVar);

ReloadBrowserLists();
}
Expand Down Expand Up @@ -3711,6 +3717,13 @@ void CSettings::SaveData()
bBrowserSettingChanged = true;
}

bool bBrowserGPUEnabled = false;
CVARS_GET("browser_enable_gpu", bBrowserGPUEnabled);

bool bBrowserGPUSetting = m_pCheckBoxBrowserGPUEnabled->GetSelected();
bool bBrowserGPUSettingChanged = (bBrowserGPUSetting != bBrowserGPUEnabled);
CVARS_SET("browser_enable_gpu", bBrowserGPUSetting);

// Ensure CVARS ranges ok
CClientVariables::GetSingleton().ValidateValues();

Expand All @@ -3720,7 +3733,7 @@ void CSettings::SaveData()
gameSettings->Save();

// Ask to restart?
if (bIsVideoModeChanged || bIsAntiAliasingChanged || bIsCustomizedSAFilesChanged || processsDPIAwareChanged)
if (bIsVideoModeChanged || bIsAntiAliasingChanged || bIsCustomizedSAFilesChanged || processsDPIAwareChanged || bBrowserGPUSettingChanged)
ShowRestartQuestion();
else if (CModManager::GetSingleton().IsLoaded() && bBrowserSettingChanged)
ShowDisconnectQuestion();
Expand Down
1 change: 1 addition & 0 deletions Client/core/CSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ class CSettings
CGUIButton* m_pButtonBrowserWhitelistAdd;
CGUIGridList* m_pGridBrowserWhitelist;
CGUIButton* m_pButtonBrowserWhitelistRemove;
CGUICheckBox* m_pCheckBoxBrowserGPUEnabled;
bool m_bBrowserListsChanged;
bool m_bBrowserListsLoadEnabled;

Expand Down
14 changes: 14 additions & 0 deletions Client/game_sa/CSettingsSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,20 @@ void CSettingsSA::SetDynamicPedShadowsEnabled(bool bEnable)
m_bDynamicPedShadowsEnabled = bEnable;
}

bool CSettingsSA::IsDynamicPedShadowsEnabledByVideoSetting() const noexcept
{
bool pedDynamicShadows;
g_pCore->GetCVars()->Get("dynamic_ped_shadows", pedDynamicShadows);
return pedDynamicShadows;
}

bool CSettingsSA::ResetDynamicPedShadows() noexcept
{
pGame->GetSettings()->SetDynamicPedShadowsEnabled(pGame->GetSettings()->IsDynamicPedShadowsEnabledByVideoSetting());
return true;
}


//
// Volumetric shadow hooks
//
Expand Down
2 changes: 2 additions & 0 deletions Client/game_sa/CSettingsSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ class CSettingsSA : public CGameSettings

bool IsDynamicPedShadowsEnabled();
void SetDynamicPedShadowsEnabled(bool bEnable);
bool IsDynamicPedShadowsEnabledByVideoSetting() const noexcept;
bool ResetDynamicPedShadows() noexcept;

float GetAspectRatioValue();
eAspectRatio GetAspectRatio();
Expand Down
12 changes: 8 additions & 4 deletions Client/game_sa/CVehicleSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,16 +1345,20 @@ void CVehicleSA::RecalculateHandling()
continue;

// If NOS is installed we need set the flag
if ((upgradeID >= 1008 && upgradeID <= 1010) && !(uiHandlingFlags & HANDLING_NOS_Flag))
if ((upgradeID >= 1008 && upgradeID <= 1010))
{
uiHandlingFlags |= HANDLING_NOS_Flag;
if (!(uiHandlingFlags & HANDLING_NOS_Flag))
uiHandlingFlags |= HANDLING_NOS_Flag;

nitroInstalled = true;
}

// If hydraulics is installed we need set the flag
if ((upgradeID == 1087) && !(uiHandlingFlags & HANDLING_Hydraulics_Flag))
if ((upgradeID == 1087))
{
uiHandlingFlags |= HANDLING_Hydraulics_Flag;
if (!(uiHandlingFlags & HANDLING_Hydraulics_Flag))
uiHandlingFlags |= HANDLING_Hydraulics_Flag;

hydralicsInstalled = true;
}
}
Expand Down
10 changes: 6 additions & 4 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5456,10 +5456,6 @@ void CClientGame::ResetMapInfo()
// Players
m_pPlayerManager->ResetAll();

// Reset Frozen Time
g_pGame->GetClock()->ResetTimeFrozen();
g_pGame->GetSettings()->ResetVolumetricShadows();

// Disable the change of any player stats
g_pMultiplayer->SetLocalStatsStatic(true);

Expand Down Expand Up @@ -6887,6 +6883,12 @@ void CClientGame::ResetWorldProperties(const ResetWorldPropsInfo& resetPropsInfo

// Reset volumetric shadows
g_pGame->GetSettings()->ResetVolumetricShadows();

// Reset Frozen Time
g_pGame->GetClock()->ResetTimeFrozen();

// Reset DynamicPedShadows
g_pGame->GetSettings()->ResetDynamicPedShadows();
}

void CClientGame::OnWindowFocusChange(bool state)
Expand Down
7 changes: 7 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaBrowserDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void CLuaBrowserDefs::LoadFunctions()
{"resizeBrowser", ResizeBrowser},
{"guiCreateBrowser", GUICreateBrowser},
{"guiGetBrowser", GUIGetBrowser},
{"isBrowserGPUEnabled", ArgumentParser<IsBrowserGPUEnabled>},
};

// Add browser functions
Expand Down Expand Up @@ -97,6 +98,7 @@ void CLuaBrowserDefs::AddClass(lua_State* luaVM)
lua_classvariable(luaVM, "renderingPaused", "setBrowserRenderingPaused", "isBrowserRenderingPaused");
lua_classvariable(luaVM, "volume", "setBrowserVolume", "getBrowserVolume");
lua_classvariable(luaVM, "devTools", "toggleBrowserDevTools", nullptr);
lua_classvariable(luaVM, "gpuEnabled", nullptr, "isBrowserGPUEnabled");

lua_registerclass(luaVM, "Browser", "DxTexture");

Expand Down Expand Up @@ -1054,3 +1056,8 @@ int CLuaBrowserDefs::SetBrowserAjaxHandler(lua_State* luaVM)
lua_pushboolean(luaVM, false);
return 1;
}

bool CLuaBrowserDefs::IsBrowserGPUEnabled() noexcept
{
return g_pCore->GetWebCore()->GetGPUEnabled();
}
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaBrowserDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ class CLuaBrowserDefs : public CLuaDefs
LUA_DECLARE(ResizeBrowser);
LUA_DECLARE(GUICreateBrowser);
LUA_DECLARE(GUIGetBrowser);
static bool IsBrowserGPUEnabled() noexcept;
};
19 changes: 19 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ void CLuaVehicleDefs::LoadFunctions()
{"getVehicleModelWheelSize", ArgumentParser<GetVehicleModelWheelSize>},
{"getVehicleWheelFrictionState", ArgumentParser<GetVehicleWheelFrictionState>},
{"getVehicleEntryPoints", ArgumentParser<GetVehicleEntryPoints>},
{"isVehicleSmokeTrailEnabled", ArgumentParser<IsSmokeTrailEnabled>},

// Vehicle set funcs
{"createVehicle", CreateVehicle},
Expand Down Expand Up @@ -158,6 +159,7 @@ void CLuaVehicleDefs::LoadFunctions()
{"setVehicleWheelScale", ArgumentParser<SetVehicleWheelScale>},
{"setVehicleModelWheelSize", ArgumentParser<SetVehicleModelWheelSize>},
{"spawnVehicleFlyingComponent", ArgumentParser<SpawnVehicleFlyingComponent>},
{"setVehicleSmokeTrailEnabled", ArgumentParser<SetSmokeTrailEnabled>},
};

// Add functions
Expand Down Expand Up @@ -246,6 +248,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "getModelWheelSize", "getVehicleModelWheelSize");
lua_classfunction(luaVM, "getWheelFrictionState", "getVehicleWheelFrictionState");
lua_classfunction(luaVM, "getEntryPoints", ArgumentParser<OOP_GetVehicleEntryPoints>);
lua_classfunction(luaVM, "isSmokeTrailEnabled", "isVehicleSmokeTrailEnabled");

lua_classfunction(luaVM, "setComponentVisible", "setVehicleComponentVisible");
lua_classfunction(luaVM, "setSirensOn", "setVehicleSirensOn");
Expand Down Expand Up @@ -294,6 +297,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "setVariant", "setVehicleVariant");
lua_classfunction(luaVM, "setWheelScale", "setVehicleWheelScale");
lua_classfunction(luaVM, "setModelWheelSize", "setVehicleModelWheelSize");
lua_classfunction(luaVM, "setSmokeTrailEnabled", "setVehicleSmokeTrailEnabled");

lua_classfunction(luaVM, "resetComponentPosition", "resetVehicleComponentPosition");
lua_classfunction(luaVM, "resetComponentRotation", "resetVehicleComponentRotation");
Expand Down Expand Up @@ -4366,3 +4370,18 @@ bool CLuaVehicleDefs::RemoveVehicleSirens(CClientVehicle* vehicle) noexcept
vehicle->RemoveVehicleSirens();
return true;
}

bool CLuaVehicleDefs::SetSmokeTrailEnabled(CClientVehicle* vehicle, bool state)
{
std::uint16_t model = vehicle->GetModel();
if (model != 512 && model != 513)
throw LuaFunctionError("Invaild model ID");

vehicle->SetSmokeTrailEnabled(state);
return true;
}

bool CLuaVehicleDefs::IsSmokeTrailEnabled(CClientVehicle* vehicle) noexcept
{
return vehicle->IsSmokeTrailEnabled();
}
3 changes: 3 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,7 @@ class CLuaVehicleDefs : public CLuaDefs
LUA_DECLARE(GetVehicleComponents);

static bool SpawnVehicleFlyingComponent(CClientVehicle* const vehicle, std::uint8_t nodeIndex, std::optional<std::uint8_t> componentCollisionType, std::optional<std::uint32_t> removalTime);

static bool SetSmokeTrailEnabled(CClientVehicle* vehicle, bool state);
static bool IsSmokeTrailEnabled(CClientVehicle* vehicle) noexcept;
};
Loading

0 comments on commit 9d1bc82

Please sign in to comment.