name = correctDupeName(name); send(connId, new Packet(Packet.COMMAND_SERVER_CORRECT_NAME, name));
    private void receivePlayerName(Packet packet, int connId) {        final Connection conn = getPendingConnection(connId);        String name = (String)packet.getObject(0);        boolean returning = false;        // this had better be from a pending connection        if (conn == null) {            System.out.println("server: got a client name from a non-pending" +                               " connection");            return;        }        // check if they're connecting with the same name as a ghost player        for (Enumeration i = game.getPlayers(); i.hasMoreElements();) {            Player player = (Player)i.nextElement();            if (player.isGhost() && player.getName().equals(name)) {                returning = true;                player.setGhost(false);                // switch id                connId = player.getId();                conn.setId(connId);            }        }        // right, switch the connection into the "active" bin        connectionsPending.removeElement(conn);        connections.addElement(conn);        connectionIds.put(new Integer(conn.getId()), conn);        // add and validate the player info        if (!returning) {            game.addPlayer(connId, new Player(connId, name));            validatePlayerInfo(connId);        }        // if it is not the lounge phase, this player becomes an observer        Player player = getPlayer( connId );        if ( game.getPhase() != IGame.PHASE_LOUNGE             && null != player             && game.getEntitiesOwnedBy(player) < 1) {            player.setObserver(true);        }        // send the player the motd        sendServerChat(connId, motd);        // send info that the player has connected        send(createPlayerConnectPacket(connId));        // tell them their local playerId        send(connId, new Packet(Packet.COMMAND_LOCAL_PN, new Integer(connId)));        // send current game info        sendCurrentInfo(connId);        try {            InetAddress[] addresses = InetAddress.getAllByName(InetAddress                                                               .getLocalHost()                                                               .getHostName());            for (int i = 0; i < addresses.length; i++) {                sendServerChat(connId, "Machine IP is " +                               addresses[i].getHostAddress());            }        } catch (UnknownHostException  e) {            // oh well.        }        // Send the port we're listening on. Only useful for the player        // on the server machine to check.        sendServerChat(connId, "Listening on port " + serverSocket                                                      .getLocalPort());        // Get the player *again*, because they may have disconnected.        player = getPlayer( connId );        if ( null != player ) {            StringBuffer buff = new StringBuffer();            buff.append( player.getName() )                .append( " connected from " )                .append( getClient(connId).getSocket().getInetAddress() );            String who = buff.toString();            System.out.print( "s: player #" );            System.out.print( connId );            System.out.print( ", " );            System.out.println( who );            sendServerChat( who );        } // Found the player    }