Skip to content

Commit

Permalink
HLE: optional hack: disable IsAnyInternetRequestAccepted
Browse files Browse the repository at this point in the history
  • Loading branch information
GreemDev committed Mar 6, 2025
1 parent 44632e5 commit 0db85d0
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/Ryujinx.Common/Configuration/DirtyHack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace Ryujinx.Common.Configuration
public enum DirtyHack : byte
{
Xc2MenuSoftlockFix = 1,
ShaderTranslationDelay = 2
// ShaderTranslationDelay = 2
NifmServiceDisableIsAnyInternetRequestAccepted = 3
}

public readonly struct EnabledDirtyHack(DirtyHack hack, int value)
Expand Down
4 changes: 2 additions & 2 deletions src/Ryujinx.HLE/HOS/Services/Nifm/IStaticService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public IStaticService(ServiceCtx context) { }
// CreateGeneralServiceOld() -> object<nn::nifm::detail::IGeneralService>
public ResultCode CreateGeneralServiceOld(ServiceCtx context)
{
MakeObject(context, new IGeneralService());
MakeObject(context, new IGeneralService(context));

return ResultCode.Success;
}
Expand All @@ -22,7 +22,7 @@ public ResultCode CreateGeneralServiceOld(ServiceCtx context)
// CreateGeneralService(u64, pid) -> object<nn::nifm::detail::IGeneralService>
public ResultCode CreateGeneralService(ServiceCtx context)
{
MakeObject(context, new IGeneralService());
MakeObject(context, new IGeneralService(context));

return ResultCode.Success;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Ryujinx.Common;
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Logging;
using Ryujinx.Common.Utilities;
using Ryujinx.HLE.HOS.Services.Nifm.StaticService.GeneralService;
Expand All @@ -17,12 +18,12 @@ class IGeneralService : DisposableIpcService
private UnicastIPAddressInformation _targetAddressInfoCache = null;
private string _cacheChosenInterface = null;

public IGeneralService()
public IGeneralService(ServiceCtx context)
{
_generalServiceDetail = new GeneralServiceDetail
{
ClientId = GeneralServiceManager.Count,
IsAnyInternetRequestAccepted = true, // NOTE: Why not accept any internet request?
IsAnyInternetRequestAccepted = !context.Device.DirtyHacks.IsEnabled(DirtyHack.NifmServiceDisableIsAnyInternetRequestAccepted), // NOTE: Why not accept any internet request?
};

NetworkChange.NetworkAddressChanged += LocalInterfaceCacheHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ in _migrations.OrderBy(x => x.Key))
DirtyHacks hacks = new (cff.DirtyHacks ?? []);

Hacks.Xc2MenuSoftlockFix.Value = hacks.IsEnabled(DirtyHack.Xc2MenuSoftlockFix);

Hacks.EnableShaderTranslationDelay.Value = hacks.IsEnabled(DirtyHack.ShaderTranslationDelay);
Hacks.ShaderTranslationDelay.Value = hacks[DirtyHack.ShaderTranslationDelay].CoerceAtLeast(0);

}

if (configurationFileUpdated)
Expand Down
13 changes: 5 additions & 8 deletions src/Ryujinx/Systems/Configuration/ConfigurationState.Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -683,18 +683,15 @@ public class HacksSection

public ReactiveObject<bool> Xc2MenuSoftlockFix { get; private set; }

public ReactiveObject<bool> EnableShaderTranslationDelay { get; private set; }

public ReactiveObject<int> ShaderTranslationDelay { get; private set; }
public ReactiveObject<bool> DisableNifmIsAnyInternetRequestAccepted { get; private set; }

public HacksSection()
{
ShowDirtyHacks = new ReactiveObject<bool>();
Xc2MenuSoftlockFix = new ReactiveObject<bool>();
Xc2MenuSoftlockFix.Event += HackChanged;
EnableShaderTranslationDelay = new ReactiveObject<bool>();
EnableShaderTranslationDelay.Event += HackChanged;
ShaderTranslationDelay = new ReactiveObject<int>();
DisableNifmIsAnyInternetRequestAccepted = new ReactiveObject<bool>();
DisableNifmIsAnyInternetRequestAccepted.Event += HackChanged;
}

