Skip to content

improve: allow loot pouch reordering in Store Inbox#3872

Open
dudantas wants to merge 4 commits intomainfrom
dudantas/fix-store-inbox
Open

improve: allow loot pouch reordering in Store Inbox#3872
dudantas wants to merge 4 commits intomainfrom
dudantas/fix-store-inbox

Conversation

@dudantas
Copy link
Member

@dudantas dudantas commented Feb 23, 2026

This pull request updates the logic for moving items—particularly the gold pouch—between containers, with a focus on special handling for the Store Inbox. The changes ensure that gold pouches can be reordered within the Store Inbox even if they are not normally movable, and strengthen checks to prevent moving items into or within the Store Inbox unless specific conditions are met.

Key changes:

Special handling for gold pouch and Store Inbox:

  • Updated playerMoveItem to allow the gold pouch (ITEM_GOLD_POUCH) to be reordered within the Store Inbox even if it is not pushable, by setting a special move flag (FLAG_IGNORENOTMOVABLE). This ensures internal organization is possible for this item in the Store Inbox.
  • In checkMoveItemToCylinder, added logic to restrict the gold pouch so it can only be moved inside the Store Inbox (i.e., internal reordering), blocking moves to or from other containers.

Stricter Store Inbox movement checks:

  • Enhanced checks in checkMoveItemToCylinder to ensure items can only be moved to the Store Inbox if they are eligible (movable or gold pouch) and originate from within the Store Inbox, preventing unauthorized moves.
  • Allowed items that are store items or the gold pouch to be moved within the Store Inbox by updating the validity check for such moves.

These changes collectively reinforce item movement rules, particularly for the Store Inbox and gold pouch, improving both security and user experience for inventory management.

Summary by CodeRabbit

  • Bug Fixes
    • Improved item move validation around store inboxes so inventory reorganization works correctly while preserving transfer restrictions.
    • Allowed internal reordering of loot pouches only within store inbox contexts.
    • Expanded checks so moves into/out of store inboxes respect ownership and movability rules, and only permit visible or explicitly movable items.

Special-case gold pouch (ITEM_GOLD_POUCH) moves to allow internal reordering inside Store Inbox containers. Add checks to recognize when both source and destination are Store Inbox (including root parent) and bypass the normal non-movable restriction by passing a move flag (FLAG_IGNORENOTMOVABLE) to internalMoveItem. Update checkMoveItemToCylinder to permit gold pouch internal moves and to apply stricter checks for non-store-movable items only when appropriate (direct Store Inbox drops vs. top-parent Store Inbox reorganizations). Also enable valid-move detection for items moved into Store Inbox parent containers.
@dudantas dudantas changed the title Allow loot pouch reordering in Store Inbox improve: allow loot pouch reordering in Store Inbox Feb 23, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 23, 2026

📝 Walkthrough

Walkthrough

This change updates item-move validation to recognize store-inbox contexts and adjust movability rules for loot containers (notably GOLD_POUCH). It permits loot-pouch reordering inside store-inbox contexts, propagates store-inbox awareness through movability checks, and applies moveFlags for specific internal reorders.

Changes

Cohort / File(s) Summary
Item Movement Logic
src/game/game.cpp
Added store-inbox context checks (fromIsStoreInbox, toIsStoreInbox, topParentIsStoreInbox, directIsStoreInbox) and isLootPouchStoreInboxReorder. Adjusted movability and cylinder-to-cylinder validation to allow GOLD_POUCH reordering only within store-inbox contexts, propagated roots into movability checks, and passed FLAG_IGNORENOTMOVABLE for loot-pouch store-inbox reorders.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through code with nimble paws,

Store inbox rules and pouchy laws.
Gold stays guarded, yet can twirl inside,
Reordered safe where store roots bide.
A merry hop — logic verified.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: enabling loot pouch reordering within Store Inbox, which is the core feature added by the pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dudantas/fix-store-inbox

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

dudantas and others added 3 commits February 24, 2026 01:27
Reformatted a multi-line comment in game.cpp regarding Store Inbox reorganization into a single-line comment. This is a non-functional change intended to improve code readability.
@sonarqubecloud
Copy link

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/game/game.cpp (1)

1892-1907: Consider centralizing Store Inbox context detection.

