if (!hasSlot) { Enumeration pE = server.getGame().getPlayers(); while (pE.hasMoreElements()) { Player tmpP = (Player)pE.nextElement(); if (tmpP.getName().equals(sd.localName)) tmpP.setObserver(true); } }
    public void scenario() {        FileDialog fd = new FileDialog(frame, Messages.getString("MegaMek.SelectScenarioDialog.title"), FileDialog.LOAD); //$NON-NLS-1$        fd.setDirectory("data" + File.separatorChar + "scenarios"); //$NON-NLS-1$ //$NON-NLS-2$        // the filter doesn't seem to do anything in windows.  oh well        FilenameFilter ff = new FilenameFilter() {            public boolean accept(File f, String s) {                return s.endsWith(".mms"); //$NON-NLS-1$            }        };        fd.setFilenameFilter(ff);        fd.setFile("*.mms"); //see comment above for load game dialog //$NON-NLS-1$        fd.show();        if (fd.getFile() == null) {            return;        }        ScenarioLoader sl = new ScenarioLoader(new File(fd.getDirectory(), fd.getFile()));        IGame g = null;        try {            g = sl.createGame();        } catch (Exception e) {            new AlertDialog(frame, Messages.getString("MegaMek.HostScenarioAllert.title"), Messages.getString("MegaMek.HostScenarioAllert.message") + e.getMessage()).show(); //$NON-NLS-1$ //$NON-NLS-2$            return;        }        // get player types and colors set        Player[] pa = new Player[g.getPlayersVector().size()];        g.getPlayersVector().copyInto(pa);        ScenarioDialog sd = new ScenarioDialog(frame, pa);        sd.show();        if (!sd.bSet) {            return;        }        // host with the scenario.  essentially copied from host()        HostDialog hd = new HostDialog(frame);        hd.yourNameF.setText(sd.localName);        hd.show();        // verify dialog data        if (hd.name == null || hd.serverPass == null || hd.port == 0) {            return;        }        // Players should have to enter a non-blank, non-whitespace name.        boolean foundValid = false;        char[] nameChars = hd.name.toCharArray();        for (int loop = 0; !foundValid && loop < nameChars.length; loop++) {            if (!Character.isWhitespace(nameChars[loop])) {                foundValid = true;            }        }        if (!foundValid) {            new AlertDialog(frame, Messages.getString("MegaMek.HostScenarioAllert1.title"), Messages.getString("MegaMek.HostScenarioAllert1.message")).show(); //$NON-NLS-1$ //$NON-NLS-2$            return;        }        // kick off a RNG check        megamek.common.Compute.d6();        // start server        server = new Server(hd.serverPass, hd.port);        server.setGame(g);        // apply any scenario damage        sl.applyDamage(server);        ClientGUI gui = null;        if (sd.localName != "") { //$NON-NLS-1$            // initialize game            client = new Client(hd.name, "localhost", hd.port); //$NON-NLS-1$            gui = new ClientGUI(client);            gui.initialize();            try {                client.connect();            } catch (Exception e) {                        }            Vector changedOptions = server.getGame().getOptions().loadOptions(hd.serverPass);            if ( changedOptions.size() > 0 ) {                client.sendGameOptions(hd.serverPass, changedOptions);            }            // popup options dialog            gui.getGameOptionsDialog().update(client.game.getOptions());            gui.getGameOptionsDialog().show();        }        optdlg = null;        // setup any bots        for (int x = 0; x < pa.length; x++) {            if (sd.playerTypes[x] == ScenarioDialog.T_BOT) {                BotClient c = new TestBot(pa[x].getName(), "localhost", hd.port); //$NON-NLS-1$                c.game.addGameListener(new BotGUI(c));                try {                    c.connect();                } catch (Exception e) {                                    }                c.retrieveServerInfo();             }        }        launch(gui.getFrame());    }