Fixed item deletion error - Use separate record for item deletions
This commit is contained in:
@@ -1074,7 +1074,9 @@ public class InventoryController(
|
||||
}
|
||||
|
||||
destinationItem.Upd.StackObjectsCount += sourceItem.Upd.StackObjectsCount; // Add source stackcount to destination
|
||||
output.ProfileChanges[sessionID].Items.DeletedItems.Add(new Item { Id = sourceItem.Id }); // Inform client source item being deleted
|
||||
output
|
||||
.ProfileChanges[sessionID]
|
||||
.Items.DeletedItems.Add(new DeletedItem { Id = sourceItem.Id }); // Inform client source item being deleted
|
||||
|
||||
var indexOfItemToRemove = inventoryItems.From.FindIndex(x => x.Id == sourceItem.Id);
|
||||
if (indexOfItemToRemove == -1)
|
||||
|
||||
@@ -320,7 +320,7 @@ public class QuestController(
|
||||
// Important: don't tell the client to remove the attachments, it will handle it
|
||||
output
|
||||
.ProfileChanges[sessionID]
|
||||
.Items.DeletedItems.Add(new Item { Id = itemHandover.Id });
|
||||
.Items.DeletedItems.Add(new DeletedItem { Id = itemHandover.Id });
|
||||
|
||||
// Important: loop backward when removing items from the array we're looping on
|
||||
while (index-- > 0)
|
||||
|
||||
@@ -533,10 +533,7 @@ public class InventoryHelper(
|
||||
var insuredItems = profile.InsuredItems;
|
||||
|
||||
// We have output object, inform client of root item deletion, not children
|
||||
if (output is not null)
|
||||
{
|
||||
output.ProfileChanges[sessionId].Items.DeletedItems.Add(new Item { Id = itemId });
|
||||
}
|
||||
output?.ProfileChanges[sessionId].Items.DeletedItems.Add(new DeletedItem { Id = itemId });
|
||||
|
||||
foreach (var item in itemAndChildrenToRemove)
|
||||
{
|
||||
|
||||
@@ -666,7 +666,9 @@ public class QuestHelper(
|
||||
{
|
||||
// this case is probably dead Code right now, since the only calling function
|
||||
// checks explicitly for Value > 0.
|
||||
output.ProfileChanges[sessionID].Items.DeletedItems.Add(new Item { Id = itemId });
|
||||
output
|
||||
.ProfileChanges[sessionID]
|
||||
.Items.DeletedItems.Add(new DeletedItem { Id = itemId });
|
||||
pmcData.Inventory.Items.RemoveAt(inventoryItemIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,13 @@ public record ItemChanges
|
||||
public List<Item>? ChangedItems { get; set; }
|
||||
|
||||
[JsonPropertyName("del")]
|
||||
public List<Item> DeletedItems { get; set; } // Only needs _id property
|
||||
public List<DeletedItem> DeletedItems { get; set; } // Only needs _id property
|
||||
}
|
||||
|
||||
public record DeletedItem
|
||||
{
|
||||
[JsonPropertyName("_id")]
|
||||
public string Id { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -102,7 +102,7 @@ public class EventOutputHolder(
|
||||
profileChanges.Skills.Common = cloner.Clone(pmcData.Skills.Common); // Always send skills for Item event route response
|
||||
profileChanges.Skills.Mastering = cloner.Clone(pmcData.Skills.Mastering);
|
||||
|
||||
// Clone productions to ensure we preseve the profile jsons data
|
||||
// Clone productions to ensure we preserve the profile jsons data
|
||||
profileChanges.Production = GetProductionsFromProfileAndFlagComplete(
|
||||
cloner.Clone(pmcData.Hideout.Production),
|
||||
sessionId
|
||||
|
||||
Reference in New Issue
Block a user