The Store Inbox context predicates are duplicated here and in checkMoveItemToCylinder, which raises drift risk (e.g., slightly different fromIsStoreInbox logic). A small helper (e.g., isStoreInboxContext(Container*)) would keep the rules consistent.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/game/game.cpp` around lines 1892 - 1907, The Store Inbox detection logic
is duplicated between this block (using fromContainer/fromRoot and computing
fromIsStoreInbox/toIsStoreInbox) and checkMoveItemToCylinder, risking
inconsistencies; extract that predicate into a single helper (e.g.,
isStoreInboxContext(Container* container) or isStoreInboxContext(const Cylinder*
cyl)) and replace the local computations here (references: fromContainer,
toContainer, fromRoot, toRoot, fromIsStoreInbox, toIsStoreInbox,
isLootPouchStoreInboxReorder) and inside checkMoveItemToCylinder to call the
helper so both sites share the same rule and reduce drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/game/game.cpp`:
- Around line 1965-1982: playerMoveItem and moveItem use different predicates to
detect a Store Inbox which causes inconsistent acceptance of loot pouch moves;
update moveItem so its fromIsStoreInbox calculation matches playerMoveItem by
checking both fromContainer->isStoreInbox() and (fromRoot &&
fromRoot->isStoreInbox()) instead of only fromRoot, i.e. compute fromContainer,
fromRoot and set fromIsStoreInbox = (fromContainer &&
fromContainer->isStoreInbox()) || (fromRoot && fromRoot->isStoreInbox()); ensure
this change is applied to the fromIsStoreInbox variable used in the
ITEM_GOLD_POUCH and directIsStoreInbox checks in moveItem.

---

Nitpick comments:
In `@src/game/game.cpp`:
- Around line 1892-1907: The Store Inbox detection logic is duplicated between
this block (using fromContainer/fromRoot and computing
fromIsStoreInbox/toIsStoreInbox) and checkMoveItemToCylinder, risking
inconsistencies; extract that predicate into a single helper (e.g.,
isStoreInboxContext(Container* container) or isStoreInboxContext(const Cylinder*
cyl)) and replace the local computations here (references: fromContainer,
toContainer, fromRoot, toRoot, fromIsStoreInbox, toIsStoreInbox,
isLootPouchStoreInboxReorder) and inside checkMoveItemToCylinder to call the
helper so both sites share the same rule and reduce drift.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5db9357 and a132c40.

📒 Files selected for processing (1)
  • src/game/game.cpp

Comment on lines +1965 to +1982
const bool topParentIsStoreInbox = topParentContainer && topParentContainer->isStoreInbox();
const bool directIsStoreInbox = (containerID == ITEM_STORE_INBOX);
const auto fromContainer = fromCylinder->getContainer();
const auto fromRoot = fromContainer ? fromContainer->getRootContainer() : nullptr;
const bool fromIsStoreInbox = fromRoot && fromRoot->isStoreInbox();
const bool toIsStoreInbox = directIsStoreInbox || topParentIsStoreInbox;

if (item->getID() == ITEM_GOLD_POUCH && !containerToStow) {
// Loot pouch can only be moved inside Store Inbox (internal reordering).
if (!(fromIsStoreInbox && toIsStoreInbox)) {
return RETURNVALUE_ITEMCANNOTBEMOVEDTHERE;
}
}

if (!item->canBeMovedToStore()) {
if (directIsStoreInbox) {
if (!(fromIsStoreInbox && (item->isMovable() || item->getID() == ITEM_GOLD_POUCH))) {
return RETURNVALUE_NOTBOUGHTINSTORE;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Inspect getRootContainer and isStoreInbox implementations
rg -n "getRootContainer\s*\(" -S src -A 10 --max-count=5

Repository: opentibiabr/canary

Length of output: 3927


🏁 Script executed:

# Find isStoreInbox implementation
rg -n "isStoreInbox\s*\(" -S src -A 3 --max-count=10

Repository: opentibiabr/canary

Length of output: 3640


🏁 Script executed:

# Find playerMoveItem function
rg -n "playerMoveItem" -S src --max-count=5

Repository: opentibiabr/canary

Length of output: 1270


🏁 Script executed:

# Get getTopParentContainer implementation
rg -n "getTopParentContainer\s*\(" -S src -A 10 --max-count=5

Repository: opentibiabr/canary

Length of output: 3027


🏁 Script executed:

# Check if Store Inbox can be nested or what its typical parent structure is
rg -n "ITEM_STORE_INBOX" -S src --max-count=15

Repository: opentibiabr/canary

Length of output: 1490


Align Store Inbox detection between playerMoveItem and moveItem functions.

A semantic mismatch exists: playerMoveItem (line 1896) checks fromContainer && (fromContainer->isStoreInbox() || (fromRoot && fromRoot->isStoreInbox())), while moveItem (line 1969) checks only fromRoot && fromRoot->isStoreInbox(). Since moveItem's check is more restrictive, it will reject loot pouch reorders (line 1974) that playerMoveItem would allow. Both functions must use consistent predicates for Store Inbox detection.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/game/game.cpp` around lines 1965 - 1982, playerMoveItem and moveItem use
different predicates to detect a Store Inbox which causes inconsistent
acceptance of loot pouch moves; update moveItem so its fromIsStoreInbox
calculation matches playerMoveItem by checking both
fromContainer->isStoreInbox() and (fromRoot && fromRoot->isStoreInbox()) instead
of only fromRoot, i.e. compute fromContainer, fromRoot and set fromIsStoreInbox
= (fromContainer && fromContainer->isStoreInbox()) || (fromRoot &&
fromRoot->isStoreInbox()); ensure this change is applied to the fromIsStoreInbox
variable used in the ITEM_GOLD_POUCH and directIsStoreInbox checks in moveItem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant