From 9afe8ccedbe68283c87197c642ad8f0e3dcf838b Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Fri, 2 Oct 2026 10:30:24 -0500 Subject: [PATCH] fix(inventory): inventory group names are cut to 64 characters, as the client LWOInventoryComponent_Common::msgUpdateInventoryGroup (0x00c955b0) resizes the group name to 64 characters on ADD and MODIFY. The server kept names of any length in the charxml. Co-Authored-By: Claude Opus 5.5 --- dGame/dComponents/InventoryComponent.cpp | 3 ++- dGame/dComponents/InventoryComponent.h | 1 + .../dGameTests/dComponentsTests/InventoryGroupTests.cpp | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 645f63816..36c20530f 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -2399,7 +2399,8 @@ void InventoryComponent::OnUpdateInventoryGroup(const GameMessages::UpdateInvent GroupUpdate groupUpdate; groupUpdate.groupId = msg.groupID; groupUpdate.inventory = msg.inventoryType; - groupUpdate.groupName = GeneralUtils::UTF16ToWTF8(msg.groupName); + // msgUpdateInventoryGroup (0x00c955b0) cuts names to 64 characters + groupUpdate.groupName = GeneralUtils::UTF16ToWTF8(msg.groupName.substr(0, MaximumGroupNameLength)); if (msg.action == "ADD") groupUpdate.command = GroupUpdateCommand::ADD; else if (msg.action == "MODIFY") groupUpdate.command = GroupUpdateCommand::MODIFY; diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index f071407b7..234a3e012 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -99,6 +99,7 @@ public: }; static constexpr uint32_t MaximumGroupCount = 50; + static constexpr size_t MaximumGroupNameLength = 64; // UTF-16 characters static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::INVENTORY; diff --git a/tests/dGameTests/dComponentsTests/InventoryGroupTests.cpp b/tests/dGameTests/dComponentsTests/InventoryGroupTests.cpp index ddbe8dfa7..e2b9a22af 100644 --- a/tests/dGameTests/dComponentsTests/InventoryGroupTests.cpp +++ b/tests/dGameTests/dComponentsTests/InventoryGroupTests.cpp @@ -60,3 +60,12 @@ TEST_F(InventoryGroupTests, AddingAGroupThatExistsDoesNothing) { EXPECT_EQ(Groups()[0].groupName, "first"); EXPECT_EQ(Groups()[0].lots.size(), 1u); } + +TEST_F(InventoryGroupTests, NamesAreCutTo64Characters) { + const std::u16string longName(70, u'a'); + Group("ADD", "user_group1", longName); + EXPECT_EQ(Groups()[0].groupName, std::string(64, 'a')); + + Group("MODIFY", "user_group1", std::u16string(65, u'b')); + EXPECT_EQ(Groups()[0].groupName, std::string(64, 'b')); +}