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

Improving Client Unknown Phase Logging During Initial Connection #2930

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
42 changes: 17 additions & 25 deletions MekHQ/src/mekhq/AtBGameThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -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))) {
Expand All @@ -125,17 +117,17 @@ 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) {
mapSettings.setMedium(MapSettings.MEDIUM_SPACE);
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);
}
Expand All @@ -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());

Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/GameThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down