mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
commit
9403f4ef97
@ -28,12 +28,12 @@ public:
|
||||
{
|
||||
case R5Net::EResponseStatus::SUCCESS:
|
||||
{
|
||||
g_GameConsole->AddLog("SUCCESS: %d players, %d servers", response.noPlayers, response.noServers);
|
||||
g_pIConsole->AddLog("SUCCESS: %d players, %d servers", response.noPlayers, response.noServers);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
g_GameConsole->AddLog("ERROR: %s", response.error.c_str());
|
||||
g_pIConsole->AddLog("ERROR: %s", response.error.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -50,18 +50,17 @@ public:
|
||||
{
|
||||
case R5Net::EResponseStatus::SUCCESS:
|
||||
{
|
||||
g_GameConsole->AddLog("SUCCESS: %s", response.gameServer.name.c_str());
|
||||
g_pIConsole->AddLog("SUCCESS: %s", response.gameServer.name.c_str());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
g_GameConsole->AddLog("ERROR: %s", response.error.c_str());
|
||||
g_pIConsole->AddLog("ERROR: %s", response.error.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (*bDraw == NULL)
|
||||
{
|
||||
g_bShowBrowser = false;
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
@ -9,6 +9,25 @@
|
||||
#include "squirrel/sqinit.h"
|
||||
#include "public/include/bansystem.h"
|
||||
|
||||
|
||||
|
||||
|
||||
inline int GetLocalPlayersNum()
|
||||
{
|
||||
int currPlayers = 0;
|
||||
for (int i = 0; i < MAX_PLAYERS; i++)
|
||||
{
|
||||
CClient* client = g_pClient->GetClientInstance(i); // Get client instance.
|
||||
if (client)
|
||||
{
|
||||
if (client->GetNetChan())
|
||||
currPlayers++;
|
||||
}
|
||||
}
|
||||
return currPlayers;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Send keep alive request to Pylon Master Server.
|
||||
// NOTE: When Pylon update reaches indev remove this and implement properly.
|
||||
@ -20,27 +39,28 @@ void KeepAliveToPylon()
|
||||
std::string m_szHostToken = std::string();
|
||||
std::string m_szHostRequestMessage = std::string();
|
||||
DevMsg(eDLL_T::CLIENT, "Sending PostServerHost request\n");
|
||||
bool result = g_pR5net->PostServerHost(m_szHostRequestMessage, m_szHostToken,
|
||||
ServerListing{
|
||||
g_pCVar->FindVar("hostname")->GetString(),
|
||||
std::string(g_pHostState->m_levelName),
|
||||
"",
|
||||
g_pCVar->FindVar("hostport")->GetString(),
|
||||
g_pCVar->FindVar("mp_gamemode")->GetString(),
|
||||
false,
|
||||
|
||||
// BUG BUG: Checksum is null on dedi
|
||||
// ADDITIONAL NOTES: seems to be related to scripts, this also happens when the listen server is started but the client from the same process never connects.
|
||||
// Checksum only gets set on the server if the client from its own process connects to it.
|
||||
std::to_string(*g_nRemoteFunctionCallsChecksum),
|
||||
std::string(),
|
||||
g_szNetKey.c_str()
|
||||
}
|
||||
);
|
||||
R5Net::UpdateGameServerMSRequest Request;
|
||||
|
||||
Request.gameServer = *(R5Net::LocalServer);
|
||||
|
||||
if(Request.gameServer.name.empty())
|
||||
Request.gameServer.name = g_pCVar->FindVar("hostname")->GetString();
|
||||
|
||||
Request.gameServer.mapName = std::string(g_pHostState->m_levelName);
|
||||
sscanf_s(g_pCVar->FindVar("hostport")->GetString(), "%d", &Request.gameServer.gamePort);
|
||||
Request.gameServer.playlist = g_pCVar->FindVar("mp_gamemode")->GetString();
|
||||
Request.gameServer.remoteChecksum = std::to_string(*g_nRemoteFunctionCallsChecksum);
|
||||
Request.gameServer.encryptionKey = g_szNetKey.c_str();
|
||||
Request.gameServer.playerCount = GetLocalPlayersNum();
|
||||
Request.gameServer.maxPlayerCount = MAX_PLAYERS; // TODO: replace with actual max_players
|
||||
|
||||
auto Response = g_pR5net->UpdateMyGameServer(Request);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Check refuse list and kill netchan connection.
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -164,6 +184,8 @@ void HCHostState_FrameUpdate(void* rcx, void* rdx, float time)
|
||||
}
|
||||
});
|
||||
|
||||
PylonThread.detach();
|
||||
|
||||
static std::thread BanlistThread([]()
|
||||
{
|
||||
while (true)
|
||||
@ -173,6 +195,8 @@ void HCHostState_FrameUpdate(void* rcx, void* rdx, float time)
|
||||
}
|
||||
});
|
||||
|
||||
BanlistThread.detach();
|
||||
|
||||
if (net_userandomkey->GetBool())
|
||||
{
|
||||
HNET_GenerateKey();
|
||||
|
164
r5dev/gameui/IBrowser.cpp
Normal file
164
r5dev/gameui/IBrowser.cpp
Normal file
@ -0,0 +1,164 @@
|
||||
/******************************************************************************
|
||||
-------------------------------------------------------------------------------
|
||||
File : IBrowser.cpp
|
||||
Date : 09:06:2021
|
||||
Author : Sal
|
||||
Purpose: Implements the in-game server browser front-end
|
||||
-------------------------------------------------------------------------------
|
||||
History:
|
||||
- 09:06:2021 21:07 : Created by Sal
|
||||
- 25:07:2021 14:26 : Implement private servers connect dialog and password field
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#include "core/stdafx.h"
|
||||
#include "core/init.h"
|
||||
#include "core/resource.h"
|
||||
#include "tier0/IConVar.h"
|
||||
#include "tier0/cvar.h"
|
||||
#include "tier0/completion.h"
|
||||
#include "windows/id3dx.h"
|
||||
#include "windows/console.h"
|
||||
#include "engine/net_chan.h"
|
||||
#include "engine/sys_utils.h"
|
||||
#include "engine/host_state.h"
|
||||
#include "server/server.h"
|
||||
#include "client/IVEngineClient.h"
|
||||
#include "networksystem/net_structs.h"
|
||||
#include "networksystem/r5net.h"
|
||||
#include "vpc/keyvalues.h"
|
||||
#include "squirrel/sqinit.h"
|
||||
#include "gameui/IBrowser.h"
|
||||
#include "squirrel/sqapi.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
IBrowser::IBrowser()
|
||||
{
|
||||
|
||||
std::string path = "stbsp";
|
||||
for (const auto& entry : std::filesystem::directory_iterator(path))
|
||||
{
|
||||
std::string filename = entry.path().string();
|
||||
int slashPos = filename.rfind("\\", std::string::npos);
|
||||
filename = filename.substr(static_cast<std::basic_string<char, std::char_traits<char>, std::allocator<char>>::size_type>(slashPos) + 1, std::string::npos);
|
||||
filename = filename.substr(0, filename.size() - 6);
|
||||
|
||||
auto it = mapArray.find(filename); // Find MapName in mapArray.
|
||||
if (it != mapArray.end())
|
||||
{
|
||||
m_vszMapsList.push_back(it->second);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_vszMapsList.push_back(filename);
|
||||
}
|
||||
m_vszMapFileNameList.push_back(filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
IBrowser::~IBrowser()
|
||||
{
|
||||
//delete r5net;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: get server list from pylon.
|
||||
//-----------------------------------------------------------------------------
|
||||
void IBrowser::GetServerList()
|
||||
{
|
||||
auto Response = g_pR5net->GetGameServersList();
|
||||
m_vServerList.clear();
|
||||
m_vServerList.insert(m_vServerList.end(), Response.publicServers.begin(), Response.publicServers.end());
|
||||
m_vServerList.insert(m_vServerList.end(), Response.privateServers.begin(), Response.privateServers.end());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: connects to specified server
|
||||
//-----------------------------------------------------------------------------
|
||||
void IBrowser::ConnectToServer(const std::string& ip, const int port, const std::string& encKey)
|
||||
{
|
||||
if (!encKey.empty())
|
||||
{
|
||||
ChangeEncryptionKeyTo(encKey);
|
||||
}
|
||||
|
||||
std::stringstream cmd;
|
||||
cmd << "connect " << ip << ":" << port;
|
||||
ProcessCommand(cmd.str().c_str());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: connects to specified server
|
||||
//-----------------------------------------------------------------------------
|
||||
void IBrowser::ConnectToServer(const std::string& connString, const std::string& encKey)
|
||||
{
|
||||
if (!encKey.empty())
|
||||
{
|
||||
ChangeEncryptionKeyTo(encKey);
|
||||
}
|
||||
|
||||
std::stringstream cmd;
|
||||
cmd << "connect " << connString;
|
||||
ProcessCommand(cmd.str().c_str());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Launch server with given parameters
|
||||
//-----------------------------------------------------------------------------
|
||||
void IBrowser::LaunchServer()
|
||||
{
|
||||
DevMsg(eDLL_T::ENGINE, "Starting Server with name '%s', map '%s' and playlist '%s'\n", R5Net::LocalServer->name.c_str(), R5Net::LocalServer->mapName.c_str(), R5Net::LocalServer->playlist.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(R5Net::LocalServer->playlist.c_str());
|
||||
std::stringstream cgmd;
|
||||
cgmd << "mp_gamemode " << R5Net::LocalServer->playlist;
|
||||
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 " << R5Net::LocalServer->mapName;
|
||||
ProcessCommand(cmd.str().c_str());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: executes submitted commands in a separate thread
|
||||
//-----------------------------------------------------------------------------
|
||||
void IBrowser::ProcessCommand(const char* command_line)
|
||||
{
|
||||
std::thread t(IVEngineClient_CommandExecute, this, command_line);
|
||||
t.detach(); // Detach from render thread.
|
||||
|
||||
// This is to avoid a race condition.
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: regenerates encryption key
|
||||
//-----------------------------------------------------------------------------
|
||||
void IBrowser::RegenerateEncryptionKey()
|
||||
{
|
||||
HNET_GenerateKey();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: changes encryption key to specified one
|
||||
//-----------------------------------------------------------------------------
|
||||
void IBrowser::ChangeEncryptionKeyTo(const std::string& str)
|
||||
{
|
||||
HNET_SetKey(str);
|
||||
}
|
||||
|
||||
IBrowser* g_pIBrowser = new IBrowser();
|
69
r5dev/gameui/IBrowser.h
Normal file
69
r5dev/gameui/IBrowser.h
Normal file
@ -0,0 +1,69 @@
|
||||
#pragma once
|
||||
#ifndef DEDICATED
|
||||
#include "networksystem/net_structs.h"
|
||||
#include "networksystem/r5net.h"
|
||||
|
||||
|
||||
class IBrowser
|
||||
{
|
||||
private:
|
||||
bool m_bInitialized = false;
|
||||
public:
|
||||
public:
|
||||
////////////////////
|
||||
// Funcs //
|
||||
////////////////////
|
||||
IBrowser();
|
||||
~IBrowser();
|
||||
|
||||
|
||||
void GetServerList();
|
||||
|
||||
void ConnectToServer(const std::string& ip, const int port, const std::string& encKey);
|
||||
void ConnectToServer(const std::string& connString, const std::string& encKey);
|
||||
|
||||
|
||||
void ProcessCommand(const char* command_line);
|
||||
void LaunchServer();
|
||||
|
||||
void RegenerateEncryptionKey();
|
||||
void ChangeEncryptionKeyTo(const std::string& str);
|
||||
|
||||
|
||||
////////////////////
|
||||
// Server Browser //
|
||||
////////////////////
|
||||
public:
|
||||
bool m_bActivate = false;
|
||||
|
||||
std::vector<R5Net::NetGameServer> m_vServerList;
|
||||
ImGuiTextFilter m_imServerBrowserFilter;
|
||||
std::string m_szServerListMessage = std::string();
|
||||
|
||||
std::map<std::string, std::string> mapArray =
|
||||
{
|
||||
{ "mp_rr_canyonlands_64k_x_64k", "King's Canyon Season 0" },
|
||||
{ "mp_rr_desertlands_64k_x_64k", "World's Edge Season 3" },
|
||||
{ "mp_rr_canyonlands_mu1", "King's Canyon Season 2" },
|
||||
{ "mp_rr_canyonlands_mu1_night", "King's Canyon Season 2 After Dark" },
|
||||
{ "mp_rr_desertlands_64k_x_64k_nx", "World's Edge Season 3 After Dark" },
|
||||
{ "mp_lobby", "Lobby Season 3" },
|
||||
{ "mp_rr_canyonlands_staging", "King's Canyon Firing Range" }
|
||||
};
|
||||
|
||||
////////////////////
|
||||
// Settings //
|
||||
////////////////////
|
||||
std::string m_szMatchmakingHostName;
|
||||
|
||||
////////////////////
|
||||
// Host Server //
|
||||
////////////////////
|
||||
std::vector<std::string> m_vszMapsList;
|
||||
std::vector<std::string> m_vszMapFileNameList;
|
||||
|
||||
|
||||
};
|
||||
|
||||
extern IBrowser* g_pIBrowser;
|
||||
#endif
|
@ -1,3 +1,5 @@
|
||||
#include "core/stdafx.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace R5Net {
|
||||
|
@ -4,4 +4,8 @@
|
||||
#include "core/stdafx.h"
|
||||
#include <networksystem/r5net.h>
|
||||
|
||||
namespace R5Net
|
||||
{
|
||||
NetGameServer* LocalServer = new R5Net::NetGameServer{};
|
||||
}
|
||||
R5Net::Client* g_pR5net = new R5Net::Client("127.0.0.1:3000");
|
||||
|
@ -119,6 +119,8 @@ void FuncName##_Async(const RequestStructType& request, std::function<void(Respo
|
||||
|
||||
|
||||
};
|
||||
|
||||
extern NetGameServer* LocalServer;
|
||||
}
|
||||
|
||||
extern R5Net::Client* g_pR5net;
|
@ -40,6 +40,7 @@
|
||||
<ClCompile Include="engine\sys_dll.cpp" />
|
||||
<ClCompile Include="engine\sys_dll2.cpp" />
|
||||
<ClCompile Include="engine\sys_utils.cpp" />
|
||||
<ClCompile Include="gameui\IBrowser.cpp" />
|
||||
<ClCompile Include="gameui\IConsole.cpp" />
|
||||
<ClCompile Include="IDevPallete.cpp" />
|
||||
<ClCompile Include="inputsystem\inputsystem.cpp" />
|
||||
@ -234,6 +235,7 @@
|
||||
<ClInclude Include="engine\sys_dll.h" />
|
||||
<ClInclude Include="engine\sys_dll2.h" />
|
||||
<ClInclude Include="engine\sys_utils.h" />
|
||||
<ClInclude Include="gameui\IBrowser.h" />
|
||||
<ClInclude Include="gameui\IConsole.h" />
|
||||
<ClInclude Include="IDevPalette.h" />
|
||||
<ClInclude Include="inputsystem\ButtonCode.h" />
|
||||
@ -248,6 +250,7 @@
|
||||
<ClInclude Include="mathlib\parallel_for.h" />
|
||||
<ClInclude Include="mathlib\vector.h" />
|
||||
<ClInclude Include="milessdk\win64_rrthreads.h" />
|
||||
<ClInclude Include="networksystem\net_structs.h" />
|
||||
<ClInclude Include="networksystem\r5net.h" />
|
||||
<ClInclude Include="networksystem\sm_protocol.h" />
|
||||
<ClInclude Include="public\include\memaddr.h" />
|
||||
|
@ -405,6 +405,10 @@
|
||||
<ClCompile Include="squirrel\sqnativefunctions.cpp">
|
||||
<Filter>sdk\squirrel</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IDevPallete.cpp" />
|
||||
<ClCompile Include="gameui\IBrowser.cpp">
|
||||
<Filter>sdk\gameui</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="client\cdll_engine_int.h">
|
||||
@ -1043,6 +1047,13 @@
|
||||
<ClInclude Include="squirrel\sqnativefunctions.h">
|
||||
<Filter>sdk\squirrel</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="IDevPalette.h" />
|
||||
<ClInclude Include="networksystem\net_structs.h">
|
||||
<Filter>sdk\networksystem</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="gameui\IBrowser.h">
|
||||
<Filter>sdk\gameui</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="r5dev.def" />
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "engine/sys_utils.h"
|
||||
#include "gameui/IBrowser.h"
|
||||
#include <networksystem/r5net.h>
|
||||
|
||||
namespace SQNativeFunctions
|
||||
{
|
||||
@ -15,7 +16,17 @@ namespace SQNativeFunctions
|
||||
SQRESULT GetServerName(void* sqvm)
|
||||
{
|
||||
int svIndex = hsq_getinteger(sqvm, 1);
|
||||
std::string szSvName = g_pIBrowser->m_vServerList[svIndex].svServerName;
|
||||
std::string szSvName = g_pIBrowser->m_vServerList[svIndex].name;
|
||||
|
||||
hsq_pushstring(sqvm, szSvName.c_str(), -1);
|
||||
|
||||
return SQ_OK;
|
||||
}
|
||||
|
||||
SQRESULT GetServerDescription(void* sqvm)
|
||||
{
|
||||
int svIndex = hsq_getinteger(sqvm, 1);
|
||||
std::string szSvName = g_pIBrowser->m_vServerList[svIndex].description;
|
||||
|
||||
hsq_pushstring(sqvm, szSvName.c_str(), -1);
|
||||
|
||||
@ -28,7 +39,7 @@ namespace SQNativeFunctions
|
||||
SQRESULT GetServerPlaylist(void* sqvm)
|
||||
{
|
||||
int svIndex = hsq_getinteger(sqvm, 1);
|
||||
std::string szSvPlaylist = g_pIBrowser->m_vServerList[svIndex].svPlaylist;
|
||||
std::string szSvPlaylist = g_pIBrowser->m_vServerList[svIndex].playlist;
|
||||
|
||||
hsq_pushstring(sqvm, szSvPlaylist.c_str(), -1);
|
||||
|
||||
@ -41,13 +52,33 @@ namespace SQNativeFunctions
|
||||
SQRESULT GetServerMap(void* sqvm)
|
||||
{
|
||||
int svIndex = hsq_getinteger(sqvm, 1);
|
||||
std::string szSvMapName = g_pIBrowser->m_vServerList[svIndex].svMapName;
|
||||
std::string szSvMapName = g_pIBrowser->m_vServerList[svIndex].mapName;
|
||||
|
||||
hsq_pushstring(sqvm, szSvMapName.c_str(), -1);
|
||||
|
||||
return SQ_OK;
|
||||
}
|
||||
|
||||
SQRESULT GetServerPlayersNum(void* sqvm)
|
||||
{
|
||||
int svIndex = hsq_getinteger(sqvm, 1);
|
||||
int szSvPlayersNum = g_pIBrowser->m_vServerList[svIndex].playerCount;
|
||||
|
||||
hsq_pushinteger(sqvm, szSvPlayersNum);
|
||||
|
||||
return SQ_OK;
|
||||
}
|
||||
|
||||
SQRESULT GetServerMaxPlayersNum(void* sqvm)
|
||||
{
|
||||
int svIndex = hsq_getinteger(sqvm, 1);
|
||||
int szSvMaxPlayersNum = g_pIBrowser->m_vServerList[svIndex].maxPlayerCount;
|
||||
|
||||
hsq_pushinteger(sqvm, szSvMaxPlayersNum);
|
||||
|
||||
return SQ_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Purpose: get current server count from pylon
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -65,7 +96,7 @@ namespace SQNativeFunctions
|
||||
//-----------------------------------------------------------------------------
|
||||
SQRESULT GetSDKVersion(void* sqvm)
|
||||
{
|
||||
hsq_pushstring(sqvm, g_pR5net->GetSDKVersion().c_str(), -1);
|
||||
hsq_pushstring(sqvm, /*g_pR5net->GetSDKVersion().c_str()*/ "TEMP TEMP!!", -1);
|
||||
|
||||
return SQ_OK;
|
||||
}
|
||||
@ -140,7 +171,7 @@ namespace SQNativeFunctions
|
||||
{
|
||||
int svIndex = hsq_getinteger(sqvm, 1);
|
||||
|
||||
g_pIBrowser->ConnectToServer(g_pIBrowser->m_vServerList[svIndex].svIpAddress, g_pIBrowser->m_vServerList[svIndex].svPort, g_pIBrowser->m_vServerList[svIndex].svEncryptionKey);
|
||||
g_pIBrowser->ConnectToServer(g_pIBrowser->m_vServerList[svIndex].ipAddress, g_pIBrowser->m_vServerList[svIndex].gamePort, g_pIBrowser->m_vServerList[svIndex].encryptionKey);
|
||||
|
||||
return SQ_OK;
|
||||
}
|
||||
@ -151,18 +182,23 @@ namespace SQNativeFunctions
|
||||
SQRESULT CreateServerFromMenu(void* sqvm)
|
||||
{
|
||||
std::string szSvName = hsq_getstring(sqvm, 1);
|
||||
std::string szSvMapName = hsq_getstring(sqvm, 2);
|
||||
std::string szSvPlaylist = hsq_getstring(sqvm, 3);
|
||||
EServerVisibility eSvVisibility = (EServerVisibility)hsq_getinteger(sqvm, 4);
|
||||
std::string szSvDescription = hsq_getstring(sqvm, 2);
|
||||
std::string szSvMapName = hsq_getstring(sqvm, 3);
|
||||
std::string szSvPlaylist = hsq_getstring(sqvm, 4);
|
||||
std::string szSvPassword = hsq_getstring(sqvm, 5);
|
||||
|
||||
// Visibility got deprecated in favor of a password system.
|
||||
//EServerVisibility eSvVisibility = (EServerVisibility)hsq_getinteger(sqvm, 4);
|
||||
|
||||
if (szSvName.empty() || szSvMapName.empty() || szSvPlaylist.empty())
|
||||
return SQ_OK;
|
||||
|
||||
// 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;
|
||||
R5Net::LocalServer->playlist = szSvPlaylist;
|
||||
R5Net::LocalServer->mapName = szSvMapName;
|
||||
R5Net::LocalServer->name = szSvName;
|
||||
R5Net::LocalServer->description = szSvDescription;
|
||||
R5Net::LocalServer->password = szSvPassword;
|
||||
|
||||
// Launch server.
|
||||
g_pIBrowser->LaunchServer();
|
||||
@ -175,7 +211,7 @@ namespace SQNativeFunctions
|
||||
//-----------------------------------------------------------------------------
|
||||
SQRESULT JoinPrivateServerFromMenu(void* sqvm)
|
||||
{
|
||||
std::string szHiddenServerRequestMessage = std::string();
|
||||
/*std::string szHiddenServerRequestMessage = std::string();
|
||||
|
||||
std::string szToken = hsq_getstring(sqvm, 1);
|
||||
|
||||
@ -186,6 +222,7 @@ namespace SQNativeFunctions
|
||||
g_pIBrowser->ConnectToServer(svListing.svIpAddress, svListing.svPort, svListing.svEncryptionKey);
|
||||
}
|
||||
|
||||
return SQ_OK;*/
|
||||
return SQ_OK;
|
||||
}
|
||||
|
||||
@ -194,7 +231,7 @@ namespace SQNativeFunctions
|
||||
//-----------------------------------------------------------------------------
|
||||
SQRESULT GetPrivateServerMessage(void* sqvm)
|
||||
{
|
||||
std::string szHiddenServerRequestMessage = std::string();
|
||||
/*std::string szHiddenServerRequestMessage = std::string();
|
||||
|
||||
std::string szToken = hsq_getstring(sqvm, 1);
|
||||
|
||||
@ -215,6 +252,7 @@ namespace SQNativeFunctions
|
||||
|
||||
DevMsg(eDLL_T::UI, "GetPrivateServeMessage response: %s\n", szHiddenServerRequestMessage.c_str());
|
||||
|
||||
return SQ_OK;*/
|
||||
return SQ_OK;
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,11 @@ namespace SQNativeFunctions
|
||||
namespace IBrowser
|
||||
{
|
||||
SQRESULT GetServerName(void* sqvm);
|
||||
SQRESULT GetServerDescription(void* sqvm);
|
||||
SQRESULT GetServerPlaylist(void* sqvm);
|
||||
SQRESULT GetServerMap(void* sqvm);
|
||||
SQRESULT GetServerPlayersNum(void* sqvm);
|
||||
SQRESULT GetServerMaxPlayersNum(void* sqvm);
|
||||
SQRESULT GetServerCount(void* sqvm);
|
||||
SQRESULT GetSDKVersion(void* sqvm);
|
||||
SQRESULT GetPromoData(void* sqvm);
|
||||
|
@ -253,16 +253,20 @@ void RegisterUIScriptFunctions(void* sqvm)
|
||||
|
||||
// functions for retrieving server browser data
|
||||
HSQVM_RegisterFunction(sqvm, "GetServerName", "get name of the server at the specified index of the server list", "string", "int", &SQNativeFunctions::IBrowser::GetServerName);
|
||||
HSQVM_RegisterFunction(sqvm, "GetServerDescription", "get description of the server at the specified index of the server list", "string", "int", &SQNativeFunctions::IBrowser::GetServerDescription);
|
||||
HSQVM_RegisterFunction(sqvm, "GetServerPlaylist", "get playlist of the server at the specified index of the server list", "string", "int", &SQNativeFunctions::IBrowser::GetServerPlaylist);
|
||||
HSQVM_RegisterFunction(sqvm, "GetServerMap", "get map of the server at the specified index of the server list", "string", "int", &SQNativeFunctions::IBrowser::GetServerMap);
|
||||
HSQVM_RegisterFunction(sqvm, "GetServerPlayersNum", "get num of connected players of the server at the specified index of the server list", "int", "int", &SQNativeFunctions::IBrowser::GetServerPlayersNum);
|
||||
HSQVM_RegisterFunction(sqvm, "GetServerMaxPlayersNum", "get num of max players of the server at the specified index of the server list", "int", "int", &SQNativeFunctions::IBrowser::GetServerMaxPlayersNum);
|
||||
HSQVM_RegisterFunction(sqvm, "GetServerCount", "get number of public servers", "int", "", &SQNativeFunctions::IBrowser::GetServerCount);
|
||||
|
||||
|
||||
// misc main menu functions
|
||||
HSQVM_RegisterFunction(sqvm, "GetSDKVersion", "get sdk version as a string", "string", "", &SQNativeFunctions::IBrowser::GetSDKVersion);
|
||||
HSQVM_RegisterFunction(sqvm, "GetPromoData", "get promo data for specified slot type", "string", "int", &SQNativeFunctions::IBrowser::GetPromoData);
|
||||
|
||||
// functions for connecting to servers
|
||||
HSQVM_RegisterFunction(sqvm, "CreateServer", "start server with the specified settings", "void", "string,string,string,int", &SQNativeFunctions::IBrowser::CreateServerFromMenu);
|
||||
HSQVM_RegisterFunction(sqvm, "CreateServer", "start server with the specified settings", "void", "string,string,string,string,string", &SQNativeFunctions::IBrowser::CreateServerFromMenu);
|
||||
HSQVM_RegisterFunction(sqvm, "SetEncKeyAndConnect", "set the encryption key to that of the specified server and connects to it", "void", "int", &SQNativeFunctions::IBrowser::SetEncKeyAndConnect);
|
||||
HSQVM_RegisterFunction(sqvm, "JoinPrivateServerFromMenu", "join private server by token", "void", "string", &SQNativeFunctions::IBrowser::JoinPrivateServerFromMenu);
|
||||
HSQVM_RegisterFunction(sqvm, "GetPrivateServerMessage", "get private server join status message", "string", "string", &SQNativeFunctions::IBrowser::GetPrivateServerMessage);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "inputsystem/inputsystem.h"
|
||||
#include "public/include/stb_image.h"
|
||||
#include <IDevPalette.h>
|
||||
#include <gameui/IBrowser.h>
|
||||
|
||||
/**********************************************************************************
|
||||
-----------------------------------------------------------------------------------
|
||||
@ -274,7 +275,7 @@ void DrawImGui()
|
||||
if (g_pIBrowser->m_bActivate)
|
||||
{
|
||||
g_pInputSystem->EnableInput(false); // Disable input to game when browser is drawn.
|
||||
g_pIBrowser->Draw("Server Browser", &g_pIBrowser->m_bActivate);
|
||||
//g_pIBrowser->Draw("Server Browser", &g_pIBrowser->m_bActivate);
|
||||
}
|
||||
if (g_pIConsole->m_bActivate)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user