Skip to content

Commit

Permalink
Merge branch 'master' into 230924_Add_C++20_Deathmatch
Browse files Browse the repository at this point in the history
  • Loading branch information
TracerDS authored Nov 13, 2024
2 parents b0a5deb + 750d09a commit c2ac31f
Show file tree
Hide file tree
Showing 37 changed files with 462 additions and 302 deletions.
9 changes: 3 additions & 6 deletions Client/cefweb/CWebApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ void CWebApp::OnBeforeCommandLineProcessing(const CefString& process_type, CefRe
{
CWebCore* pWebCore = static_cast<CWebCore*>(g_pCore->GetWebCore());

if (!pWebCore->GetGPUEnabled()) // if GPU is disabled...
{
command_line->AppendSwitch("disable-gpu-compositing");
if (!pWebCore->GetGPUEnabled())
command_line->AppendSwitch("disable-gpu");
}
else if (!pWebCore->GetGPUCompositingEnabled()) // if GPU is enabled, but compositing is disabled...
command_line->AppendSwitch("disable-gpu-compositing");

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
8 changes: 1 addition & 7 deletions Client/cefweb/CWebCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@ CWebCore::~CWebCore()
delete m_pXmlConfig;
}

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

m_bGPUEnabled = gpuEnabled;
m_bGPUCompositingEnabled = gpuCompositingEnabled;

CefRefPtr<CWebApp> app(new CWebApp);

Expand Down Expand Up @@ -878,8 +877,3 @@ bool CWebCore::GetGPUEnabled() const noexcept
{
return m_bGPUEnabled;
}

bool CWebCore::GetGPUCompositingEnabled() const noexcept
{
return m_bGPUCompositingEnabled;
}
4 changes: 1 addition & 3 deletions 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(bool gpuEnabled, bool gpuCompositingEnabled) 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 @@ -109,7 +109,6 @@ class CWebCore : public CWebCoreInterface
static void StaticFetchBlacklistFinished(const SHttpDownloadResult& result);

bool GetGPUEnabled() const noexcept;
bool GetGPUCompositingEnabled() const noexcept;

private:
typedef std::pair<bool, eWebFilterType> WebFilterPair;
Expand All @@ -135,5 +134,4 @@ class CWebCore : public CWebCoreInterface

// Shouldn't be changed after init
bool m_bGPUEnabled;
bool m_bGPUCompositingEnabled;
};
1 change: 0 additions & 1 deletion Client/core/CClientVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ void CClientVariables::LoadDefaults()
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)
DEFAULT("browser_enable_gpu_compositing", true); // Enable GPU compositing in CEF? (required GPU enabled)

if (!Exists("locale"))
{
Expand Down
4 changes: 1 addition & 3 deletions Client/core/CCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,13 +1156,11 @@ CWebCoreInterface* CCore::GetWebCore()
if (m_pWebCore == nullptr)
{
bool gpuEnabled;
bool gpuCompositingEnabled;
auto cvars = g_pCore->GetCVars();
cvars->Get("browser_enable_gpu", gpuEnabled);
cvars->Get("browser_enable_gpu_compositing", gpuCompositingEnabled);

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

#include "StdInc.h"
#include "time.h"
#include <random>

// These words are of a maximum length of 10 characters, capitalized, and stripped of whitespace
const char* const CNickGen::m_szAdjectives[] = {
const char* const szAdjectives[] = {
"Aback", "Abaft", "Abandoned", "Abashed", "Aberrant", "Abhorrent", "Abiding", "Abject", "Ablaze", "Able", "Abnormal",
"Aboard", "Aboriginal", "Abortive", "Abounding", "Abrasive", "Abrupt", "Absent", "Absorbed", "Absorbing", "Abstracted", "Absurd",
"Abundant", "Abusive", "Acceptable", "Accessible", "Accidental", "Accurate", "Acid", "Acidic", "Acoustic", "Acrid", "Actually",
Expand Down Expand Up @@ -109,7 +109,7 @@ const char* const CNickGen::m_szAdjectives[] = {
"Worried", "Worthless", "Wrathful", "Wretched", "Wrong", "Wry",
};

const char* const CNickGen::m_szNouns[] = {
const char* const szNouns[] = {
"Aardvark", "Buffalo", "Alligator", "Ant", "Anteater", "Antelope", "Ape", "Armadillo", "Donkey", "Baboon", "Badger",
"Barracuda", "Bat", "Bear", "Beaver", "Bee", "Bison", "Boar", "Bush", "Butterfly", "Camel", "Calf",
"Cat", "Kitten", "Cattle", "Chamois", "Cheetah", "Chicken", "Chick", "Chimpanzee", "Infant", "Empress", "Troop",
Expand Down Expand Up @@ -196,10 +196,18 @@ const char* const CNickGen::m_szNouns[] = {
"Vampire", "Parasite", "Tramp", "Bum", "Hobo", "Hitchhiker", "Deadbeat", "Acrobat",
};

constexpr auto numAdjectives = std::size(szAdjectives);
constexpr auto numNouns = std::size(szNouns);
constexpr auto maxNum = 100;

SString CNickGen::GetRandomNickname()
{
srand((unsigned int)time(NULL));
int iAdjective = rand() % NICKGEN_NUM_ADJECTIVES;
int iNoun = rand() % NICKGEN_NUM_NOUNS;
return SString("%s%s%i", m_szAdjectives[iAdjective], m_szNouns[iNoun], rand() % 100);
std::random_device rd;
std::mt19937 gen(rd());

std::uniform_int_distribution<int> adjectiveDist(0, numAdjectives - 1);
std::uniform_int_distribution<int> nounDist(0, numNouns - 1);
std::uniform_int_distribution<int> numDist(0, maxNum);

return SString("%s%s%i", szAdjectives[adjectiveDist(gen)], szNouns[nounDist(gen)], numDist(gen));
}
5 changes: 0 additions & 5 deletions Client/core/CNickGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@

#pragma once

#define NICKGEN_NUM_ADJECTIVES 1048
#define NICKGEN_NUM_NOUNS 934

class CNickGen
{
public:
static const char* const m_szAdjectives[NICKGEN_NUM_ADJECTIVES];
static const char* const m_szNouns[NICKGEN_NUM_NOUNS];
static SString GetRandomNickname();
};
30 changes: 2 additions & 28 deletions Client/core/CSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,14 +918,8 @@ void CSettings::CreateGUI()
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 - 20.0f));
m_pCheckBoxBrowserGPUEnabled->SetPosition(CVector2D(vecTemp.fX + 300.0f, vecTemp.fY - 25.0f));
m_pCheckBoxBrowserGPUEnabled->AutoSize(NULL, 20.0f);
m_pCheckBoxBrowserGPUEnabled->SetClickHandler(GUI_CALLBACK(&CSettings::OnGPUSettingChanged, this));

m_pCheckBoxBrowserGPUCompositingEnabled =
reinterpret_cast<CGUICheckBox*>(pManager->CreateCheckBox(m_pTabBrowser, _("Enable GPU compositing"), true));
m_pCheckBoxBrowserGPUCompositingEnabled->SetPosition(CVector2D(vecTemp.fX + 300.0f, vecTemp.fY));
m_pCheckBoxBrowserGPUCompositingEnabled->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));
Expand Down Expand Up @@ -3300,12 +3294,6 @@ void CSettings::LoadData()
CVARS_GET("browser_enable_gpu", bVar);
m_pCheckBoxBrowserGPUEnabled->SetSelected(bVar);

if (!bVar)
m_pCheckBoxBrowserGPUCompositingEnabled->SetEnabled(false);

CVARS_GET("browser_enable_gpu_compositing", bVar);
m_pCheckBoxBrowserGPUCompositingEnabled->SetSelected(bVar);

ReloadBrowserLists();
}

Expand Down Expand Up @@ -3736,13 +3724,6 @@ void CSettings::SaveData()
bool bBrowserGPUSettingChanged = (bBrowserGPUSetting != bBrowserGPUEnabled);
CVARS_SET("browser_enable_gpu", bBrowserGPUSetting);

bool bBrowserGPUCompositingEnabled = false;
CVARS_GET("browser_enable_gpu_compositing", bBrowserGPUCompositingEnabled);

bool bBrowserGPUCompositingSetting = m_pCheckBoxBrowserGPUCompositingEnabled->GetSelected();
bool bBrowserGPUCompositingSettingChanged = (bBrowserGPUCompositingSetting != bBrowserGPUCompositingEnabled);
CVARS_SET("browser_enable_gpu_compositing", bBrowserGPUCompositingSetting);

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

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

// Ask to restart?
if (bIsVideoModeChanged || bIsAntiAliasingChanged || bIsCustomizedSAFilesChanged || processsDPIAwareChanged || bBrowserGPUSettingChanged ||
bBrowserGPUCompositingSettingChanged)
if (bIsVideoModeChanged || bIsAntiAliasingChanged || bIsCustomizedSAFilesChanged || processsDPIAwareChanged || bBrowserGPUSettingChanged)
ShowRestartQuestion();
else if (CModManager::GetSingleton().IsLoaded() && bBrowserSettingChanged)
ShowDisconnectQuestion();
Expand Down Expand Up @@ -4906,9 +4886,3 @@ bool CSettings::IsActive()
{
return m_pWindow->IsActive();
}

bool CSettings::OnGPUSettingChanged(CGUIElement* pElement)
{
m_pCheckBoxBrowserGPUCompositingEnabled->SetEnabled(m_pCheckBoxBrowserGPUEnabled->GetSelected());
return true;
}
2 changes: 0 additions & 2 deletions Client/core/CSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ class CSettings
CGUIGridList* m_pGridBrowserWhitelist;
CGUIButton* m_pButtonBrowserWhitelistRemove;
CGUICheckBox* m_pCheckBoxBrowserGPUEnabled;
CGUICheckBox* m_pCheckBoxBrowserGPUCompositingEnabled;
bool m_bBrowserListsChanged;
bool m_bBrowserListsLoadEnabled;

Expand Down Expand Up @@ -384,7 +383,6 @@ class CSettings
bool OnBrowserWhitelistRemove(CGUIElement* pElement);
bool OnBrowserWhitelistDomainAddFocused(CGUIElement* pElement);
bool OnBrowserWhitelistDomainAddDefocused(CGUIElement* pElement);
bool OnGPUSettingChanged(CGUIElement* pElement);

bool OnMouseDoubleClick(CGUIMouseEventArgs Args);

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
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
20 changes: 20 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 @@ -156,6 +157,7 @@ void CLuaVehicleDefs::LoadFunctions()
{"setVehicleWheelScale", ArgumentParser<SetVehicleWheelScale>},
{"setVehicleModelWheelSize", ArgumentParser<SetVehicleModelWheelSize>},
{"spawnVehicleFlyingComponent", ArgumentParser<SpawnVehicleFlyingComponent>},
{"setVehicleSmokeTrailEnabled", ArgumentParser<SetSmokeTrailEnabled>},
};

