Skip to content

Commit

Permalink
Merge pull request #57 from project-fika/dev
Browse files Browse the repository at this point in the history
dev > main
  • Loading branch information
Lacyway authored May 23, 2024
2 parents 73000be + df9e0e5 commit e2075c6
Show file tree
Hide file tree
Showing 43 changed files with 996 additions and 507 deletions.
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 @@ -456,7 +456,7 @@ private void UpdateBTRSideDoorState(byte state)
{
try
{
BTRSide btrSide = lastInteractPlayer.BtrInteractionSide ?? lastInteractedBtrSide;
BTRSide btrSide = lastInteractPlayer.BtrInteractionSide != null ? lastInteractPlayer.BtrInteractionSide : lastInteractedBtrSide;
byte sideId = btrClientSide.GetSideId(btrSide);
switch (sideId)
{
Expand Down
4 changes: 2 additions & 2 deletions Fika.Core/Coop/BotClasses/CoopBotHealthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public override void SendNetworkSyncPacket(GStruct346 packet)
{
if (packet.SyncType == GStruct346.ESyncType.IsAlive && !packet.Data.IsAlive.IsAlive)
{
coopBot?.PacketSender?.HealthSyncPackets.Enqueue(coopBot.SetupDeathPacket(packet));
coopBot.PacketSender.HealthSyncPackets.Enqueue(coopBot.SetupDeathPacket(packet));
return;
}

coopBot?.PacketSender?.HealthSyncPackets.Enqueue(new(coopBot.NetId)
coopBot.PacketSender.HealthSyncPackets.Enqueue(new(coopBot.NetId)
{
Packet = packet
});
Expand Down
2 changes: 1 addition & 1 deletion Fika.Core/Coop/BotClasses/CoopBotInventoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override void Execute(GClass2837 operation, [CanBeNull] Callback callback
OperationBytes = opBytes
};

CoopBot.PacketSender?.InventoryPackets?.Enqueue(packet);
CoopBot.PacketSender.InventoryPackets.Enqueue(packet);
}
}
}
4 changes: 2 additions & 2 deletions Fika.Core/Coop/ClientClasses/CoopClientHealthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public override void SendNetworkSyncPacket(GStruct346 packet)
{
if (packet.SyncType == GStruct346.ESyncType.IsAlive && !packet.Data.IsAlive.IsAlive)
{
coopPlayer?.PacketSender?.HealthSyncPackets.Enqueue(coopPlayer.SetupDeathPacket(packet));
coopPlayer.PacketSender.HealthSyncPackets.Enqueue(coopPlayer.SetupDeathPacket(packet));
return;
}

coopPlayer?.PacketSender?.HealthSyncPackets.Enqueue(new(coopPlayer.NetId)
coopPlayer.PacketSender.HealthSyncPackets.Enqueue(new(coopPlayer.NetId)
{
Packet = packet
});
Expand Down
49 changes: 24 additions & 25 deletions Fika.Core/Coop/ClientClasses/CoopClientInventoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,36 @@ public override void CallMalfunctionRepaired(Weapon weapon)
base.CallMalfunctionRepaired(weapon);
if (!Player.IsAI && (bool)Singleton<SharedGameSettingsClass>.Instance.Game.Settings.MalfunctionVisability)
{
MonoBehaviourSingleton<PreloaderUI>.Instance.MalfunctionGlow.ShowGlow(BattleUIMalfunctionGlow.GlowType.Repaired, force: true, method_44());
MonoBehaviourSingleton<PreloaderUI>.Instance.MalfunctionGlow.ShowGlow(BattleUIMalfunctionGlow.GlowType.Repaired, true, method_44());
}
}

public override void Execute(GClass2837 operation, [CanBeNull] Callback callback)
{
// Do not replicate picking up quest items, throws an error on the other clients
if (operation is GClass2839 pickupOperation)
{
if (pickupOperation.Item.Template.QuestItem)
{
base.Execute(operation, callback);
return;
}
}

if (MatchmakerAcceptPatches.IsServer)
{
// Do not replicate quest operations
if (operation is GClass2866 or GClass2879)
{
base.Execute(operation, callback);
return;
}

HostInventoryOperationManager operationManager = new(this, operation, callback);
if (vmethod_0(operationManager.operation))
{
operationManager.operation.vmethod_0(operationManager.HandleResult);

// Do not replicate picking up quest items, throws an error on the other clients
if (operation is GClass2839 pickupOperation)
{
if (pickupOperation.Item.Template.QuestItem)
{
return;
}
}

// TODO: Check for glass increments
if (operation is GClass2870)
{
return;
}

InventoryPacket packet = new()
{
HasItemControllerExecutePacket = true
Expand All @@ -69,7 +71,7 @@ public override void Execute(GClass2837 operation, [CanBeNull] Callback callback
OperationBytes = opBytes
};

CoopPlayer.PacketSender?.InventoryPackets?.Enqueue(packet);
CoopPlayer.PacketSender.InventoryPackets.Enqueue(packet);

return;
}
Expand All @@ -78,14 +80,11 @@ public override void Execute(GClass2837 operation, [CanBeNull] Callback callback
}
else if (MatchmakerAcceptPatches.IsClient)
{
// Do not replicate picking up quest items, throws an error on the other clients
if (operation is GClass2839 pickupOperation)
// Do not replicate quest operations
if (operation is GClass2866 or GClass2879)
{
if (pickupOperation.Item.Template.QuestItem)
{
base.Execute(operation, callback);
return;
}
base.Execute(operation, callback);
return;
}

InventoryPacket packet = new()
Expand Down Expand Up @@ -113,7 +112,7 @@ public override void Execute(GClass2837 operation, [CanBeNull] Callback callback
OperationBytes = opBytes
};

CoopPlayer.PacketSender?.InventoryPackets?.Enqueue(packet);
CoopPlayer.PacketSender.InventoryPackets.Enqueue(packet);
}
}

Expand Down
Loading

0 comments on commit e2075c6

Please sign in to comment.