Server browser cleanup

* Moved server utility to dedicated class shared by browser panel and UI script VM.
* Additional code improvements and optimizations.
This commit is contained in:
Kawe Mazidjatari 2022-08-14 15:43:49 +02:00
parent 27f9d6b110
commit bf3b7bdace
15 changed files with 328 additions and 181 deletions

View File

@ -13,7 +13,6 @@
#include "engine/server/sv_rcon.h"
#else
#include "vgui/vgui_debugpanel.h"
#include "gameui/IConsole.h"
#endif // !DEDICATED

View File

@ -4,52 +4,22 @@
#include "windows/resource.h"
#include "networksystem/serverlisting.h"
#include "networksystem/pylon.h"
#include "public/isurfacesystem.h"
enum class eHostStatus
class CBrowser : public ISurface
{
NOT_HOSTING,
HOSTING
};
enum class EServerVisibility
{
OFFLINE,
HIDDEN,
PUBLIC
};
class CBrowser
{
private:
bool m_bInitialized = false;
bool m_bModernTheme = false;
bool m_bLegacyTheme = false;
bool m_bDefaultTheme = false;
public:
////////////////////
// Enum Vars //
////////////////////
eHostStatus eHostingStatus = eHostStatus::NOT_HOSTING;
EServerVisibility eServerVisibility = EServerVisibility::OFFLINE;
public:
////////////////////
// Funcs //
////////////////////
CBrowser(void);
~CBrowser(void);
virtual ~CBrowser(void);
void Draw(void);
void Think(void);
virtual bool Init(void);
virtual void Think(void);
void BasePanel(void);
virtual void RunFrame(void);
virtual void DrawSurface(void);
void BrowserPanel(void);
void RefreshServerList(void);
void GetServerList(void);
void ConnectToServer(const string& svIp, const string& svPort, const string& svNetKey);
void ConnectToServer(const string& svServer, const string& svNetKey);
void HiddenServersModal(void);
void HostPanel(void);
@ -57,38 +27,36 @@ public:
void UpdateHostingStatus(void);
void SendHostingPostRequest(void);
void ProcessCommand(const char* pszCommand);
void LaunchServer(void);
void ProcessCommand(const char* pszCommand) const;
void SettingsPanel(void);
void RegenerateEncryptionKey(void) const;
void ChangeEncryptionKey(const std::string& svNetKey) const;
void SetStyleVar(void);
virtual void SetStyleVar(void);
////////////////////
// Server Browser //
////////////////////
public:
bool m_bActivate = false;
float m_flFadeAlpha = 0.f;
const char* m_pszBrowserTitle = nullptr;
vector<NetGameServer_t> m_vServerList;
ImGuiTextFilter m_imServerBrowserFilter;
bool m_bActivate = false;
private:
bool m_bInitialized = false;
bool m_bModernTheme = false;
bool m_bLegacyTheme = false;
bool m_bDefaultTheme = false;
char m_szServerAddressBuffer[256] = { '\0' };
char m_szServerEncKeyBuffer[30] = { '\0' };
string m_svServerListMessage;
float m_flFadeAlpha = 0.f;
ID3D11ShaderResourceView* m_idLockedIcon = nullptr;
MODULERESOURCE m_rLockedIconBlob;
////////////////////
// Settings //
// Server List //
////////////////////
ImGuiTextFilter m_imServerBrowserFilter;
string m_svServerListMessage;
string m_szMatchmakingHostName;
////////////////////
// Host Server //
////////////////////
NetGameServer_t m_Server;
string m_svHostRequestMessage;
string m_svHostToken;
ImVec4 m_HostRequestMessageColor = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
@ -98,11 +66,7 @@ public:
////////////////////
string m_svHiddenServerToken;
string m_svHiddenServerRequestMessage;
ImVec4 m_ivHiddenServerMessageColor = ImVec4(0.00f, 1.00f, 0.00f, 1.00f);
/* Texture */
ID3D11ShaderResourceView* m_idLockedIcon = nullptr;
MODULERESOURCE m_rLockedIconBlob;
ImVec4 m_ivHiddenServerMessageColor = ImVec4(0.00f, 1.00f, 0.00f, 1.00f);
};
extern CBrowser* g_pBrowser;

