diff --git a/megamek/src/megamek/common/Entity.java b/megamek/src/megamek/common/Entity.java index b4a63758ee4..0e153643465 100644 --- a/megamek/src/megamek/common/Entity.java +++ b/megamek/src/megamek/common/Entity.java @@ -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 { diff --git a/megamek/src/megamek/common/Mech.java b/megamek/src/megamek/common/Mech.java index 3021d6b2007..f75e1f58680 100644 --- a/megamek/src/megamek/common/Mech.java +++ b/megamek/src/megamek/common/Mech.java @@ -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); diff --git a/megamek/src/megamek/common/loaders/MtfFile.java b/megamek/src/megamek/common/loaders/MtfFile.java index 58997a523d8..b27137787dc 100644 --- a/megamek/src/megamek/common/loaders/MtfFile.java +++ b/megamek/src/megamek/common/loaders/MtfFile.java @@ -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)); @@ -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));