use of games.strategy.net.HeadlessServerMessenger in project triplea by triplea-game.
the class LocalLauncher method launchInNewThread.
@Override
protected void launchInNewThread(final Component parent) {
Exception exceptionLoadingGame = null;
ServerGame game = null;
try {
gameData.doPreGameStartDataModifications(playerListing);
final Messengers messengers = new Messengers(new HeadlessServerMessenger());
final Set<IGamePlayer> gamePlayers = gameData.getGameLoader().createPlayers(playerListing.getLocalPlayerTypes());
game = new ServerGame(gameData, gamePlayers, new HashMap<>(), messengers);
game.setRandomSource(randomSource);
// for debugging, we can use a scripted random source
if (ScriptedRandomSource.useScriptedRandom()) {
game.setRandomSource(new ScriptedRandomSource());
}
gameData.getGameLoader().startGame(game, gamePlayers, headless);
} catch (final MapNotFoundException e) {
exceptionLoadingGame = e;
} catch (final Exception ex) {
ClientLogger.logQuietly("Failed to start game", ex);
exceptionLoadingGame = ex;
} finally {
gameLoadingWindow.doneWait();
}
try {
if (exceptionLoadingGame == null) {
game.startGame();
}
} finally {
// todo(kg), this does not occur on the swing thread, and this notifies setupPanel observers
// having an oddball issue with the zip stream being closed while parsing to load default game. might be caused
// by closing of stream while unloading map resources.
Interruptibles.sleep(100);
gameSelectorModel.loadDefaultGameNewThread();
SwingUtilities.invokeLater(() -> JOptionPane.getFrameForComponent(parent).setVisible(true));
}
}
Aggregations