Exemple #1
0
 @Override
 public void serialize(EasyBuffering p_buf) {
   p_buf.put(playerName);
   p_buf.put(zildoId);
   p_buf.put(nDied);
   p_buf.put(nKill);
 }
 /**
  * Serialize this object into a ByteBuffer
  *
  * @return EasyBuffering
  */
 @Override
 public void serialize(EasyBuffering p_buffer) {
   p_buffer.clear();
   int index = 0;
   for (KeysConfiguration key : KeysConfiguration.values()) {
     bools[index++] = kbdInstant.get(key);
   }
   p_buffer.putBooleans(bools);
 }
  static Vector4f[] loadPalette(String fileName) {
    // Load the palette
    EasyBuffering file = Zildo.pdPlugin.openFile(fileName);

    Vector4f[] pal = new Vector4f[256];
    int a, b, c;
    for (int i = 0; i < 256; i++) {
      a = file.readUnsignedByte();
      b = file.readUnsignedByte();
      c = file.readUnsignedByte();
      pal[i] = new Vector4f(a, b, c, 1);
    }

    return pal;
  }
Exemple #4
0
 /**
  * Read the servers configuration file to return a list of {@link ServerInfo}.<br>
  * In any error case, return an empty list.
  *
  * @return List<ServerInfo>
  */
 public static List<ServerInfo> loadServersInfos() {
   List<ServerInfo> infos = new ArrayList<ServerInfo>();
   try {
     EasyBuffering file = Zildo.pdPlugin.openFile(Constantes.SERVER_FILE);
     while (!file.eof()) {
       String name = file.readString();
       String ip = file.readString();
       int port = file.readInt();
       infos.add(new ServerInfo(name, ip, port));
     }
     return infos;
   } catch (Exception e) {
     return infos;
   }
 }
 /**
  * Get a SpriteEntity list from a ByteBuffer.
  *
  * @param p_buffer
  * @return List<SpriteEntity>
  */
 public static List<SpriteEntity> deserializeEntities(EasyBuffering p_buffer) {
   List<SpriteEntity> entities = new ArrayList<SpriteEntity>();
   while (!p_buffer.eof()) {
     entities.add(SpriteEntity.deserialize(p_buffer));
   }
   return entities;
 }
 /** Serialize this chaining point. */
 @Override
 public void serialize(EasyBuffering p_buffer) {
   int saveX = px;
   int saveY = py;
   if (single) {
     saveX |= 64;
   }
   if (vertical) {
     saveX |= 128;
   }
   if (border) {
     saveY |= 128;
   }
   p_buffer.put((byte) saveX);
   p_buffer.put((byte) saveY);
   p_buffer.put((byte) comingAngle.value);
   p_buffer.put((byte) transitionAnim.ordinal());
   p_buffer.put(mapname);
 }
 /**
  * Deserialize a ByteBuffer into a KeyboardInstant object.
  *
  * @param p_buffer
  * @return
  */
 public static KeyboardInstant deserialize(EasyBuffering p_buffer) {
   EnumMap<KeysConfiguration, Boolean> instant =
       new EnumMap<KeysConfiguration, Boolean>(KeysConfiguration.class);
   boolean[] bools = p_buffer.readBooleans(KEYS_LENGTH);
   int index = 0;
   for (KeysConfiguration key : KeysConfiguration.values()) {
     instant.put(key, bools[index++]);
   }
   return new KeyboardInstant(instant);
 }
Exemple #8
0
 /**
  * Add given server to the server file {@link Constantes#SERVER_FILE}
  *
  * @param p_serverInfo
  */
 private void saveServerInfos(ServerInfo p_serverInfo) {
   // Read the file
   List<ServerInfo> infos = loadServersInfos();
   // Replace server with same name, if needed.
   int idx = infos.indexOf(p_serverInfo);
   if (idx != -1) {
     infos.remove(idx);
   }
   infos.add(p_serverInfo);
   // And save the file
   EasyBuffering buffer = new EasyBuffering();
   for (ServerInfo info : infos) {
     buffer.put(info.name);
     buffer.put(info.ip);
     buffer.put(info.port);
   }
   EasyWritingFile file = new EasyWritingFile(buffer);
   file.saveFile(Constantes.SERVER_FILE);
 }
  /**
   * Deserialize a chaining point from a given buffer.
   *
   * @param p_buffer
   * @return ChainingPoint
   */
  public static ChainingPoint deserialize(EasyBuffering p_buffer) {
    ChainingPoint pe = new ChainingPoint();
    pe.px = p_buffer.readUnsignedByte();
    pe.py = p_buffer.readUnsignedByte();
    pe.comingAngle = Angle.fromInt(p_buffer.readUnsignedByte());
    pe.transitionAnim = FilterEffect.values()[p_buffer.readUnsignedByte()];
    String mapName = p_buffer.readString();
    pe.mapname = mapName;

    // Set the linked properties
    if ((pe.px & 64) != 0) {
      pe.single = true;
      pe.px &= 128 + 63;
    }
    if (pe.px > 127) {
      pe.vertical = true;
      pe.px &= 127;
    }
    if (pe.py > 127) {
      pe.border = true;
      pe.py &= 127;
    }
    return pe;
  }
Exemple #10
0
 public static PlayerState deserialize(EasyBuffering p_buffer) {
   PlayerState s = new PlayerState(p_buffer.readString(), p_buffer.readInt());
   s.nDied = p_buffer.readInt();
   s.nKill = p_buffer.readInt();
   return s;
 }