Skip to content

Commit

Permalink
Merge branch 'master' into feature/setElementOnFire
Browse files Browse the repository at this point in the history
  • Loading branch information
FileEX authored Nov 22, 2024
2 parents ab6bea5 + 6683086 commit e3bbba4
Show file tree
Hide file tree
Showing 112 changed files with 3,274 additions and 2,305 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;
};
5 changes: 4 additions & 1 deletion Client/core/CClientVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ void CClientVariables::ValidateValues()
ClampValue("mtavolume", 0.0f, 1.0f);
ClampValue("voicevolume", 0.0f, 1.0f);
ClampValue("mapalpha", 0, 255);
ClampValue("mapimage", 0, 1);
}

void CClientVariables::LoadDefaults()
Expand Down Expand Up @@ -313,7 +314,8 @@ void CClientVariables::LoadDefaults()
DEFAULT("mastervolume", 1.0f); // master volume
DEFAULT("mtavolume", 1.0f); // custom sound's volume
DEFAULT("voicevolume", 1.0f); // voice chat output volume
DEFAULT("mapalpha", 155); // map alpha
DEFAULT("mapalpha", 155); // player map alpha
DEFAULT("mapimage", 0); // player map image
DEFAULT("browser_speed", 1); // Browser speed
DEFAULT("single_download", 0); // Single connection for downloads
DEFAULT("packet_tag", 0); // Tag network packets
Expand Down Expand Up @@ -358,6 +360,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
1 change: 0 additions & 1 deletion Client/core/CConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class CConsole : public CConsoleInterface
bool IsInputActive();
void ActivateInput();

void HandleTextAccepted(bool bHandled);
void GetCommandInfo(const std::string& strIn, std::string& strCmdOut, std::string& strCmdLineOut);

void ResetHistoryChanges();
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
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();
};
10 changes: 9 additions & 1 deletion Client/core/CQueryReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ SQueryInfo CQueryReceiver::GetServerResponse()

// Recover server ping status if present
const SString strPingStatus = strBuildNumber.Right(strBuildNumber.length() - strlen(strBuildNumber) - 1);
CCore::GetSingleton().GetNetwork()->UpdatePingStatus(*strPingStatus, info.players);
CCore::GetSingleton().GetNetwork()->UpdatePingStatus(*strPingStatus, info.players, info.isStatusVerified);

// Recover server http port if present
const SString strNetRoute = strPingStatus.Right(strPingStatus.length() - strlen(strPingStatus) - 1);
Expand Down Expand Up @@ -213,7 +213,15 @@ SQueryInfo CQueryReceiver::GetServerResponse()
return info;
}
}

InvalidateSocket();

if (info.players > info.playerSlot)
{
info.players = info.playerSlot;
info.isStatusVerified = false;
}

info.containingInfo = true;
}

Expand Down
2 changes: 2 additions & 0 deletions Client/core/CQueryReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct SQueryInfo
{
containingInfo = false;
port = 0;
isStatusVerified = true;
isPassworded = false;
serials = false;
players = 0;
Expand All @@ -33,6 +34,7 @@ struct SQueryInfo
SString gameType;
SString mapName;
SString versionText;
bool isStatusVerified;
bool isPassworded;
bool serials;
ushort players;
Expand Down
Loading

0 comments on commit e3bbba4

Please sign in to comment.