Skip to content

Commit

Permalink
Merge branch '3.9-dev' into natpunch-3.9-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
trippyone committed Jun 15, 2024
2 parents 098a0b9 + a9eff94 commit ee0748c
Show file tree
Hide file tree
Showing 67 changed files with 1,617 additions and 1,112 deletions.
4 changes: 2 additions & 2 deletions Fika.Core/Console/FikaCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using EFT.UI;
using Fika.Core.Coop.Components;
using Fika.Core.Coop.GameMode;
using Fika.Core.Coop.Matchmaker;
using Fika.Core.Coop.Players;
using Fika.Core.Coop.Utils;

namespace Fika.Core.Console
{
Expand All @@ -30,7 +30,7 @@ public static void Bring()

if (CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler))
{
if (MatchmakerAcceptPatches.IsServer)
if (FikaBackendUtils.IsServer)
{
int count = 0;
foreach (CoopPlayer player in coopHandler.Players.Values)
Expand Down
4 changes: 2 additions & 2 deletions Fika.Core/Coop/Airdrops/FikaAirdropBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using EFT.Airdrop;
using EFT.Interactive;
using EFT.SynchronizableObjects;
using Fika.Core.Coop.Matchmaker;
using Fika.Core.Coop.Utils;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
Expand Down Expand Up @@ -151,7 +151,7 @@ private void OnBoxLand(out float clipLength)
Volume = surfaceSet.LandingSoundBank.BaseVolume
});

if (MatchmakerAcceptPatches.IsServer)
if (FikaBackendUtils.IsServer)
{
AddNavMeshObstacle();
}
Expand Down
16 changes: 8 additions & 8 deletions Fika.Core/Coop/Airdrops/FikaAirdropsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Fika.Core.Coop.Airdrops.Utils;
using Fika.Core.Coop.Components;
using Fika.Core.Coop.GameMode;
using Fika.Core.Coop.Matchmaker;
using Fika.Core.Coop.Utils;
using Fika.Core.Networking;
using LiteNetLib;
using LiteNetLib.Utils;
Expand Down Expand Up @@ -82,7 +82,7 @@ protected async void Start()
}

// If this is not the server, then this manager will have to wait for the packet to initialize stuff.
if (MatchmakerAcceptPatches.IsClient)
if (FikaBackendUtils.IsClient)
{
return;
}
Expand Down Expand Up @@ -128,7 +128,7 @@ protected async void Start()

public void SendParamsToClients()
{
if (!MatchmakerAcceptPatches.IsServer)
if (!FikaBackendUtils.IsServer)
{
return;
}
Expand Down Expand Up @@ -162,13 +162,13 @@ protected async void FixedUpdate()
}

// If we are a client. Wait until the server has sent all the data.
if (MatchmakerAcceptPatches.IsClient && rootItem == null)
if (FikaBackendUtils.IsClient && rootItem == null)
{
return;
}

// If we have all the parameters sent from the Server. Lets build the plane, box, container and loot
if (MatchmakerAcceptPatches.IsClient && !ClientLootBuilt)
if (FikaBackendUtils.IsClient && !ClientLootBuilt)
{
ClientLootBuilt = true;

Expand Down Expand Up @@ -208,7 +208,7 @@ protected async void FixedUpdate()
return;
}

