From 4ffe0041d24ea01e38b9ada38ec64b219b70dae8 Mon Sep 17 00:00:00 2001 From: Kaioru Date: Wed, 2 Oct 2024 12:41:50 +0800 Subject: [PATCH] Fix rechargeable items being mergeable --- .../Inventories/Modifiers/ModifyInventoryContext.cs | 1 + .../Entities/Inventories/ItemSlotBaseExtensions.cs | 4 +++- .../Entities/Inventories/ItemSlotBundle.cs | 7 +++++-- .../Entities/Inventories/StructuredItemSlotInfoBundle.cs | 5 ++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/common/Edelstein.Common.Gameplay/Entities/Inventories/Modifiers/ModifyInventoryContext.cs b/src/common/Edelstein.Common.Gameplay/Entities/Inventories/Modifiers/ModifyInventoryContext.cs index 82c174829..05ce14e14 100644 --- a/src/common/Edelstein.Common.Gameplay/Entities/Inventories/Modifiers/ModifyInventoryContext.cs +++ b/src/common/Edelstein.Common.Gameplay/Entities/Inventories/Modifiers/ModifyInventoryContext.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; +using Edelstein.Protocol.Gameplay.Constants; using Edelstein.Protocol.Gameplay.Entities.Inventories; using Edelstein.Protocol.Gameplay.Entities.Inventories.Modifiers; using Edelstein.Protocol.Gameplay.Entities.Inventories.Modifiers.Operations; diff --git a/src/protocol/Edelstein.Protocol.Gameplay/Entities/Inventories/ItemSlotBaseExtensions.cs b/src/protocol/Edelstein.Protocol.Gameplay/Entities/Inventories/ItemSlotBaseExtensions.cs index e47e165f3..5485b4700 100644 --- a/src/protocol/Edelstein.Protocol.Gameplay/Entities/Inventories/ItemSlotBaseExtensions.cs +++ b/src/protocol/Edelstein.Protocol.Gameplay/Entities/Inventories/ItemSlotBaseExtensions.cs @@ -1,4 +1,5 @@ using System; +using Edelstein.Protocol.Gameplay.Constants; using Edelstein.Protocol.Network.Packets.Types; namespace Edelstein.Protocol.Gameplay.Entities.Inventories; @@ -65,7 +66,8 @@ public static StructuredItemSlot ToStructured(this ItemSlotBase item) Number = bundle.Number, Title = new LPString(bundle.Title ?? ""), - Attribute = bundle.Attribute + Attribute = bundle.Attribute, + SN = bundle.TemplateID.IsRechargeableItem() ? 0 : null }, ItemSlotPet pet => new StructuredItemSlotInfoPet { diff --git a/src/protocol/Edelstein.Protocol.Gameplay/Entities/Inventories/ItemSlotBundle.cs b/src/protocol/Edelstein.Protocol.Gameplay/Entities/Inventories/ItemSlotBundle.cs index 3973dea35..2436d7d6a 100644 --- a/src/protocol/Edelstein.Protocol.Gameplay/Entities/Inventories/ItemSlotBundle.cs +++ b/src/protocol/Edelstein.Protocol.Gameplay/Entities/Inventories/ItemSlotBundle.cs @@ -1,4 +1,6 @@ -namespace Edelstein.Protocol.Gameplay.Entities.Inventories; +using Edelstein.Protocol.Gameplay.Constants; + +namespace Edelstein.Protocol.Gameplay.Entities.Inventories; public record ItemSlotBundle : ItemSlotBase { @@ -8,7 +10,8 @@ public record ItemSlotBundle : ItemSlotBase public string? Title { get; set; } public bool IsMergeableWith(ItemSlotBundle bundle) - => TemplateID == bundle.TemplateID && + => !TemplateID.IsRechargeableItem() && + TemplateID == bundle.TemplateID && Attribute == bundle.Attribute && Title == bundle.Title && DateExpire == bundle.DateExpire; diff --git a/src/protocol/Edelstein.Protocol.Gameplay/Entities/Inventories/StructuredItemSlotInfoBundle.cs b/src/protocol/Edelstein.Protocol.Gameplay/Entities/Inventories/StructuredItemSlotInfoBundle.cs index 0613e5649..196b8848a 100644 --- a/src/protocol/Edelstein.Protocol.Gameplay/Entities/Inventories/StructuredItemSlotInfoBundle.cs +++ b/src/protocol/Edelstein.Protocol.Gameplay/Entities/Inventories/StructuredItemSlotInfoBundle.cs @@ -1,4 +1,5 @@ using BinarySerialization; +using Edelstein.Protocol.Gameplay.Constants; using Edelstein.Protocol.Network.Packets.Types; namespace Edelstein.Protocol.Gameplay.Entities.Inventories; @@ -8,5 +9,7 @@ public record StructuredItemSlotInfoBundle : StructuredItemSlotInfoBase [FieldOrder(0)] public short Number { get; init; } [FieldOrder(1)] public LPString Title { get; init; } = new(); [FieldOrder(2)] public short Attribute { get; init; } - [FieldOrder(3)] public long? SN { get; init; } + + [FieldOrder(3)] + public long? SN { get; init; } }