Beispiel #1
0
 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
   int featuresLength;
   int version = in.readInt();
   ilist = (InstanceList) in.readObject();
   numTopics = in.readInt();
   alpha = in.readDouble();
   beta = in.readDouble();
   tAlpha = in.readDouble();
   vBeta = in.readDouble();
   int numDocs = ilist.size();
   topics = new int[numDocs][];
   for (int di = 0; di < ilist.size(); di++) {
     int docLen = ((FeatureSequence) ilist.get(di).getData()).getLength();
     topics[di] = new int[docLen];
     for (int si = 0; si < docLen; si++) topics[di][si] = in.readInt();
   }
   docTopicCounts = new int[numDocs][numTopics];
   for (int di = 0; di < ilist.size(); di++)
     for (int ti = 0; ti < numTopics; ti++) docTopicCounts[di][ti] = in.readInt();
   int numTypes = ilist.getDataAlphabet().size();
   typeTopicCounts = new int[numTypes][numTopics];
   for (int fi = 0; fi < numTypes; fi++)
     for (int ti = 0; ti < numTopics; ti++) typeTopicCounts[fi][ti] = in.readInt();
   tokensPerTopic = new int[numTopics];
   for (int ti = 0; ti < numTopics; ti++) tokensPerTopic[ti] = in.readInt();
 }
Beispiel #2
0
 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
   int version = in.readInt();
   int len = in.readInt();
   data = new double[len];
   for (int i = 1; i < len; i++) {
     data[i] = in.readDouble();
   }
   size = in.readInt();
 }
  private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    this.mapType = (MapType) in.readObject();
    this.num = 0;
    this.locked = false;

    int n = in.readInt();
    allocate(getCapacity(n, true));

    for (int i = 0; i < n; i++) {
      String key = ((String) in.readObject()).intern();
      double value = in.readDouble();
      if (mapType == MapType.SORTED_LIST) {
        // Assume keys and values serialized in sorted order
        keys[num] = key;
        values[num] = value;
        num++;
      } else if (mapType == MapType.HASH_TABLE) {
        put(key, value);
      }
    }
  }
Beispiel #4
0
 public void run() {
   Server.preRunOperations(this);
   while (true) {
     try {
       String type = in.readUTF();
       if (type.equals("newObject")) {
         Object object = in.readObject();
         if (object instanceof String) {
           // Adding player..
           this.player = new Player((String) object, Entity.BLUE);
           boolean addPlayer = true;
           for (int i = 0; i < Server.players.size(); i++) {
             if (this.player.name.equals(Server.players.get(i).name)) {
               // Set to online!
               if (Server.players.get(i).online) {
                 System.out.println(
                     "Player " + player.name + " is already connected! " + (userID + 1));
                 this.player = null;
                 addPlayer = false;
               } else {
                 this.player = Server.players.get(i);
                 System.out.println("Returning User: "******", " + (userID + 1));
                 this.player.online = true;
                 addPlayer = false;
               }
               break;
             }
           }
           if (addPlayer) {
             System.out.println("New User: "******", " + (userID + 1));
             Server.players.add(this.player);
           }
         }
       } else if (type.equals(
           "MoveUnit")) { // this needs to require the player to be the owner of the unit
         short unit = in.readShort();
         double cX = in.readDouble();
         double cY = in.readDouble();
         double x = in.readDouble();
         double y = in.readDouble();
         boolean stacked = in.readBoolean();
         // Pretty simple: (If the unit doesn't "exist", game will take care of that.) [Keep in
         // mind, this currently could easily let the player control enemy units]
         new PathFind(
             unit, cX, cY, x, y,
             stacked); // All commands take the liberty of adding themselves to the game stack.
       } else if (type.equals(
           "SetTarget")) { // this needs to require the player to be the owner of the unit
         short unit = in.readShort();
         short enemy = in.readShort();
         boolean stacked = in.readBoolean();
         // Pretty simple:
         new SetTarget(unit, enemy, stacked);
       } else if (type.equals("AddOrder")) {
         short unit = in.readShort();
         byte order = in.readByte();
         double atX = in.readDouble();
         double atY = in.readDouble();
         boolean stacked = in.readBoolean();
         new AddOrder(unit, order, atX, atY, stacked);
       } else if (type.equals("Uber")) {
         short unit = in.readShort();
         boolean stacked = in.readBoolean();
         new Uber(unit, stacked);
       } else if (type.equals("Exiting")) {
         disconnect();
         return;
       }
     } catch (IOException e) {
       disconnect();
       return;
     } catch (Exception e) {
       System.out.println("Alternate error.");
       e.printStackTrace();
     }
   }
 }