new FileOutputStream(sFinalFile));
new FileOutputStream(localFile));
    protected void handlePacket(Packet c) {        if (c == null) {            System.out.println("client: got null packet"); //$NON-NLS-1$            return;        }        switch (c.getCommand()) {            case Packet.COMMAND_CLOSE_CONNECTION :                disconnected();                break;            case Packet.COMMAND_SERVER_GREETING :                connected = true;                send(new Packet(Packet.COMMAND_CLIENT_NAME, name));                break;            case Packet.COMMAND_SERVER_CORRECT_NAME :                correctName(c);                break;            case Packet.COMMAND_LOCAL_PN :                this.local_pn = c.getIntValue(0);                break;            case Packet.COMMAND_PLAYER_UPDATE :                receivePlayerInfo(c);                break;            case Packet.COMMAND_PLAYER_READY :                getPlayer(c.getIntValue(0)).setDone(c.getBooleanValue(1));                break;            case Packet.COMMAND_PLAYER_ADD :                receivePlayerInfo(c);                break;            case Packet.COMMAND_PLAYER_REMOVE :                game.removePlayer(c.getIntValue(0));                break;            case Packet.COMMAND_CHAT :                if (log == null)                    initGameLog();                if (log != null && keepGameLog()) {                    log.append( (String) c.getObject(0) );                }                game.processGameEvent(new GamePlayerChatEvent(this,null, (String) c.getObject(0)));                break;            case Packet.COMMAND_ENTITY_ADD :                receiveEntityAdd(c);                break;            case Packet.COMMAND_ENTITY_UPDATE :                receiveEntityUpdate(c);                break;            case Packet.COMMAND_ENTITY_REMOVE :                receiveEntityRemove(c);                break;            case Packet.COMMAND_ENTITY_VISIBILITY_INDICATOR :                receiveEntityVisibilityIndicator(c);                break;            case Packet.COMMAND_SENDING_MINEFIELDS :                receiveSendingMinefields(c);                break;            case Packet.COMMAND_DEPLOY_MINEFIELDS :                receiveDeployMinefields(c);                break;            case Packet.COMMAND_REVEAL_MINEFIELD :                receiveRevealMinefield(c);                break;            case Packet.COMMAND_REMOVE_MINEFIELD :                receiveRemoveMinefield(c);                break;            case Packet.COMMAND_CHANGE_HEX :                game.getBoard().setHex((Coords) c.getObject(0), (IHex) c.getObject(1));                break;            case Packet.COMMAND_BLDG_UPDATE_CF :                receiveBuildingUpdateCF(c);                break;            case Packet.COMMAND_BLDG_COLLAPSE :                receiveBuildingCollapse(c);                break;            case Packet.COMMAND_PHASE_CHANGE :                changePhase(c.getIntValue(0));                break;            case Packet.COMMAND_TURN :                changeTurnIndex(c.getIntValue(0));                break;            case Packet.COMMAND_ROUND_UPDATE :                game.setRoundCount(c.getIntValue(0));                break;            case Packet.COMMAND_SENDING_TURNS :                receiveTurns(c);                break;            case Packet.COMMAND_SENDING_BOARD :                receiveBoard(c);                break;            case Packet.COMMAND_SENDING_ENTITIES :                receiveEntities(c);                break;            case Packet.COMMAND_SENDING_REPORTS :            case Packet.COMMAND_SENDING_REPORTS_TACTICAL_GENIUS :                phaseReport = receiveReport((Vector) c.getObject(0));                if (keepGameLog()) {                    if (log == null && game.getRoundCount() == 1)                        initGameLog();                    if (log != null)                        log.append(phaseReport);                }                game.addReports((Vector) c.getObject(0));                roundReport = receiveReport(game.getReports(game.getRoundCount()));                if (c.getCommand() ==                    Packet.COMMAND_SENDING_REPORTS_TACTICAL_GENIUS) {                    game.processGameEvent(new GameReportEvent(this, null));                }                break;            case Packet.COMMAND_SENDING_REPORTS_SPECIAL :                game.processGameEvent(new GameReportEvent(this, receiveReport((Vector) c.getObject(0))));                break;            case Packet.COMMAND_SENDING_REPORTS_ALL :                Vector allReports = (Vector) c.getObject(0);                game.setAllReports(allReports);                if (keepGameLog()) {                    //Re-write gamelog.txt from scratch                    initGameLog();                    if (log != null) {                        for (int i = 0; i < allReports.size(); i++) {                            log.append(receiveReport((Vector)allReports.elementAt(i)));                        }                    }                }                roundReport = receiveReport(game.getReports(game.getRoundCount()));                //We don't really have a copy of the phase report at                // this point, so I guess we'll just use the round report                // until the next phase actually completes.                phaseReport = roundReport;                break;            case Packet.COMMAND_ENTITY_ATTACK :                receiveAttack(c);                break;            case Packet.COMMAND_SENDING_GAME_SETTINGS :                game.setOptions((GameOptions) c.getObject(0));                break;            case Packet.COMMAND_SENDING_MAP_SETTINGS :                mapSettings = (MapSettings) c.getObject(0);                game.processGameEvent(new GameSettingsChangeEvent(this));                break;            case Packet.COMMAND_QUERY_MAP_SETTINGS :                game.processGameEvent(new GameMapQueryEvent(this, (MapSettings)c.getObject(0)));                break;            case Packet.COMMAND_END_OF_GAME :                String sEntityStatus = (String) c.getObject(0);                game.end(c.getIntValue(1), c.getIntValue(2));                // save victory report                saveEntityStatus(sEntityStatus);                break;            case Packet.COMMAND_SENDING_ARTILLERYATTACKS :                Vector v = (Vector)c.getObject(0);                game.setArtilleryVector(v);                break;            case Packet.COMMAND_SENDING_FLARES :                Vector v2 = (Vector)c.getObject(0);                game.setFlares(v2);                break;            case Packet.COMMAND_SEND_SAVEGAME:                String sFinalFile = (String)c.getObject(0);                try {                    File sDir = new File("savegames");                    if (!sDir.exists()) {                        sDir.mkdir();                    }                } catch (Exception e) {                    System.err.println("Unable to create savegames directory");                }                try {                    ObjectOutputStream oos = new ObjectOutputStream(                        new FileOutputStream(sFinalFile));                    oos.writeObject(c.getObject(1));                    oos.flush();                    oos.close();                } catch (Exception e) {                    System.err.println("Unable to save file: " + sFinalFile);                    e.printStackTrace();                }                break;        }    }