mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Cleaned up native server browser and commented functions.
This commit is contained in:
parent
b366e4ce82
commit
4da14d7dde
@ -90,30 +90,6 @@ IBrowser::~IBrowser()
|
|||||||
//delete r5net;
|
//delete r5net;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Sets needed create game vars
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void IBrowser::SetMenuVars(std::string name, EServerVisibility vis)
|
|
||||||
{
|
|
||||||
switch (vis)
|
|
||||||
{
|
|
||||||
case EServerVisibility::PUBLIC:
|
|
||||||
m_Server.bHidden = false;
|
|
||||||
break;
|
|
||||||
case EServerVisibility::HIDDEN:
|
|
||||||
m_Server.bHidden = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
m_Server.bHidden = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
eServerVisibility = vis;
|
|
||||||
m_Server.svServerName = name;
|
|
||||||
|
|
||||||
UpdateHostingStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: draws the main browser front-end
|
// Purpose: draws the main browser front-end
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -311,7 +287,7 @@ void IBrowser::GetServerList()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: connects to specified server
|
// Purpose: connects to specified server
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void IBrowser::ConnectToServer(const std::string ip, const std::string port, const std::string encKey)
|
void IBrowser::ConnectToServer(const std::string& ip, const std::string& port, const std::string& encKey)
|
||||||
{
|
{
|
||||||
if (!encKey.empty())
|
if (!encKey.empty())
|
||||||
{
|
{
|
||||||
@ -326,7 +302,7 @@ void IBrowser::ConnectToServer(const std::string ip, const std::string port, con
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: connects to specified server
|
// Purpose: connects to specified server
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void IBrowser::ConnectToServer(const std::string connString, const std::string encKey)
|
void IBrowser::ConnectToServer(const std::string& connString, const std::string& encKey)
|
||||||
{
|
{
|
||||||
if (!encKey.empty())
|
if (!encKey.empty())
|
||||||
{
|
{
|
||||||
@ -339,11 +315,27 @@ void IBrowser::ConnectToServer(const std::string connString, const std::string e
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Load playlist into KeyValues.
|
// Purpose: Launch server with given parameters
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void IBrowser::LoadPlaylist(const char* playlistName)
|
void IBrowser::LaunchServer()
|
||||||
{
|
{
|
||||||
KeyValues_LoadPlaylist(playlistName);
|
DevMsg(eDLL_T::ENGINE, "Starting Server with name '%s', map '%s' and playlist '%s'\n", m_Server.svServerName.c_str(), m_Server.svMapName.c_str(), m_Server.svPlaylist.c_str());
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Playlist gets parsed in two instances, first in LoadPlaylist 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_LoadPlaylist(m_Server.svPlaylist.c_str());
|
||||||
|
std::stringstream cgmd;
|
||||||
|
cgmd << "mp_gamemode " << m_Server.svPlaylist;
|
||||||
|
ProcessCommand(cgmd.str().c_str());
|
||||||
|
|
||||||
|
// This is to avoid a race condition.
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
|
||||||
|
std::stringstream cmd;
|
||||||
|
cmd << "map " << m_Server.svMapName;
|
||||||
|
ProcessCommand(cmd.str().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -481,25 +473,8 @@ void IBrowser::HostServerSection()
|
|||||||
szServerNameErr.clear();
|
szServerNameErr.clear();
|
||||||
if (!m_Server.svServerName.empty() && !m_Server.svPlaylist.empty() && !m_Server.svMapName.empty())
|
if (!m_Server.svServerName.empty() && !m_Server.svPlaylist.empty() && !m_Server.svMapName.empty())
|
||||||
{
|
{
|
||||||
DevMsg(eDLL_T::ENGINE, "Starting Server with name '%s', map '%s' and playlist '%s'\n", m_Server.svServerName.c_str(), m_Server.svMapName.c_str(), m_Server.svPlaylist.c_str());
|
LaunchServer(); // Launch server.
|
||||||
szServerNameErr = std::string();
|
UpdateHostingStatus(); // Update hosting status.
|
||||||
UpdateHostingStatus();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Playlist gets parsed in two instances, first in LoadPlaylist 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..
|
|
||||||
*/
|
|
||||||
LoadPlaylist(m_Server.svPlaylist.c_str());
|
|
||||||
std::stringstream cgmd;
|
|
||||||
cgmd << "mp_gamemode " << m_Server.svPlaylist;
|
|
||||||
ProcessCommand(cgmd.str().c_str());
|
|
||||||
|
|
||||||
// This is to avoid a race condition.
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
||||||
|
|
||||||
std::stringstream cmd;
|
|
||||||
cmd << "map " << m_Server.svMapName;
|
|
||||||
ProcessCommand(cmd.str().c_str());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -524,25 +499,8 @@ void IBrowser::HostServerSection()
|
|||||||
szServerNameErr.clear();
|
szServerNameErr.clear();
|
||||||
if (!m_Server.svPlaylist.empty() && !m_Server.svMapName.empty())
|
if (!m_Server.svPlaylist.empty() && !m_Server.svMapName.empty())
|
||||||
{
|
{
|
||||||
DevMsg(eDLL_T::ENGINE, "Starting Server with map '%s' and playlist '%s'\n", m_Server.svMapName.c_str(), m_Server.svPlaylist.c_str());
|
LaunchServer(); // Launch server.
|
||||||
szServerNameErr = std::string();
|
UpdateHostingStatus(); // Update hosting status.
|
||||||
UpdateHostingStatus();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Playlist gets parsed in two instances, first in LoadPlaylist 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..
|
|
||||||
*/
|
|
||||||
LoadPlaylist(m_Server.svPlaylist.c_str());
|
|
||||||
std::stringstream cgmd;
|
|
||||||
cgmd << "mp_gamemode " << m_Server.svPlaylist;
|
|
||||||
ProcessCommand(cgmd.str().c_str());
|
|
||||||
|
|
||||||
// This is to avoid a race condition.
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
||||||
|
|
||||||
std::stringstream cmd;
|
|
||||||
cmd << "map " << m_Server.svMapName;
|
|
||||||
ProcessCommand(cmd.str().c_str());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -686,6 +644,7 @@ void IBrowser::SendHostingPostRequest()
|
|||||||
msg << "Share the following token for clients to connect: ";
|
msg << "Share the following token for clients to connect: ";
|
||||||
}
|
}
|
||||||
m_szHostRequestMessage = msg.str().c_str();
|
m_szHostRequestMessage = msg.str().c_str();
|
||||||
|
DevMsg(eDLL_T::CLIENT, "PostServerHost replied with: %s\n", m_szHostRequestMessage);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -738,7 +697,7 @@ void IBrowser::RegenerateEncryptionKey()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: changes encryption key to specified one
|
// Purpose: changes encryption key to specified one
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void IBrowser::ChangeEncryptionKeyTo(const std::string str)
|
void IBrowser::ChangeEncryptionKeyTo(const std::string& str)
|
||||||
{
|
{
|
||||||
HNET_SetKey(str);
|
HNET_SetKey(str);
|
||||||
}
|
}
|
||||||
|
@ -49,9 +49,8 @@ public:
|
|||||||
void RefreshServerList();
|
void RefreshServerList();
|
||||||
void GetServerList();
|
void GetServerList();
|
||||||
|
|
||||||
void ConnectToServer(const std::string ip, const std::string port, const std::string encKey);
|
void ConnectToServer(const std::string& ip, const std::string& port, const std::string& encKey);
|
||||||
void ConnectToServer(const std::string connString, const std::string encKey);
|
void ConnectToServer(const std::string& connString, const std::string& encKey);
|
||||||
void SetMenuVars(std::string name, EServerVisibility vis);
|
|
||||||
|
|
||||||
void HiddenServersModal();
|
void HiddenServersModal();
|
||||||
void HostServerSection();
|
void HostServerSection();
|
||||||
@ -60,11 +59,11 @@ public:
|
|||||||
void SendHostingPostRequest();
|
void SendHostingPostRequest();
|
||||||
|
|
||||||
void ProcessCommand(const char* command_line);
|
void ProcessCommand(const char* command_line);
|
||||||
void LoadPlaylist(const char* playlistName);
|
void LaunchServer();
|
||||||
|
|
||||||
void SettingsSection();
|
void SettingsSection();
|
||||||
void RegenerateEncryptionKey();
|
void RegenerateEncryptionKey();
|
||||||
void ChangeEncryptionKeyTo(const std::string str);
|
void ChangeEncryptionKeyTo(const std::string& str);
|
||||||
|
|
||||||
void SetStyleVar();
|
void SetStyleVar();
|
||||||
|
|
||||||
|
@ -8,45 +8,61 @@ namespace SQNativeFunctions
|
|||||||
{
|
{
|
||||||
namespace IBrowser
|
namespace IBrowser
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// Purpose: get servers current server name from serverlist index
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
SQRESULT GetServerName(void* sqvm)
|
SQRESULT GetServerName(void* sqvm)
|
||||||
{
|
{
|
||||||
int svIndex = hsq_getinteger(sqvm, 1);
|
int svIndex = hsq_getinteger(sqvm, 1);
|
||||||
std::string svName = g_pIBrowser->m_vServerList[svIndex].svServerName;
|
std::string szSvName = g_pIBrowser->m_vServerList[svIndex].svServerName;
|
||||||
|
|
||||||
hsq_pushstring(sqvm, svName.c_str(), -1);
|
hsq_pushstring(sqvm, szSvName.c_str(), -1);
|
||||||
|
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// Purpose: get servers current playlist via serverlist index
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
SQRESULT GetServerPlaylist(void* sqvm)
|
SQRESULT GetServerPlaylist(void* sqvm)
|
||||||
{
|
{
|
||||||
int svIndex = hsq_getinteger(sqvm, 1);
|
int svIndex = hsq_getinteger(sqvm, 1);
|
||||||
std::string svPlaylist = g_pIBrowser->m_vServerList[svIndex].svPlaylist;
|
std::string szSvPlaylist = g_pIBrowser->m_vServerList[svIndex].svPlaylist;
|
||||||
|
|
||||||
hsq_pushstring(sqvm, svPlaylist.c_str(), -1);
|
hsq_pushstring(sqvm, szSvPlaylist.c_str(), -1);
|
||||||
|
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// Purpose: get servers current map via serverlist index
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
SQRESULT GetServerMap(void* sqvm)
|
SQRESULT GetServerMap(void* sqvm)
|
||||||
{
|
{
|
||||||
int svIndex = hsq_getinteger(sqvm, 1);
|
int svIndex = hsq_getinteger(sqvm, 1);
|
||||||
std::string svMapName = g_pIBrowser->m_vServerList[svIndex].svMapName;
|
std::string szSvMapName = g_pIBrowser->m_vServerList[svIndex].svMapName;
|
||||||
|
|
||||||
hsq_pushstring(sqvm, svMapName.c_str(), -1);
|
hsq_pushstring(sqvm, szSvMapName.c_str(), -1);
|
||||||
|
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// Purpose: get current server count from pylon
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
SQRESULT GetServerCount(void* sqvm)
|
SQRESULT GetServerCount(void* sqvm)
|
||||||
{
|
{
|
||||||
g_pIBrowser->GetServerList(); // Refresh server list.
|
g_pIBrowser->GetServerList(); // Refresh svListing list.
|
||||||
|
|
||||||
hsq_pushinteger(sqvm, g_pIBrowser->m_vServerList.size());
|
hsq_pushinteger(sqvm, g_pIBrowser->m_vServerList.size());
|
||||||
|
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// Purpose: expose SDK version to SQ
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
SQRESULT GetSDKVersion(void* sqvm)
|
SQRESULT GetSDKVersion(void* sqvm)
|
||||||
{
|
{
|
||||||
hsq_pushstring(sqvm, g_pR5net->GetSDKVersion().c_str(), -1);
|
hsq_pushstring(sqvm, g_pR5net->GetSDKVersion().c_str(), -1);
|
||||||
@ -54,6 +70,9 @@ namespace SQNativeFunctions
|
|||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// Purpose: get promo data for serverbrowser panels
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
SQRESULT GetPromoData(void* sqvm)
|
SQRESULT GetPromoData(void* sqvm)
|
||||||
{
|
{
|
||||||
enum class R5RPromoData : int
|
enum class R5RPromoData : int
|
||||||
@ -66,54 +85,57 @@ namespace SQNativeFunctions
|
|||||||
PromoRightDesc
|
PromoRightDesc
|
||||||
};
|
};
|
||||||
|
|
||||||
R5RPromoData prIndex = (R5RPromoData)hsq_getinteger(sqvm, 1);
|
R5RPromoData ePromoIndex = (R5RPromoData)hsq_getinteger(sqvm, 1);
|
||||||
|
|
||||||
std::string prStr = std::string();
|
std::string szPromo = std::string();
|
||||||
|
|
||||||
switch (prIndex)
|
switch (ePromoIndex)
|
||||||
{
|
{
|
||||||
case R5RPromoData::PromoLargeTitle:
|
case R5RPromoData::PromoLargeTitle:
|
||||||
{
|
{
|
||||||
prStr = "Welcome To R5Reloaded!";
|
szPromo = "Welcome To R5Reloaded!";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case R5RPromoData::PromoLargeDesc:
|
case R5RPromoData::PromoLargeDesc:
|
||||||
{
|
{
|
||||||
prStr = "Make sure to join the discord! discord.gg/r5reloaded";
|
szPromo = "Make sure to join the discord! discord.gg/r5reloaded";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case R5RPromoData::PromoLeftTitle:
|
case R5RPromoData::PromoLeftTitle:
|
||||||
{
|
{
|
||||||
prStr = "Yes";
|
szPromo = "Yes";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case R5RPromoData::PromoLeftDesc:
|
case R5RPromoData::PromoLeftDesc:
|
||||||
{
|
{
|
||||||
prStr = "Your ad could be here";
|
szPromo = "Your ad could be here";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case R5RPromoData::PromoRightTitle:
|
case R5RPromoData::PromoRightTitle:
|
||||||
{
|
{
|
||||||
prStr = "Yes2";
|
szPromo = "Yes2";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case R5RPromoData::PromoRightDesc:
|
case R5RPromoData::PromoRightDesc:
|
||||||
{
|
{
|
||||||
prStr = "Yes3";
|
szPromo = "Yes3";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
prStr = "You should not see this.";
|
szPromo = "You should not see this.";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hsq_pushstring(sqvm, prStr.c_str(), -1);
|
hsq_pushstring(sqvm, szPromo.c_str(), -1);
|
||||||
|
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: set netchannel encryption key and connect to server
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
SQRESULT SetEncKeyAndConnect(void* sqvm)
|
SQRESULT SetEncKeyAndConnect(void* sqvm)
|
||||||
{
|
{
|
||||||
int svIndex = hsq_getinteger(sqvm, 1);
|
int svIndex = hsq_getinteger(sqvm, 1);
|
||||||
@ -123,90 +145,110 @@ namespace SQNativeFunctions
|
|||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: create server via native serverbrowser entries
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
SQRESULT CreateServerFromMenu(void* sqvm)
|
SQRESULT CreateServerFromMenu(void* sqvm)
|
||||||
{
|
{
|
||||||
std::string svName = hsq_getstring(sqvm, 1);
|
std::string szSvName = hsq_getstring(sqvm, 1);
|
||||||
std::string svMapName = hsq_getstring(sqvm, 2);
|
std::string szSvMapName = hsq_getstring(sqvm, 2);
|
||||||
std::string svPlaylist = hsq_getstring(sqvm, 3);
|
std::string szSvPlaylist = hsq_getstring(sqvm, 3);
|
||||||
EServerVisibility svVisibility = (EServerVisibility)hsq_getinteger(sqvm, 4);
|
EServerVisibility eSvVisibility = (EServerVisibility)hsq_getinteger(sqvm, 4);
|
||||||
|
|
||||||
if (svMapName.empty() || svPlaylist.empty())
|
if (szSvName.empty() || szSvMapName.empty() || szSvPlaylist.empty())
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
|
|
||||||
g_pIBrowser->SetMenuVars(svName, svVisibility); // Pass integer instead
|
// Adjust browser settings.
|
||||||
|
g_pIBrowser->m_Server.svPlaylist = szSvPlaylist;
|
||||||
|
g_pIBrowser->m_Server.svMapName = szSvMapName;
|
||||||
|
g_pIBrowser->m_Server.svServerName = szSvName;
|
||||||
|
g_pIBrowser->eServerVisibility = eSvVisibility;
|
||||||
|
|
||||||
/* Changing this up to call a IBrowser method eventually. */
|
// Launch server.
|
||||||
DevMsg(eDLL_T::ENGINE, "Starting Server with map '%s' and playlist '%s'\n", svMapName.c_str(), svPlaylist.c_str());
|
g_pIBrowser->LaunchServer();
|
||||||
|
|
||||||
g_pIBrowser->LoadPlaylist(svPlaylist.c_str());
|
|
||||||
std::stringstream cgmd;
|
|
||||||
cgmd << "mp_gamemode " << svPlaylist;
|
|
||||||
g_pIBrowser->ProcessCommand(cgmd.str().c_str());
|
|
||||||
|
|
||||||
// This is to avoid svIndex race condition.
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
||||||
|
|
||||||
std::stringstream cmd;
|
|
||||||
cmd << "map " << svMapName;
|
|
||||||
g_pIBrowser->ProcessCommand(cmd.str().c_str());
|
|
||||||
|
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// // Purpose: request token from pylon and join server with result.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
SQRESULT JoinPrivateServerFromMenu(void* sqvm)
|
SQRESULT JoinPrivateServerFromMenu(void* sqvm)
|
||||||
{
|
{
|
||||||
std::string m_szHiddenServerRequestMessage;
|
std::string szHiddenServerRequestMessage = std::string();
|
||||||
|
|
||||||
std::string token = hsq_getstring(sqvm, 1);
|
std::string szToken = hsq_getstring(sqvm, 1);
|
||||||
|
|
||||||
ServerListing server;
|
ServerListing svListing;
|
||||||
bool result = g_pR5net->GetServerByToken(server, m_szHiddenServerRequestMessage, token); // Send token connect request.
|
bool result = g_pR5net->GetServerByToken(svListing, szHiddenServerRequestMessage, szToken); // Send szToken connect request.
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
g_pIBrowser->ConnectToServer(server.svIpAddress, server.svPort, server.svEncryptionKey);
|
g_pIBrowser->ConnectToServer(svListing.svIpAddress, svListing.svPort, svListing.svEncryptionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: get response from private server request
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
SQRESULT GetPrivateServerMessage(void* sqvm)
|
SQRESULT GetPrivateServerMessage(void* sqvm)
|
||||||
{
|
{
|
||||||
std::string m_szHiddenServerRequestMessage;
|
std::string szHiddenServerRequestMessage = std::string();
|
||||||
|
|
||||||
std::string token = hsq_getstring(sqvm, 1);
|
std::string szToken = hsq_getstring(sqvm, 1);
|
||||||
|
|
||||||
ServerListing server;
|
ServerListing slServer;
|
||||||
bool result = g_pR5net->GetServerByToken(server, m_szHiddenServerRequestMessage, token); // Send token connect request.
|
bool result = g_pR5net->GetServerByToken(slServer, szHiddenServerRequestMessage, szToken); // Send szToken connect request.
|
||||||
if (!server.svServerName.empty())
|
if (!slServer.svServerName.empty())
|
||||||
{
|
{
|
||||||
m_szHiddenServerRequestMessage = "Found Server: " + server.svServerName;
|
szHiddenServerRequestMessage = "Found Server: " + slServer.svServerName;
|
||||||
|
|
||||||
hsq_pushstring(sqvm, m_szHiddenServerRequestMessage.c_str(), -1);
|
hsq_pushstring(sqvm, szHiddenServerRequestMessage.c_str(), -1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_szHiddenServerRequestMessage = "Error: Server Not Found";
|
szHiddenServerRequestMessage = "Error: Server Not Found";
|
||||||
|
|
||||||
hsq_pushstring(sqvm, m_szHiddenServerRequestMessage.c_str(), -1);
|
hsq_pushstring(sqvm, szHiddenServerRequestMessage.c_str(), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DevMsg(eDLL_T::UI, "GetPrivateServeMessage response: %s\n", szHiddenServerRequestMessage.c_str());
|
||||||
|
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: connect to server from native server browser entries
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
SQRESULT ConnectToIPFromMenu(void* sqvm)
|
SQRESULT ConnectToIPFromMenu(void* sqvm)
|
||||||
{
|
{
|
||||||
std::string ip = hsq_getstring(sqvm, 1);
|
std::string szIP = hsq_getstring(sqvm, 1);
|
||||||
std::string key = hsq_getstring(sqvm, 2);
|
std::string szEncKey = hsq_getstring(sqvm, 2);
|
||||||
|
|
||||||
g_pIBrowser->ConnectToServer(ip, key);
|
if (szIP.empty() || szEncKey.empty())
|
||||||
|
return SQ_OK;
|
||||||
|
|
||||||
|
DevMsg(eDLL_T::UI, "Connecting to server with connection string %s and encryptionkey %s\n", szIP, szEncKey);
|
||||||
|
|
||||||
|
g_pIBrowser->ConnectToServer(szIP, szEncKey);
|
||||||
|
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: return all available map
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
SQRESULT GetAvailableMaps(void* sqvm)
|
SQRESULT GetAvailableMaps(void* sqvm)
|
||||||
{
|
{
|
||||||
std::vector<std::string> mapList = g_pIBrowser->m_vszMapFileNameList;
|
std::vector<std::string> mapList = g_pIBrowser->m_vszMapFileNameList;
|
||||||
|
|
||||||
|
if (mapList.empty())
|
||||||
|
{
|
||||||
|
DevMsg(eDLL_T::UI, "Available maps is empty!!!\n");
|
||||||
|
return SQ_OK;
|
||||||
|
}
|
||||||
|
|
||||||
DevMsg(eDLL_T::UI, "Requesting an array of %i available maps from script\n", mapList.size());
|
DevMsg(eDLL_T::UI, "Requesting an array of %i available maps from script\n", mapList.size());
|
||||||
|
|
||||||
hsq_newarray(sqvm, 0);
|
hsq_newarray(sqvm, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user