Skip to content

fix: safely merge, stack, and prioritize AoE loot#66

Open
Souicia wants to merge 2 commits into
azerothcore:masterfrom
Souicia:fix/safe-loot-merging
Open

fix: safely merge, stack, and prioritize AoE loot#66
Souicia wants to merge 2 commits into
azerothcore:masterfrom
Souicia:fix/safe-loot-merging

Conversation

@Souicia

@Souicia Souicia commented Jul 16, 2026

Copy link
Copy Markdown

Changes Proposed:

  • Merge compatible stackable items collected from different nearby corpses, respecting the database stack limit with an additional module limit of 200.
  • Keep non-stackable items in separate loot rows.
  • Prioritize displayed loot by quality, followed by normal materials, miscellaneous normal items, grey items, food/drink, and normal-quality recipes.
  • Preserve items that cannot fit within the loot-window row limit on their original corpses.
  • Finalize only fully looted corpses, allowing remaining loot to be collected afterward.
  • Process all eligible corpses within the configured AoE-loot range instead of stopping after ten.

Issues Addressed:

  • Prevents identical stackable drops from unnecessarily occupying separate loot rows.
  • Prevents overflow loot from being discarded or incorrectly finalizing its source corpse.
  • No linked issue.

SOURCE:

  • Uses the existing AzerothCore Loot, LootItem, and ItemTemplate APIs.
  • Stack sizes are obtained from each item's database template.
  • No external source or core modification is required.

Tests Performed:

  • Successfully built worldserver in RelWithDebInfo on Windows.
  • Tested in-game on a solo AzerothCore server.
  • Tested duplicate stackable drops collected from different corpses.
  • Tested loot ordering with items of different qualities.
  • Tested overflow using a temporarily reduced loot-row limit.
  • Confirmed overflow remained on sparkling corpses and could be collected afterward.
  • Repeatedly looted and skinned eligible beasts without encountering the previously observed skinning problem.
  • Group-loot ownership behavior was not changed or tested.

How to Test the Changes:

  1. Build AzerothCore with the module and start worldserver.
  2. Ensure AOELoot.Enable = 1 and configure the desired AOELoot.Range.
  3. Kill several nearby creatures whose loot includes duplicate stackable items.
  4. Loot one corpse and confirm compatible items are merged into stacks rather than displayed in duplicate rows.
  5. Confirm the displayed loot follows the documented quality and category priority.
  6. Create enough unique loot to exceed the loot-window row limit. For easier testing, temporarily reduce MAX_LOOT_ITEMS, rebuild, and repeat the pull.
  7. Loot the displayed items and confirm the remaining corpses continue sparkling.
  8. Loot again and confirm the preserved overflow becomes available.
  9. Repeat the test with skinnable creatures and confirm fully looted corpses can still be skinned.

Summary by CodeRabbit

  • New Features

    • Improved area-loot merging for regular items, including smarter stacking and prioritization.
    • Preserves excess items when loot-window stack limits are reached.
    • Transfers eligible quest items directly to inventory while respecting required quantities.
  • Bug Fixes

    • Prevents partially transferred or unsuccessful loot from being incorrectly marked as collected.
    • Improves loot-window cleanup and final item ordering after area looting.

Souicia added 2 commits July 16, 2026 23:03
Remove leftover commented code from the completed AoE-loot implementation.
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2cc71b69-80e4-4a6d-823f-8dd9badcefb4

📥 Commits

Reviewing files that changed from the base of the PR and between 2ddf6ff and 1533c9b.

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

📝 Walkthrough

Walkthrough

AOE loot merging now collects regular and quest candidates before transfer, orders and stacks regular items safely, adds quest items directly to inventory, preserves partially transferred source rows, and cleans up only fully looted corpses.

Changes

AOE loot transfer

Layer / File(s) Summary
Regular loot stacking and ordering
src/aoe_loot.cpp
Adds helpers for stack eligibility, capacity-aware insertion, safe compaction, and priority-based regular-loot sorting.
Candidate collection and preparation
src/aoe_loot.cpp
Collects regular and quest candidates from nearby corpses, tracks processed sources, caps quest quantities, and merges gold with overflow protection.
Loot transfer and cleanup
src/aoe_loot.cpp
Transfers regular items into the loot window and quest items into inventory, preserves partial source stacks, clears fully looted corpses, and sorts the final window.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AOELootServer
  participant SourceCorpses
  participant MainLootWindow
  participant PlayerInventory
  AOELootServer->>SourceCorpses: collect regular and quest candidates
  SourceCorpses-->>AOELootServer: candidate rows and gold
  AOELootServer->>MainLootWindow: stack and transfer regular items
  MainLootWindow-->>AOELootServer: transferred quantities
  AOELootServer->>PlayerInventory: add quest items
  PlayerInventory-->>AOELootServer: successful additions
  AOELootServer->>SourceCorps: preserve partial rows and clear completed corpses
  AOELootServer->>MainLootWindow: apply gold and sort final loot
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main AoE loot merging, stacking, and prioritization changes.
Description check ✅ Passed The description follows the template and includes the requested changes, issues, source, tests, and test steps.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@Helias

Helias commented Jul 18, 2026

Copy link
Copy Markdown
Member

@pangolp

@pangolp

pangolp commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

@pangolp

The module has changed a lot since I last worked on it... I really would have to look at all the code again. If there are other reviews or the argument of the creator of the PR is solid, I will not oppose it. I have already asked him for the history of changes that this code has actually undergone.

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.

3 participants