From 042594e3dd526b3c6682d3cba4589b79075b41f8 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Fri, 2 Oct 2026 10:30:51 -0500 Subject: [PATCH] fix(inventory): UpdateInventoryGroupContents CLEAR empties the group, as the client LWOInventoryComponent_Common::msgUpdateInventoryGroupContents (0x00ce1f50) takes ADD, REMOVE and CLEAR; CLEAR removes every LOT from the group. The server logged CLEAR as an invalid action and kept the LOTs. Co-Authored-By: Claude Opus 5.5 --- dGame/dComponents/InventoryComponent.cpp | 5 +++++ dGame/dComponents/InventoryComponent.h | 1 + .../dComponentsTests/InventoryGroupTests.cpp | 10 ++++++++++ 3 files changed, 16 insertions(+) diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 1c9ba7258..8075579c7 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -2032,6 +2032,10 @@ void InventoryComponent::UpdateGroup(const GroupUpdate& groupUpdate) { groupItr->lots.erase(groupUpdate.lot); break; } + case GroupUpdateCommand::CLEAR_LOTS: { + groupItr->lots.clear(); + break; + } case GroupUpdateCommand::MODIFY: { groupItr->groupName = groupUpdate.groupName; break; @@ -2420,6 +2424,7 @@ void InventoryComponent::OnUpdateInventoryGroupContents(const GameMessages::Upda if (msg.action == "ADD") groupUpdate.command = GroupUpdateCommand::ADD_LOT; else if (msg.action == "REMOVE") groupUpdate.command = GroupUpdateCommand::REMOVE_LOT; + else if (msg.action == "CLEAR") groupUpdate.command = GroupUpdateCommand::CLEAR_LOTS; else { LOG("Invalid action %s", msg.action.c_str()); return; diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index 234a3e012..b9e1c107a 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -86,6 +86,7 @@ public: MODIFY, REMOVE, REMOVE_LOT, + CLEAR_LOTS, }; // Based on the command, certain fields will be used or not used. diff --git a/tests/dGameTests/dComponentsTests/InventoryGroupTests.cpp b/tests/dGameTests/dComponentsTests/InventoryGroupTests.cpp index ac6a3352d..c697950d0 100644 --- a/tests/dGameTests/dComponentsTests/InventoryGroupTests.cpp +++ b/tests/dGameTests/dComponentsTests/InventoryGroupTests.cpp @@ -78,3 +78,13 @@ TEST_F(InventoryGroupTests, TheModelVaultUsesTheModelsGroups) { EXPECT_EQ(Groups(eInventoryType::MODELS)[0].lots.size(), 1u); EXPECT_FALSE(inventory->GetGroups().contains(eInventoryType::VAULT_MODELS)); } + +TEST_F(InventoryGroupTests, ClearEmptiesAGroup) { + Group("ADD", "user_group1", u"bricks"); + Contents("ADD", "user_group1", 3001); + Contents("ADD", "user_group1", 3002); + Contents("CLEAR", "user_group1", 0); + + ASSERT_EQ(Groups().size(), 1u); + EXPECT_TRUE(Groups()[0].lots.empty()); +}