private void HackChanged(object sender, ReactiveEventArgs<bool> rxe)
Expand Down Expand Up @@ -725,8 +722,8 @@ public EnabledDirtyHack[] EnabledHacks
if (Xc2MenuSoftlockFix)
Apply(DirtyHack.Xc2MenuSoftlockFix);

if (EnableShaderTranslationDelay)
Apply(DirtyHack.ShaderTranslationDelay, ShaderTranslationDelay);
if (DisableNifmIsAnyInternetRequestAccepted)
Apply(DirtyHack.NifmServiceDisableIsAnyInternetRequestAccepted);

return enabledHacks.ToArray();

Expand Down
12 changes: 11 additions & 1 deletion src/Ryujinx/UI/ViewModels/SettingsHacksViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ public SettingsHacksViewModel(SettingsViewModel settingsVm)
}

[ObservableProperty] private bool _xc2MenuSoftlockFix = ConfigurationState.Instance.Hacks.Xc2MenuSoftlockFix;
[ObservableProperty] private bool _nifmDisableIsAnyInternetRequestAccepted = ConfigurationState.Instance.Hacks.DisableNifmIsAnyInternetRequestAccepted;

public static string Xc2MenuFixTooltip { get; } = Lambda.String(sb =>
{
sb.AppendLine(
"This fix applies a 2ms delay (via 'Thread.Sleep(2)') every time the game tries to read data from the emulated Switch filesystem.")
"This hack applies a 2ms delay (via 'Thread.Sleep(2)') every time the game tries to read data from the emulated Switch filesystem.")
.AppendLine();

sb.AppendLine("From the issue on GitHub:").AppendLine();
Expand All @@ -29,5 +30,14 @@ public SettingsHacksViewModel(SettingsViewModel settingsVm)
"there is a low chance that the game will softlock, " +
"the submenu won't show up, while background music is still there.");
});

public static string NifmDisableIsAnyInternetRequestAcceptedTooltip { get; } = Lambda.String(sb =>
{
sb.AppendLine(
"This hack simply sets 'IsAnyInternetRequestAccepted' to 'false' when initializing the Nifm IGeneralService.")
.AppendLine();

sb.Append("Lets DOOM 2016 go in game.");
});
}
}
2 changes: 2 additions & 0 deletions src/Ryujinx/UI/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,8 @@ public void SaveSettings()

// Dirty Hacks
config.Hacks.Xc2MenuSoftlockFix.Value = DirtyHacks.Xc2MenuSoftlockFix;
config.Hacks.DisableNifmIsAnyInternetRequestAccepted.Value =
DirtyHacks.NifmDisableIsAnyInternetRequestAccepted;

config.ToFileFormat().SaveConfig(Program.ConfigurationPath);

Expand Down
14 changes: 13 additions & 1 deletion src/Ryujinx/UI/Views/Settings/SettingsHacksView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<TextBlock
Foreground="{DynamicResource SecondaryTextColor}"
TextDecorations="Underline"
Text="Highly specific hacks &amp; tricks to alleviate performance issues, crashing, or freezing. Will cause issues." />
Text="Highly specific hacks &amp; tricks to alleviate performance issues, crashing, or freezing. Can cause issues." />
<StackPanel
Margin="0,10,0,0"
Orientation="Horizontal"
Expand All @@ -43,6 +43,18 @@
Text="Xenoblade Chronicles 2 Menu Softlock Fix" />
</StackPanel>
<Separator/>
<StackPanel
Margin="0,10,0,0"
Orientation="Horizontal"
HorizontalAlignment="Center"
ToolTip.Tip="{Binding DirtyHacks.NifmDisableIsAnyInternetRequestAcceptedTooltip}">
<CheckBox
Margin="0"
IsChecked="{Binding DirtyHacks.NifmDisableIsAnyInternetRequestAccepted}"/>
<TextBlock
VerticalAlignment="Center"
Text="Disable IsAnyInternetRequestAccepted" />
</StackPanel>
</StackPanel>
</Border>
</ScrollViewer>
Expand Down

0 comments on commit 0db85d0

Please sign in to comment.