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

Update Version data based upon Properties File #6871

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions megamek/resources/extraVersion.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
branch=PR-version-update-for-ci
gitHash=HASH-asdkj4892
108 changes: 35 additions & 73 deletions megamek/src/megamek/MegaMek.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
/*
* MegaMek - Copyright (C) 2005, 2006 Ben Mazur ([email protected])
* Copyright © 2013 Edward Cullen ([email protected])
* Copyright (c) 2014-2024 - The MegaMek Team. All Rights Reserved.
* Copyright (C) 2014-2025 The MegaMek Team. All Rights Reserved.
*
* This file is part of MegaMek.
*
* MegaMek 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.
* it under the terms of the GNU General Public License (GPL),
* version 3 or (at your option) any later version,
* as published by the Free Software Foundation.
*
* MegaMek 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.
* 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 MegaMek. If not, see <http://www.gnu.org/licenses/>.
* A copy of the GPL should have been included with this project;
* if not, see <https://www.gnu.org/licenses/>.
*
* NOTICE: The MegaMek organization is a non-profit group of volunteers
* creating free software for the BattleTech community.
*
* MechWarrior, BattleMech, `Mech and AeroTech are registered trademarks
* of The Topps Company, Inc. All Rights Reserved.
*
* Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of
* InMediaRes Productions, LLC.
*/
package megamek;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputFilter;
import java.lang.management.ManagementFactory;
import java.net.URL;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.NumberFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
Expand Down Expand Up @@ -70,7 +74,7 @@ public class MegaMek {

private static final NumberFormat numberFormatter = NumberFormat.getInstance();

private static final MMLogger logger = MMLogger.create(MegaMek.class);
private static final MMLogger LOGGER = MMLogger.create(MegaMek.class);
private static final SanityInputFilter sanityInputFilter = new SanityInputFilter();

public static void main(String... args) {
Expand All @@ -83,7 +87,9 @@ public static void main(String... args) {
options.setEnableExternalConfiguration(true);
options.setDsn("https://[email protected]/8");
options.setEnvironment("production");
options.setTracesSampleRate(0.2);
options.setTracesSampleRate(1.0);
options.setProfilesSampleRate(1.0);
options.setEnableAppStartProfiling(true);
options.setDebug(true);
options.setServerName("MegaMekClient");
options.setRelease(SuiteConstants.VERSION.toString());
Expand All @@ -96,7 +102,7 @@ public static void main(String... args) {
final String name = t.getClass().getName();
final String message = String.format(MMLoggingConstants.UNHANDLED_EXCEPTION, name);
final String title = String.format(MMLoggingConstants.UNHANDLED_EXCEPTION_TITLE, name);
logger.errorDialog(t, message, title);
LOGGER.errorDialog(t, message, title);
});

// Second, let's handle logging
Expand All @@ -109,12 +115,12 @@ public static void main(String... args) {
try {
parser.parse();
} catch (AbstractCommandLineParser.ParseException e) {
logger.fatal(e, String.format(MMLoggingConstants.AP_INCORRECT_ARGUMENTS, e.getMessage(), parser.help()));
LOGGER.fatal(e, String.format(MMLoggingConstants.AP_INCORRECT_ARGUMENTS, e.getMessage(), parser.help()));
System.exit(1);
}

// log jvm parameters
logger.info(ManagementFactory.getRuntimeMXBean().getInputArguments());
LOGGER.info(ManagementFactory.getRuntimeMXBean().getInputArguments());

String[] restArgs = parser.getRestArgs();

Expand Down Expand Up @@ -152,7 +158,7 @@ public static void main(String... args) {
}

public static void initializeLogging(final String originProject) {
logger.info(getUnderlyingInformation(originProject));
LOGGER.info(getUnderlyingInformation(originProject));
}

public static SuitePreferences getMMPreferences() {
Expand All @@ -163,50 +169,6 @@ public static MMOptions getMMOptions() {
return mmOptions;
}

/**
* Calculates the SHA-256 hash of the MegaMek.jar file Used primarily for purposes of checksum comparison when
* connecting a new client.
*
* @return String representing the SHA-256 hash
*/
public static @Nullable String getMegaMekSHA256() {
StringBuilder sb = new StringBuilder();

String filename = "MegaMek.jar";
if (new File("lib/" + filename).exists()) {
filename = "lib/" + filename;
}

if (!new File(filename).exists()) {
logger.warn("MegaMek.jar not found. Returning null checksum.");
return null;
}

MessageDigest md;
try {
md = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
logger.error(e, "SHA-256 Algorithm Can't be Found");
return null;
}

try (InputStream is = new FileInputStream(filename); InputStream dis = new DigestInputStream(is, md)) {
while (0 < dis.read()) {
// Idle Timer...
}

byte[] digest = md.digest();
for (byte d : digest) {
sb.append(String.format("%02x", d));
}
} catch (Exception e) {
logger.error(e, "Error Calculating Hash");
return null;
}

return sb.toString();
}

/**
* This function returns the memory used in the heap (heap memory - free memory).
*
Expand All @@ -225,7 +187,7 @@ public static String getMemoryUsed() {
* @param args the arguments to the dedicated server.
*/
private static void startDedicatedServer(String... args) {
logger.info(MMLoggingConstants.SC_STARTING_DEDICATED_SERVER, Arrays.toString(args));
LOGGER.info(MMLoggingConstants.SC_STARTING_DEDICATED_SERVER, Arrays.toString(args));
DedicatedServer.start(args);
}

Expand All @@ -245,7 +207,7 @@ private static void startHost(String... args) {
final String message = String.format(MMLoggingConstants.AP_INCORRECT_ARGUMENTS,
e.getMessage(),
parser.help());
logger.error(e, message);
LOGGER.error(e, message);
System.exit(1);
}

Expand All @@ -254,7 +216,7 @@ private static void startHost(String... args) {
MMConstants.LOCALHOST,
PreferenceManager.getClientPreferences().getLastPlayerName());

logger.info(MMLoggingConstants.SC_STARTING_HOST_SERVER, Arrays.toString(args));
LOGGER.info(MMLoggingConstants.SC_STARTING_HOST_SERVER, Arrays.toString(args));

SwingUtilities.invokeLater(() -> {
MegaMekGUI mmg = new MegaMekGUI();
Expand Down Expand Up @@ -284,7 +246,7 @@ private static void startQuickLoad(String... args) {
try {
parser.parse();
} catch (AbstractCommandLineParser.ParseException e) {
logger.error(e, String.format(MMLoggingConstants.AP_INCORRECT_ARGUMENTS, e.getMessage(), parser.help()));
LOGGER.error(e, String.format(MMLoggingConstants.AP_INCORRECT_ARGUMENTS, e.getMessage(), parser.help()));
System.exit(1);
}

Expand All @@ -293,7 +255,7 @@ private static void startQuickLoad(String... args) {
MMConstants.LOCALHOST,
PreferenceManager.getClientPreferences().getLastPlayerName());

logger.info(MMLoggingConstants.SC_STARTING_HOST_SERVER, Arrays.toString(args));
LOGGER.info(MMLoggingConstants.SC_STARTING_HOST_SERVER, Arrays.toString(args));

SwingUtilities.invokeLater(() -> {
MegaMekGUI mmg = new MegaMekGUI();
Expand Down Expand Up @@ -324,7 +286,7 @@ private static void startClient(String... args) {
try {
parser.parse();
} catch (AbstractCommandLineParser.ParseException e) {
logger.error(e, String.format(MMLoggingConstants.AP_INCORRECT_ARGUMENTS, e.getMessage(), parser.help()));
LOGGER.error(e, String.format(MMLoggingConstants.AP_INCORRECT_ARGUMENTS, e.getMessage(), parser.help()));
System.exit(1);
}

Expand All @@ -333,7 +295,7 @@ private static void startClient(String... args) {
MMConstants.LOCALHOST,
PreferenceManager.getClientPreferences().getLastPlayerName());

logger.info(MMLoggingConstants.SC_STARTING_CLIENT_SERVER, Arrays.toString(args));
LOGGER.info(MMLoggingConstants.SC_STARTING_CLIENT_SERVER, Arrays.toString(args));

SwingUtilities.invokeLater(() -> {
MegaMekGUI mmg = new MegaMekGUI();
Expand All @@ -346,15 +308,15 @@ private static void startGifWriter(String... args) {
try {
GifWriter.createGifFromGameSummary(args[0]);
} catch (IOException e) {
logger.error(e, "Error creating GIF");
LOGGER.error(e, "Error creating GIF");
}
}

/**
* Starts MegaMek's splash GUI
*/
private static void startGUI() {
logger.info("Starting MegaMekGUI.");
LOGGER.info("Starting MegaMekGUI.");
SwingUtilities.invokeLater(() -> new MegaMekGUI().start(true));
}

Expand Down
38 changes: 22 additions & 16 deletions megamek/src/megamek/SuiteConstants.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
/*
* Copyright (c) 2021-2025 - The MegaMek Team. All Rights Reserved.
* Copyright (C) 2021-2025 The MegaMek Team. All Rights Reserved.
*
* This file is part of MegaMek.
*
* MegaMek 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.
* it under the terms of the GNU General Public License (GPL),
* version 3 or (at your option) any later version,
* as published by the Free Software Foundation.
*
* MegaMek 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.
* 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 MegaMek. If not, see <http://www.gnu.org/licenses/>.
* A copy of the GPL should have been included with this project;
* if not, see <https://www.gnu.org/licenses/>.
*
* NOTICE: The MegaMek organization is a non-profit group of volunteers
* creating free software for the BattleTech community.
*
* MechWarrior, BattleMech, `Mech and AeroTech are registered trademarks
* of The Topps Company, Inc. All Rights Reserved.
*
* Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of
* InMediaRes Productions, LLC.
*/
package megamek;

/**
* These are constants that hold across the entire MegaMek Suite of MegaMek,
* MegaMekLab, and MekHQ.
* These are constants that hold across the entire MegaMek Suite of MegaMek, MegaMekLab, and MekHQ.
*/
public abstract class SuiteConstants {
protected SuiteConstants() {
Expand All @@ -29,7 +37,7 @@ protected SuiteConstants() {

// region General Constants
public static final String PROJECT_NAME = "MegaMek Suite";
public static final Version VERSION = new Version("0.50.05-SNAPSHOT");
public static final Version VERSION = new Version("0.50.05");
public static final Version LAST_MILESTONE = new Version("0.49.19.1");
public static final int MAXIMUM_D6_VALUE = 6;

Expand All @@ -38,10 +46,8 @@ protected SuiteConstants() {
// endregion General Constants

// region Font Constants
// FIXME : These uses all need to be converted into SuiteOptions, and this step
// was done to
// FIXME : simplify and isolate places that will be required
// FIXME : This is an accessibility issue
// FIXME : These uses all need to be converted into SuiteOptions, and this step was done to simplify and isolate
// places that will be required This is an accessibility issue
public static final String FONT_ARIAL = "Arial";
public static final String FONT_COURIER_NEW = "Courier New";
public static final String FONT_DIALOG = "Dialog";
Expand Down
Loading