-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Prevent host from clicking "Disconnect" in the main menu if peers are still connected.
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 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
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,32 @@ | ||
using Comfort.Common; | ||
using EFT.UI; | ||
using Fika.Core.Coop.Matchmaker; | ||
using Fika.Core.Networking; | ||
using SPT.Reflection.Patching; | ||
using System.Reflection; | ||
|
||
namespace Fika.Core.UI.Patches | ||
{ | ||
public class DisconnectButton_Patch : ModulePatch | ||
{ | ||
protected override MethodBase GetTargetMethod() | ||
{ | ||
return typeof(MenuScreen).GetMethod(nameof(MenuScreen.method_11)); | ||
} | ||
|
||
[PatchPrefix] | ||
static bool Prefix() | ||
{ | ||
if (MatchmakerAcceptPatches.IsServer) | ||
{ | ||
FikaServer server = Singleton<FikaServer>.Instance; | ||
if (server != null && server.NetServer.ConnectedPeersCount > 0) | ||
{ | ||
NotificationManagerClass.DisplayWarningNotification($"You cannot disconnect while there are still peers connected! Remaining: {server.NetServer.ConnectedPeersCount}"); | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
} | ||
} |