// Add functions
Expand Down Expand Up @@ -244,6 +246,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 @@ -292,6 +295,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 @@ -4340,3 +4344,19 @@ bool CLuaVehicleDefs::SpawnVehicleFlyingComponent(CClientVehicle* const vehicle,

return vehicle->SpawnFlyingComponent(partNodeIndex, collisionType, removalTime.value_or(-1));
}

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 @@ -181,4 +181,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;
};
21 changes: 20 additions & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ void CLuaWorldDefs::LoadFunctions()
{"restoreWorldModel", RestoreWorldBuilding},
{"setTimeFrozen", ArgumentParser<SetTimeFrozen>},
{"setVolumetricShadowsEnabled", ArgumentParser<SetVolumetricShadowsEnabled>},
{"setDynamicPedShadowsEnabled", ArgumentParser<SetDynamicPedShadowsEnabled>},

// World create funcs
{"createSWATRope", CreateSWATRope},
Expand All @@ -131,6 +132,7 @@ void CLuaWorldDefs::LoadFunctions()
{"resetTimeFrozen", ArgumentParser<ResetTimeFrozen>},
{"resetVolumetricShadows", ArgumentParser<ResetVolumetricShadows>},
{"resetWorldProperties", ArgumentParser<ResetWorldProperties>},
{"resetDynamicPedShadows", ArgumentParser<ResetDynamicPedShadows>},

// World check funcs
{"areTrafficLightsLocked", AreTrafficLightsLocked},
Expand All @@ -139,7 +141,8 @@ void CLuaWorldDefs::LoadFunctions()
{"isWorldSpecialPropertyEnabled", ArgumentParserWarn<false, IsWorldSpecialPropertyEnabled>},
{"isGarageOpen", IsGarageOpen},
{"isTimeFrozen", ArgumentParser<IsTimeFrozen>},
{"isVolumetricShadowsEnabled", ArgumentParser<IsVolumetricShadowsEnabled>}};
{"isVolumetricShadowsEnabled", ArgumentParser<IsVolumetricShadowsEnabled>},
{"isDynamicPedShadowsEnabled", ArgumentParser<IsDynamicPedShadowsEnabled>}};

// Add functions
for (const auto& [name, func] : functions)
Expand Down Expand Up @@ -2278,3 +2281,19 @@ void CLuaWorldDefs::ResetWorldProperties(std::optional<bool> resetSpecialWorldPr
{
g_pClientGame->ResetWorldProperties(ResetWorldPropsInfo{resetSpecialWorldProperties.value_or(true), resetWorldProperties.value_or(true), resetWeatherProperties.value_or(true), resetLODs.value_or(true), resetSounds.value_or(true)});
}

bool CLuaWorldDefs::SetDynamicPedShadowsEnabled(bool enable)
{
g_pGame->GetSettings()->SetDynamicPedShadowsEnabled(enable);
return true;
}

bool CLuaWorldDefs::IsDynamicPedShadowsEnabled() noexcept
{
return g_pGame->GetSettings()->IsDynamicPedShadowsEnabled();
}

bool CLuaWorldDefs::ResetDynamicPedShadows() noexcept
{
return g_pGame->GetSettings()->ResetDynamicPedShadows();
}
5 changes: 4 additions & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ class CLuaWorldDefs : public CLuaDefs
static bool ResetVolumetricShadows() noexcept;

static void ResetWorldProperties(std::optional<bool> resetSpecialWorldProperties, std::optional<bool> resetWorldProperties, std::optional<bool> resetWeatherProperties, std::optional<bool> resetLODs, std::optional<bool> resetSounds) noexcept;


static bool SetDynamicPedShadowsEnabled(bool enable);
static bool IsDynamicPedShadowsEnabled() noexcept;
static bool ResetDynamicPedShadows() noexcept;
};

Loading

0 comments on commit c2ac31f

Please sign in to comment.