summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2023-12-14 21:21:59 +0100
committerGitHub <noreply@github.com>2023-12-14 21:21:59 +0100
commit84ac561e46bdd62cb362e548fecaa74b50e2f05b (patch)
tree0245ab950aafc036c2788c1d71c3991230a9a93b /Source
parente34bfe0f729c26085c126653204a9fa26525d9f1 (diff)
parent88431cfbca00495f597418d87384efe8e440b628 (diff)
Merge pull request #12421 from lioncash/fwd
WC24PatchEngine: Move IniFile header dependency into the cpp file
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/WC24PatchEngine.cpp30
-rw-r--r--Source/Core/Core/WC24PatchEngine.h8
2 files changed, 18 insertions, 20 deletions
diff --git a/Source/Core/Core/WC24PatchEngine.cpp b/Source/Core/Core/WC24PatchEngine.cpp
index 1fd7462b77..7a9b5a25ff 100644
--- a/Source/Core/Core/WC24PatchEngine.cpp
+++ b/Source/Core/Core/WC24PatchEngine.cpp
@@ -4,17 +4,19 @@
// WC24PatchEngine
// Allows for replacing URLs used in WC24 requests
+#include "Core/WC24PatchEngine.h"
+
#include <algorithm>
#include <array>
#include <fmt/format.h>
+#include "Common/IniFile.h"
#include "Common/StringUtil.h"
#include "Core/CheatCodes.h"
#include "Core/CommonTitles.h"
#include "Core/Config/MainSettings.h"
#include "Core/ConfigManager.h"
-#include "Core/WC24PatchEngine.h"
namespace WC24PatchEngine
{
@@ -38,7 +40,7 @@ static constexpr std::array<u64, 15> s_wc24_channels{
static std::vector<NetworkPatch> s_patches;
-bool DeserializeLine(const std::string& line, NetworkPatch* patch)
+static bool DeserializeLine(const std::string& line, NetworkPatch* patch)
{
const std::vector<std::string> items = SplitString(line, ':');
@@ -54,13 +56,13 @@ bool DeserializeLine(const std::string& line, NetworkPatch* patch)
return patch;
}
-void LoadPatchSection(const Common::IniFile& ini)
+static void LoadPatchSection(const Common::IniFile& ini)
{
std::vector<std::string> lines;
NetworkPatch patch;
ini.GetLines("WC24Patch", &lines);
- for (std::string& line : lines)
+ for (const std::string& line : lines)
{
if (line.empty())
continue;
@@ -81,6 +83,15 @@ void LoadPatchSection(const Common::IniFile& ini)
ReadEnabledAndDisabled(ini, "WC24Patch", &s_patches);
}
+static bool IsWC24Channel()
+{
+ const auto& sconfig = SConfig::GetInstance();
+ const auto found =
+ std::find(s_wc24_channels.begin(), s_wc24_channels.end(), sconfig.GetTitleID());
+
+ return found != s_wc24_channels.end();
+}
+
static void LoadPatches()
{
const auto& sconfig = SConfig::GetInstance();
@@ -98,22 +109,13 @@ static void LoadPatches()
LoadPatchSection(ini);
}
-bool IsWC24Channel()
-{
- const auto& sconfig = SConfig::GetInstance();
- const auto found =
- std::find(s_wc24_channels.begin(), s_wc24_channels.end(), sconfig.GetTitleID());
-
- return found != s_wc24_channels.end();
-}
-
void Reload()
{
s_patches.clear();
LoadPatches();
}
-std::optional<std::string> GetNetworkPatch(const std::string& source, IsKD is_kd)
+std::optional<std::string> GetNetworkPatch(std::string_view source, IsKD is_kd)
{
const auto patch =
std::find_if(s_patches.begin(), s_patches.end(), [&source, &is_kd](const NetworkPatch& p) {
diff --git a/Source/Core/Core/WC24PatchEngine.h b/Source/Core/Core/WC24PatchEngine.h
index abbfcc0d58..5e019a67a1 100644
--- a/Source/Core/Core/WC24PatchEngine.h
+++ b/Source/Core/Core/WC24PatchEngine.h
@@ -6,8 +6,6 @@
#include <optional>
#include <string>
-#include "Common/IniFile.h"
-
namespace WC24PatchEngine
{
enum class IsKD : bool;
@@ -22,9 +20,7 @@ struct NetworkPatch final
};
void Reload();
-bool DeserializeLine(const std::string& line, NetworkPatch* patch);
-bool IsWC24Channel();
-void LoadPatchSection(const Common::IniFile& ini);
-std::optional<std::string> GetNetworkPatch(const std::string& source, IsKD is_kd);
+
+std::optional<std::string> GetNetworkPatch(std::string_view source, IsKD is_kd);
std::optional<std::string> GetNetworkPatchByPayload(std::string_view source);
} // namespace WC24PatchEngine