From 5e3e8d5a5f36bff0bbf83f4de262155c8dd11e5c Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 13 Aug 2021 22:57:47 +0300 Subject: [PATCH] Fixed prev commit (mostly) --- r5dev/r5dev.vcxproj | 1 + r5dev/r5dev.vcxproj.filters | 1 + r5dev/src/CCompanion.cpp | 9 +++++---- r5net/include/{pch.h => netpch.h} | 0 r5net/include/r5net.h | 1 + r5net/include/serverlisting.h | 2 +- r5net/r5net.vcxproj | 8 ++++---- r5net/r5net.vcxproj.filters | 4 ++-- r5net/src/netpch.cpp | 3 +++ r5net/src/pch.cpp | 3 --- r5net/src/r5net.cpp | 10 +++++----- r5net/src/serverlisting.cpp | 2 +- 12 files changed, 24 insertions(+), 20 deletions(-) rename r5net/include/{pch.h => netpch.h} (100%) create mode 100644 r5net/src/netpch.cpp delete mode 100644 r5net/src/pch.cpp diff --git a/r5dev/r5dev.vcxproj b/r5dev/r5dev.vcxproj index 00dd2b71..7dc184fa 100644 --- a/r5dev/r5dev.vcxproj +++ b/r5dev/r5dev.vcxproj @@ -320,6 +320,7 @@ + diff --git a/r5dev/r5dev.vcxproj.filters b/r5dev/r5dev.vcxproj.filters index 36ede3c6..7ef923d9 100644 --- a/r5dev/r5dev.vcxproj.filters +++ b/r5dev/r5dev.vcxproj.filters @@ -551,6 +551,7 @@ gui\include + diff --git a/r5dev/src/CCompanion.cpp b/r5dev/src/CCompanion.cpp index 48d1a41e..878f4b5d 100644 --- a/r5dev/src/CCompanion.cpp +++ b/r5dev/src/CCompanion.cpp @@ -97,7 +97,7 @@ void CCompanion::RefreshServerList() void CCompanion::SendHostingPostRequest() { HostToken = ""; - bool result = r5net.PostServerHost(HostRequestMessage, HostToken, ServerListing{ MyServer.name, std::string(GameGlobals::HostState->m_levelName), GameGlobals::Cvar->FindVar("hostport")->m_pzsCurrentValue, MyServer.password }); + bool result = r5net.PostServerHost(HostRequestMessage, HostToken, ServerListing{ MyServer.name, std::string(GameGlobals::HostState->m_levelName), "", GameGlobals::Cvar->FindVar("hostport")->m_pzsCurrentValue, MyServer.password}); if (result) { HostRequestMessageColor = ImVec4(0.00f, 1.00f, 0.00f, 1.00f); @@ -150,7 +150,7 @@ void CCompanion::ServerBrowserSection() const float FooterHeight = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing(); ImGui::BeginChild("ServerListChild", { 0, -FooterHeight }, true, ImGuiWindowFlags_AlwaysVerticalScrollbar); - ImGui::BeginTable("##ServerBrowser_ServerList", 4, ImGuiTableFlags_Resizable); + if(ImGui::BeginTable("##ServerBrowser_ServerList", 4, ImGuiTableFlags_Resizable)) { ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthStretch, 35); ImGui::TableSetupColumn("Map", ImGuiTableColumnFlags_WidthStretch, 25); @@ -183,18 +183,19 @@ void CCompanion::ServerBrowserSection() if (ImGui::Button(selectButtonText.c_str())) { - //server->Select(); + ConnectToServer(server.ip, server.port); } } } + ImGui::EndTable(); } - ImGui::EndTable(); ImGui::EndChild(); ImGui::Separator(); ImGui::InputTextWithHint("##ServerBrowser_ServerConnString", "Enter IP address or \"localhost\"", ServerConnStringBuffer, IM_ARRAYSIZE(ServerConnStringBuffer)); + ImGui::Text("hello"); ImGui::SameLine(); if (ImGui::Button("Connect", ImVec2(ImGui::GetWindowContentRegionWidth() * (1.f / 3.f /2.f), 19))) diff --git a/r5net/include/pch.h b/r5net/include/netpch.h similarity index 100% rename from r5net/include/pch.h rename to r5net/include/netpch.h diff --git a/r5net/include/r5net.h b/r5net/include/r5net.h index 5a708dd3..fba7f02e 100644 --- a/r5net/include/r5net.h +++ b/r5net/include/r5net.h @@ -19,6 +19,7 @@ namespace R5Net Client(std::string serverString) : m_HttpClient(serverString.c_str()) { m_HttpClient.set_connection_timeout(10); + } diff --git a/r5net/include/serverlisting.h b/r5net/include/serverlisting.h index 86811e5f..92cd0a30 100644 --- a/r5net/include/serverlisting.h +++ b/r5net/include/serverlisting.h @@ -1,6 +1,6 @@ #pragma once -#include "pch.h" +#include "netpch.h" struct ServerListing { diff --git a/r5net/r5net.vcxproj b/r5net/r5net.vcxproj index 2fc91ca7..081afc9e 100644 --- a/r5net/r5net.vcxproj +++ b/r5net/r5net.vcxproj @@ -19,12 +19,12 @@ - + - + Create Create @@ -142,7 +142,7 @@ _DEBUG;_LIB;%(PreprocessorDefinitions) true Use - pch.h + netpch.h stdcpp17 @@ -160,7 +160,7 @@ NDEBUG;_LIB;%(PreprocessorDefinitions) true Use - pch.h + netpch.h stdcpp17 diff --git a/r5net/r5net.vcxproj.filters b/r5net/r5net.vcxproj.filters index 849b004e..f76f868a 100644 --- a/r5net/r5net.vcxproj.filters +++ b/r5net/r5net.vcxproj.filters @@ -15,7 +15,7 @@ include - + include @@ -26,7 +26,7 @@ src - + src diff --git a/r5net/src/netpch.cpp b/r5net/src/netpch.cpp new file mode 100644 index 00000000..783231ed --- /dev/null +++ b/r5net/src/netpch.cpp @@ -0,0 +1,3 @@ +#pragma once + +#include "netpch.h" \ No newline at end of file diff --git a/r5net/src/pch.cpp b/r5net/src/pch.cpp deleted file mode 100644 index 8d6bea21..00000000 --- a/r5net/src/pch.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#include "pch.h" \ No newline at end of file diff --git a/r5net/src/r5net.cpp b/r5net/src/r5net.cpp index 269dccf0..28d2fca3 100644 --- a/r5net/src/r5net.cpp +++ b/r5net/src/r5net.cpp @@ -1,7 +1,7 @@ // r5net.cpp : Defines the functions for the static library. // -#include "pch.h" +#include "netpch.h" #include "r5net.h" @@ -77,10 +77,10 @@ bool R5Net::Client::GetServerByToken(ServerListing& outServer, std::string& outE if (res && resBody["success"].is_boolean() && resBody["success"]) { outServer = ServerListing{ - reqBody["name"].get(), - reqBody["map"].get(), - reqBody["ip"].get(), - reqBody["port"].get() + resBody["server"]["name"].get(), + resBody["server"]["map"].get(), + resBody["server"]["ip"].get(), + resBody["server"]["port"].get() }; return true; } diff --git a/r5net/src/serverlisting.cpp b/r5net/src/serverlisting.cpp index 376b3ca2..fecac08a 100644 --- a/r5net/src/serverlisting.cpp +++ b/r5net/src/serverlisting.cpp @@ -1,3 +1,3 @@ -#include "pch.h" +#include "netpch.h" #include "serverlisting.h"