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

Suite Version Tracking: MekHQ Changes #2880

Merged
merged 2 commits into from
Oct 1, 2021
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
1 change: 0 additions & 1 deletion MekHQ/resources/mekhq/resources/MekHQ.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

Application.name = MekHQ
Application.title = MekHQ
Application.version = 0.49.4-SNAPSHOT
Application.vendor= MekHQ Project
Application.homepage=https://github.com/MegaMek
Application.description = A program for managing BattleTech campaigns played via MegaMek or tabletop
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/MekHQ.java
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ private void showInfo() {

StringBuilder msg = new StringBuilder();
msg.append("\t").append(resourceMap.getString("Application.name")).append(" ")
.append(resourceMap.getString("Application.version"));
.append(MekHqConstants.VERSION);
if (TIMESTAMP > 0) {
msg.append("\n\tCompiled on ").append(Instant.ofEpochMilli(TIMESTAMP));
}
Expand Down
5 changes: 3 additions & 2 deletions MekHQ/src/mekhq/MekHqConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
*/
package mekhq;

public final class MekHqConstants {
import megamek.SuiteConstants;

public final class MekHqConstants extends SuiteConstants {
// This is used in creating the name of save files, e.g. the MekHQ campaign file
public static final String FILENAME_DATE_FORMAT = "yyyyMMdd";
public static final int MAXIMUM_D6_VALUE = 6;
public static final int ASTECH_TEAM_SIZE = 6;

//region MekHQ Options
Expand Down
218 changes: 0 additions & 218 deletions MekHQ/src/mekhq/Version.java

This file was deleted.

3 changes: 1 addition & 2 deletions MekHQ/src/mekhq/campaign/Campaign.java
Original file line number Diff line number Diff line change
Expand Up @@ -4032,9 +4032,8 @@ public void writeToXml(PrintWriter pw1) {
// File header
pw1.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

ResourceBundle resourceMap = ResourceBundle.getBundle("mekhq.resources.MekHQ");
// Start the XML root.
pw1.println("<campaign version=\"" + resourceMap.getString("Application.version") + "\">");
pw1.println("<campaign version=\"" + MekHqConstants.VERSION + "\">");

//region Basic Campaign Info
MekHqXmlUtil.writeSimpleXMLOpenIndentedLine(pw1, indent, "info");
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/campaign/CampaignOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.Arrays;
import java.util.List;

import mekhq.Version;
import megamek.Version;
import mekhq.campaign.mission.enums.AtBLanceRole;
import mekhq.campaign.enums.PlanetaryAcquisitionFactionLimit;
import mekhq.campaign.market.enums.ContractMarketMethod;
Expand Down
12 changes: 4 additions & 8 deletions MekHQ/src/mekhq/campaign/GamePreset.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,15 @@

import javax.xml.parsers.DocumentBuilder;

import mekhq.Version;
import megamek.Version;
import mekhq.*;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import megamek.common.options.PilotOptions;
import mekhq.MekHQ;
import mekhq.MekHqXmlSerializable;
import mekhq.MekHqXmlUtil;
import mekhq.Utilities;
import mekhq.campaign.personnel.SkillType;
import mekhq.campaign.personnel.SpecialAbility;

Expand Down Expand Up @@ -133,8 +130,7 @@ public boolean isValid() {
@Override
public void writeToXml(PrintWriter pw, int indent) {
pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
pw.println("<gamePreset version=\"" + ResourceBundle.getBundle("mekhq.resources.MekHQ")
.getString("Application.version") + "\">");
pw.println("<gamePreset version=\"" + MekHqConstants.VERSION + "\">");
MekHqXmlUtil.writeSimpleXmlTag(pw, indent, "title", title);
MekHqXmlUtil.writeSimpleXmlTag(pw, indent, "description", description);
if (getOptions() != null) {
Expand Down Expand Up @@ -190,7 +186,7 @@ public static GamePreset createGamePresetFromXMLFileInputStream(FileInputStream

// Legacy Parsing method for any presets created before 0.47.11, as they did not include a version
final String versionString = optionsEle.getAttribute("version");
Version version = new Version(versionString.isBlank() ? "0.47.11" : versionString);
final Version version = new Version(versionString.isBlank() ? "0.47.11" : versionString);

// Okay, lets iterate through the children, eh?
for (int x = 0; x < nl.getLength(); x++) {
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/campaign/Kill.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import mekhq.MekHQ;
import mekhq.MekHqXmlUtil;
import mekhq.Version;
import megamek.Version;

/**
* A kill record
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/campaign/RandomSkillPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import mekhq.MekHQ;
import mekhq.MekHqXmlUtil;

import mekhq.Version;
import megamek.Version;
import mekhq.campaign.personnel.enums.PersonnelRole;
import org.apache.commons.lang3.StringUtils;
import org.w3c.dom.Node;
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/campaign/force/Force.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

import mekhq.MekHQ;
import mekhq.MekHqXmlUtil;
import mekhq.Version;
import megamek.Version;
import mekhq.campaign.Campaign;
import mekhq.campaign.mission.Scenario;
import mekhq.campaign.unit.Unit;
Expand Down
13 changes: 5 additions & 8 deletions MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import mekhq.MhqFileUtil;
import mekhq.NullEntityException;
import mekhq.Utilities;
import mekhq.Version;
import megamek.Version;
import mekhq.campaign.Campaign;
import mekhq.campaign.CampaignOptions;
import mekhq.campaign.CurrentLocation;
Expand Down Expand Up @@ -160,7 +160,7 @@ public Campaign parse() throws CampaignXmlParseException, NullEntityException {
// Stupid weird parsing of XML. At least this cleans it up.
campaignEle.normalize();

Version version = new Version(campaignEle.getAttribute("version"));
final Version version = new Version(campaignEle.getAttribute("version"));

// Indicates whether or not new units were written to disk while
// loading the Campaign file. If so, we need to kick back off loading
Expand Down Expand Up @@ -1319,8 +1319,7 @@ private static void postProcessParts(Campaign retVal, Version version) {

// Fixup LargeCraftAmmoBins from old versions
if ((prt.getUnit() != null) && (prt.getUnit().getEntity() != null)
&& ((version.getMinorVersion() < 43)
|| ((version.getMinorVersion() == 43) && (version.getSnapshot() < 5)))
&& version.isLowerThan("0.43.5")
&& ((prt instanceof AmmoBin) || (prt instanceof MissingAmmoBin))) {
if (prt.getUnit().getEntity().usesWeaponBays()) {
Mounted ammo;
Expand Down Expand Up @@ -1475,7 +1474,7 @@ private static void postProcessParts(Campaign retVal, Version version) {
}
}

// old versions didnt distinguish tank engines
// old versions didn't distinguish tank engines
if ((prt instanceof EnginePart) && prt.getName().contains("Vehicle")) {
boolean isHover = null != u
&& u.getEntity().getMovementMode() == EntityMovementMode.HOVER && u.getEntity() instanceof Tank;
Expand All @@ -1497,9 +1496,7 @@ private static void postProcessParts(Campaign retVal, Version version) {
((MissingEnginePart) prt).fixClanFlag();
}

if ((version.getMajorVersion() == 0)
&& ((version.getMinorVersion() < 44)
|| ((version.getMinorVersion() == 43) && (version.getSnapshot() < 7)))) {
if (version.isLowerThan("0.44.0")) {
if ((prt instanceof MekLocation)
&& (((MekLocation) prt).getStructureType() == EquipmentType.T_STRUCTURE_ENDO_STEEL)) {
if (null != u) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import megamek.common.icons.Camouflage;
import mekhq.MekHQ;
import mekhq.Version;
import megamek.Version;

/**
* This migrates Camouflage from SeaBee's Pack to Deadborder's Pack.
Expand Down
Loading