From a20d6a163ee1f1361161a05ee9f2abad267def64 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Tue, 28 Jun 2022 00:47:01 +0200 Subject: [PATCH] Work-in-progress pylon master server implementation Still in development. Implemented new fields provided by pylon-ms. --- r5dev/gameui/IBrowser.cpp | 87 +++++++++++++------------ r5dev/networksystem/pylon.cpp | 30 +++++---- r5dev/networksystem/r5net.cpp | 99 +++++++++++++++++------------ r5dev/networksystem/serverlisting.h | 36 +++++++---- r5dev/squirrel/sqinit.cpp | 24 +++---- r5dev/tier0/basetypes.h | 2 +- r5dev/tier1/IConVar.cpp | 5 +- r5dev/tier1/cvar.cpp | 1 + r5dev/tier1/cvar.h | 1 + r5dev/vpc/keyvalues.cpp | 2 +- 10 files changed, 170 insertions(+), 117 deletions(-) diff --git a/r5dev/gameui/IBrowser.cpp b/r5dev/gameui/IBrowser.cpp index 3b4b73c7..20498277 100644 --- a/r5dev/gameui/IBrowser.cpp +++ b/r5dev/gameui/IBrowser.cpp @@ -35,6 +35,7 @@ History: #include "vstdlib/callback.h" #include "vpklib/packedstore.h" #include "gameui/IBrowser.h" +#include "public/include/edict.h" //----------------------------------------------------------------------------- // Purpose: @@ -196,11 +197,11 @@ void CBrowser::BrowserPanel(void) for (NetGameServer_t& server : m_vServerList) { - const char* pszHostName = server.svServerName.c_str(); - const char* pszHostMap = server.svMapName.c_str(); - const char* pszHostPort = server.svPort.c_str(); - const char* pszPlaylist = server.svPlaylist.c_str(); - const char* pszPlayers = server.svPlaylist.c_str(); + const char* pszHostName = server.m_svHostName.c_str(); + const char* pszHostMap = server.m_svMapName.c_str(); + const char* pszPlaylist = server.m_svPlaylist.c_str(); + const char* pszHostPort = std::to_string(server.m_nGamePort).c_str(); + const char* pszPlayers = std::to_string(server.m_nPlayerCount).c_str(); if (m_imServerBrowserFilter.PassFilter(pszHostName) || m_imServerBrowserFilter.PassFilter(pszHostMap) @@ -223,11 +224,11 @@ void CBrowser::BrowserPanel(void) ImGui::TableNextColumn(); string svConnectBtn = "Connect##"; - svConnectBtn.append(server.svServerName + server.svIpAddress + server.svMapName); + svConnectBtn.append(server.m_svHostName + server.m_svIpAddress + server.m_svMapName); if (ImGui::Button(svConnectBtn.c_str())) { - ConnectToServer(server.svIpAddress, server.svPort, server.svEncryptionKey); + ConnectToServer(server.m_svIpAddress, pszHostPort, server.m_svEncryptionKey); } } @@ -331,22 +332,22 @@ void CBrowser::ConnectToServer(const string& svServer, const string& svNetKey) void CBrowser::LaunchServer(void) { #ifndef CLIENT_DLL - DevMsg(eDLL_T::ENGINE, "Starting server with name: \"%s\" map: \"%s\" playlist: \"%s\"\n", m_Server.svServerName.c_str(), m_Server.svMapName.c_str(), m_Server.svPlaylist.c_str()); + 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.svPlaylist.c_str()); + KeyValues::ParsePlaylists(m_Server.m_svPlaylist.c_str()); stringstream ssModeCommand; - ssModeCommand << "mp_gamemode " << m_Server.svPlaylist; + ssModeCommand << "mp_gamemode " << m_Server.m_svPlaylist; ProcessCommand(ssModeCommand.str().c_str()); // This is to avoid a race condition. std::this_thread::sleep_for(std::chrono::milliseconds(100)); stringstream ssMapCommand; - ssMapCommand << "map " << m_Server.svMapName; + ssMapCommand << "map " << m_Server.m_svMapName; ProcessCommand(ssMapCommand.str().c_str()); #endif // !CLIENT_DLL } @@ -393,10 +394,10 @@ void CBrowser::HiddenServersModal(void) m_svHiddenServerRequestMessage.clear(); NetGameServer_t server; bool result = g_pR5net->GetServerByToken(server, m_svHiddenServerRequestMessage, m_svHiddenServerToken); // Send token connect request. - if (!server.svServerName.empty()) + if (!server.m_svHostName.empty()) { - ConnectToServer(server.svIpAddress, server.svPort, server.svEncryptionKey); // Connect to the server - m_svHiddenServerRequestMessage = "Found Server: " + server.svServerName; + ConnectToServer(server.m_svIpAddress, std::to_string(server.m_nGamePort), server.m_svEncryptionKey); // Connect to the server + m_svHiddenServerRequestMessage = "Found Server: " + server.m_svHostName; m_ivHiddenServerMessageColor = ImVec4(0.00f, 1.00f, 0.00f, 1.00f); ImGui::CloseCurrentPopup(); } @@ -425,28 +426,28 @@ void CBrowser::HostPanel(void) #ifndef CLIENT_DLL static string svServerNameErr = ""; - ImGui::InputTextWithHint("##ServerHost_ServerName", "Server Name (Required)", &m_Server.svServerName); + ImGui::InputTextWithHint("##ServerHost_ServerName", "Server Name (Required)", &m_Server.m_svHostName); ImGui::Spacing(); - if (ImGui::BeginCombo("Playlist", m_Server.svPlaylist.c_str())) + if (ImGui::BeginCombo("Playlist", m_Server.m_svPlaylist.c_str())) { for (auto& item : g_vAllPlaylists) { - if (ImGui::Selectable(item.c_str(), item == m_Server.svPlaylist)) + if (ImGui::Selectable(item.c_str(), item == m_Server.m_svPlaylist)) { - m_Server.svPlaylist = item; + m_Server.m_svPlaylist = item; } } ImGui::EndCombo(); } - if (ImGui::BeginCombo("Map##ServerHost_MapListBox", m_Server.svMapName.c_str())) + if (ImGui::BeginCombo("Map##ServerHost_MapListBox", m_Server.m_svMapName.c_str())) { for (auto& item : g_vAllMaps) { - if (ImGui::Selectable(item.c_str(), item == m_Server.svMapName)) + if (ImGui::Selectable(item.c_str(), item == m_Server.m_svMapName)) { - m_Server.svMapName = item; + m_Server.m_svMapName = item; } } ImGui::EndCombo(); @@ -479,22 +480,22 @@ void CBrowser::HostPanel(void) if (ImGui::Button("Start Server", ImVec2(ImGui::GetWindowSize().x, 32))) { svServerNameErr.clear(); - if (!m_Server.svServerName.empty() && !m_Server.svPlaylist.empty() && !m_Server.svMapName.empty()) + if (!m_Server.m_svHostName.empty() && !m_Server.m_svPlaylist.empty() && !m_Server.m_svMapName.empty()) { LaunchServer(); // Launch server. UpdateHostingStatus(); // Update hosting status. } else { - if (m_Server.svServerName.empty()) + if (m_Server.m_svHostName.empty()) { svServerNameErr = "No server name assigned."; } - else if (m_Server.svPlaylist.empty()) + else if (m_Server.m_svPlaylist.empty()) { svServerNameErr = "No playlist assigned."; } - else if (m_Server.svMapName.empty()) + else if (m_Server.m_svMapName.empty()) { svServerNameErr = "No level name assigned."; } @@ -505,18 +506,18 @@ void CBrowser::HostPanel(void) if (ImGui::Button("Force Start", ImVec2(ImGui::GetWindowSize().x, 32))) { svServerNameErr.clear(); - if (!m_Server.svPlaylist.empty() && !m_Server.svMapName.empty()) + if (!m_Server.m_svPlaylist.empty() && !m_Server.m_svMapName.empty()) { LaunchServer(); // Launch server. UpdateHostingStatus(); // Update hosting status. } else { - if (m_Server.svPlaylist.empty()) + if (m_Server.m_svPlaylist.empty()) { svServerNameErr = "No playlist assigned."; } - else if (m_Server.svMapName.empty()) + else if (m_Server.m_svMapName.empty()) { svServerNameErr = "No level name assigned."; } @@ -541,9 +542,9 @@ void CBrowser::HostPanel(void) if (ImGui::Button("Change Level", ImVec2(ImGui::GetWindowSize().x, 32))) { - if (!m_Server.svMapName.empty()) + if (!m_Server.m_svMapName.empty()) { - strncpy_s(g_pHostState->m_levelName, m_Server.svMapName.c_str(), 64); // Copy new map into hoststate levelname. 64 is size of m_levelname. + strncpy_s(g_pHostState->m_levelName, m_Server.m_svMapName.c_str(), 64); // Copy new map into hoststate levelname. 64 is size of m_levelname. g_pHostState->m_iNextState = HostStates_t::HS_CHANGE_LEVEL_MP; // Force CHostState::FrameUpdate to change the level. } else @@ -605,10 +606,10 @@ void CBrowser::UpdateHostingStatus(void) { case EServerVisibility::HIDDEN: - m_Server.bHidden = true; + m_Server.m_bHidden = true; break; case EServerVisibility::PUBLIC: - m_Server.bHidden = false; + m_Server.m_bHidden = false; break; default: break; @@ -633,16 +634,20 @@ void CBrowser::SendHostingPostRequest(void) bool result = g_pR5net->PostServerHost(m_svHostRequestMessage, m_svHostToken, NetGameServer_t { - m_Server.svServerName.c_str(), - string(g_pHostState->m_levelName), - "", - hostport->GetString(), + m_Server.m_svHostName.c_str(), + "", // description. + "", // password. + m_Server.m_bHidden, + g_pHostState->m_levelName, mp_gamemode->GetString(), - m_Server.bHidden, - std::to_string(*g_nClientRemoteChecksum), - - string(), - g_svNetKey.c_str() + hostip->GetString(), + hostport->GetInt(), + g_svNetKey.c_str(), + std::to_string(*g_nServerRemoteChecksum), + SDK_VERSION, + "", + g_pServer->GetNumHumanPlayers() + g_pServer->GetNumFakeClients(), + g_ServerGlobalVariables->m_nMaxClients } ); diff --git a/r5dev/networksystem/pylon.cpp b/r5dev/networksystem/pylon.cpp index a31cef45..dce0e88a 100644 --- a/r5dev/networksystem/pylon.cpp +++ b/r5dev/networksystem/pylon.cpp @@ -10,9 +10,11 @@ #include #include #include +#include #include #include #include +#include //----------------------------------------------------------------------------- // Purpose: Send keep alive request to Pylon Master Server. @@ -27,17 +29,23 @@ void KeepAliveToPylon() std::string m_szHostRequestMessage = std::string(); bool result = g_pR5net->PostServerHost(m_szHostRequestMessage, m_szHostToken, - NetGameServer_t{ - hostname->GetString(), - std::string(g_pHostState->m_levelName), - "", - hostport->GetString(), - mp_gamemode->GetString(), - false, - std::to_string(*g_nServerRemoteChecksum), - std::string(), - g_svNetKey.c_str() - } + NetGameServer_t + { + hostname->GetString(), + "", // description. + "", // password. + sv_pylonVisibility->GetInt() == 1, + g_pHostState->m_levelName, + mp_gamemode->GetString(), + hostip->GetString(), + hostport->GetInt(), + g_svNetKey.c_str(), + std::to_string(*g_nServerRemoteChecksum), + SDK_VERSION, + "", + g_pServer->GetNumHumanPlayers() + g_pServer->GetNumFakeClients(), + g_ServerGlobalVariables->m_nMaxClients + } ); } #endif // !CLIENT_DLL diff --git a/r5dev/networksystem/r5net.cpp b/r5dev/networksystem/r5net.cpp index e64ecc49..4689497d 100644 --- a/r5dev/networksystem/r5net.cpp +++ b/r5dev/networksystem/r5net.cpp @@ -31,11 +31,12 @@ vector R5Net::Client::GetServersList(string& svOutMessage) DevMsg(eDLL_T::ENGINE, "%s - Sending server list request to comp-server:\n%s\n", __FUNCTION__, svRequestBody.c_str()); } - httplib::Result htResults = m_HttpClient.Post("/servers", jsRequestBody.dump().c_str(), jsRequestBody.dump().length(), "application/json"); + //httplib::Result htResults = m_HttpClient.Post("/api/game_servers/list", jsRequestBody.dump(4).c_str(), jsRequestBody.dump(4).length(), "application/json"); + httplib::Result htResults = m_HttpClient.Get("/api/game_servers/list"); if (htResults && r5net_show_debug->GetBool()) { - DevMsg(eDLL_T::ENGINE, "GetServerList replied with '%d'.\n", htResults->status); + DevMsg(eDLL_T::ENGINE, "%s - replied with '%d'.\n", __FUNCTION__, htResults->status); } if (htResults && htResults->status == 200) // STATUS_OK @@ -46,16 +47,23 @@ vector R5Net::Client::GetServersList(string& svOutMessage) for (auto &obj : jsResultBody["servers"]) { vslList.push_back( - NetGameServer_t{ + NetGameServer_t + { obj.value("name",""), - obj.value("map", ""), - obj.value("ip", ""), - obj.value("port", ""), - obj.value("gamemode", ""), - obj.value("hidden", "false") == "true", - obj.value("remote_checksum", ""), + obj.value("description",""), + obj.value("password",""), + obj.value("hidden","false") == "true", + obj.value("map",""), + obj.value("playlist",""), + obj.value("ip",""), + obj.value("port", 0), + obj.value("key",""), + obj.value("checksum",""), obj.value("version", GetSDKVersion()), - obj.value("encKey", "") + obj.value("publicRef", ""), + obj.value("playerCount", 0), + obj.value("maxPlayers", 0), + obj.value("lastHeartbeat", 0), } ); } @@ -86,17 +94,17 @@ vector R5Net::Client::GetServersList(string& svOutMessage) } else { - svOutMessage = string("Failed to reach comp-server ") + std::to_string(htResults->status); + svOutMessage = string("Failed to reach comp-server: ") + std::to_string(htResults->status); } return vslList; } - svOutMessage = string("Failed to reach comp-server ") + std::to_string(htResults->status); + svOutMessage = string("Failed to reach comp-server: ") + std::to_string(htResults->status); return vslList; } - svOutMessage = "Failed to reach comp-server. Unknown error code."; + svOutMessage = "Failed to reach comp-server: Unknown error code"; return vslList; } @@ -110,17 +118,23 @@ vector R5Net::Client::GetServersList(string& svOutMessage) // &slServerListing - // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- -bool R5Net::Client::PostServerHost(string& svOutMessage, string& svOutToken, const NetGameServer_t& slServerListing) +bool R5Net::Client::PostServerHost(string& svOutMessage, string& svOutToken, const NetGameServer_t& slServerListing) // isBanned { nlohmann::json jsRequestBody = nlohmann::json::object(); - jsRequestBody["name"] = slServerListing.svServerName; - jsRequestBody["map"] = slServerListing.svMapName; - jsRequestBody["port"] = slServerListing.svPort; - jsRequestBody["remote_checksum"] = slServerListing.svRemoteChecksum; + jsRequestBody["name"] = slServerListing.m_svHostName; + jsRequestBody["description"] = slServerListing.m_svDescription; + jsRequestBody["password"] = slServerListing.m_svPassword; + jsRequestBody["hidden"] = slServerListing.m_bHidden; + jsRequestBody["map"] = slServerListing.m_svMapName; + jsRequestBody["playlist"] = slServerListing.m_svPlaylist; + jsRequestBody["ip"] = slServerListing.m_svIpAddress; + jsRequestBody["port"] = slServerListing.m_nGamePort; + jsRequestBody["key"] = slServerListing.m_svEncryptionKey; + jsRequestBody["checksum"] = slServerListing.m_svRemoteChecksum; jsRequestBody["version"] = GetSDKVersion(); - jsRequestBody["gamemode"] = slServerListing.svPlaylist; - jsRequestBody["encKey"] = slServerListing.svEncryptionKey; - jsRequestBody["hidden"] = slServerListing.bHidden; + jsRequestBody["playerCount"] = slServerListing.m_nPlayerCount; + jsRequestBody["maxPlayers"] = slServerListing.m_nMaxPlayers; + jsRequestBody["lastHeartbeat"] = slServerListing.m_nLastPing; string svRequestBody = jsRequestBody.dump(4); @@ -129,7 +143,7 @@ bool R5Net::Client::PostServerHost(string& svOutMessage, string& svOutToken, con DevMsg(eDLL_T::ENGINE, "%s - Sending post host request to comp-server:\n%s\n", __FUNCTION__, svRequestBody.c_str()); } - httplib::Result htResults = m_HttpClient.Post("/servers/add", svRequestBody.c_str(), svRequestBody.length(), "application/json"); + httplib::Result htResults = m_HttpClient.Post("/api/game_servers/update", svRequestBody.c_str(), svRequestBody.length(), "application/json"); if (htResults && r5net_show_debug->GetBool()) { @@ -187,12 +201,12 @@ bool R5Net::Client::PostServerHost(string& svOutMessage, string& svOutToken, con } svOutToken = string(); - svOutMessage = string("Failed to reach comp-server ") + std::to_string(htResults->status); + svOutMessage = string("Failed to reach comp-server: ") + std::to_string(htResults->status); return false; } svOutToken = string(); - svOutMessage = "Failed to reach comp-server. Unknown error code."; + svOutMessage = "Failed to reach comp-server: Unknown error code"; return false; } @@ -218,7 +232,7 @@ bool R5Net::Client::GetServerByToken(NetGameServer_t& slOutServer, string& svOut DevMsg(eDLL_T::ENGINE, "%s - Sending token connect request to comp-server:\n%s\n", __FUNCTION__, svRequestBody.c_str()); } - httplib::Result htResults = m_HttpClient.Post("/server/byToken", jsRequestBody.dump().c_str(), jsRequestBody.dump().length(), "application/json"); + httplib::Result htResults = m_HttpClient.Post("/api/game_servers/game_server_private_info", jsRequestBody.dump(4).c_str(), jsRequestBody.dump(4).length(), "application/json"); if (r5net_show_debug->GetBool()) { @@ -233,16 +247,23 @@ bool R5Net::Client::GetServerByToken(NetGameServer_t& slOutServer, string& svOut if (htResults && jsResultBody["success"].is_boolean() && jsResultBody["success"]) { - slOutServer = NetGameServer_t{ + slOutServer = NetGameServer_t + { jsResultBody["server"].value("name",""), - jsResultBody["server"].value("map", ""), - jsResultBody["server"].value("ip", ""), - jsResultBody["server"].value("port", ""), - jsResultBody["server"].value("gamemode", ""), - jsResultBody["server"].value("hidden", "false") == "true", - jsResultBody["server"].value("remote_checksum", ""), + jsResultBody["server"].value("description",""), + jsResultBody["server"].value("password",""), + jsResultBody["server"].value("hidden","false") == "true", + jsResultBody["server"].value("map",""), + jsResultBody["server"].value("playlist",""), + jsResultBody["server"].value("ip",""), + jsResultBody["server"].value("port", 0), + jsResultBody["server"].value("key",""), + jsResultBody["server"].value("checksum",""), jsResultBody["server"].value("version", GetSDKVersion()), - jsResultBody["server"].value("encKey", "") + jsResultBody["server"].value("publicRef", ""), + jsResultBody["server"].value("playerCount", 0), + jsResultBody["server"].value("maxPlayers", 0), + jsResultBody["server"].value("lastHeartbeat", 0), }; return true; } @@ -276,17 +297,17 @@ bool R5Net::Client::GetServerByToken(NetGameServer_t& slOutServer, string& svOut } else { - svOutMessage = string("Failed to reach comp-server ") + std::to_string(htResults->status); + svOutMessage = string("Failed to reach comp-server: ") + std::to_string(htResults->status); } return false; } - svOutMessage = string("Failed to reach comp-server ") + std::to_string(htResults->status); + svOutMessage = string("Failed to reach comp-server: ") + std::to_string(htResults->status); return false; } - svOutMessage = "Failed to reach comp-server. Unknown error code."; + svOutMessage = "Failed to reach comp-server: Unknown error code"; slOutServer = NetGameServer_t{}; return false; } @@ -304,10 +325,10 @@ bool R5Net::Client::GetServerByToken(NetGameServer_t& slOutServer, string& svOut bool R5Net::Client::GetClientIsBanned(const string& svIpAddress, uint64_t nOriginID, string& svOutErrCl) { nlohmann::json jsRequestBody = nlohmann::json::object(); + jsRequestBody["oid"] = nOriginID; jsRequestBody["ip"] = svIpAddress; - jsRequestBody["orid"] = nOriginID; - httplib::Result htResults = m_HttpClient.Post("/banlist/isBanned", jsRequestBody.dump().c_str(), jsRequestBody.dump().length(), "application/json"); + httplib::Result htResults = m_HttpClient.Post("/api/ban_system/is_user_banned", jsRequestBody.dump(4).c_str(), jsRequestBody.dump(4).length(), "application/json"); if (htResults && htResults->status == 200) { @@ -315,7 +336,7 @@ bool R5Net::Client::GetClientIsBanned(const string& svIpAddress, uint64_t nOrigi if (jsResultBody["success"].is_boolean() && jsResultBody["success"].get()) { - if (jsResultBody["isBanned"].is_boolean() && jsResultBody["isBanned"].get()) + if (jsResultBody["banned"].is_boolean() && jsResultBody["banned"].get()) { svOutErrCl = jsResultBody.value("errCl", "#DISCONNECT_BANNED"); return true; diff --git a/r5dev/networksystem/serverlisting.h b/r5dev/networksystem/serverlisting.h index 0799e614..2c66d8f2 100644 --- a/r5dev/networksystem/serverlisting.h +++ b/r5dev/networksystem/serverlisting.h @@ -8,18 +8,32 @@ struct NetGameMod_t bool m_bRequired; string m_svDownloadLink; - NLOHMANN_DEFINE_TYPE_INTRUSIVE(NetGameMod_t, m_svPackage, m_nNumber, m_bRequired, m_svDownloadLink) + //NLOHMANN_DEFINE_TYPE_INTRUSIVE(NetGameMod_t, m_svPackage, m_nNumber, m_bRequired, m_svDownloadLink) }; struct NetGameServer_t { - string svServerName; - string svMapName = "mp_lobby"; - string svPlaylist = "dev_default"; - string svIpAddress; - string svPort; - bool bHidden{}; - string svRemoteChecksum; - string svVersion; - string svEncryptionKey; -}; + string m_svHostName; + string m_svDescription; + + string m_svPassword; + bool m_bHidden; + + string m_svMapName = "mp_lobby"; + string m_svPlaylist = "dev_default"; + + string m_svIpAddress; + int m_nGamePort; + + string m_svEncryptionKey; + string m_svRemoteChecksum; + + string m_svSDKVersion; + string m_svPublicRef; + + int m_nPlayerCount; + int m_nMaxPlayers; + int m_nLastPing = -1; + + //vector m_vMods; +}; \ No newline at end of file diff --git a/r5dev/squirrel/sqinit.cpp b/r5dev/squirrel/sqinit.cpp index 9b08b339..2c80e18a 100644 --- a/r5dev/squirrel/sqinit.cpp +++ b/r5dev/squirrel/sqinit.cpp @@ -130,7 +130,7 @@ namespace VSquirrel SQRESULT GetServerName(HSQUIRRELVM v) { SQInteger iServerIndex = sq_getinteger(v, 1); - string svServerName = g_pBrowser->m_vServerList[iServerIndex].svServerName; + string svServerName = g_pBrowser->m_vServerList[iServerIndex].m_svHostName; sq_pushstring(v, svServerName.c_str(), -1); @@ -143,7 +143,7 @@ namespace VSquirrel SQRESULT GetServerPlaylist(HSQUIRRELVM v) { SQInteger iServerIndex = sq_getinteger(v, 1); - string svServerPlaylist = g_pBrowser->m_vServerList[iServerIndex].svPlaylist; + string svServerPlaylist = g_pBrowser->m_vServerList[iServerIndex].m_svPlaylist; sq_pushstring(v, svServerPlaylist.c_str(), -1); @@ -156,7 +156,7 @@ namespace VSquirrel SQRESULT GetServerMap(HSQUIRRELVM v) { SQInteger iServerIndex = sq_getinteger(v, 1); - string svServerMapName = g_pBrowser->m_vServerList[iServerIndex].svMapName; + string svServerMapName = g_pBrowser->m_vServerList[iServerIndex].m_svMapName; sq_pushstring(v, svServerMapName.c_str(), -1); @@ -245,7 +245,9 @@ namespace VSquirrel SQInteger iServerIndex = sq_getinteger(v, 1); // !TODO: Create glue class instead. - g_pBrowser->ConnectToServer(g_pBrowser->m_vServerList[iServerIndex].svIpAddress, g_pBrowser->m_vServerList[iServerIndex].svPort, g_pBrowser->m_vServerList[iServerIndex].svEncryptionKey); + g_pBrowser->ConnectToServer(g_pBrowser->m_vServerList[iServerIndex].m_svIpAddress, + std::to_string(g_pBrowser->m_vServerList[iServerIndex].m_nGamePort), + g_pBrowser->m_vServerList[iServerIndex].m_svEncryptionKey); return SQ_OK; } @@ -264,9 +266,9 @@ namespace VSquirrel return SQ_OK; // Adjust browser settings. - g_pBrowser->m_Server.svPlaylist = svServerPlaylist; - g_pBrowser->m_Server.svMapName = svServerMapName; - g_pBrowser->m_Server.svServerName = svServerName; + g_pBrowser->m_Server.m_svPlaylist = svServerPlaylist; + g_pBrowser->m_Server.m_svMapName = svServerMapName; + g_pBrowser->m_Server.m_svHostName = svServerName; g_pBrowser->eServerVisibility = eServerVisibility; // Launch server. @@ -287,7 +289,7 @@ namespace VSquirrel bool result = g_pR5net->GetServerByToken(svListing, svHiddenServerRequestMessage, svToken); // Send szToken connect request. if (result) { - g_pBrowser->ConnectToServer(svListing.svIpAddress, svListing.svPort, svListing.svEncryptionKey); + g_pBrowser->ConnectToServer(svListing.m_svIpAddress, std::to_string(svListing.m_nGamePort), svListing.m_svEncryptionKey); } return SQ_OK; @@ -302,10 +304,10 @@ namespace VSquirrel string svToken = sq_getstring(v, 1); NetGameServer_t serverListing; - bool result = g_pR5net->GetServerByToken(serverListing, svHiddenServerRequestMessage, svToken); // Send szToken connect request. - if (!serverListing.svServerName.empty()) + bool result = g_pR5net->GetServerByToken(serverListing, svHiddenServerRequestMessage, svToken); // Send token connect request. + if (!serverListing.m_svHostName.empty()) { - svHiddenServerRequestMessage = "Found Server: " + serverListing.svServerName; + svHiddenServerRequestMessage = "Found Server: " + serverListing.m_svHostName; sq_pushstring(v, svHiddenServerRequestMessage.c_str(), -1); } else diff --git a/r5dev/tier0/basetypes.h b/r5dev/tier0/basetypes.h index ed044e58..fe0e77f9 100644 --- a/r5dev/tier0/basetypes.h +++ b/r5dev/tier0/basetypes.h @@ -134,7 +134,7 @@ #endif // Max BSP file name len. #define MAX_MAP_NAME 64 -#define SDK_VERSION "beta 1.6"/*"VGameSDK001"*/ // Increment this with every /breaking/ SDK change (i.e. security/backend changes breaking compatibility). +#define SDK_VERSION "VGameSDK001" // Increment this with every /breaking/ SDK change (i.e. security/backend changes breaking compatibility). #ifndef DEDICATED #define SDK_DEFAULT_CFG "platform\\cfg\\startup_default.cfg" diff --git a/r5dev/tier1/IConVar.cpp b/r5dev/tier1/IConVar.cpp index fca670b6..18d89adc 100644 --- a/r5dev/tier1/IConVar.cpp +++ b/r5dev/tier1/IConVar.cpp @@ -67,7 +67,7 @@ void ConVar::Init(void) const navmesh_always_reachable = new ConVar("navmesh_always_reachable" , "1", FCVAR_DEVELOPMENTONLY, "Marks poly from agent to target on navmesh as reachable regardless of table data ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr); // !TODO: Default to '0' once the reachability table gets properly parsed. sv_showconnecting = new ConVar("sv_showconnecting" , "1", FCVAR_RELEASE, "Logs information about the connecting client to the console.", false, 0.f, false, 0.f, nullptr, nullptr); - sv_pylonVisibility = new ConVar("sv_pylonVisibility", "0", FCVAR_RELEASE, "Determines the visiblity to the Pylon master server, 0 = Not visible, 1 = Hidden, 2 = Visible !TODO: not implemented yet.", false, 0.f, false, 0.f, nullptr, nullptr); + sv_pylonVisibility = new ConVar("sv_pylonVisibility", "0", FCVAR_RELEASE, "Determines the visiblity to the Pylon master server, 0 = Offline, 1 = Hidden, 2 = Public.", false, 0.f, false, 0.f, nullptr, nullptr); sv_pylonRefreshInterval = new ConVar("sv_pylonRefreshInterval" , "5.0", FCVAR_RELEASE, "Pylon server host request post update interval (seconds).", true, 2.f, true, 8.f, nullptr, nullptr); sv_banlistRefreshInterval = new ConVar("sv_banlistRefreshInterval", "1.0", FCVAR_RELEASE, "Banlist refresh interval (seconds).", true, 1.f, false, 0.f, nullptr, nullptr); sv_statusRefreshInterval = new ConVar("sv_statusRefreshInterval" , "0.5", FCVAR_RELEASE, "Server status bar update interval (seconds).", false, 0.f, false, 0.f, nullptr, nullptr); @@ -151,7 +151,7 @@ void ConVar::Init(void) const net_tracePayload = new ConVar("net_tracePayload" , "0", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT , "Log the payload of the send/recv datagram to a file on the disk.", false, 0.f, false, 0.f, nullptr, nullptr); net_encryptionEnable = new ConVar("net_encryptionEnable" , "1", FCVAR_DEVELOPMENTONLY | FCVAR_REPLICATED , "Use AES encryption on game packets.", false, 0.f, false, 0.f, nullptr, nullptr); net_useRandomKey = new ConVar("net_useRandomKey" , "1" , FCVAR_RELEASE , "Use random base64 netkey for game packets.", false, 0.f, false, 0.f, nullptr, nullptr); - r5net_matchmaking_hostname = new ConVar("r5net_matchmaking_hostname", "r5a-comp-sv.herokuapp.com", FCVAR_RELEASE , "Holds the R5Net matchmaking hostname.", false, 0.f, false, 0.f, nullptr, nullptr); + r5net_matchmaking_hostname = new ConVar("r5net_matchmaking_hostname", "127.0.0.1:3000" , FCVAR_RELEASE , "Holds the R5Net matchmaking hostname.", false, 0.f, false, 0.f, nullptr, nullptr); r5net_show_debug = new ConVar("r5net_show_debug" , "0" , FCVAR_DEVELOPMENTONLY, "Shows debug output for R5Net.", false, 0.f, false, 0.f, nullptr, nullptr); //------------------------------------------------------------------------- // RTECH API | @@ -177,6 +177,7 @@ void ConVar::InitShipped(void) const old_gather_props = g_pCVar->FindVar("old_gather_props"); mp_gamemode = g_pCVar->FindVar("mp_gamemode"); hostname = g_pCVar->FindVar("hostname"); + hostip = g_pCVar->FindVar("hostip"); hostport = g_pCVar->FindVar("hostport"); host_hasIrreversibleShutdown = g_pCVar->FindVar("host_hasIrreversibleShutdown"); net_usesocketsforloopback = g_pCVar->FindVar("net_usesocketsforloopback"); diff --git a/r5dev/tier1/cvar.cpp b/r5dev/tier1/cvar.cpp index 2e8c021f..482201ff 100644 --- a/r5dev/tier1/cvar.cpp +++ b/r5dev/tier1/cvar.cpp @@ -17,6 +17,7 @@ ConVar* model_defaultFadeDistScale = nullptr; ConVar* model_defaultFadeDistMin = nullptr; ConVar* hostname = nullptr; +ConVar* hostip = nullptr; ConVar* hostport = nullptr; ConVar* host_hasIrreversibleShutdown = nullptr; ConVar* mp_gamemode = nullptr; diff --git a/r5dev/tier1/cvar.h b/r5dev/tier1/cvar.h index 683c6637..b64ccfbf 100644 --- a/r5dev/tier1/cvar.h +++ b/r5dev/tier1/cvar.h @@ -15,6 +15,7 @@ extern ConVar* model_defaultFadeDistScale; extern ConVar* model_defaultFadeDistMin; extern ConVar* hostname; +extern ConVar* hostip; extern ConVar* hostport; extern ConVar* host_hasIrreversibleShutdown; diff --git a/r5dev/vpc/keyvalues.cpp b/r5dev/vpc/keyvalues.cpp index d40be2b0..083a501f 100644 --- a/r5dev/vpc/keyvalues.cpp +++ b/r5dev/vpc/keyvalues.cpp @@ -1343,4 +1343,4 @@ void CKeyValueSystem_Detach() /////////////////////////////////////////////////////////////////////////////// inline KeyValues** g_pPlaylistKeyValues = nullptr; // Get the KeyValue for the playlist file. vector g_vAllPlaylists = { "<>" }; -vector g_vGameInfoPaths = { "\\" }; \ No newline at end of file +vector g_vGameInfoPaths = { "/" }; \ No newline at end of file