View File

@ -58,7 +58,7 @@ CConsole::~CConsole(void)
// Purpose: game console setup
// Output : true on success, false otherwise
//-----------------------------------------------------------------------------
bool CConsole::Setup(void)
bool CConsole::Init(void)
{
SetStyleVar();
return LoadFlagIcons();
@ -67,11 +67,11 @@ bool CConsole::Setup(void)
//-----------------------------------------------------------------------------
// Purpose: game console main render loop
//-----------------------------------------------------------------------------
void CConsole::Draw(void)
void CConsole::RunFrame(void)
{
if (!m_bInitialized)
{
Setup();
Init();
m_bInitialized = true;
}
@ -101,7 +101,7 @@ void CConsole::Draw(void)
}
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(618, 524)); nVars++;
BasePanel();
DrawSurface();
ImGui::PopStyleVar(nVars);
}
@ -182,7 +182,7 @@ void CConsole::Think(void)
// Purpose: draws the console's main surface
// Input : *bDraw -
//-----------------------------------------------------------------------------
void CConsole::BasePanel(void)
void CConsole::DrawSurface(void)
{
if (!ImGui::Begin(m_pszConsoleLabel, &m_bActivate))
{

View File

@ -2,36 +2,54 @@
#ifndef DEDICATED
#include "common/sdkdefs.h"
#include "windows/resource.h"
#include "public/isurfacesystem.h"
#include "thirdparty/imgui/include/imgui_logger.h"
struct CSuggest
class CConsole : public ISurface
{
CSuggest(const string& svName, int nFlags)
{
m_svName = svName;
m_nFlags = nFlags;
}
bool operator==(const string& a) const
{
return m_svName.compare(a) == 0;
}
bool operator<(const CSuggest& a) const
{
return m_svName < a.m_svName;
}
string m_svName;
int m_nFlags;
};
public:
///////////////////////////////////////////////////////////////////////////
CConsole(void);
virtual ~CConsole(void);
virtual bool Init(void);
virtual void Think(void);
virtual void RunFrame(void);
virtual void DrawSurface(void);
void OptionsPanel(void);
void SuggestPanel(void);
bool AutoComplete(void);
void ResetAutoComplete(void);
void ClearAutoComplete(void);
void FindFromPartial(void);
void ProcessCommand(const char* pszCommand);
void BuildSummary(string svConVar = "");
bool LoadFlagIcons(void);
int ColorCodeFlags(int nFlags) const;
int TextEditCallback(ImGuiInputTextCallbackData* pData);
static int TextEditCallbackStub(ImGuiInputTextCallbackData* pData);
///////////////////////////////////////////////////////////////////////////
void AddLog(const ConLog_t& conLog);
void AddLog(const ImVec4& color, const char* fmt, ...) IM_FMTARGS(2);
void ClearLog(void);
///////////////////////////////////////////////////////////////////////////
virtual void SetStyleVar(void);
class CConsole
{
private:
///////////////////////////////////////////////////////////////////////////
const char* m_pszConsoleLabel = nullptr;
const char* m_pszLoggingLabel = nullptr;
char m_szInputBuf[512] = { '\0' };
char m_szSummary[512] = { '\0' };
char m_szWindowLabel[512] = { '\0' };
const char* m_pszConsoleLabel = nullptr;
const char* m_pszLoggingLabel = nullptr;
vector<string> m_vCommands;
vector<string> m_vHistory;
@ -63,12 +81,12 @@ private:
CTextLogger m_Logger;
ImGuiInputTextFlags m_nInputFlags =
ImGuiInputTextFlags_AutoCaretEnd |
ImGuiInputTextFlags_CallbackCompletion |
ImGuiInputTextFlags_CallbackHistory |
ImGuiInputTextFlags_CallbackAlways |
ImGuiInputTextFlags_CallbackEdit |
ImGuiInputTextFlags_EnterReturnsTrue |
ImGuiInputTextFlags_AutoCaretEnd |
ImGuiInputTextFlags_CallbackCompletion |
ImGuiInputTextFlags_CallbackHistory |
ImGuiInputTextFlags_CallbackAlways |
ImGuiInputTextFlags_CallbackEdit |
ImGuiInputTextFlags_EnterReturnsTrue |
ImGuiInputTextFlags_NoUndoRedo;
ImGuiWindowFlags m_nSuggestFlags =
@ -80,47 +98,12 @@ private:
ImGuiWindowFlags_AlwaysHorizontalScrollbar;
ImGuiWindowFlags m_nLoggingFlags =
ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_HorizontalScrollbar |
ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_HorizontalScrollbar |
ImGuiWindowFlags_AlwaysVerticalScrollbar;
public:
bool m_bActivate = false;
vector<CSuggest> m_vsvCommandBases;
///////////////////////////////////////////////////////////////////////////
CConsole(void);
~CConsole(void);
bool Setup(void);
void Draw(void);
void Think(void);
void BasePanel(void);
void OptionsPanel(void);
void SuggestPanel(void);
bool AutoComplete(void);
void ResetAutoComplete(void);
void ClearAutoComplete(void);
void FindFromPartial(void);
void ProcessCommand(const char* pszCommand);
void BuildSummary(string svConVar = "");
bool LoadFlagIcons(void);
int ColorCodeFlags(int nFlags) const;
int TextEditCallback(ImGuiInputTextCallbackData* pData);
static int TextEditCallbackStub(ImGuiInputTextCallbackData* pData);
///////////////////////////////////////////////////////////////////////////
void AddLog(const ConLog_t& conLog);
void AddLog(const ImVec4& color, const char* fmt, ...) IM_FMTARGS(2);
void ClearLog(void);
///////////////////////////////////////////////////////////////////////////
void SetStyleVar(void);
};
///////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,98 @@
//=============================================================================//
//
// Purpose:
//
//-----------------------------------------------------------------------------
//
//=============================================================================//
#include "core/stdafx.h"
#include "tier1/cmd.h"
#include "tier1/cvar.h"
#include "engine/net.h"
#include "vpc/keyvalues.h"
#include "pylon.h"
#include "listmanager.h"
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CServerListManager::CServerListManager(void)
: m_HostingStatus(EHostStatus_t::NOT_HOSTING)
, m_ServerVisibility(EServerVisibility_t::OFFLINE)
{
}
//-----------------------------------------------------------------------------
// Purpose: get server list from pylon.
// Input : &svMessage -
//-----------------------------------------------------------------------------
void CServerListManager::GetServerList(string& svMessage)
{
m_vServerList.clear();
m_vServerList = g_pMasterServer->GetServerList(svMessage);
}
//-----------------------------------------------------------------------------
// Purpose: Launch server with given parameters
//-----------------------------------------------------------------------------
void CServerListManager::LaunchServer(void) const
{
#ifndef CLIENT_DLL
DevMsg(eDLL_T::ENGINE, "Starting server with name: \"%s\" map: \"%s\" playlist: \"%s\"\n", m_Server.m_svHostName.c_str(), m_Server.m_svMapName.c_str(), m_Server.m_svPlaylist.c_str());
/*
* Playlist gets parsed in two instances, first in KeyValues::ParsePlaylists with all the neccessary values.
* Then when you would normally call launchplaylist which calls StartPlaylist it would cmd call mp_gamemode which parses the gamemode specific part of the playlist..
*/
KeyValues::ParsePlaylists(m_Server.m_svPlaylist.c_str());
mp_gamemode->SetValue(m_Server.m_svPlaylist.c_str());
ProcessCommand(fmt::format("{:s} \"{:s}\"", "map", m_Server.m_svMapName).c_str());
#endif // !CLIENT_DLL
}
//-----------------------------------------------------------------------------
// Purpose: connects to specified server
// Input : &svIp -
// &svPort -
// &svNetKey -
//-----------------------------------------------------------------------------
void CServerListManager::ConnectToServer(const string& svIp, const string& svPort, const string& svNetKey) const
{
printf("%s %s\n", svIp.c_str(), svPort.c_str());
if (!svNetKey.empty())
{
NET_SetKey(svNetKey);
}
ProcessCommand(fmt::format("{:s} \"[{:s}]:{:s}\"", "connect", svIp, svPort).c_str());
}
//-----------------------------------------------------------------------------
// Purpose: connects to specified server
// Input : &svServer -
// &svNetKey -
//-----------------------------------------------------------------------------
void CServerListManager::ConnectToServer(const string& svServer, const string& svNetKey) const
{
if (!svNetKey.empty())
{
NET_SetKey(svNetKey);
}
ProcessCommand(fmt::format("{:s} \"{:s}\"", "connect", svServer).c_str());
}
//-----------------------------------------------------------------------------
// Purpose: executes submitted commands in a separate thread
// Input : *pszCommand -
//-----------------------------------------------------------------------------
void CServerListManager::ProcessCommand(const char* pszCommand) const
{
Cbuf_AddText(Cbuf_GetCurrentPlayer(), pszCommand, cmd_source_t::kCommandSrcCode);
std::thread t(Cbuf_Execute);
t.detach(); // Detatch from caller thread (would otherwise deadlock!).
}
CServerListManager* g_pServerListManager = new CServerListManager();

View File

@ -0,0 +1,39 @@
#ifndef LISTMANAGER_H
#define LISTMANAGER_H
#include <networksystem/serverlisting.h>
enum EHostStatus_t
{
NOT_HOSTING,
HOSTING
};
enum EServerVisibility_t
{
OFFLINE,
HIDDEN,
PUBLIC
};
class CServerListManager
{
public:
CServerListManager();
void GetServerList(string& svMessage);
void LaunchServer(void) const;
void ConnectToServer(const string& svIp, const string& svPort, const string& svNetKey) const;
void ConnectToServer(const string& svServer, const string& svNetKey) const;
void ProcessCommand(const char* pszCommand) const;
EHostStatus_t m_HostingStatus;
EServerVisibility_t m_ServerVisibility;
NetGameServer_t m_Server;
vector<NetGameServer_t> m_vServerList;
};
extern CServerListManager* g_pServerListManager;
#endif // LISTMANAGER_H

View File

@ -15,6 +15,7 @@
#endif
#include <squirrel/sqinit.h>
#include <networksystem/pylon.h>
#include <networksystem/listmanager.h>
#include <public/edict.h>
//-----------------------------------------------------------------------------
@ -34,7 +35,7 @@ void KeepAliveToPylon()
{
hostname->GetString(),
hostdesc->GetString(),
sv_pylonVisibility->GetInt() == 1,
sv_pylonVisibility->GetInt() == EServerVisibility_t::HIDDEN,
g_pHostState->m_levelName,
mp_gamemode->GetString(),
hostip->GetString(),
@ -56,7 +57,7 @@ void KeepAliveToPylon()
//-----------------------------------------------------------------------------
// Purpose: returns a vector of hosted servers.
//-----------------------------------------------------------------------------
vector<NetGameServer_t> CPylon::GetServersList(string& svOutMessage)
vector<NetGameServer_t> CPylon::GetServerList(string& svOutMessage)
{
vector<NetGameServer_t> vslList{};

View File

@ -11,7 +11,7 @@ public:
m_HttpClient.set_connection_timeout(10);
}
vector<NetGameServer_t> GetServersList(string& svOutMessage);
vector<NetGameServer_t> GetServerList(string& svOutMessage);
bool PostServerHost(string& svOutMessage, string& svOutToken, const NetGameServer_t& slServerListing);
bool GetServerByToken(NetGameServer_t& slOutServer, string& svOutMessage, const string& svToken);
bool GetClientIsBanned(const string& svIpAddress, uint64_t nOriginID, string& svOutErrCl);

View File

@ -0,0 +1,34 @@
#ifndef ISURFACESYSTEM_H
#define ISURFACESYSTEM_H
class ISurface
{
public:
virtual ~ISurface() { };
virtual bool Init() = 0;
virtual void Think() = 0;
virtual void RunFrame() = 0;
virtual void DrawSurface() = 0;
virtual void SetStyleVar() = 0;
};
struct CSuggest
{
CSuggest(const string& svName, int nFlags)
{
m_svName = svName;
m_nFlags = nFlags;
}
bool operator==(const string& a) const
{
return m_svName.compare(a) == 0;
}
bool operator<(const CSuggest& a) const
{
return m_svName < a.m_svName;
}
string m_svName;
int m_nFlags;
};
#endif // ISURFACESYSTEM_H

View File

@ -22,9 +22,8 @@
#include "squirrel/sqapi.h"
#include "squirrel/sqinit.h"
#include "networksystem/pylon.h"
#ifndef DEDICATED
#include "gameui/IBrowser.h" // TODO: create dedicated class for exposing server utils to ImGui and UI VM.
#include "networksystem/listmanager.h"
#endif // !DEDICATED
namespace VSquirrel
@ -130,14 +129,15 @@ namespace VSquirrel
SQRESULT GetServerName(HSQUIRRELVM v)
{
SQInteger iServer = sq_getinteger(v, 1);
if (iServer >= static_cast<SQInteger>(g_pBrowser->m_vServerList.size()))
SQInteger iCount = static_cast<SQInteger>(g_pServerListManager->m_vServerList.size());
if (iServer >= iCount)
{
v_SQVM_RaiseError(v, "Index must be less than %i.\n",
static_cast<SQInteger>(g_pBrowser->m_vServerList.size()));
v_SQVM_RaiseError(v, "Index must be less than %i.\n", iCount);
return SQ_ERROR;
}
string svServerName = g_pBrowser->m_vServerList[iServer].m_svHostName;
string svServerName = g_pServerListManager->m_vServerList[iServer].m_svHostName;
sq_pushstring(v, svServerName.c_str(), -1);
return SQ_OK;
@ -149,14 +149,15 @@ namespace VSquirrel
SQRESULT GetServerDescription(HSQUIRRELVM v)
{
SQInteger iServer = sq_getinteger(v, 1);
if (iServer >= static_cast<SQInteger>(g_pBrowser->m_vServerList.size()))
SQInteger iCount = static_cast<SQInteger>(g_pServerListManager->m_vServerList.size());
if (iServer >= iCount)
{
v_SQVM_RaiseError(v, "Index must be less than %i.\n",
static_cast<SQInteger>(g_pBrowser->m_vServerList.size()));
v_SQVM_RaiseError(v, "Index must be less than %i.\n", iCount);
return SQ_ERROR;
}
string svServerDescription = g_pBrowser->m_vServerList[iServer].m_svDescription;
string svServerDescription = g_pServerListManager->m_vServerList[iServer].m_svDescription;
sq_pushstring(v, svServerDescription.c_str(), -1);
return SQ_OK;
@ -168,14 +169,15 @@ namespace VSquirrel
SQRESULT GetServerMap(HSQUIRRELVM v)
{
SQInteger iServer = sq_getinteger(v, 1);
if (iServer >= static_cast<SQInteger>(g_pBrowser->m_vServerList.size()))
SQInteger iCount = static_cast<SQInteger>(g_pServerListManager->m_vServerList.size());
if (iServer >= iCount)
{
v_SQVM_RaiseError(v, "Index must be less than %i.\n",
static_cast<SQInteger>(g_pBrowser->m_vServerList.size()));
v_SQVM_RaiseError(v, "Index must be less than %i.\n", iCount);
return SQ_ERROR;
}
string svServerMapName = g_pBrowser->m_vServerList[iServer].m_svMapName;
string svServerMapName = g_pServerListManager->m_vServerList[iServer].m_svMapName;
sq_pushstring(v, svServerMapName.c_str(), -1);
return SQ_OK;
@ -187,14 +189,15 @@ namespace VSquirrel
SQRESULT GetServerPlaylist(HSQUIRRELVM v)
{
SQInteger iServer = sq_getinteger(v, 1);
if (iServer >= static_cast<SQInteger>(g_pBrowser->m_vServerList.size()))
SQInteger iCount = static_cast<SQInteger>(g_pServerListManager->m_vServerList.size());
if (iServer >= iCount)
{
v_SQVM_RaiseError(v, "Index must be less than %i.\n",
static_cast<SQInteger>(g_pBrowser->m_vServerList.size()));
v_SQVM_RaiseError(v, "Index must be less than %i.\n", iCount);
return SQ_ERROR;
}
string svServerPlaylist = g_pBrowser->m_vServerList[iServer].m_svPlaylist;
string svServerPlaylist = g_pServerListManager->m_vServerList[iServer].m_svPlaylist;
sq_pushstring(v, svServerPlaylist.c_str(), -1);
return SQ_OK;
@ -206,14 +209,15 @@ namespace VSquirrel
SQRESULT GetServerCurrentPlayers(HSQUIRRELVM v)
{
SQInteger iServer = sq_getinteger(v, 1);
if (iServer >= static_cast<SQInteger>(g_pBrowser->m_vServerList.size()))
SQInteger iCount = static_cast<SQInteger>(g_pServerListManager->m_vServerList.size());
if (iServer >= iCount)
{
v_SQVM_RaiseError(v, "Index must be less than %i.\n",
static_cast<SQInteger>(g_pBrowser->m_vServerList.size()));
v_SQVM_RaiseError(v, "Index must be less than %i.\n", iCount);
return SQ_ERROR;
}
sq_pushinteger(v, strtol(g_pBrowser->m_vServerList[iServer].m_svPlayerCount.c_str(), NULL, NULL));
sq_pushinteger(v, strtol(g_pServerListManager->m_vServerList[iServer].m_svPlayerCount.c_str(), NULL, NULL));
return SQ_OK;
}
@ -224,14 +228,15 @@ namespace VSquirrel
SQRESULT GetServerMaxPlayers(HSQUIRRELVM v)
{
SQInteger iServer = sq_getinteger(v, 1);
if (iServer >= static_cast<SQInteger>(g_pBrowser->m_vServerList.size()))
SQInteger iCount = static_cast<SQInteger>(g_pServerListManager->m_vServerList.size());
if (iServer >= iCount)
{
v_SQVM_RaiseError(v, "Index must be less than %i.\n",
static_cast<SQInteger>(g_pBrowser->m_vServerList.size()));
v_SQVM_RaiseError(v, "Index must be less than %i.\n", iCount);
return SQ_ERROR;
}
sq_pushinteger(v, strtol(g_pBrowser->m_vServerList[iServer].m_svMaxPlayers.c_str(), NULL, NULL));
sq_pushinteger(v, strtol(g_pServerListManager->m_vServerList[iServer].m_svMaxPlayers.c_str(), NULL, NULL));
return SQ_OK;
}
@ -241,8 +246,10 @@ namespace VSquirrel
//-----------------------------------------------------------------------------
SQRESULT GetServerCount(HSQUIRRELVM v)
{
g_pBrowser->GetServerList(); // Refresh svListing list.
sq_pushinteger(v, g_pBrowser->m_vServerList.size());
string svMessage;
g_pServerListManager->GetServerList(svMessage); // Refresh svListing list.
sq_pushinteger(v, g_pServerListManager->m_vServerList.size());
return SQ_OK;
}
@ -263,7 +270,6 @@ namespace VSquirrel
};
R5RPromoData ePromoIndex = static_cast<R5RPromoData>(sq_getinteger(v, 1));
string svPromo;
switch (ePromoIndex)
@ -306,7 +312,6 @@ namespace VSquirrel
}
sq_pushstring(v, svPromo.c_str(), -1);
return SQ_OK;
}
@ -316,17 +321,17 @@ namespace VSquirrel
SQRESULT SetEncKeyAndConnect(HSQUIRRELVM v)
{
SQInteger iServer = sq_getinteger(v, 1);
if (iServer >= static_cast<SQInteger>(g_pBrowser->m_vServerList.size()))
SQInteger iCount = static_cast<SQInteger>(g_pServerListManager->m_vServerList.size());
if (iServer >= iCount)
{
v_SQVM_RaiseError(v, "Index must be less than %i.\n",
static_cast<SQInteger>(g_pBrowser->m_vServerList.size()));
v_SQVM_RaiseError(v, "Index must be less than %i.\n", iCount);
return SQ_ERROR;
}
// !TODO: Create glue class instead.
g_pBrowser->ConnectToServer(g_pBrowser->m_vServerList[iServer].m_svIpAddress,
g_pBrowser->m_vServerList[iServer].m_svGamePort,
g_pBrowser->m_vServerList[iServer].m_svEncryptionKey);
g_pServerListManager->ConnectToServer(g_pServerListManager->m_vServerList[iServer].m_svIpAddress,
g_pServerListManager->m_vServerList[iServer].m_svGamePort,
g_pServerListManager->m_vServerList[iServer].m_svEncryptionKey);
return SQ_OK;
}
@ -340,20 +345,20 @@ namespace VSquirrel
string svServerDescription = sq_getstring(v, 2);
string svServerMapName = sq_getstring(v, 3);
string svServerPlaylist = sq_getstring(v, 4);
EServerVisibility eServerVisibility = static_cast<EServerVisibility>(sq_getinteger(v, 5));
EServerVisibility_t eServerVisibility = static_cast<EServerVisibility_t>(sq_getinteger(v, 5));
if (svServerName.empty() || svServerMapName.empty() || svServerPlaylist.empty())
return SQ_OK;
// Adjust browser settings.
g_pBrowser->m_Server.m_svHostName = svServerName;
g_pBrowser->m_Server.m_svDescription = svServerDescription;
g_pBrowser->m_Server.m_svMapName = svServerMapName;
g_pBrowser->m_Server.m_svPlaylist = svServerPlaylist;
g_pBrowser->eServerVisibility = eServerVisibility;
g_pServerListManager->m_Server.m_svHostName = svServerName;
g_pServerListManager->m_Server.m_svDescription = svServerDescription;
g_pServerListManager->m_Server.m_svMapName = svServerMapName;
g_pServerListManager->m_Server.m_svPlaylist = svServerPlaylist;
g_pServerListManager->m_ServerVisibility = eServerVisibility;
// Launch server.
g_pBrowser->LaunchServer();
g_pServerListManager->LaunchServer();
return SQ_OK;
}
@ -370,7 +375,7 @@ namespace VSquirrel
bool result = g_pMasterServer->GetServerByToken(svListing, svHiddenServerRequestMessage, svToken); // Send szToken connect request.
if (result)
{
g_pBrowser->ConnectToServer(svListing.m_svIpAddress, svListing.m_svGamePort, svListing.m_svEncryptionKey);
g_pServerListManager->ConnectToServer(svListing.m_svIpAddress, svListing.m_svGamePort, svListing.m_svEncryptionKey);
}
return SQ_OK;
@ -414,7 +419,7 @@ namespace VSquirrel
return SQ_OK;
DevMsg(eDLL_T::UI, "Connecting to server with ip-address '%s' and encryption key '%s'\n", svIpAddr.c_str(), svEncKey.c_str());
g_pBrowser->ConnectToServer(svIpAddr, svEncKey);
g_pServerListManager->ConnectToServer(svIpAddr, svEncKey);
return SQ_OK;
}

View File

@ -76,6 +76,7 @@
<ClCompile Include="..\mathlib\ssenoise.cpp" />
<ClCompile Include="..\mathlib\transform.cpp" />
<ClCompile Include="..\mathlib\vmatrix.cpp" />
<ClCompile Include="..\networksystem\listmanager.cpp" />
<ClCompile Include="..\networksystem\pylon.cpp" />
<ClCompile Include="..\protoc\cl_rcon.pb.cc">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
@ -229,6 +230,7 @@
<ClInclude Include="..\mathlib\vmatrix.h" />
<ClInclude Include="..\mathlib\vplane.h" />
<ClInclude Include="..\milessdk\win64_rrthreads.h" />
<ClInclude Include="..\networksystem\listmanager.h" />
<ClInclude Include="..\networksystem\pylon.h" />
<ClInclude Include="..\networksystem\serverlisting.h" />
<ClInclude Include="..\networksystem\sm_protocol.h" />
@ -257,6 +259,7 @@
<ClInclude Include="..\public\ihandleentity.h" />
<ClInclude Include="..\public\inetchannel.h" />
<ClInclude Include="..\public\inetmsghandler.h" />
<ClInclude Include="..\public\isurfacesystem.h" />
<ClInclude Include="..\public\ivrenderview.h" />
<ClInclude Include="..\public\ivscript.h" />
<ClInclude Include="..\public\model_types.h" />

View File

@ -576,6 +576,9 @@
<ClCompile Include="..\tier1\generichash.cpp">
<Filter>sdk\tier1</Filter>
</ClCompile>
<ClCompile Include="..\networksystem\listmanager.cpp">
<Filter>sdk\networksystem</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\client\cdll_engine_int.h">
@ -1712,6 +1715,12 @@
<ClInclude Include="..\vstdlib\concommandhash.h">
<Filter>sdk\vstdlib</Filter>
</ClInclude>
<ClInclude Include="..\networksystem\listmanager.h">
<Filter>sdk\networksystem</Filter>
</ClInclude>
<ClInclude Include="..\public\isurfacesystem.h">
<Filter>sdk\public</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="..\shared\resource\lockedserver.png">

View File

@ -84,6 +84,7 @@
<ClCompile Include="..\mathlib\transform.cpp" />
<ClCompile Include="..\mathlib\vmatrix.cpp" />
<ClCompile Include="..\networksystem\bansystem.cpp" />
<ClCompile Include="..\networksystem\listmanager.cpp" />
<ClCompile Include="..\networksystem\pylon.cpp" />
<ClCompile Include="..\protoc\cl_rcon.pb.cc">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
@ -253,6 +254,7 @@
<ClInclude Include="..\mathlib\vplane.h" />
<ClInclude Include="..\milessdk\win64_rrthreads.h" />
<ClInclude Include="..\networksystem\bansystem.h" />
<ClInclude Include="..\networksystem\listmanager.h" />
<ClInclude Include="..\networksystem\pylon.h" />
<ClInclude Include="..\networksystem\serverlisting.h" />
<ClInclude Include="..\networksystem\sm_protocol.h" />
@ -283,6 +285,7 @@
<ClInclude Include="..\public\inetchannel.h" />
<ClInclude Include="..\public\inetmsghandler.h" />
<ClInclude Include="..\public\iserver.h" />
<ClInclude Include="..\public\isurfacesystem.h" />
<ClInclude Include="..\public\ivrenderview.h" />
<ClInclude Include="..\public\ivscript.h" />
<ClInclude Include="..\public\model_types.h" />

View File

@ -615,6 +615,9 @@
<ClCompile Include="..\tier1\generichash.cpp">
<Filter>sdk\tier1</Filter>
</ClCompile>
<ClCompile Include="..\networksystem\listmanager.cpp">
<Filter>sdk\networksystem</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\client\cdll_engine_int.h">
@ -1799,6 +1802,12 @@
<ClInclude Include="..\tier1\utllinkedlist.h">
<Filter>sdk\tier1</Filter>
</ClInclude>
<ClInclude Include="..\public\isurfacesystem.h">
<Filter>sdk\public</Filter>
</ClInclude>
<ClInclude Include="..\networksystem\listmanager.h">
<Filter>sdk\networksystem</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="..\shared\resource\lockedserver.png">

View File

@ -276,12 +276,12 @@ void DrawImGui()
if (g_pBrowser->m_bActivate)
{
g_pInputSystem->EnableInput(false); // Disable input to game when browser is drawn.
g_pBrowser->Draw();
g_pBrowser->RunFrame();
}
if (g_pConsole->m_bActivate)
{
g_pInputSystem->EnableInput(false); // Disable input to game when console is drawn.
g_pConsole->Draw();
g_pConsole->RunFrame();
}
if (!g_pConsole->m_bActivate && !g_pBrowser->m_bActivate)
{