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

Fix Targeting Comp loading (.20!) #5461

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions megamek/src/megamek/common/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3790,6 +3790,10 @@ public void addEquipment(Mounted<?> mounted, int loc, boolean rearMounted)
if (mounted instanceof MiscMounted) {
miscList.add((MiscMounted) mounted);
}
if (!(mounted instanceof AmmoMounted) && !(mounted instanceof BombMounted) && !(mounted instanceof MiscMounted)
&& !(mounted instanceof WeaponMounted) && !(mounted instanceof InfantryWeaponMounted)) {
LogManager.getLogger().error("Trying to add plain Mounted class {} on {}!", mounted, this);
}
}

private void addOneshotAmmo(Mounted<?> mounted) throws LocationFullException {
Expand Down
4 changes: 2 additions & 2 deletions megamek/src/megamek/common/Mech.java
Original file line number Diff line number Diff line change
Expand Up @@ -2756,8 +2756,8 @@ public void addClanCase() {
* Adds equipment without adding slots for it.
* Specifically for targeting computers, which when loaded from a file don't have a correct size and get loaded slot by slot
*/
public Mounted addTargCompWithoutSlots(EquipmentType etype, int loc, boolean omniPod, boolean armored) throws LocationFullException {
Mounted mounted = new Mounted(this, etype);
public MiscMounted addTargCompWithoutSlots(MiscType etype, int loc, boolean omniPod, boolean armored) throws LocationFullException {
MiscMounted mounted = (MiscMounted) MiscMounted.createMounted(this, etype);
mounted.setOmniPodMounted(omniPod);
mounted.setArmored(armored);
super.addEquipment(mounted, loc, false);
Expand Down
8 changes: 4 additions & 4 deletions megamek/src/megamek/common/loaders/MtfFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ private void parseCrits(Mech mech, int loc) throws EntityLoadingException {
if (etype != null) {
if (etype.isSpreadable()) {
// do we already have one of these? Key on Type
Mounted m = hSharedEquip.get(etype);
Mounted<?> m = hSharedEquip.get(etype);
if (m != null) {
// use the existing one
mech.addCritical(loc, new CriticalSlot(m));
Expand All @@ -800,11 +800,11 @@ private void parseCrits(Mech mech, int loc) throws EntityLoadingException {
isTurreted);
m.setOmniPodMounted(isOmniPod);
hSharedEquip.put(etype, m);
} else if (etype instanceof MiscType && etype.hasFlag(MiscType.F_TARGCOMP)) {
} else if (etype instanceof MiscType && etype.hasFlag(MiscType.F_TARGCOMP)) {
// Targeting computers are special, they need to be loaded like spreadable equipment, but they aren't spreadable
Mounted m = hSharedEquip.get(etype);
Mounted<?> m = hSharedEquip.get(etype);
if (m == null) {
m = mech.addTargCompWithoutSlots(etype, loc, isOmniPod, isArmored);
m = mech.addTargCompWithoutSlots((MiscType) etype, loc, isOmniPod, isArmored);
hSharedEquip.put(etype, m);
}
mech.addCritical(loc, new CriticalSlot(m));
Expand Down
Loading