Merge pull request #12421 from lioncash/fwd
WC24PatchEngine: Move IniFile header dependency into the cpp file
This commit is contained in:
commit
84ac561e46
|
@ -4,17 +4,19 @@
|
||||||
// WC24PatchEngine
|
// WC24PatchEngine
|
||||||
// Allows for replacing URLs used in WC24 requests
|
// Allows for replacing URLs used in WC24 requests
|
||||||
|
|
||||||
|
#include "Core/WC24PatchEngine.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
|
#include "Common/IniFile.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
|
|
||||||
#include "Core/CheatCodes.h"
|
#include "Core/CheatCodes.h"
|
||||||
#include "Core/CommonTitles.h"
|
#include "Core/CommonTitles.h"
|
||||||
#include "Core/Config/MainSettings.h"
|
#include "Core/Config/MainSettings.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/WC24PatchEngine.h"
|
|
||||||
|
|
||||||
namespace WC24PatchEngine
|
namespace WC24PatchEngine
|
||||||
{
|
{
|
||||||
|
@ -38,7 +40,7 @@ static constexpr std::array<u64, 15> s_wc24_channels{
|
||||||
|
|
||||||
static std::vector<NetworkPatch> s_patches;
|
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, ':');
|
const std::vector<std::string> items = SplitString(line, ':');
|
||||||
|
|
||||||
|
@ -54,13 +56,13 @@ bool DeserializeLine(const std::string& line, NetworkPatch* patch)
|
||||||
return patch;
|
return patch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadPatchSection(const Common::IniFile& ini)
|
static void LoadPatchSection(const Common::IniFile& ini)
|
||||||
{
|
{
|
||||||
std::vector<std::string> lines;
|
std::vector<std::string> lines;
|
||||||
NetworkPatch patch;
|
NetworkPatch patch;
|
||||||
ini.GetLines("WC24Patch", &lines);
|
ini.GetLines("WC24Patch", &lines);
|
||||||
|
|
||||||
for (std::string& line : lines)
|
for (const std::string& line : lines)
|
||||||
{
|
{
|
||||||
if (line.empty())
|
if (line.empty())
|
||||||
continue;
|
continue;
|
||||||
|
@ -81,6 +83,15 @@ void LoadPatchSection(const Common::IniFile& ini)
|
||||||
ReadEnabledAndDisabled(ini, "WC24Patch", &s_patches);
|
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()
|
static void LoadPatches()
|
||||||
{
|
{
|
||||||
const auto& sconfig = SConfig::GetInstance();
|
const auto& sconfig = SConfig::GetInstance();
|
||||||
|
@ -98,22 +109,13 @@ static void LoadPatches()
|
||||||
LoadPatchSection(ini);
|
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()
|
void Reload()
|
||||||
{
|
{
|
||||||
s_patches.clear();
|
s_patches.clear();
|
||||||
LoadPatches();
|
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 =
|
const auto patch =
|
||||||
std::find_if(s_patches.begin(), s_patches.end(), [&source, &is_kd](const NetworkPatch& p) {
|
std::find_if(s_patches.begin(), s_patches.end(), [&source, &is_kd](const NetworkPatch& p) {
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "Common/IniFile.h"
|
|
||||||
|
|
||||||
namespace WC24PatchEngine
|
namespace WC24PatchEngine
|
||||||
{
|
{
|
||||||
enum class IsKD : bool;
|
enum class IsKD : bool;
|
||||||
|
@ -22,9 +20,7 @@ struct NetworkPatch final
|
||||||
};
|
};
|
||||||
|
|
||||||
void Reload();
|
void Reload();
|
||||||
bool DeserializeLine(const std::string& line, NetworkPatch* patch);
|
|
||||||
bool IsWC24Channel();
|
std::optional<std::string> GetNetworkPatch(std::string_view source, IsKD is_kd);
|
||||||
void LoadPatchSection(const Common::IniFile& ini);
|
|
||||||
std::optional<std::string> GetNetworkPatch(const std::string& source, IsKD is_kd);
|
|
||||||
std::optional<std::string> GetNetworkPatchByPayload(std::string_view source);
|
std::optional<std::string> GetNetworkPatchByPayload(std::string_view source);
|
||||||
} // namespace WC24PatchEngine
|
} // namespace WC24PatchEngine
|
||||||
|
|
Loading…
Reference in New Issue