Merge with all weapon blueprints that have the given label when using MergeLabel - #7191
Merge with all weapon blueprints that have the given label when using MergeLabel#7191lL1l1 wants to merge 5 commits into
Conversation
📝 WalkthroughWalkthroughUpdates weapon blueprint merging to clear processed mod data and documents that ChangesWeapon blueprint merging
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lua/system/Blueprints.lua`:
- Around line 1006-1013: Update the weapon-merging flow around BlueprintMerged
so it continues scanning all weapons after a label match instead of returning
immediately. Perform fallback insertion only after the full collection has been
checked and no match was found, and add a regression test covering multiple
weapons sharing the same label.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7665dc0d-9635-4136-8170-b80f9d115521
📒 Files selected for processing (4)
changelog/snippets/fix.7191.mdengine/Core/Blueprints/WeaponBlueprint.lualua/MODS.LUAlua/system/Blueprints.lua
| local merged = false | ||
| if w.Label == label then | ||
| weaponTable[i] = BlueprintMerged(w, newBp) | ||
| merged = true | ||
| end | ||
| if merged then | ||
| return | ||
| end |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Continue merging after the first matching weapon.
The immediate return still limits merging to one weapon with the label, so duplicate-label blueprints remain only partially merged. Remove this early return and perform the fallback insertion only when no match was found; add a regression test covering multiple weapons with the same label.
Proposed fix
for i, w in weaponTable do
- local merged = false
if w.Label == label then
weaponTable[i] = BlueprintMerged(w, newBp)
- merged = true
- end
- if merged then
- return
+ merged = true
end
end🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@lua/system/Blueprints.lua` around lines 1006 - 1013, Update the
weapon-merging flow around BlueprintMerged so it continues scanning all weapons
after a label match instead of returning immediately. Perform fallback insertion
only after the full collection has been checked and no match was found, and add
a regression test covering multiple weapons sharing the same label.
Description of the proposed changes
When implementing weapon merging, I assumed weapon labels should be unique, but according to @The-Balthazar they're sometimes used for using the same weapon script class.
Testing done on the proposed changes
none
Checklist
Summary by CodeRabbit
Bug Fixes
MergeLabelnow applies to all matching weapon blueprints, rather than only one.Documentation