Fix bug where dummy weapon bps are assigned to non-dummy weapons#6882
Fix bug where dummy weapon bps are assigned to non-dummy weapons#6882lL1l1 wants to merge 9 commits intoFAForever:developfrom
Conversation
Credit to Laserstorm on the faf discord for the initial code which I fixed and cleaned up for testing here. Error message: `ERROR: No RackBones table specified, aborting weapon setup. Weapon: TeleportWeapon on Unit: uel0001`
The UEF ACU no longer errors upon spawning
This reverts commit 6d95720.
also a small refactor This avoids the warning being given later on unnecessarily
Garanas
left a comment
There was a problem hiding this comment.
Would it not be better to throw a warning and let the author fix it?
I'm not sure if re-ordering the weapons is the best thing to do here. It would make a unit 'work' for FAF, but not for Steam or LOUD for example.
|
It already gives a warning. I agree that the author should learn and fix their mistakes, improving compatibility with other environments, if they do a custom implementation of the weapons table (as simple as writing it in a blueprint). But the |
|
It's unlikely, but auto-fixing it could also break mods that hacked around the bug or fix old mods that had the bug. Would just have to see if there are any new warnings when I play. |
|
Maybe @The-Balthazar has an idea how often that can happen in practice, based on his own sim mods and unit packs. |
Issue
Discovered when I was helping a new modder on Discord.
If a dummy weapon is before a non-dummy weapon in the unit blueprint's
Weapontable, then the engine assigns the dummy weapon's bp to the non-dummy weapon. This is because the engine counts n real weapons, and simply assigns indices 1-n to weapons 1-n. If a dummy weapon is in 1-n then it gets assigned to a real weapon which breaks that weapon.This is an easy issue to run into if using the
ModWeaponfield in blueprints, which by default places weapons at the end of the weapons table.It can also happen if someone doesn't know about this issue and places a dummy weapon in the middle by chance.
Description of the proposed changes
In post-mod weapon processing, detect if non-dummy weapons are placed after dummy weapons, and re-order the dummy weapons to the end of the array.
Also check for dummy weapons in the weapon merge function.
Testing done on the proposed changes
The error from the test commit disappears after applying the changes.
Checklist