Skip to content

Commit

Permalink
Showing 13 changed files with 56 additions and 84 deletions.
11 changes: 4 additions & 7 deletions Fika.Core/Coop/GameMode/CoopGame.cs
Original file line number Diff line number Diff line change
@@ -719,16 +719,13 @@ public override async Task<LocalPlayer> vmethod_2(int playerId, Vector3 position
if (!CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler))
{
Logger.LogDebug($"{nameof(vmethod_2)}:Unable to find {nameof(CoopHandler)}");
await Task.Delay(5000);
throw new MissingComponentException("CoopHandler was missing during CoopGame init");
}

if (MatchmakerAcceptPatches.IsServer)
if (RaidSettings.MetabolismDisabled)
{
if (RaidSettings.MetabolismDisabled)
{
myPlayer.HealthController.DisableMetabolism();
NotificationManagerClass.DisplayMessageNotification("Metabolism disabled", iconType: EFT.Communications.ENotificationIconType.Alert);
}
myPlayer.HealthController.DisableMetabolism();
NotificationManagerClass.DisplayMessageNotification("Metabolism disabled", iconType: EFT.Communications.ENotificationIconType.Alert);
}

CoopPlayer coopPlayer = (CoopPlayer)myPlayer;
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ public static void SetTimestamp(long ts)
timestamp = ts;
}

