Skip to content

Commit

Permalink
Merge pull request #2372 from Windchild292/dev_Windchild_InfantryMoti…
Browse files Browse the repository at this point in the history
…veType

Infantry Motive Type File I/O Fixes
  • Loading branch information
Windchild292 authored Jan 14, 2021
2 parents c9eab51 + 3589bb4 commit b47adac
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 37 deletions.
17 changes: 5 additions & 12 deletions MekHQ/src/mekhq/campaign/parts/InfantryMotiveType.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,25 +178,18 @@ public boolean isSamePartType(Part part) {

@Override
public void writeToXml(PrintWriter pw1, int indent) {
writeToXmlBegin(pw1, indent);
pw1.println(MekHqXmlUtil.indentStr(indent+1)
+"<moveMode>"
+mode
+"</moveMode>");
writeToXmlEnd(pw1, indent);
writeToXmlBegin(pw1, indent++);
MekHqXmlUtil.writeSimpleXmlTag(pw1, indent, "moveMode", mode.name());
writeToXmlEnd(pw1, --indent);
}

@Override
protected void loadFieldsFromXmlNode(Node wn) {
NodeList nl = wn.getChildNodes();

for (int x=0; x<nl.getLength(); x++) {
for (int x = 0; x < nl.getLength(); x++) {
Node wn2 = nl.item(x);
if (wn2.getNodeName().equalsIgnoreCase("mode")) {
mode = EntityMovementMode.getMode(wn2.getTextContent());
assignName();
}
else if (wn2.getNodeName().equalsIgnoreCase("moveMode")) {
if (wn2.getNodeName().equalsIgnoreCase("moveMode")) {
mode = EntityMovementMode.getMode(wn2.getTextContent());
assignName();
}
Expand Down
47 changes: 22 additions & 25 deletions MekHQ/src/mekhq/campaign/parts/MissingInfantryMotiveType.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*
* MissingInfantryMotiveType.java
*
*
* Copyright (c) 2009 Jay Lawson <jaylawson39 at yahoo.com>. All rights reserved.
*
*
* This file is part of MekHQ.
*
*
* MekHQ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* MekHQ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with MekHQ. If not, see <http://www.gnu.org/licenses/>.
*/
Expand All @@ -40,33 +40,33 @@
public class MissingInfantryMotiveType extends MissingPart {

/**
*
*
*/
private static final long serialVersionUID = 2454012279066776500L;
private EntityMovementMode mode;

public MissingInfantryMotiveType() {
this(0, null, null);
}

public MissingInfantryMotiveType(int tonnage, Campaign c, EntityMovementMode m) {
super(tonnage, c);
this.mode = m;
if(null != mode) {
assignName();
}
}
@Override

@Override
public int getBaseTime() {
return 0;
}

@Override
public int getDifficulty() {
return 0;
}

private void assignName() {
switch (mode) {
case INF_UMU:
Expand All @@ -91,10 +91,10 @@ private void assignName() {
name = "Unknown Motive Type";
}
}

@Override
public void updateConditionFromPart() {
//Do nothing
//Do nothing
}

@Override
Expand All @@ -119,22 +119,19 @@ public double getTonnage() {

@Override
public void writeToXml(PrintWriter pw1, int indent) {
writeToXmlBegin(pw1, indent);
pw1.println(MekHqXmlUtil.indentStr(indent+1)
+"<moveMode>"
+mode
+"</moveMode>");
writeToXmlEnd(pw1, indent);
writeToXmlBegin(pw1, indent++);
MekHqXmlUtil.writeSimpleXmlTag(pw1, indent, "moveMode", mode.name());
writeToXmlEnd(pw1, --indent);
}

@Override
protected void loadFieldsFromXmlNode(Node wn) {
NodeList nl = wn.getChildNodes();
for (int x=0; x<nl.getLength(); x++) {
Node wn2 = nl.item(x);

for (int x = 0; x < nl.getLength(); x++) {
Node wn2 = nl.item(x);
if (wn2.getNodeName().equalsIgnoreCase("moveMode")) {
mode = EntityMovementMode.getMode(wn2.getTextContent());
mode = EntityMovementMode.getMode(wn2.getTextContent().trim());
assignName();
}
}
Expand All @@ -155,5 +152,5 @@ public int getLocation() {
public TechAdvancement getTechAdvancement() {
return Infantry.getMotiveTechAdvancement(mode);
}
}

}

0 comments on commit b47adac

Please sign in to comment.