From 1f765381c34e7005f2fbbcce3a7a7da8f6160cf5 Mon Sep 17 00:00:00 2001 From: rjindael Date: Thu, 7 Sep 2023 16:02:32 -0700 Subject: [PATCH] feat: parse AppSettings for BaseUrl and fixes --- CMakeLists.txt | 4 ++++ Kiseki.Patcher/CMakeLists.txt | 4 +++- Kiseki.Patcher/Header/Discord.hpp | 2 ++ Kiseki.Patcher/Header/Helpers.hpp | 2 ++ Kiseki.Patcher/Source/Helpers.cpp | 24 ++++++++++++++++++++++++ vcpkg.json | 1 + 6 files changed, 36 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12e86d4..d659a4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.4) set(CMAKE_CXX_STANDARD 17) +# TODO: This shouldn't be necessary. +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") + project(Kiseki.Patcher VERSION 1.0.0) option(COMPILE_PLAYER "Include player-specific code" OFF) diff --git a/Kiseki.Patcher/CMakeLists.txt b/Kiseki.Patcher/CMakeLists.txt index f437fc3..438f54d 100644 --- a/Kiseki.Patcher/CMakeLists.txt +++ b/Kiseki.Patcher/CMakeLists.txt @@ -43,12 +43,14 @@ add_library(Kiseki.Patcher SHARED ${SOURCE} ${HEADER}) # Packages find_package(CURL CONFIG REQUIRED) +find_package(rapidjson CONFIG REQUIRED) +find_package(pugixml CONFIG REQUIRED) find_path(DETOURS_INCLUDE_DIRS "detours/detours.h") find_library(DETOURS_LIBRARY detours REQUIRED) target_include_directories(Kiseki.Patcher PRIVATE Header ${DETOURS_INCLUDE_DIRS}) -target_link_libraries(Kiseki.Patcher PRIVATE CURL::libcurl ${DETOURS_LIBRARY}) +target_link_libraries(Kiseki.Patcher PRIVATE CURL::libcurl ${DETOURS_LIBRARY} pugixml::static pugixml::pugixml rapidjson) # Target-specific linking and compile options if(COMPILE_PLAYER) diff --git a/Kiseki.Patcher/Header/Discord.hpp b/Kiseki.Patcher/Header/Discord.hpp index c3d5523..c5a635f 100644 --- a/Kiseki.Patcher/Header/Discord.hpp +++ b/Kiseki.Patcher/Header/Discord.hpp @@ -2,6 +2,8 @@ #pragma once +#include + #include #include #include diff --git a/Kiseki.Patcher/Header/Helpers.hpp b/Kiseki.Patcher/Header/Helpers.hpp index 1563a78..0468832 100644 --- a/Kiseki.Patcher/Header/Helpers.hpp +++ b/Kiseki.Patcher/Header/Helpers.hpp @@ -8,6 +8,7 @@ #include #include +#include #include "Globals.hpp" @@ -30,4 +31,5 @@ public: static std::string getISOTimestamp(); static std::pair> parseURL(const std::string url); static std::pair httpGet(const std::string url); + static std::string getBaseUrl(); }; \ No newline at end of file diff --git a/Kiseki.Patcher/Source/Helpers.cpp b/Kiseki.Patcher/Source/Helpers.cpp index 31a35cd..724c5f6 100644 --- a/Kiseki.Patcher/Source/Helpers.cpp +++ b/Kiseki.Patcher/Source/Helpers.cpp @@ -211,3 +211,27 @@ std::pair Helpers::httpGet(const std::string url) return std::make_pair(true, data); } + +std::string Helpers::getBaseUrl() +{ + std::string path = Helpers::getModulePath(); + path = path.substr(0, path.find_last_of("\\/")); + + pugi::xml_document document; + pugi::xml_parse_result result = document.load_file((path + "\\AppSettings.xml").c_str()); + + if (!result) + { + return ""; + } + + pugi::xml_node settings = document.child("Settings"); + pugi::xml_node baseUrl = settings.child("BaseUrl"); + + if (!baseUrl) + { + return ""; + } + + return baseUrl.child_value(); +} \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json index 339d7a0..543de3a 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -6,6 +6,7 @@ "curl", "detours", "discord-rpc", + "pugixml", "rapidjson" ] } \ No newline at end of file