Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change made it so Coolant Pods not shown in Equipment View unless hide option is disabled #1353

Closed
redbatz opened this issue Dec 28, 2023 · 0 comments · Fixed by #1354
Closed

Comments

@redbatz
Copy link
Contributor

redbatz commented Dec 28, 2023

MegaMekLab 0.49.15 (also verified on latest master)
Windows 10, Java Version: 11

Since Coolant Pods are implemented as an ammo type within MegaMek, there in the past was some issues with them not appearing in the Equipment Database View. Some time back I supplied a then merged PR to show Coolant Pods as part of the Other category (PR #1027 / issue #1026), which was a more intuitive way to solve this issue.

Now it seems this fix has broken due to other logic around equipment database views changing.
The reason seems to be that with commit a22a802 a new check for AmmoType equipment's useability has been added to the global hidden equipment check, the last line in this method:

    private boolean hiddenEquipment(EquipmentType equipment) {
        return (hideProtoButton.isSelected() && PROTOTYPE.passesFilter(equipment, getEntity()))
                || (hideOneShotButton.isSelected() && ONE_SHOT.passesFilter(equipment, getEntity()))
                || (hideTorpedoButton.isSelected() && TORPEDO.passesFilter(equipment, getEntity()))
                || (hideAPButton.isSelected() && AP.passesFilter(equipment, getEntity()))
                || (hideUnusableAmmoButton.isSelected() && UNUSABLE_AMMO.passesFilter(equipment, getEntity()));
    }

This filter check calls !UnitUtil.canUseAmmo(en, (AmmoType) eq, false)),
which in turn checks against all weapons of the unit for any that can fire the AmmoType, before allowing it to be displayed in the view.

However, this logic does not consider the case that Coolant Pods are implemented as an AmmoType even though no weapon can fire them, and as a result are not able to be shown under the Other (or any tab) without having to disable the Ammo w/o Weapon Hide filter - which is very counterintuitive.

A simple solution would be to just add an exception to this logic, so Coolant Pods are not being checked for being usable by a unit's weapons, e.g. at line 119 add something like
&& ((AmmoType)eq).getAmmoType() != AmmoType.T_COOLANT_POD.
This however makes Coolant Pods always appear in the Ammo view, since it technically is an AmmoType and that view now doesn't filter it out because it is exempt from the hidden equipment check.
The fix here could be to add an exclusion check in the Ammo to not show Coolant Pods in similar fashion to the check above.

But I don't know if you would prefer a more robust solution as this is the second time (that I am aware of) the same feature broke due to similar issue with not considering how Coolant Pods are implemented.

However, if a PR for the simple fix above is enough, I will happily submit one.

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 a pull request may close this issue.

1 participant