Skip to content

Commit

Permalink
Cleaned up lookups for refits
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleet01 committed Mar 24, 2024
1 parent e389e13 commit f21251e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
9 changes: 2 additions & 7 deletions MekHQ/src/mekhq/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -1269,19 +1269,14 @@ public static MechSummary retrieveOriginalUnit(Entity newE) throws EntityLoading
cacheInstance.loadMechData();

// I need to change the new entity to the one from the mtf file now, so that equipment numbers will match
MechSummary summary = cacheInstance.getMech(newE.getChassis() + " " + newE.getModel());
MechSummary summary = cacheInstance.getMech(newE.getFullChassis() + " " + newE.getModel());

// Need to deal with old naming conventions
if (null == summary) {
// Attempt to deal with new naming convention directly
summary = cacheInstance.getMech(
newE.getChassis() + " (" + newE.getClanChassisName() + ") " + newE.getModel());
}

// Try the first fuzzy match
if (null == summary) {
summary = cacheInstance.fuzzyGetMech(newE.getChassis() + " " + newE.getModel()).get(0);
}

// If we got this far with no summary loaded, give up
if (null == summary) {
throw new EntityLoadingException(String.format("Could not load %s %s from the mech cache",
Expand Down
3 changes: 2 additions & 1 deletion MekHQ/src/mekhq/gui/dialog/ChooseRefitDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,9 @@ private void populateRefits() {
List<Refit> refits = new ArrayList<>();
Entity e = unit.getEntity();
for (String model : Utilities.getAllVariants(e, campaign)) {
MechSummary summary = MechSummaryCache.getInstance().getMech(e.getChassis() + " " + model);
MechSummary summary = MechSummaryCache.getInstance().getMech(e.getFullChassis() + " " + model);
if (null == summary) {
// Attempt to deal with new naming scheme directly
summary = MechSummaryCache.getInstance().getMech(e.getChassis() + " (" + e.getClanChassisName() + ") " + model);
if (null == summary) {
continue;
Expand Down

0 comments on commit f21251e

Please sign in to comment.