Skip to content

Commit

Permalink
Restored Award Unmarshalling Method Call
Browse files Browse the repository at this point in the history
Restored functionality to process awards from XML in personnel logs. Removed ancient, <0.47.15, compatibility handler from `generateNewFromXML` method.
  • Loading branch information
IllianiCBT committed Sep 26, 2024
1 parent 6e2a350 commit 02b5e79
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
31 changes: 13 additions & 18 deletions MekHQ/src/mekhq/campaign/personnel/AwardsFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,6 @@
*/
package mekhq.campaign.personnel;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Unmarshaller;
Expand All @@ -41,6 +28,18 @@
import mekhq.MHQConstants;
import mekhq.campaign.AwardSet;
import mekhq.utilities.MHQXMLUtility;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* This class is responsible to control the awards. It loads one instance of
Expand Down Expand Up @@ -117,7 +116,7 @@ public List<Award> getAllAwardsForSet(String setName) {
* to be migrated
* @return an award
*/
public @Nullable Award generateNewFromXML(final Node node, final boolean defaultSetMigration) {
public @Nullable Award generateNewFromXML(final Node node) {
String name = null;
String set = null;
List<LocalDate> dates = new ArrayList<>();
Expand All @@ -140,10 +139,6 @@ public List<Award> getAllAwardsForSet(String setName) {
logger.error("", ex);
}

if (defaultSetMigration && "Default Set".equalsIgnoreCase(set)) {
name = (name == null) ? "" : name;
}

final Award award = generateNew(set, name);
if (award != null) {
award.setDates(dates);
Expand Down
3 changes: 3 additions & 0 deletions MekHQ/src/mekhq/campaign/personnel/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -2494,6 +2494,9 @@ public static Person generateInstanceFromXML(Node wn, Campaign c, Version versio
logger.error("Unknown node type not loaded in personnel log nodes: {}", wn3.getNodeName());
continue;
}

retVal.getAwardController().addAwardFromXml(AwardsFactory.getInstance()
.generateNewFromXML(wn3));
}
} else if (wn2.getNodeName().equalsIgnoreCase("injuries")) {
NodeList nl2 = wn2.getChildNodes();
Expand Down

0 comments on commit 02b5e79

Please sign in to comment.