diff --git a/src/ApplicationServer/NeoServer.Server.Contracts/Contracts/Network/IConnection.cs b/src/ApplicationServer/NeoServer.Server.Contracts/Contracts/Network/IConnection.cs index 2875a354b..9a4df2222 100644 --- a/src/ApplicationServer/NeoServer.Server.Contracts/Contracts/Network/IConnection.cs +++ b/src/ApplicationServer/NeoServer.Server.Contracts/Contracts/Network/IConnection.cs @@ -17,6 +17,7 @@ public interface IConnection string Ip { get; } long TimeStamp { get; } byte RandomNumber { get; } + ushort OtcV8Version { get; set; } event EventHandler OnProcessEvent; event EventHandler OnCloseEvent; diff --git a/src/ApplicationServer/NeoServer.Server.Contracts/Contracts/Network/INetworkMessage.cs b/src/ApplicationServer/NeoServer.Server.Contracts/Contracts/Network/INetworkMessage.cs index daa2ddf75..d320563dc 100644 --- a/src/ApplicationServer/NeoServer.Server.Contracts/Contracts/Network/INetworkMessage.cs +++ b/src/ApplicationServer/NeoServer.Server.Contracts/Contracts/Network/INetworkMessage.cs @@ -14,7 +14,7 @@ public interface INetworkMessage : IReadOnlyNetworkMessage void AddUInt32(uint value); void WriteUint32(uint value, int position); byte[] AddHeader(bool addChecksum = true); - void AddItem(IItem item); + void AddItem(IItem item, bool showItemDescription = false); void AddLocation(Location location); void AddLength(); } \ No newline at end of file diff --git a/src/ApplicationServer/NeoServer.Server.Events/Items/ContentModifiedOnContainerEventHandler.cs b/src/ApplicationServer/NeoServer.Server.Events/Items/ContentModifiedOnContainerEventHandler.cs index e71c35dae..363357419 100644 --- a/src/ApplicationServer/NeoServer.Server.Events/Items/ContentModifiedOnContainerEventHandler.cs +++ b/src/ApplicationServer/NeoServer.Server.Events/Items/ContentModifiedOnContainerEventHandler.cs @@ -30,10 +30,16 @@ public void Execute(IPlayer player, ContainerOperation operation, byte container connection.OutgoingPackets.Enqueue(new RemoveItemContainerPacket(containerId, slotIndex, item)); break; case ContainerOperation.ItemAdded: - connection.OutgoingPackets.Enqueue(new AddItemContainerPacket(containerId, item)); + connection.OutgoingPackets.Enqueue(new AddItemContainerPacket(containerId, item) + { + ShowItemDescription = connection.OtcV8Version > 0 + }); break; case ContainerOperation.ItemUpdated: - connection.OutgoingPackets.Enqueue(new UpdateItemContainerPacket(containerId, slotIndex, item)); + connection.OutgoingPackets.Enqueue(new UpdateItemContainerPacket(containerId, slotIndex, item) + { + ShowItemDescription = connection.OtcV8Version > 0 + }); break; } diff --git a/src/ApplicationServer/NeoServer.Server.Events/Player/Containers/PlayerOpenedContainerEventHandler.cs b/src/ApplicationServer/NeoServer.Server.Events/Player/Containers/PlayerOpenedContainerEventHandler.cs index a59bfcfe9..aed80a703 100644 --- a/src/ApplicationServer/NeoServer.Server.Events/Player/Containers/PlayerOpenedContainerEventHandler.cs +++ b/src/ApplicationServer/NeoServer.Server.Events/Player/Containers/PlayerOpenedContainerEventHandler.cs @@ -23,7 +23,10 @@ private void SendContainerPacket(IPlayer player, byte containerId, IContainer co { if (!game.CreatureManager.GetPlayerConnection(player.CreatureId, out var connection)) return; - connection.OutgoingPackets.Enqueue(new OpenContainerPacket(container, containerId)); + connection.OutgoingPackets.Enqueue(new OpenContainerPacket(container, containerId) + { + WithDescription = connection.OtcV8Version > 0 + }); connection.Send(); } } \ No newline at end of file diff --git a/src/ApplicationServer/NeoServer.Server.Events/Player/PlayerChangedInventoryEventHandler.cs b/src/ApplicationServer/NeoServer.Server.Events/Player/PlayerChangedInventoryEventHandler.cs index 15cb44398..c815ee32b 100644 --- a/src/ApplicationServer/NeoServer.Server.Events/Player/PlayerChangedInventoryEventHandler.cs +++ b/src/ApplicationServer/NeoServer.Server.Events/Player/PlayerChangedInventoryEventHandler.cs @@ -28,7 +28,10 @@ public void Execute(IInventory inventory, IItem item, Slot slot, byte amount = 1 if (!game.CreatureManager.GetPlayerConnection(player.CreatureId, out var connection)) return; - connection.OutgoingPackets.Enqueue(new PlayerInventoryItemPacket(player.Inventory, slot)); + connection.OutgoingPackets.Enqueue(new PlayerInventoryItemPacket(player.Inventory, slot) + { + ShowItemDescription = connection.OtcV8Version > 0 + }); if (player.Shopping) connection.OutgoingPackets.Enqueue(new SaleItemListPacket(player, diff --git a/src/ApplicationServer/NeoServer.Server.Events/Player/PlayerSelfAppearOnMapEventHandler.cs b/src/ApplicationServer/NeoServer.Server.Events/Player/PlayerSelfAppearOnMapEventHandler.cs index 38aa4fe24..672501764 100644 --- a/src/ApplicationServer/NeoServer.Server.Events/Player/PlayerSelfAppearOnMapEventHandler.cs +++ b/src/ApplicationServer/NeoServer.Server.Events/Player/PlayerSelfAppearOnMapEventHandler.cs @@ -39,7 +39,10 @@ private void SendPacketsToPlayer(IPlayer player, IConnection connection) connection.OutgoingPackets.Enqueue(new SelfAppearPacket(player)); connection.OutgoingPackets.Enqueue(new MapDescriptionPacket(player, map)); connection.OutgoingPackets.Enqueue(new MagicEffectPacket(player.Location, EffectT.BubbleBlue)); - connection.OutgoingPackets.Enqueue(new PlayerInventoryPacket(player.Inventory)); + connection.OutgoingPackets.Enqueue(new PlayerInventoryPacket(player.Inventory) + { + ShowItemDescription = connection.OtcV8Version > 0 + }); connection.OutgoingPackets.Enqueue(new PlayerStatusPacket(player)); connection.OutgoingPackets.Enqueue(new PlayerSkillsPacket(player)); diff --git a/src/ApplicationServer/NeoServer.Server.Events/Player/Trade/TradeRequestedEventHandler.cs b/src/ApplicationServer/NeoServer.Server.Events/Player/Trade/TradeRequestedEventHandler.cs index 79a767917..9a366c788 100644 --- a/src/ApplicationServer/NeoServer.Server.Events/Player/Trade/TradeRequestedEventHandler.cs +++ b/src/ApplicationServer/NeoServer.Server.Events/Player/Trade/TradeRequestedEventHandler.cs @@ -27,7 +27,10 @@ public void Execute(TradeRequest tradeRequest) out var playerRequestedConnection); playerRequestingConnection.OutgoingPackets.Enqueue(new TradeRequestPacket(tradeRequest.PlayerRequesting.Name, - tradeRequest.Items)); + tradeRequest.Items) + { + ShowItemDescription = playerRequestingConnection.OtcV8Version > 0 + }); SendTradeMessage(tradeRequest, playerRequestedConnection); @@ -55,9 +58,15 @@ private static void SendAcknowledgeTradeToBothPlayers(TradeRequest tradeRequest, var items = SafeTradeSystem.GetTradedItems(tradeRequest.PlayerRequested); playerRequestingConnection.OutgoingPackets.Enqueue(new TradeRequestPacket(tradeRequest.PlayerRequested.Name, - items, true)); + items, true) + { + ShowItemDescription = playerRequestingConnection.OtcV8Version > 0 + }); playerRequestedConnection.OutgoingPackets.Enqueue(new TradeRequestPacket(tradeRequest.PlayerRequesting.Name, - tradeRequest.Items, true)); + tradeRequest.Items, true) + { + ShowItemDescription = playerRequestedConnection.OtcV8Version > 0 + }); } } \ No newline at end of file diff --git a/src/NetworkingServer/NeoServer.Networking.Handlers/LogIn/PlayerLogInHandler.cs b/src/NetworkingServer/NeoServer.Networking.Handlers/LogIn/PlayerLogInHandler.cs index f32f19a5b..de2906a07 100644 --- a/src/NetworkingServer/NeoServer.Networking.Handlers/LogIn/PlayerLogInHandler.cs +++ b/src/NetworkingServer/NeoServer.Networking.Handlers/LogIn/PlayerLogInHandler.cs @@ -75,7 +75,9 @@ private async Task Connect(IConnection connection, PlayerLogInPacket packet) Disconnect(connection, "Your account is banned."); return; } - + + connection.OtcV8Version = packet.OtcV8Version; + _game.Dispatcher.AddEvent(new Event(() => { var result = _playerLogInCommand.Execute(playerRecord, connection); diff --git a/src/NetworkingServer/NeoServer.Networking.Packets/Connection/Connection.cs b/src/NetworkingServer/NeoServer.Networking.Packets/Connection/Connection.cs index 1bea74383..6cc342190 100644 --- a/src/NetworkingServer/NeoServer.Networking.Packets/Connection/Connection.cs +++ b/src/NetworkingServer/NeoServer.Networking.Packets/Connection/Connection.cs @@ -62,6 +62,7 @@ private bool Closed public long LastPingResponse { get; set; } public long TimeStamp { get; } public byte RandomNumber { get; } + public ushort OtcV8Version { get; set; } public event EventHandler OnProcessEvent; public event EventHandler OnCloseEvent; public event EventHandler OnPostProcessEvent; diff --git a/src/NetworkingServer/NeoServer.Networking.Packets/Messages/NetworkMessage.cs b/src/NetworkingServer/NeoServer.Networking.Packets/Messages/NetworkMessage.cs index 9d559efd9..53de79824 100644 --- a/src/NetworkingServer/NeoServer.Networking.Packets/Messages/NetworkMessage.cs +++ b/src/NetworkingServer/NeoServer.Networking.Packets/Messages/NetworkMessage.cs @@ -60,13 +60,17 @@ public void AddString(string value) /// Inserts item object into the buffer. /// /// - public void AddItem(IItem item) + public void AddItem(IItem item, bool showItemDescription = false) { if (item == null) //todo log return; AddBytes(item.GetRaw().ToArray()); + if (showItemDescription) + { + AddString(""); + } } /// diff --git a/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Item/AddItemContainerPacket.cs b/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Item/AddItemContainerPacket.cs index 34e7ce3d5..9daa77cc1 100644 --- a/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Item/AddItemContainerPacket.cs +++ b/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Item/AddItemContainerPacket.cs @@ -7,6 +7,7 @@ public class AddItemContainerPacket : OutgoingPacket { private readonly byte containerId; private readonly IItem item; + public required bool ShowItemDescription { get; init; } public AddItemContainerPacket(byte containerId, IItem item) { @@ -14,11 +15,12 @@ public AddItemContainerPacket(byte containerId, IItem item) this.item = item; } + public override void WriteToMessage(INetworkMessage message) { message.AddByte((byte)GameOutgoingPacketType.ContainerAddItem); message.AddByte(containerId); - message.AddItem(item); + message.AddItem(item, ShowItemDescription); } } \ No newline at end of file diff --git a/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Item/UpdateItemContainerPacket.cs b/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Item/UpdateItemContainerPacket.cs index f83745add..834b094bc 100644 --- a/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Item/UpdateItemContainerPacket.cs +++ b/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Item/UpdateItemContainerPacket.cs @@ -16,12 +16,14 @@ public UpdateItemContainerPacket(byte containerId, byte slot, IItem item) this.slot = slot; } + public required bool ShowItemDescription { get; init; } + public override void WriteToMessage(INetworkMessage message) { message.AddByte((byte)GameOutgoingPacketType.ContainerUpdateItem); message.AddByte(containerId); message.AddByte(slot); - message.AddItem(item); + message.AddItem(item, ShowItemDescription); } } \ No newline at end of file diff --git a/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Player/OpenContainerPacket.cs b/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Player/OpenContainerPacket.cs index db211ef2b..877d5a0c4 100644 --- a/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Player/OpenContainerPacket.cs +++ b/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Player/OpenContainerPacket.cs @@ -8,6 +8,7 @@ public class OpenContainerPacket : OutgoingPacket { private readonly IContainer container; private readonly byte containerId; + public required bool WithDescription { get; init; } public OpenContainerPacket(IContainer container, byte containerId) { @@ -20,7 +21,7 @@ public override void WriteToMessage(INetworkMessage message) message.AddByte((byte)GameOutgoingPacketType.ContainerOpen); message.AddByte(containerId); - message.AddItem(container); + message.AddItem(container, WithDescription); message.AddString(container.Name); message.AddByte(container.Capacity); @@ -28,6 +29,6 @@ public override void WriteToMessage(INetworkMessage message) message.AddByte(Math.Min((byte)0xFF, container.SlotsUsed)); - for (byte i = 0; i < container.SlotsUsed; i++) message.AddItem(container.Items[i]); + for (byte i = 0; i < container.SlotsUsed; i++) message.AddItem(container.Items[i], WithDescription); } } \ No newline at end of file diff --git a/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Player/PlayerInventoryItemPacket.cs b/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Player/PlayerInventoryItemPacket.cs index 2cce908d6..472eb176b 100644 --- a/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Player/PlayerInventoryItemPacket.cs +++ b/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Player/PlayerInventoryItemPacket.cs @@ -8,6 +8,7 @@ public class PlayerInventoryItemPacket : OutgoingPacket { private readonly IInventory inventory; private readonly Slot slot; + public required bool ShowItemDescription { get; init; } public PlayerInventoryItemPacket(IInventory inventory, Slot slot) { @@ -26,7 +27,7 @@ public override void WriteToMessage(INetworkMessage message) { message.AddByte((byte)GameOutgoingPacketType.InventoryItem); message.AddByte((byte)slot); - message.AddItem(inventory[slot]); + message.AddItem(inventory[slot], ShowItemDescription); } } } \ No newline at end of file diff --git a/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Player/PlayerInventoryPacket.cs b/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Player/PlayerInventoryPacket.cs index 9cd2011df..21e1bc4a9 100644 --- a/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Player/PlayerInventoryPacket.cs +++ b/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Player/PlayerInventoryPacket.cs @@ -8,6 +8,7 @@ namespace NeoServer.Networking.Packets.Outgoing.Player; public class PlayerInventoryPacket : OutgoingPacket { private readonly IInventory inventory; + public required bool ShowItemDescription { get; init; } public PlayerInventoryPacket(IInventory inventory) { @@ -27,7 +28,7 @@ public override void WriteToMessage(INetworkMessage message) { message.AddByte((byte)GameOutgoingPacketType.InventoryItem); message.AddByte((byte)slot); - message.AddItem(inventory[slot]); + message.AddItem(inventory[slot], ShowItemDescription); } }); diff --git a/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Trade/TradeRequestPacket.cs b/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Trade/TradeRequestPacket.cs index 15121ff8a..c42eef4c3 100644 --- a/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Trade/TradeRequestPacket.cs +++ b/src/NetworkingServer/NeoServer.Networking.Packets/Outgoing/Trade/TradeRequestPacket.cs @@ -15,7 +15,7 @@ public TradeRequestPacket(string playerName, IItem[] items, bool acknowledged = private string PlayerName { get; } private IItem[] Items { get; } private bool Acknowledged { get; } - + public required bool ShowItemDescription { get; init; } public void WriteToMessage(INetworkMessage message) { message.AddByte(Acknowledged @@ -25,6 +25,6 @@ public void WriteToMessage(INetworkMessage message) message.AddString(PlayerName); message.AddByte((byte)Items.Length); - foreach (var item in Items) message.AddItem(item); + foreach (var item in Items) message.AddItem(item, ShowItemDescription); } } \ No newline at end of file