Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add default support for WiiLink + configuration
- Loading branch information
1 parent
63090d4
commit fa0f536
Showing
18 changed files
with
288 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# HAFE01 - Forecast Channel | ||
|
||
[WC24Patch] | ||
$Main | ||
weather.wapp.wii.com:fore.wiilink24.com:1 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# HATE01 - Nintendo Channel (NTSC-U) | ||
|
||
[Core] | ||
# Values set here will override the main Dolphin settings. | ||
|
||
[OnLoad] | ||
# Add memory patches to be loaded once on boot here. | ||
|
||
[OnFrame] | ||
# Add memory patches to be applied every frame here. | ||
|
||
[ActionReplay] | ||
# Add action replay cheats here. | ||
|
||
[Video] | ||
|
||
[Video_Settings] | ||
|
||
[Video_Hacks] | ||
ImmediateXFBEnable = False | ||
|
||
[Gecko] | ||
$SSL Patch [Papelli] | ||
2A35AB5C 00003A2F | ||
80010000 0035AA4D | ||
8A00570F 0035AA4C | ||
80010000 0035AACD | ||
8A00380F 0035AACC | ||
80010000 0035AB0D | ||
8A004A0F 0035AB0C | ||
80010000 0035AB5D | ||
8A00390F 0035AB5C | ||
E2000001 00000000 | ||
|
||
[WC24Patch] | ||
$Main | ||
a248.e.akamai.net:nc.wiinoma.com:0 | ||
entu.wapp.wii.com:ncc.wiilink24.com:1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
// Copyright 2023 Dolphin Emulator Project | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
// WC24PatchEngine | ||
// Allows for replacing URLs used in WC24 requests | ||
|
||
#include "Core/WC24PatchEngine.h" | ||
#include <algorithm> | ||
#include <array> | ||
#include "Common/StringUtil.h" | ||
#include "Core/CheatCodes.h" | ||
#include "Core/CommonTitles.h" | ||
#include "Core/Config/MainSettings.h" | ||
#include "Core/ConfigManager.h" | ||
|
||
namespace WC24PatchEngine | ||
{ | ||
static std::array<u64, 12> s_wc24_channels{ | ||
// Nintendo Channel | ||
Titles::NINTENDO_CHANNEL_NTSC_U, | ||
Titles::NINTENDO_CHANNEL_NTSC_J, | ||
Titles::NINTENDO_CHANNEL_PAL, | ||
Titles::FORECAST_CHANNEL_NTSC_U, | ||
Titles::FORECAST_CHANNEL_NTSC_J, | ||
Titles::FORECAST_CHANNEL_PAL, | ||
Titles::NEWS_CHANNEL_NTSC_U, | ||
Titles::NEWS_CHANNEL_NTSC_J, | ||
Titles::NEWS_CHANNEL_PAL, | ||
Titles::EVERYBODY_VOTES_CHANNEL_NTSC_U, | ||
Titles::EVERYBODY_VOTES_CHANNEL_NTSC_J, | ||
Titles::EVERYBODY_VOTES_CHANNEL_PAL, | ||
}; | ||
|
||
static std::vector<NetworkPatch> s_patches; | ||
|
||
bool DeserializeLine(const std::string& line, NetworkPatch* patch) | ||
{ | ||
const std::vector<std::string> items = SplitString(line, ':'); | ||
|
||
if (items.size() != 3) | ||
return false; | ||
|
||
patch->source = items[0]; | ||
patch->replacement = items[1]; | ||
|
||
if (!TryParse(items[2], &patch->is_kd)) | ||
return false; | ||
|
||
return patch; | ||
} | ||
|
||
void LoadPatchSection(const Common::IniFile& ini) | ||
{ | ||
std::vector<std::string> lines; | ||
NetworkPatch patch; | ||
ini.GetLines("WC24Patch", &lines); | ||
|
||
for (std::string& line : lines) | ||
{ | ||
if (line.empty()) | ||
continue; | ||
|
||
if (line[0] == '$') | ||
{ | ||
patch.name = line.substr(1, line.size() - 1); | ||
} | ||
else | ||
{ | ||
if (DeserializeLine(line, &patch)) | ||
{ | ||
s_patches.push_back(patch); | ||
} | ||
} | ||
} | ||
|
||
ReadEnabledAndDisabled(ini, "WC24Patch", &s_patches); | ||
} | ||
|
||
void LoadPatches() | ||
{ | ||
const auto& sconfig = SConfig::GetInstance(); | ||
// We can only load WC24 Channels. | ||
if (!IsWC24Channel()) | ||
return; | ||
|
||
Common::IniFile ini; | ||
// If WiiLink is enabled then we load the Default Ini as that has the WiiLink URLs. | ||
if (Config::Get(Config::MAIN_WII_WIILINK_ENABLE)) | ||
ini = sconfig.LoadDefaultGameIni(); | ||
else | ||
ini = sconfig.LoadLocalGameIni(); | ||
|
||
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) | ||
{ | ||
const auto patch = | ||
std::find_if(s_patches.begin(), s_patches.end(), [&source, &is_kd](NetworkPatch& patch) { | ||
return patch.source == source && patch.is_kd == is_kd; | ||
}); | ||
if (patch == s_patches.end()) | ||
return std::nullopt; | ||
|
||
return patch->replacement; | ||
} | ||
|
||
// When we patch for the Socket, we aren't given the URL. Instead, it is in a Host header | ||
// in the payload that the socket is going to send. We need to manually find which patch to apply. | ||
std::optional<std::string> GetNetworkPatchByPayload(std::string_view source) | ||
{ | ||
for (const NetworkPatch& patch : s_patches) | ||
{ | ||
if (source.find(patch.source) != std::string::npos && patch.is_kd != IsKD{true}) | ||
// We found the correct patch, return it! | ||
return ReplaceAll(std::string{source}, patch.source, patch.replacement); | ||
} | ||
|
||
return std::nullopt; | ||
} | ||
} // namespace WC24PatchEngine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2023 Dolphin Emulator Project | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#pragma once | ||
|
||
#include <optional> | ||
#include <string> | ||
|
||
#include "Common/IniFile.h" | ||
|
||
namespace WC24PatchEngine | ||
{ | ||
enum class IsKD : bool; | ||
|
||
struct NetworkPatch final | ||
{ | ||
std::string name; | ||
std::string source; | ||
std::string replacement; | ||
bool enabled = false; | ||
IsKD is_kd = IsKD{false}; | ||
}; | ||
|
||
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> GetNetworkPatchByPayload(std::string_view source); | ||
} // namespace WC24PatchEngine |
Oops, something went wrong.