Skip to content

Commit

Permalink
Merge pull request dolphin-emu#11903 from noahpistilli/wiilink
Browse files Browse the repository at this point in the history
IOS/KD: Add WiiLink as WC24 service provider by default
  • Loading branch information
AdmiralCurtiss authored Jun 26, 2023
2 parents ac53ab1 + f9f8e94 commit 3a8e7de
Show file tree
Hide file tree
Showing 20 changed files with 473 additions and 25 deletions.
8 changes: 8 additions & 0 deletions Data/Sys/GameSettings/HAF.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# HAFx01 - Forecast Channel

[WC24Patch]
$Main
weather.wapp.wii.com:fore.wiilink24.com:1

[WC24Patch_Enabled]
$Main
20 changes: 0 additions & 20 deletions Data/Sys/GameSettings/HAT.ini

This file was deleted.

56 changes: 56 additions & 0 deletions Data/Sys/GameSettings/HATE01.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 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 [Palapeli]
2A35AB5C 00003A2F
80010000 0035AA4D
8A00570F 0035AA4C
80010000 0035AACD
8A00380F 0035AACC
80010000 0035AB0D
8A004A0F 0035AB0C
80010000 0035AB5D
8A00390F 0035AB5C
80010000 0035ABF9
8A00170F 0035ABF8
80010000 0035AC15
8A00170F 0035AC14
E2000001 00000000

[Gecko_Enabled]
$SSL Patch

[WC24Patch]
$Main
a248.e.akamai.net:dol.n.wiinoma.com:0
$Suggestions
entup.wapp.wii.com:post.n.wiinoma.com:0
$Info
entuc.wapp.wii.com:conf.n.wiinoma.com:0
$WC24
entu.wapp.wii.com:ncc.wiilink24.com:1

[WC24Patch_Enabled]
$Main
$Suggestions
$Info
$WC24
54 changes: 54 additions & 0 deletions Data/Sys/GameSettings/HATJ01.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# HATJ01 - Nintendo Channel (NTSC-J)

