⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fateserver.java

📁 Massively Multiplayer Space Trading and Combat game. This is an online strategy game, not a 3D space
💻 JAVA
字号:
/*
 * FateServer.java
 *
 * Copyright (C) 2000 Jason M. Hanley
 * Released under the GNU General Public License (GPL)
 * See license.txt for additional information.
 *
 * Created on July 25, 2000, 11:29 PM
 */
 
package fate;

import java.util.*;
import java.io.*;

import fate.network.*;
import fate.messages.*;
import fate.util.*;
import fate.server.*;
import fate.ui.*;
import fate.world.*;

/** 
 * Server executable.
 *
 * @author  preylude@s3m.com
 * @version 0.1.0
 */
public class FateServer extends Object {
  
  public static final String programName = "FateServer 0.1.3";
  public static final String playerDBFile = "data/PlayerInfo.dat";
  public static final String universeFile = "data/FateUniverse.dat";
  static ServerConnection serverConnection;
  public static MapPlayerInfo mapPlayerInfo;
  public static Universe universe;
  
  /** Creates new FateServer */
  public FateServer() {
    // Don't do anything here since this will never be initialized
  }
  
  /** Runs the FateServer application */
  public static void main(String[] args) {
    System.out.println( programName + " initializing...");

    // Load the player database
    try {
      Debug.trace( "Attempting to load player database" );
      FileInputStream fileIn = new FileInputStream( playerDBFile );
      ObjectInputStream in = new ObjectInputStream( fileIn );
      mapPlayerInfo = (MapPlayerInfo) in.readObject();
      in.close();
      fileIn.close();
    } catch( Exception e ) {
      // Create a new player database
      Debug.trace( "Couldn't read MapPlayerInfo, creating new one" );
      mapPlayerInfo = new MapPlayerInfo();
    }

    // Load the universe
    try {
      Debug.trace( "Attempting to load Universee" );
      FileInputStream fileIn = new FileInputStream( universeFile );
      ObjectInputStream in = new ObjectInputStream( fileIn );
      universe = (Universe) in.readObject();
      in.close();
      fileIn.close();
    } catch( Exception e ) {
      // Create a new player database
      Debug.trace( "Couldn't read Universe, creating new one" );
      universe = new Universe();
      universe.create(); // initialize the universe
    }

    // Start listening for clients
    try {
      serverConnection = new ServerConnection(
        ServerConnection.FATE_PORT, mapPlayerInfo );
      serverConnection.initialize();
      serverConnection.start();
    } catch ( Exception e ) {
      Debug.trace( "Error while trying to connect" );
      e.printStackTrace();
    }

    // Start off the MessageProcessor thread
    MessageProcessor messageProcessor = new MessageProcessor( serverConnection, 
      mapPlayerInfo );
    messageProcessor.start();

    // Start off the UpdaterThread thread
    UpdaterThread updaterThread = new UpdaterThread( serverConnection, 
      mapPlayerInfo );
    updaterThread.start();

    // Bring up the UI
    MainFrame mainFrame = new MainFrame( programName, mapPlayerInfo );
    mainFrame.pack();
    SwingUtil.centerWindow( mainFrame );
    mainFrame.setVisible(true);
    
    Debug.trace("FateServer main thread exiting.");
  }
  
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -