Exemple #1
0
 public void readObject(ObjectInputStream in)
     throws java.io.IOException, ClassNotFoundException, InstantiationException {
   in.readObjectStart();
   port = in.readShort();
   {
     int len = 0;
     len = in.readInt();
     serviceTypes = new String[len];
   }
   int i1;
   for (i1 = 0; i1 < serviceTypes.length; i1++) {
     serviceTypes[i1] = in.readString();
   }
   {
     int len = 0;
     len = in.readInt();
     groups = new String[len];
   }
   for (i1 = 0; i1 < groups.length; i1++) {
     groups[i1] = in.readString();
   }
   {
     int len = 0;
     len = in.readInt();
     heard = new String[len];
   }
   for (i1 = 0; i1 < heard.length; i1++) {
     heard[i1] = in.readString();
   }
   in.readObjectEnd();
 }
 private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
   short version = ois.readShort();
   switch (version) {
     case VERSION:
       setUpPropertyEvents();
       break;
     default:
       throw new IOException("Unsupported Serialized Version: " + version);
   }
 }
 private void readObject(ObjectInputStream in) throws IOException {
   short version = in.readShort();
   switch (version) {
     case 0x0001:
       this.value = in.readInt();
       break;
     default:
       throw new UnsupportedVersionException(this, version);
   }
 }
Exemple #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();
     }
   }
 }