public static bool JoinMatch(RaidSettings settings, string profileId, string serverId, out CreateMatch result, out string errorMessage)
public static bool JoinMatch(string profileId, string serverId, out CreateMatch result, out string errorMessage)
{
result = new CreateMatch();
errorMessage = $"No server matches the data provided or the server no longer exists";
Original file line number Diff line number Diff line change
@@ -12,12 +12,10 @@ namespace Fika.Core.Coop.Matchmaker
public class MatchmakerAcceptScreen_Show_Patch : ModulePatch
{
protected override MethodBase GetTargetMethod() => typeof(MatchMakerAcceptScreen).GetMethods(BindingFlags.Public | BindingFlags.Instance).First(x => x.Name == "Show" && x.GetParameters()[0].Name == "session");

private static GameObject MatchmakerObject { get; set; }

[PatchPrefix]
private static void PreFix(ref ISession session, ref RaidSettings raidSettings, Profile ___profile_0, MatchMakerAcceptScreen __instance,
DefaultUIButton ____acceptButton, DefaultUIButton ____backButton, MatchMakerPlayerPreview ____playerModelView)
private static void PreFix(ref RaidSettings raidSettings, DefaultUIButton ____acceptButton, DefaultUIButton ____backButton)
{
if (MatchmakerObject == null)
{
4 changes: 0 additions & 4 deletions Fika.Core/Coop/PacketHandlers/ClientPacketSender.cs
Original file line number Diff line number Diff line change
@@ -140,10 +140,6 @@ private IEnumerator SyncWorld()
yield return null;
}

Writer?.Reset();
SessionSettingsPacket settingsPacket = new(true);
Client?.SendData(Writer, ref settingsPacket, DeliveryMethod.ReliableOrdered);

CoopGame coopGame = (CoopGame)Singleton<IFikaGame>.Instance;

if (coopGame == null)
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@
using Fika.Core.Coop.Matchmaker;
using Fika.Core.Modding;
using Fika.Core.Modding.Events;
using Fika.Core.Networking.Http.Models;
using Fika.Core.Networking.Http;
using System;
using System.Linq;
using System.Reflection;
@@ -82,15 +84,11 @@ public static async Task Postfix(Task __result, TarkovApplication __instance, Ti

ISession session = CurrentSession;

/*Profile profile = session.Profile;
Profile profileScav = session.ProfileOfPet;*/

Profile profile = session.GetProfileBySide(____raidSettings.Side);

profile.Inventory.Stash = null;
profile.Inventory.QuestStashItems = null;
profile.Inventory.DiscardLimits = Singleton<ItemFactory>.Instance.GetDiscardLimits();
//____raidSettings.RaidMode = ERaidMode.Online;

Logger.LogDebug("TarkovApplication_LocalGameCreator_Patch:Postfix: Attempt to set Raid Settings");

@@ -99,6 +97,12 @@ public static async Task Postfix(Task __result, TarkovApplication __instance, Ti
if (MatchmakerAcceptPatches.IsClient)
{
timeHasComeScreenController.ChangeStatus("Joining Coop Game");

RaidSettingsRequest data = new();
RaidSettingsResponse raidSettingsResponse = await FikaRequestHandler.GetRaidSettings(data);

____raidSettings.MetabolismDisabled = raidSettingsResponse.MetabolismDisabled;
____raidSettings.PlayersSpawnPlace = (EPlayersSpawnPlace)Enum.Parse(typeof(EPlayersSpawnPlace), raidSettingsResponse.PlayersSpawnPlace);
}
else
{
@@ -114,6 +118,7 @@ public static async Task Postfix(Task __result, TarkovApplication __instance, Ti
____raidSettings.WavesSettings, ____raidSettings.SelectedDateTime, new Callback<ExitStatus, TimeSpan, MetricsClass>(startHandler.HandleStart),
____fixedDeltaTime, EUpdateQueue.Update, session, TimeSpan.FromSeconds(60 * ____raidSettings.SelectedLocation.EscapeTimeLimit), ____raidSettings
);

Singleton<AbstractGame>.Create(localGame);
FikaEventDispatcher.DispatchEvent(new AbstractGameCreatedEvent(localGame));

2 changes: 1 addition & 1 deletion Fika.Core/FikaPlugin.cs
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ namespace Fika.Core
/// Originally by: Paulov <br/>
/// Re-written by: Lacyway
/// </summary>
[BepInPlugin("com.fika.core", "Fika.Core", "0.9.89")]
[BepInPlugin("com.fika.core", "Fika.Core", "0.9.8906")]
[BepInProcess("EscapeFromTarkov.exe")]
[BepInDependency("com.spt-aki.custom", BepInDependency.DependencyFlags.HardDependency)] // This is used so that we guarantee to load after aki-custom, that way we can disable its patches
[BepInDependency("com.spt-aki.singleplayer", BepInDependency.DependencyFlags.HardDependency)] // This is used so that we guarantee to load after aki-singleplayer, that way we can disable its patches
13 changes: 0 additions & 13 deletions Fika.Core/Networking/FikaClient.cs
Original file line number Diff line number Diff line change
@@ -80,7 +80,6 @@ protected void Start()
packetProcessor.SubscribeNetSerializable<AssignNetIdPacket>(OnAssignNetIdPacketReceived);
packetProcessor.SubscribeNetSerializable<SyncNetIdPacket>(OnSyncNetIdPacketReceived);
packetProcessor.SubscribeNetSerializable<OperationCallbackPacket>(OnOperationCallbackPacketReceived);
packetProcessor.SubscribeNetSerializable<SessionSettingsPacket>(OnSessionSettingsPacketReceived);

_netClient = new NetManager(this)
{
@@ -115,18 +114,6 @@ protected void Start()
ClientReady = true;
}

private void OnSessionSettingsPacketReceived(SessionSettingsPacket packet)
{
if (!packet.IsRequest)
{
if (packet.MetabolismDisabled)
{
Singleton<GameWorld>.Instance.MainPlayer.HealthController.DisableMetabolism();
NotificationManagerClass.DisplayMessageNotification("Metabolism disabled", iconType: EFT.Communications.ENotificationIconType.Alert);
}
}
}

private void OnOperationCallbackPacketReceived(OperationCallbackPacket packet)
{
if (Players.TryGetValue(packet.NetId, out CoopPlayer player) && player.IsYourPlayer)
18 changes: 0 additions & 18 deletions Fika.Core/Networking/FikaServer.cs
Original file line number Diff line number Diff line change
@@ -83,7 +83,6 @@ public async void Start()
packetProcessor.SubscribeNetSerializable<MinePacket, NetPeer>(OnMinePacketReceived);
packetProcessor.SubscribeNetSerializable<BorderZonePacket, NetPeer>(OnBorderZonePacketReceived);
packetProcessor.SubscribeNetSerializable<SendCharacterPacket, NetPeer>(OnSendCharacterPacketReceived);
packetProcessor.SubscribeNetSerializable<SessionSettingsPacket, NetPeer>(OnSessionSettingsPacketReceived);

_netServer = new NetManager(this)
{
@@ -165,23 +164,6 @@ await Task.Run(async () =>
ServerReady = true;
}

private void OnSessionSettingsPacketReceived(SessionSettingsPacket packet, NetPeer peer)
{
if (packet.IsRequest)
{
CoopGame coopGame = (CoopGame)Singleton<IFikaGame>.Instance;
if (coopGame != null)
{
SessionSettingsPacket returnPacket = new(false)
{
MetabolismDisabled = coopGame.RaidSettings.MetabolismDisabled
};

SendDataToPeer(peer, new(), ref returnPacket, DeliveryMethod.ReliableUnordered);
}
}
}

public int PopNetId()
{
int netId = _currentNetId;
5 changes: 5 additions & 0 deletions Fika.Core/Networking/Http/FikaHttpHandler.cs
Original file line number Diff line number Diff line change
@@ -135,5 +135,10 @@ public static Dictionary<string, string> AvailableReceivers(AvailableReceiversRe
{
return PostJson<AvailableReceiversRequest, Dictionary<string, string>>("/fika/senditem/availablereceivers", data);
}

public static async Task<RaidSettingsResponse> GetRaidSettings(RaidSettingsRequest data)
{
return await PostJsonAsync<RaidSettingsRequest, RaidSettingsResponse>("/fika/raid/getsettings", data);
}
}
}
17 changes: 17 additions & 0 deletions Fika.Core/Networking/Models/RaidSettingsRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Fika.Core.Coop.Components;
using System.Runtime.Serialization;

namespace Fika.Core.Networking.Http.Models
{
[DataContract]
public struct RaidSettingsRequest
{
[DataMember(Name = "serverId")]
public string ServerId;

public RaidSettingsRequest()
{
ServerId = CoopHandler.GetServerId();
}
}
}
13 changes: 13 additions & 0 deletions Fika.Core/Networking/Models/RaidSettingsResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Runtime.Serialization;

namespace Fika.Core.Networking.Http.Models
{
[DataContract]
public struct RaidSettingsResponse(bool metabolismDisabled, string playersSpawnPlace)
{
[DataMember(Name = "metabolismDisabled")]
public bool MetabolismDisabled = metabolismDisabled;
[DataMember(Name = "playersSpawnPlace")]
public string PlayersSpawnPlace = playersSpawnPlace;
}
}
28 changes: 0 additions & 28 deletions Fika.Core/Networking/Packets/Backend/SessionSettingsPacket.cs

This file was deleted.

10 changes: 5 additions & 5 deletions Fika.Core/UI/Custom/MatchMakerUIScript.cs
Original file line number Diff line number Diff line change
@@ -34,14 +34,14 @@ internal class MatchMakerUIScript : MonoBehaviour

private float _lastRefreshed;

private void Start()
protected void Start()
{
CreateMatchMakerUI();

StartCoroutine(ServerQuery());
}

void Update()
protected void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
@@ -64,7 +64,7 @@ private void DestroyThis()
Destroy(this);
}

private void OnDestroy()
protected void OnDestroy()
{
StopQuery = true;
if (NewBackButton != null)
@@ -232,12 +232,12 @@ private IEnumerator JoinMatch(string profileId, string serverId, Button button)
pingingClient.NetClient?.Stop();
pingingClient = null;

if (MatchmakerAcceptPatches.JoinMatch(RaidSettings, profileId, serverId, out CreateMatch result, out string errorMessage))
if (MatchmakerAcceptPatches.JoinMatch(profileId, serverId, out CreateMatch result, out string errorMessage))
{
MatchmakerAcceptPatches.SetGroupId(result.ServerId);
MatchmakerAcceptPatches.SetTimestamp(result.Timestamp);
MatchmakerAcceptPatches.MatchingType = EMatchmakerType.GroupPlayer;
MatchmakerAcceptPatches.HostExpectedNumberOfPlayers = result.ExpectedNumberOfPlayers;
MatchmakerAcceptPatches.HostExpectedNumberOfPlayers = result.ExpectedNumberOfPlayers;

DestroyThis();

0 comments on commit a781981

Please sign in to comment.