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

Remove old migration code #2289

Merged
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
22 changes: 4 additions & 18 deletions MekHQ/src/mekhq/campaign/Kill.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.io.PrintWriter;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Map;
import java.util.UUID;

import org.w3c.dom.Node;
Expand All @@ -46,9 +45,6 @@ public class Kill implements Serializable {
private String killed;
private String killer;

//reverse compatibility
private int oldPilotId = -1;

public Kill() {
}

Expand Down Expand Up @@ -92,8 +88,6 @@ public void setKilledByWhat(String s) {
}

public static Kill generateInstanceFromXML(Node wn, Version version) {
final String METHOD_NAME = "generateInstanceFromXML(Node,Version)";

Kill retVal = null;
try {
retVal = new Kill();
Expand All @@ -104,13 +98,9 @@ public static Kill generateInstanceFromXML(Node wn, Version version) {
if (wn2.getNodeName().equalsIgnoreCase("killed")) {
retVal.killed = wn2.getTextContent();
} else if (wn2.getNodeName().equalsIgnoreCase("pilotId")) {
if(version.getMajorVersion() == 0 && version.getMinorVersion() < 2 && version.getSnapshot() < 14) {
retVal.oldPilotId = Integer.parseInt(wn2.getTextContent());
} else {
retVal.pilotId = UUID.fromString(wn2.getTextContent());
}
retVal.pilotId = UUID.fromString(wn2.getTextContent());
} else if (wn2.getNodeName().equalsIgnoreCase("killer")) {
retVal.killer = (wn2.getTextContent());
retVal.killer = wn2.getTextContent();
} else if (wn2.getNodeName().equalsIgnoreCase("date")) {
retVal.date = MekHqXmlUtil.parseDate(wn2.getTextContent().trim());
}
Expand All @@ -119,24 +109,20 @@ public static Kill generateInstanceFromXML(Node wn, Version version) {
// Errrr, apparently either the class name was invalid...
// Or the listed name doesn't exist.
// Doh!
MekHQ.getLogger().error(Kill.class, METHOD_NAME, ex);
MekHQ.getLogger().error(ex);
}
return retVal;
}

public void writeToXml(PrintWriter pw1, int indent) {
MekHqXmlUtil.writeSimpleXMLOpenIndentedLine(pw1, indent++, "kill");
MekHqXmlUtil.writeSimpleXmlTag(pw1, indent, "pilotId", pilotId.toString());
MekHqXmlUtil.writeSimpleXmlTag(pw1, indent, "pilotId", pilotId);
MekHqXmlUtil.writeSimpleXmlTag(pw1, indent, "killed", killed);
MekHqXmlUtil.writeSimpleXmlTag(pw1, indent, "killer", killer);
MekHqXmlUtil.writeSimpleXmlTag(pw1, indent, "date", MekHqXmlUtil.saveFormattedDate(date));
MekHqXmlUtil.writeSimpleXMLCloseIndentedLine(pw1, --indent, "kill");
}

public void fixIdReferences(Map<Integer, UUID> pHash) {
pilotId = pHash.get(oldPilotId);
}

@Override
public Kill clone() {
return new Kill(getPilotId(), getWhatKilled(), getKilledByWhat(), getDate());
Expand Down
6 changes: 1 addition & 5 deletions MekHQ/src/mekhq/campaign/force/Force.java
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,7 @@ private static void processUnitNodes(Force retVal, Node wn, Version version) {
NamedNodeMap attrs = wn2.getAttributes();
Node classNameNode = attrs.getNamedItem("id");
String idString = classNameNode.getTextContent();
if (version.getMajorVersion() == 0 && version.getMinorVersion() < 2 && version.getSnapshot() < 14) {
retVal.oldUnits.add(Integer.parseInt(idString));
} else {
retVal.addUnit(UUID.fromString(idString));
}
retVal.addUnit(UUID.fromString(idString));
}
}

Expand Down
69 changes: 4 additions & 65 deletions MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

import javax.xml.parsers.DocumentBuilder;

import mekhq.campaign.io.Migration.PersonMigrator;
import mekhq.campaign.personnel.enums.FamilialRelationshipType;
import megamek.client.generator.RandomGenderGenerator;
import megamek.client.generator.RandomNameGenerator;
Expand All @@ -44,7 +43,6 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import megamek.common.BattleArmor;
import megamek.common.Entity;
import megamek.common.EntityMovementMode;
import megamek.common.EquipmentType;
Expand Down Expand Up @@ -105,7 +103,6 @@
import mekhq.campaign.personnel.SkillType;
import mekhq.campaign.personnel.SpecialAbility;
import mekhq.campaign.unit.Unit;
import mekhq.campaign.universe.Faction;
import mekhq.campaign.universe.Planet;
import mekhq.campaign.universe.Planet.PlanetaryEvent;
import mekhq.campaign.universe.PlanetarySystem;
Expand Down Expand Up @@ -335,13 +332,6 @@ else if (xn.equalsIgnoreCase("info")) {
// Fixup any ghost kills
cleanupGhostKills(retVal);

// adjust tech levels for version before 0.1.21
if (version.getMajorVersion() == 0 && version.getMinorVersion() < 2
&& version.getSnapshot() < 21) {
retVal.getCampaignOptions().setTechLevel(retVal.getCampaignOptions()
.getTechLevel() + 1);
}

long timestamp = System.currentTimeMillis();

// loop through forces to set force id
Expand Down Expand Up @@ -428,22 +418,6 @@ else if (xn.equalsIgnoreCase("info")) {
s.addUnit(unit.getId());
}
}

//get rid of BA parts before 0.3.4
if (unit.getEntity() instanceof BattleArmor
&& version.getMajorVersion() == 0
&& (version.getMinorVersion() <= 2 ||
(version.getMinorVersion() <= 3 && version.getSnapshot() < 16))) {
for (Part p : unit.getParts()) {
retVal.getWarehouse().removePart(p);
}
unit.resetParts();
if (version.getSnapshot() < 4) {
for (int loc = 0; loc < unit.getEntity().locations(); loc++) {
unit.getEntity().setInternal(0, loc);
}
}
}
});

MekHQ.getLogger().info(String.format("[Campaign Load] Pilot references fixed in %dms",
Expand Down Expand Up @@ -620,7 +594,6 @@ private static void processInfoNode(Campaign retVal, Node wni, Version version)

String rankNames = null;
int officerCut = 0;
int rankSystem = -1;

// Okay, lets iterate through the children, eh?
for (int x = 0; x < nl.getLength(); x++) {
Expand Down Expand Up @@ -707,12 +680,7 @@ private static void processInfoNode(Campaign retVal, Node wni, Version version)
}
}
} else if (xn.equalsIgnoreCase("faction")) {
if (version.getMajorVersion() == 0
&& version.getMinorVersion() < 2 && version.getSnapshot() < 14) {
retVal.setFactionCode(Faction.getFactionCode(Integer.parseInt(wn.getTextContent())));
} else {
retVal.setFactionCode(wn.getTextContent());
}
retVal.setFactionCode(wn.getTextContent());
retVal.updateTechFactionCode();
} else if (xn.equalsIgnoreCase("retainerEmployerCode")) {
retVal.setRetainerEmployerCode(wn.getTextContent());
Expand All @@ -721,33 +689,14 @@ private static void processInfoNode(Campaign retVal, Node wni, Version version)
} else if (xn.equalsIgnoreCase("rankNames")) {
rankNames = wn.getTextContent().trim();
} else if (xn.equalsIgnoreCase("ranks") || xn.equalsIgnoreCase("rankSystem")) {
if (version.isLowerThan("0.3.4-r1645")) {
rankSystem = Integer.parseInt(wn.getTextContent().trim());
} else {
Ranks r = Ranks.generateInstanceFromXML(wn, version);
if (r != null) {
retVal.setRanks(r);
}
Ranks r = Ranks.generateInstanceFromXML(wn, version);
if (r != null) {
retVal.setRanks(r);
}
} else if (xn.equalsIgnoreCase("gmMode")) {
retVal.setGMMode(Boolean.parseBoolean(wn.getTextContent().trim()));
} else if (xn.equalsIgnoreCase("showOverview")) {
retVal.setOverviewLoadingValue(Boolean.parseBoolean(wn.getTextContent().trim()));
/* CAW: Not used anymore as the Campaign tracks this internally via TreeMap's.
} else if (xn.equalsIgnoreCase("lastPartId")) {
retVal.setLastPartId(Integer.parseInt(wn.getTextContent()
.trim()));
} else if (xn.equalsIgnoreCase("lastForceId")) {
retVal.setLastForceId(Integer.parseInt(wn.getTextContent()
.trim()));
} else if (xn.equalsIgnoreCase("lastTeamId")) {
retVal.setLastTeamId(Integer.parseInt(wn.getTextContent()
.trim()));
} else if (xn.equalsIgnoreCase("lastMissionId")) {
retVal.setLastMissionId(Integer.parseInt(wn.getTextContent()
.trim()));
} else if (xn.equalsIgnoreCase("lastScenarioId")) {
retVal.setLastScenarioId(Integer.parseInt(wn.getTextContent().trim()));*/
} else if (xn.equalsIgnoreCase("name")) {
String val = wn.getTextContent().trim();

Expand Down Expand Up @@ -778,10 +727,6 @@ private static void processInfoNode(Campaign retVal, Node wni, Version version)
//backwards compatibility
retVal.getRanks().setRanksFromList(rankNames, officerCut);
}
if (rankSystem != -1) {
retVal.setRanks(Ranks.getRanksFromSystem(rankSystem));
retVal.getRanks().setOldRankSystem(rankSystem);
}

// TODO: this could probably be better
retVal.setCurrentReportHTML(Utilities.combineString(retVal.getCurrentReport(), Campaign.REPORT_LINEBREAK));
Expand Down Expand Up @@ -1473,12 +1418,6 @@ private static void postProcessParts(Campaign retVal, Version version) {
((MekLocation) prt).setLifeSupport(false);
}

if ((version.getMinorVersion() < 3) && !prt.needsFixing()
&& !prt.isSalvaging()) {
// repaired parts were not getting experience properly reset
prt.setSkillMin(SkillType.EXP_GREEN);
}

if (prt instanceof MissingPart) {
// Missing Parts should only exist on units, but there have
// been cases where they continue to float around outside of units
Expand Down
80 changes: 1 addition & 79 deletions MekHQ/src/mekhq/campaign/personnel/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,6 @@ private static String getMissionParticipatedString() {
OTHER_RANSOM_VALUES.put(SkillType.EXP_ELITE, Money.of(50000));
}

//region Reverse Compatibility
// Unknown version
private int oldId;
//endregion Reverse Compatibility
//endregion Variable Declarations

//region Constructors
Expand Down Expand Up @@ -1960,11 +1956,7 @@ public static Person generateInstanceFromXML(Node wn, Campaign c, Version versio
} else if (wn2.getNodeName().equalsIgnoreCase("idleMonths")) {
retVal.idleMonths = Integer.parseInt(wn2.getTextContent());
} else if (wn2.getNodeName().equalsIgnoreCase("id")) {
if (version.getMajorVersion() == 0 && version.getMinorVersion() < 2 && version.getSnapshot() < 14) {
retVal.oldId = Integer.parseInt(wn2.getTextContent());
} else {
retVal.id = UUID.fromString(wn2.getTextContent());
}
retVal.id = UUID.fromString(wn2.getTextContent());
} else if (wn2.getNodeName().equalsIgnoreCase("ancestors")) { // legacy - 0.47.6 removal
CampaignXmlParser.addToAncestryMigrationMap(UUID.fromString(wn2.getTextContent().trim()), retVal);
} else if (wn2.getNodeName().equalsIgnoreCase("spouse")) { // legacy - 0.47.6 removal
Expand Down Expand Up @@ -2183,72 +2175,6 @@ public static Person generateInstanceFromXML(Node wn, Campaign c, Version versio
retVal.setExpectedDueDate(retVal.getDueDate());
}

//versions before 0.3.4 did not have proper clan phenotypes
if (version.isLowerThan("0.3.4") && c.getFaction().isClan()) {
//assume personnel are clan and trueborn if the right role
retVal.setClanner(true);
switch (retVal.getPrimaryRole()) {
case Person.T_MECHWARRIOR:
retVal.setPhenotype(Phenotype.MECHWARRIOR);
break;
case Person.T_AERO_PILOT:
case Person.T_CONV_PILOT:
retVal.setPhenotype(Phenotype.AEROSPACE);
break;
case Person.T_BA:
retVal.setPhenotype(Phenotype.ELEMENTAL);
break;
case Person.T_VEE_GUNNER:
case Person.T_GVEE_DRIVER:
case Person.T_NVEE_DRIVER:
case Person.T_VTOL_PILOT:
retVal.setPhenotype(Phenotype.VEHICLE);
break;
case Person.T_PROTO_PILOT:
retVal.setPhenotype(Phenotype.PROTOMECH);
break;
default:
retVal.setPhenotype(Phenotype.NONE);
break;
}
}

if (version.getMajorVersion() == 0 && version.getMinorVersion() < 2 && version.getSnapshot() < 13) {
if (retVal.primaryRole > T_INFANTRY) {
retVal.primaryRole += 4;

}
if (retVal.secondaryRole > T_INFANTRY) {
retVal.secondaryRole += 4;
}
}

if (version.getMajorVersion() == 0 && version.getMinorVersion() == 2) {
//adjust for conventional fighter pilots
if (retVal.primaryRole >= T_CONV_PILOT) {
retVal.primaryRole += 1;
}
if (retVal.secondaryRole >= T_CONV_PILOT) {
retVal.secondaryRole += 1;
}
}

if (version.getMajorVersion() == 0 && version.getMinorVersion() == 3 && version.getSnapshot() < 1) {
//adjust for conventional fighter pilots
if (retVal.primaryRole == T_CONV_PILOT && retVal.hasSkill(SkillType.S_PILOT_SPACE) && !retVal.hasSkill(SkillType.S_PILOT_JET)) {
retVal.primaryRole += 1;
}
if (retVal.secondaryRole == T_CONV_PILOT && retVal.hasSkill(SkillType.S_PILOT_SPACE) && !retVal.hasSkill(SkillType.S_PILOT_JET)) {
retVal.secondaryRole += 1;
}
if (retVal.primaryRole == T_AERO_PILOT && !retVal.hasSkill(SkillType.S_PILOT_SPACE) && retVal.hasSkill(SkillType.S_PILOT_JET)) {
retVal.primaryRole += 8;
}
if (retVal.secondaryRole == T_AERO_PILOT && !retVal.hasSkill(SkillType.S_PILOT_SPACE) && retVal.hasSkill(SkillType.S_PILOT_JET)) {
retVal.secondaryRole += 8;
}
}

if ((null != advantages) && (advantages.trim().length() > 0)) {
StringTokenizer st = new StringTokenizer(advantages, "::");
while (st.hasMoreTokens()) {
Expand Down Expand Up @@ -3578,10 +3504,6 @@ public void resetSkillTypes() {
}
}

public int getOldId() {
return oldId;
}

public int getNTasks() {
return nTasks;
}
Expand Down
12 changes: 1 addition & 11 deletions MekHQ/src/mekhq/campaign/personnel/SkillType.java
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,6 @@ public void writeToXml(PrintWriter pw1, int indent) {
}

public static void generateInstanceFromXML(Node wn, Version version) {
final String METHOD_NAME = "generateInstanceFromXML(Node,Version)";

try {
SkillType retVal = new SkillType();
NodeList nl = wn.getChildNodes();
Expand Down Expand Up @@ -425,20 +423,12 @@ public static void generateInstanceFromXML(Node wn, Version version) {
}
}

if (version.getMinorVersion() < 3) {
//need to change negotiation and scrounge to be countUp=false with
//TNs of 10
if (retVal.name.equals(SkillType.S_NEG) || retVal.name.equals(SkillType.S_SCROUNGE)) {
retVal.countUp = false;
retVal.target = 10;
}
}
lookupHash.put(retVal.name, retVal);
} catch (Exception ex) {
// Errrr, apparently either the class name was invalid...
// Or the listed name doesn't exist.
// Doh!
MekHQ.getLogger().error(SkillType.class, METHOD_NAME, ex);
MekHQ.getLogger().error(ex);
}
}

Expand Down
12 changes: 1 addition & 11 deletions MekHQ/src/mekhq/campaign/personnel/SpecialAbility.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,6 @@ public void writeToXml(PrintWriter pw1, int indent) {

@SuppressWarnings("unchecked")
public static void generateInstanceFromXML(Node wn, PilotOptions options, Version v) {
final String METHOD_NAME = "generateInstanceFromXML(Node,PilotOptions,Version)"; //$NON-NLS-1$

try {
SpecialAbility retVal = new SpecialAbility();
NodeList nl = wn.getChildNodes();
Expand Down Expand Up @@ -381,14 +379,6 @@ else if (wn2.getNodeName().equalsIgnoreCase("lookupName")) {
retVal.desc = option.getDescription();
}
}
if (v != null) {
if (defaultSpecialAbilities != null && v.isLowerThan("0.3.6-r1965")) {
if (defaultSpecialAbilities.get(retVal.lookupName) != null
&& defaultSpecialAbilities.get(retVal.lookupName).getPrereqSkills() != null) {
retVal.prereqSkills = (Vector<SkillPrereq>) defaultSpecialAbilities.get(retVal.lookupName).getPrereqSkills().clone();
}
}
}

if (wn.getNodeName().equalsIgnoreCase("edgetrigger")) {
edgeTriggers.put(retVal.lookupName, retVal);
Expand All @@ -401,7 +391,7 @@ else if (wn2.getNodeName().equalsIgnoreCase("lookupName")) {
// Errrr, apparently either the class name was invalid...
// Or the listed name doesn't exist.
// Doh!
MekHQ.getLogger().error(SpecialAbility.class, METHOD_NAME, ex);
MekHQ.getLogger().error(ex);
}
}

Expand Down
Loading