m.setLocation(Mech.mostRestrictiveLoc(loc, m.getLocation()));
int help=m.getLocation(); m.setLocation(Mech.mostRestrictiveLoc( loc, help)); if (loc!=help) { m.setSecondLocation(Mech.leastRestrictiveLoc( loc, help)); }
    private void parseCrits(Mech mech, int loc) throws EntityLoadingException {        // check for removed arm actuators        if (!(mech instanceof QuadMech)) {            if (loc == Mech.LOC_LARM || loc == Mech.LOC_RARM) {                if (!critData[loc][3][0].equals("Hand Actuator")) {                    mech.setCritical(loc, 3, null);                }                if (!critData[loc][2][0].equals("Lower Arm Actuator")) {                    mech.setCritical(loc, 2, null);                }            }        }        // go thru file, add weapons        for (int i = 0; i < mech.getNumberOfCriticals(loc); i++) {            // if the slot's full already, skip it.            if (mech.getCritical(loc, i) != null) {                continue;            }            // parse out and add the critical            String critName = critData[loc][i][0];            boolean rearMounted = true;            if (critData[loc][i][1] == null || !isRearMounted[Integer.parseInt(critData[loc][i][1])]) {                rearMounted = false;            }            boolean split = true;            if (critData[loc][i][1] == null || !isSplit[Integer.parseInt(critData[loc][i][1])]) {                split = false;            }            if (critName.equalsIgnoreCase("Armored Cowl")) {                mech.setCowl(5);            }            if (critName.indexOf("Engine") != -1) {                mech.setCritical(loc,i, new CriticalSlot(CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_ENGINE));                continue;            }            if (critName.indexOf("Gyro") != -1) {                mech.setCritical(loc,i, new CriticalSlot(CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_GYRO));                continue;            }            if (critName.indexOf("Life Support") != -1) {                mech.setCritical(loc,i, new CriticalSlot(CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_LIFE_SUPPORT));                continue;            }            if (critName.indexOf("Sensors") != -1) {                mech.setCritical(loc,i, new CriticalSlot(CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_SENSORS));                continue;            }            if (critName.indexOf("Cockpit") != -1) {                mech.setCritical(loc,i, new CriticalSlot(CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_COCKPIT));                continue;            }            if (critName.endsWith("[LRM]") || critName.endsWith("[SRM]")) {                // This is a lame kludge for The Drawing Board, which                //  identifies which type of missle weapon an                //  Artemis IV system goes with.                critName = critName.substring(0,14);            }            if (critName.endsWith("- Artemis IV")) {                // Ugh, another lame kludge to allow for loading of                //  The Drawing Board's specially marked Artemis IV                //  missle ammo.  The only real game difference is                //  c-bill cost, which we don't care about anyway.                critName = critName.substring(0,critName.indexOf(" - Artemis IV"));            }            if (critName.endsWith("- Narc")) {                // Yet another lame kludge to allow for loading of                //  The Drawing Board's specially marked Narc                //  missle ammo.                critName = critName.substring(0,critName.indexOf(" - Narc"));            }            if (critName.equals("(C) Endosteel")) {                // MegaMek determines whether Endo Steel is IS or Clan                //  type by techbase of mech.                critName = critName.substring(4);            }            if (critName.equals("(C) Ferro-Fibrous Armor")) {                // MegaMek determines whether FF Armor is IS or Clan                //  type by techbase of mech.                critName = critName.substring(4);            }            try {                String hashPrefix;                if (critName.startsWith("(C)")) {                    //equipment specifically marked as clan                    hashPrefix = "Clan ";                    critName = critName.substring(4);                } else if (critName.startsWith("(IS)")) {                    //equipment specifically marked as inner sphere                    hashPrefix = "IS ";                    critName = critName.substring(5);                } else if (mech.isClan()) {                    //assume equipment is clan because mech is clan                    hashPrefix = "Clan ";                } else {                    //assume equipment is inner sphere                    hashPrefix = "IS ";                }                EquipmentType etype = EquipmentType.get(hashPrefix + critName);                if (etype == null) {                    //try without prefix                    etype = EquipmentType.get(critName);                }                if (etype != null) {                    if (etype.isSpreadable()) {                        // do we already have one of these?  Key on Type                        Mounted m = (Mounted)hSharedEquip.get(etype);                        if (m != null) {                            // use the existing one                            mech.addCritical(loc, new CriticalSlot(CriticalSlot.TYPE_EQUIPMENT,                                                                   mech.getEquipmentNum(m), etype.isHittable()));                            continue;                        }                        else {                            m = mech.addEquipment(etype, loc, rearMounted);                            hSharedEquip.put(etype, m);                        }                    }                    else if (etype instanceof WeaponType &&                            etype.hasFlag(WeaponType.F_SPLITABLE)) {                        // do we already have this one in this or an outer location?                        Mounted m = null;                        boolean bFound = false;                        for (int x = 0, n = vSplitWeapons.size(); x < n; x++) {                            m = (Mounted)vSplitWeapons.elementAt(x);                            int nLoc = m.getLocation();                            if ((nLoc == loc || loc == Mech.getInnerLocation(nLoc))                                && m.getType() == etype) {                                bFound = true;                                break;                            }                        }                        if (bFound) {                            m.setFoundCrits(m.getFoundCrits() + 1);                            if (m.getFoundCrits() >= etype.getCriticals(mech)) {                                vSplitWeapons.removeElement(m);                            }                            // if we're in a new location, set the                            // weapon as split                            if (loc != m.getLocation()) {                                m.setSplit(true);                            }                            // give the most restrictive location for arcs                            m.setLocation(Mech.mostRestrictiveLoc(loc, m.getLocation()));                        }                        else {                            // make a new one                            m = new Mounted(mech, etype);                            m.setFoundCrits(1);                            vSplitWeapons.addElement(m);                        }                        mech.addEquipment(m, loc, rearMounted);                    }                    else {                        mech.addEquipment(etype, loc, rearMounted);                    }                } else {                    if (!critName.equals("Empty")) {                        //Can't load this piece of equipment!                        // Add it to the list so we can show the user.                        mech.addFailedEquipment(critName);                        // Make the failed equipment an empty slot                        critData[loc][i][0] = "Empty";                        critData[loc][i][1] = null;                        // Compact criticals again                        compactCriticals(mech, loc);                        // Re-parse the same slot, since the compacting                        //  could have moved new equipment to this slot                        i--;                    }                }            } catch (LocationFullException ex) {                throw new EntityLoadingException(ex.getMessage());            }        }    }