[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 [Palapeli]
2A390014 00003A2F
80010000 00390015
8A00570F 00390014
80010000 00390095
8A00380F 00390094
80010000 003900D5
8A00390F 003900D4
80010000 00390171
8A00170F 00390170
80010000 0039018D
8A00170F 0039018C
E2000001 00000000

[Gecko_Enabled]
$SSL Patch

[WC24Patch]
$Main
a248.e.akamai.net:dol.n.wiinoma.com:0
$Suggestions
entjp.wapp.wii.com:post.n.wiinoma.com:0
$Info
entjc.wapp.wii.com:conf.n.wiinoma.com:0
$WC24
entj.wapp.wii.com:ncc.wiilink24.com:1

[WC24Patch_Enabled]
$Main
$Suggestions
$Info
$WC24
56 changes: 56 additions & 0 deletions Data/Sys/GameSettings/HATP01.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# HATP01 - Nintendo Channel (PAL)

[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 [Palapeli]
2A357D3C 00003A2F
80010000 00357D3D
8A00570F 00357D3C
80010000 00357DBD
8A00380F 00357DBC
80010000 00357DFD
8A004B0F 00357DFC
80010000 00357E4D
8A00390F 00357E4C
80010000 00357EE9
8A00170F 00357EE8
80010000 00357F05
8A00170F 00357F04
E2000001 00000000

[Gecko_Enabled]
$SSL Patch

[WC24Patch]
$Main
a248.e.akamai.net:dol.n.wiinoma.com:0
$Suggestions
entep.wapp.wii.com:post.n.wiinoma.com:0
$Info
entec.wapp.wii.com:conf.n.wiinoma.com:0
$WC24
ente.wapp.wii.com:ncc.wiilink24.com:1

[WC24Patch_Enabled]
$Main
$Suggestions
$Info
$WC24
33 changes: 31 additions & 2 deletions Source/Core/Common/StringUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@

#include "Common/CommonTypes.h"

namespace detail
{
template <typename T>
constexpr bool IsBooleanEnum()
{
if constexpr (std::is_enum_v<T>)
{
return std::is_same_v<std::underlying_type_t<T>, bool>;
}
else
{
return false;
}
}
} // namespace detail

std::string StringFromFormatV(const char* format, va_list args);

std::string StringFromFormat(const char* format, ...)
Expand Down Expand Up @@ -55,8 +71,10 @@ void TruncateToCString(std::string* s);

bool TryParse(const std::string& str, bool* output);

template <typename T, std::enable_if_t<std::is_integral_v<T> || std::is_enum_v<T>>* = nullptr>
bool TryParse(const std::string& str, T* output, int base = 0)
template <typename T>
requires(std::is_integral_v<T> ||
(std::is_enum_v<T> && !detail::IsBooleanEnum<T>())) bool TryParse(const std::string& str,
T* output, int base = 0)
{
char* end_ptr = nullptr;

Expand Down Expand Up @@ -93,6 +111,17 @@ bool TryParse(const std::string& str, T* output, int base = 0)
return true;
}

template <typename T>
requires(detail::IsBooleanEnum<T>()) bool TryParse(const std::string& str, T* output)
{
bool value;
if (!TryParse(str, &value))
return false;

*output = static_cast<T>(value);
return true;
}

template <typename T, std::enable_if_t<std::is_floating_point_v<T>>* = nullptr>
bool TryParse(std::string str, T* const output)
{
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,8 @@ add_library(core
System.h
TitleDatabase.cpp
TitleDatabase.h
WC24PatchEngine.cpp
WC24PatchEngine.h
WiiRoot.cpp
WiiRoot.h
WiiUtils.cpp
Expand Down
24 changes: 24 additions & 0 deletions Source/Core/Core/CommonTitles.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,30 @@ constexpr u64 SHOP = 0x0001000248414241;

constexpr u64 KOREAN_SHOP = 0x000100024841424b;

constexpr u64 FORECAST_CHANNEL_NTSC_U = 0x0001000248414645;

constexpr u64 FORECAST_CHANNEL_NTSC_J = 0x000100024841464a;

constexpr u64 FORECAST_CHANNEL_PAL = 0x0001000248414650;

constexpr u64 NINTENDO_CHANNEL_NTSC_U = 0x0001000148415445;

constexpr u64 NINTENDO_CHANNEL_NTSC_J = 0x000100014841544a;

constexpr u64 NINTENDO_CHANNEL_PAL = 0x0001000148415450;

constexpr u64 NEWS_CHANNEL_NTSC_U = 0x0001000248414745;

constexpr u64 NEWS_CHANNEL_NTSC_J = 0x000100024841474a;

constexpr u64 NEWS_CHANNEL_PAL = 0x0001000248414750;

constexpr u64 EVERYBODY_VOTES_CHANNEL_NTSC_U = 0x0001000148414a45;

constexpr u64 EVERYBODY_VOTES_CHANNEL_NTSC_J = 0x0001000148414a4a;

constexpr u64 EVERYBODY_VOTES_CHANNEL_PAL = 0x0001000148414a50;

constexpr u64 IOS(u32 major_version)
{
return 0x0000000100000000 | major_version;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/Config/MainSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ const Info<bool> MAIN_ALLOW_SD_WRITES{{System::Main, "Core", "WiiSDCardAllowWrit
const Info<bool> MAIN_ENABLE_SAVESTATES{{System::Main, "Core", "EnableSaveStates"}, false};
const Info<bool> MAIN_REAL_WII_REMOTE_REPEAT_REPORTS{
{System::Main, "Core", "RealWiiRemoteRepeatReports"}, true};
const Info<bool> MAIN_WII_WIILINK_ENABLE{{System::Main, "Core", "EnableWiiLink"}, false};

// Empty means use the Dolphin default URL
const Info<std::string> MAIN_WII_NUS_SHOP_URL{{System::Main, "Core", "WiiNusShopUrl"}, ""};
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/Config/MainSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ extern const Info<DiscIO::Region> MAIN_FALLBACK_REGION;
extern const Info<bool> MAIN_REAL_WII_REMOTE_REPEAT_REPORTS;
extern const Info<s32> MAIN_OVERRIDE_BOOT_IOS;
extern const Info<std::string> MAIN_WII_NUS_SHOP_URL;
extern const Info<bool> MAIN_WII_WIILINK_ENABLE;

// Main.DSP

Expand Down
3 changes: 3 additions & 0 deletions Source/Core/Core/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
#include "Core/PowerPC/PowerPC.h"
#include "Core/System.h"
#include "Core/TitleDatabase.h"
#include "Core/WC24PatchEngine.h"

#include "VideoCommon/HiresTextures.h"

#include "DiscIO/Enums.h"
Expand Down Expand Up @@ -206,6 +208,7 @@ void SConfig::OnNewTitleLoad(const Core::CPUThreadGuard& guard)
HLE::Reload(system);
PatchEngine::Reload();
HiresTexture::Update();
WC24PatchEngine::Reload();
}

void SConfig::LoadDefaults()
Expand Down
6 changes: 6 additions & 0 deletions Source/Core/Core/IOS/Network/IP/Top.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "Core/IOS/Network/MACUtils.h"
#include "Core/IOS/Network/Socket.h"
#include "Core/System.h"
#include "Core/WC24PatchEngine.h"

#ifdef _WIN32
#include <iphlpapi.h>
Expand Down Expand Up @@ -1056,6 +1057,11 @@ IPCReply NetIPTopDevice::HandleGetAddressInfoRequest(const IOCtlVRequest& reques
if (!request.in_vectors.empty() && request.in_vectors[0].size > 0)
{
nodeNameStr = memory.GetString(request.in_vectors[0].address, request.in_vectors[0].size);
if (std::optional<std::string> patch =
WC24PatchEngine::GetNetworkPatch(nodeNameStr, WC24PatchEngine::IsKD{false}))
{
nodeNameStr = patch.value();
}
pNodeName = nodeNameStr.c_str();
}

Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/IOS/Network/KD/NWC24DL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,4 @@ void NWC24Dl::SetVersion(u32 version)
{
m_data.header.version = Common::swap32(version);
}

} // namespace IOS::HLE::NWC24
19 changes: 18 additions & 1 deletion Source/Core/Core/IOS/Network/KD/NetKDRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "Core/IOS/Network/Socket.h"
#include "Core/IOS/Uids.h"
#include "Core/System.h"
#include "Core/WC24PatchEngine.h"

namespace IOS::HLE
{
Expand Down Expand Up @@ -217,7 +218,23 @@ NWC24::ErrorCode NetKDRequestDevice::KDDownload(const u16 entry_index,

// Content metadata
const std::string content_name = m_dl_list.GetVFFContentName(entry_index, subtask_id);
const std::string url = m_dl_list.GetDownloadURL(entry_index, subtask_id);
std::string url = m_dl_list.GetDownloadURL(entry_index, subtask_id);

// Reroute to custom server if enabled.
const std::vector<std::string> parts = SplitString(url, '/');
if (parts.size() < 3)
{
// Invalid URL
LogError(ErrorType::KD_Download, NWC24::WC24_ERR_SERVER);
return NWC24::WC24_ERR_SERVER;
}

if (std::optional<std::string> patch =
WC24PatchEngine::GetNetworkPatch(parts[2], WC24PatchEngine::IsKD{true}))
{
const size_t index = url.find(parts[2]);
url.replace(index, parts[2].size(), patch.value());
}

INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_DOWNLOAD_NOW_EX - NI - URL: {}", url);

Expand Down
Loading

0 comments on commit 3a8e7de

Please sign in to comment.