if (MatchmakerAcceptPatches.IsServer || MatchmakerAcceptPatches.IsSinglePlayer)
if (FikaBackendUtils.IsServer || FikaBackendUtils.IsSinglePlayer)
{
AirdropParameters.Timer += 0.02f;

Expand Down Expand Up @@ -269,7 +269,7 @@ private void StartBox()

private void BuildLootContainer(FikaAirdropConfigModel config)
{
if (MatchmakerAcceptPatches.IsClient)
if (FikaBackendUtils.IsClient)
{
return;
}
Expand Down Expand Up @@ -297,7 +297,7 @@ private void BuildLootContainer(FikaAirdropConfigModel config)
}

// Get the lootData. Send to clients.
if (MatchmakerAcceptPatches.IsServer)
if (FikaBackendUtils.IsServer)
{
StartCoroutine(SendLootToClients(isFlareDrop));
}
Expand Down
2 changes: 1 addition & 1 deletion Fika.Core/Coop/Airdrops/Utils/FikaItemFactoryUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void BuildContainer(LootableContainer container, FikaAirdropConfigModel c
if (itemFactory.ItemTemplates.TryGetValue(containerId, out ItemTemplate template))
{
Item item = itemFactory.CreateItem(containerId, template._id, null);
item.Id = Singleton<GameWorld>.Instance.MainPlayer.GClass2776_0.NextId;
item.Id = Singleton<GameWorld>.Instance.MainPlayer.GClass2777_0.NextId;
LootItem.CreateLootContainer(container, item, "CRATE", Singleton<GameWorld>.Instance);
}
else
Expand Down
4 changes: 2 additions & 2 deletions Fika.Core/Coop/BTR/FikaBTRManager_Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void OnPlayerInteractDoor(Player player, PlayerInteractPacket interactPac
// Find `BTRControllerClass.method_9(PathDestination currentDestinationPoint, bool lastRoutePoint)`
private bool IsUpdateTaxiPriceMethod(MethodInfo method)
{
return (method.GetParameters().Length == 2 && method.GetParameters()[0].ParameterType == typeof(PathDestination));
return method.GetParameters().Length == 2 && method.GetParameters()[0].ParameterType == typeof(PathDestination);
}

private void Update()
Expand Down Expand Up @@ -176,7 +176,7 @@ public void AttachBot(int netId)
weaponPrefab.transform.SetPositionAndRotation(turretView.GunRoot.position, turretView.GunRoot.rotation);
weaponTransform.SetPositionAndRotation(turretView.GunRoot.position, turretView.GunRoot.rotation);

string[] gunModsToDisable = Traverse.Create(turretView).Field("_gunModsToDisable").GetValue<string[]>();
string[] gunModsToDisable = Traverse.Create(turretView).Field<string[]>("_gunModsToDisable").Value;
if (gunModsToDisable != null)
{
foreach (Transform child in weaponTransform)
Expand Down
2 changes: 1 addition & 1 deletion Fika.Core/Coop/BTR/FikaBTRManager_Host.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public void OnPlayerInteractDoor(Player player, PlayerInteractPacket interactPac
// Find `BTRControllerClass.method_9(PathDestination currentDestinationPoint, bool lastRoutePoint)`
private bool IsUpdateTaxiPriceMethod(MethodInfo method)
{
return (method.GetParameters().Length == 2 && method.GetParameters()[0].ParameterType == typeof(PathDestination));
return method.GetParameters().Length == 2 && method.GetParameters()[0].ParameterType == typeof(PathDestination);
}

private void Update()
Expand Down
6 changes: 3 additions & 3 deletions Fika.Core/Coop/BotClasses/CoopBotHealthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Fika.Core.Coop.ClientClasses
{
public sealed class CoopBotHealthController(Profile.GClass1767 healthInfo, Player player, InventoryControllerClass inventoryController, SkillManager skillManager, bool aiHealth)
public sealed class CoopBotHealthController(Profile.GClass1768 healthInfo, Player player, InventoryControllerClass inventoryController, SkillManager skillManager, bool aiHealth)
: PlayerHealthController(healthInfo, player, inventoryController, skillManager, aiHealth)
{
private readonly CoopBot coopBot = (CoopBot)player;
Expand All @@ -18,9 +18,9 @@ public override bool _sendNetworkSyncPackets
}
}

public override void SendNetworkSyncPacket(GStruct347 packet)
public override void SendNetworkSyncPacket(GStruct346 packet)
{
if (packet.SyncType == GStruct347.ESyncType.IsAlive && !packet.Data.IsAlive.IsAlive)
if (packet.SyncType == GStruct346.ESyncType.IsAlive && !packet.Data.IsAlive.IsAlive)
{
coopBot.PacketSender.HealthSyncPackets.Enqueue(coopBot.SetupDeathPacket(packet));
return;
Expand Down
4 changes: 2 additions & 2 deletions Fika.Core/Coop/BotClasses/CoopBotInventoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CoopBotInventoryController(Player player, Profile profile, bool exa
{
private readonly CoopBot CoopBot = (CoopBot)player;

public override void Execute(GClass2853 operation, [CanBeNull] Callback callback)
public override void Execute(GClass2854 operation, [CanBeNull] Callback callback)
{
base.Execute(operation, callback);

Expand All @@ -25,7 +25,7 @@ public override void Execute(GClass2853 operation, [CanBeNull] Callback callback

using MemoryStream memoryStream = new();
using BinaryWriter binaryWriter = new(memoryStream);
binaryWriter.WritePolymorph(GClass1643.FromInventoryOperation(operation, false));
binaryWriter.WritePolymorph(FromObjectAbstractClass.FromInventoryOperation(operation, false));
byte[] opBytes = memoryStream.ToArray();
packet.ItemControllerExecutePacket = new()
{
Expand Down
6 changes: 3 additions & 3 deletions Fika.Core/Coop/ClientClasses/CoopClientHealthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Fika.Core.Coop.ClientClasses
{
public sealed class CoopClientHealthController(Profile.GClass1767 healthInfo, Player player, InventoryControllerClass inventoryController, SkillManager skillManager, bool aiHealth)
public sealed class CoopClientHealthController(Profile.GClass1768 healthInfo, Player player, InventoryControllerClass inventoryController, SkillManager skillManager, bool aiHealth)
: PlayerHealthController(healthInfo, player, inventoryController, skillManager, aiHealth)
{
private readonly CoopPlayer coopPlayer = (CoopPlayer)player;
Expand All @@ -18,9 +18,9 @@ public override bool _sendNetworkSyncPackets
}
}

public override void SendNetworkSyncPacket(GStruct347 packet)
public override void SendNetworkSyncPacket(GStruct346 packet)
{
if (packet.SyncType == GStruct347.ESyncType.IsAlive && !packet.Data.IsAlive.IsAlive)
if (packet.SyncType == GStruct346.ESyncType.IsAlive && !packet.Data.IsAlive.IsAlive)
{
coopPlayer.PacketSender.HealthSyncPackets.Enqueue(coopPlayer.SetupDeathPacket(packet));
return;
Expand Down
60 changes: 34 additions & 26 deletions Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
using EFT;
using EFT.InventoryLogic;
using EFT.UI;
using Fika.Core.Coop.Matchmaker;
using Fika.Core.Coop.Players;
using Fika.Core.Coop.Utils;
using Fika.Core.Networking;
using Fika.Core.Networking.Packets;
using JetBrains.Annotations;
using System.IO;
using UnityEngine;
Expand All @@ -16,6 +17,7 @@ public sealed class CoopClientInventoryController(Player player, Profile profile
{
public override bool HasDiscardLimits => false;


ManualLogSource BepInLogger { get; set; } = BepInEx.Logging.Logger.CreateLogSource(nameof(CoopClientInventoryController));

private readonly Player Player = player;
Expand All @@ -30,31 +32,44 @@ public override void CallMalfunctionRepaired(Weapon weapon)
}
}

public override void Execute(GClass2853 operation, [CanBeNull] Callback callback)
public override void Execute(GClass2854 operation, [CanBeNull] Callback callback)
{
#if DEBUG
ConsoleScreen.Log("InvOperation: " + operation.GetType().Name);
#endif

// Do not replicate picking up quest items, throws an error on the other clients
if (operation is GClass2855 pickupOperation)
// Do not replicate picking up quest items, throws an error on the other clients
if (operation is MoveOperationClass moveOperation)
{
if (pickupOperation.Item.Template.QuestItem)
Item lootedItem = moveOperation.Item;
if (lootedItem.Template.QuestItem)
{
if (CoopPlayer.GClass3227_0 is CoopSharedQuestController sharedQuestController)
{
if (!sharedQuestController.CheckForTemplateId(lootedItem.TemplateId))
{
sharedQuestController.AddLootedTemplateId(lootedItem.TemplateId);

// We use templateId because each client gets a unique itemId
QuestItemPacket packet = new(CoopPlayer.Profile.Info.MainProfileNickname, lootedItem.TemplateId);
CoopPlayer.PacketSender.SendQuestItemPacket(ref packet);
}
}
base.Execute(operation, callback);
return;
}
}

if (MatchmakerAcceptPatches.IsServer)
// Do not replicate quest operations
// Check for GClass increments
if (operation is GClass2897 or GClass2898 or QuestHandoverOperationClass)
{
// Do not replicate quest operations
if (operation is GClass2866 or GClass2879)
{
base.Execute(operation, callback);
return;
}
base.Execute(operation, callback);
return;
}

if (FikaBackendUtils.IsServer)
{
HostInventoryOperationManager operationManager = new(this, operation, callback);
if (vmethod_0(operationManager.operation))
{
Expand All @@ -67,7 +82,7 @@ public override void Execute(GClass2853 operation, [CanBeNull] Callback callback

using MemoryStream memoryStream = new();
using BinaryWriter binaryWriter = new(memoryStream);
binaryWriter.WritePolymorph(GClass1643.FromInventoryOperation(operation, false));
binaryWriter.WritePolymorph(FromObjectAbstractClass.FromInventoryOperation(operation, false));
byte[] opBytes = memoryStream.ToArray();
packet.ItemControllerExecutePacket = new()
{
Expand All @@ -82,15 +97,8 @@ public override void Execute(GClass2853 operation, [CanBeNull] Callback callback
operationManager.operation.Dispose();
operationManager.callback?.Fail($"Can't execute {operationManager.operation}", 1);
}
else if (MatchmakerAcceptPatches.IsClient)
else if (FikaBackendUtils.IsClient)
{
// Do not replicate quest operations
if (operation is GClass2866 or GClass2879)
{
base.Execute(operation, callback);
return;
}

InventoryPacket packet = new()
{
HasItemControllerExecutePacket = true
Expand All @@ -108,7 +116,7 @@ public override void Execute(GClass2853 operation, [CanBeNull] Callback callback

using MemoryStream memoryStream = new();
using BinaryWriter binaryWriter = new(memoryStream);
binaryWriter.WritePolymorph(GClass1643.FromInventoryOperation(operation, false));
binaryWriter.WritePolymorph(FromObjectAbstractClass.FromInventoryOperation(operation, false));
byte[] opBytes = memoryStream.ToArray();
packet.ItemControllerExecutePacket = new()
{
Expand All @@ -120,17 +128,17 @@ public override void Execute(GClass2853 operation, [CanBeNull] Callback callback
}
}

private uint AddOperationCallback(GClass2853 operation, Callback<EOperationStatus> callback)
private uint AddOperationCallback(GClass2854 operation, Callback<EOperationStatus> callback)
{
ushort id = operation.Id;
CoopPlayer.OperationCallbacks.Add(id, callback);
return id;
}

private class HostInventoryOperationManager(CoopClientInventoryController inventoryController, GClass2853 operation, Callback callback)
private class HostInventoryOperationManager(CoopClientInventoryController inventoryController, GClass2854 operation, Callback callback)
{
public readonly CoopClientInventoryController inventoryController = inventoryController;
public GClass2853 operation = operation;
public GClass2854 operation = operation;
public readonly Callback callback = callback;

public void HandleResult(IResult result)
Expand All @@ -147,7 +155,7 @@ private class ClientInventoryOperationManager
{
public EOperationStatus? serverOperationStatus;
public EOperationStatus? localOperationStatus;
public GClass2853 operation;
public GClass2854 operation;
public Callback callback;
public CoopClientInventoryController inventoryController;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public override void ShowStatNotification(LocalizationKey localizationKey1, Loca
{
if (value > 0)
{
NotificationManagerClass.DisplayNotification(new GClass2055(localizationKey1, localizationKey2, value));
NotificationManagerClass.DisplayNotification(new GClass2056(localizationKey1, localizationKey2, value));
}
}
}
Expand Down
Loading

0 comments on commit ee0748c

Please sign in to comment.