From e0cf70cdb48f930303861733e3a8754e17c7555b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 29 Oct 2021 00:04:47 -0400 Subject: [PATCH] Improving unknown phase logging, so that it properly reflects a slower initialization rather than an in-game issue --- MekHQ/src/mekhq/AtBGameThread.java | 42 ++++++++++++------------------ MekHQ/src/mekhq/GameThread.java | 2 +- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/MekHQ/src/mekhq/AtBGameThread.java b/MekHQ/src/mekhq/AtBGameThread.java index 892fea1cab..710d8421d6 100644 --- a/MekHQ/src/mekhq/AtBGameThread.java +++ b/MekHQ/src/mekhq/AtBGameThread.java @@ -20,25 +20,11 @@ */ package mekhq; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.util.*; - -import javax.swing.JOptionPane; - import megamek.client.Client; import megamek.client.bot.BotClient; import megamek.client.bot.princess.Princess; import megamek.client.ui.swing.ClientGUI; -import megamek.common.Entity; -import megamek.common.IGame; -import megamek.common.IAero; -import megamek.common.MapSettings; -import megamek.common.Minefield; -import megamek.common.PlanetaryConditions; -import megamek.common.UnitType; +import megamek.common.*; import megamek.common.logging.LogLevel; import mekhq.campaign.force.Force; import mekhq.campaign.mission.AtBDynamicScenario; @@ -47,11 +33,17 @@ import mekhq.campaign.personnel.Person; import mekhq.campaign.unit.Unit; +import javax.swing.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.*; + /** * @author Neoancient * - * Enhanced version of GameThread which imports settings and non-player - * units into the MM game + * Enhanced version of GameThread which imports settings and non-player units into the MM game */ public class AtBGameThread extends GameThread { @@ -108,7 +100,7 @@ public void run() { // phase for (int i = 0; (i < CLIENT_RETRY_COUNT) && (client.getGame().getPhase() == IGame.Phase.PHASE_UNKNOWN); i++) { Thread.sleep(50); - MekHQ.getLogger().error("Thread in unknown stage"); + MekHQ.getLogger().warning("Client has not finished initialization, and is currently in an unknown phase."); } if (((client.getGame() != null) && (client.getGame().getPhase() == IGame.Phase.PHASE_LOUNGE))) { @@ -125,9 +117,9 @@ public void run() { MapSettings mapSettings = MapSettings.getInstance(); mapSettings.setBoardSize(scenario.getMapX(), scenario.getMapY()); - mapSettings.setMapSize(1, 1); + mapSettings.setMapSize(1, 1); mapSettings.getBoardsSelectedVector().clear(); - + // if the scenario is taking place in space, do space settings instead if (scenario.getTerrainType() == AtBScenario.TER_SPACE) { @@ -135,7 +127,7 @@ public void run() { mapSettings.getBoardsSelectedVector().add(MapSettings.BOARD_GENERATED); } else if (scenario.isUsingFixedMap()) { mapSettings.getBoardsSelectedVector().add(scenario.getMap().replace(".board", "")); - + if (scenario.getTerrainType() == AtBScenario.TER_LOW_ATMO) { mapSettings.setMedium(MapSettings.MEDIUM_ATMOSPHERE); } @@ -150,13 +142,13 @@ public void run() { if (scenario.getTerrainType() == AtBScenario.TER_LOW_ATMO) { mapSettings.setMedium(MapSettings.MEDIUM_ATMOSPHERE); } - + // duplicate code, but getting a new instance of map settings resets the size parameters mapSettings.setBoardSize(scenario.getMapX(), scenario.getMapY()); - mapSettings.setMapSize(1, 1); + mapSettings.setMapSize(1, 1); mapSettings.getBoardsSelectedVector().add(MapSettings.BOARD_GENERATED); } - + client.sendMapSettings(mapSettings); Thread.sleep(MekHQ.getMekHQOptions().getStartGameDelay()); @@ -499,7 +491,7 @@ private void copyDeploymentParameters(Entity source, Entity destination) { destination.setStartingPos(source.getStartingPos(false)); destination.setAltitude(source.getAltitude()); destination.setElevation(source.getElevation()); - + if (destination.isAirborne() && (destination.getAltitude() == 0)) { ((IAero) destination).land(); } diff --git a/MekHQ/src/mekhq/GameThread.java b/MekHQ/src/mekhq/GameThread.java index b923ca9dd3..d64d43a37e 100644 --- a/MekHQ/src/mekhq/GameThread.java +++ b/MekHQ/src/mekhq/GameThread.java @@ -104,7 +104,7 @@ public void run() { // phase for (int i = 0; (i < 1000) && (client.getGame().getPhase() == IGame.Phase.PHASE_UNKNOWN); i++) { Thread.sleep(50); - MekHQ.getLogger().error("Thread in unknown stage" ); + MekHQ.getLogger().warning("Client has not finished initialization, and is currently in an unknown phase."); } if (((client.getGame() != null) && (client.getGame().getPhase() == IGame.Phase.PHASE_LOUNGE))) {