コード例 #1
0
 public final byte[] serialize() {
   final byte[] cdata = StringUtils.toUTF8(this.m_criterion);
   final int presize = cdata.length;
   final ByteBuffer bb = ByteBuffer.allocate(32 + presize);
   bb.putInt(this.m_id);
   bb.put(this.m_order);
   bb.putInt(this.m_gfx);
   bb.putInt(cdata.length);
   bb.put(cdata);
   bb.put((byte) (this.m_success ? 1 : 0));
   bb.putInt(this.m_itemId);
   bb.putShort(this.m_itemQty);
   bb.putInt(this.m_xp);
   bb.putInt(this.m_kama);
   bb.putInt(this.m_guildPoints);
   return bb.array();
 }
コード例 #2
0
 @Override
 public byte[] getBinaryData() {
   final ArrayList<byte[]> binGroups = new ArrayList<byte[]>(this.m_actionGroups.size());
   final ArrayList<byte[]> binRewars = new ArrayList<byte[]>(this.m_rewards.size());
   int presize = 0;
   presize += 4;
   try {
     for (final String var : this.m_varMapping) {
       presize += 4 + var.getBytes("UTF-8").length;
     }
   } catch (Exception e) {
     ScenarioBinaryStorable.m_logger.error((Object) "Exception", (Throwable) e);
   }
   try {
     presize += 8;
     presize +=
         ((this.m_joinCriterion != null) ? this.m_joinCriterion.getBytes("UTF-8").length : 0);
     presize +=
         ((this.m_rewardEligibilityCriterion != null)
             ? this.m_rewardEligibilityCriterion.getBytes("UTF-8").length
             : 0);
   } catch (Exception e) {
     ScenarioBinaryStorable.m_logger.error((Object) "Exception", (Throwable) e);
   }
   for (final ActionGroupStorable g : this.m_actionGroups) {
     final byte[] bin = g.serialize();
     presize += bin.length + 4;
     binGroups.add(bin);
   }
   for (final RewardStorable r : this.m_rewards) {
     final byte[] bin = r.serialize();
     presize += bin.length + 4;
     binRewars.add(bin);
   }
   try {
     presize += 4;
     presize += ((this.m_params != null) ? this.m_params.getBytes("UTF-8").length : 0);
   } catch (Exception e) {
     ScenarioBinaryStorable.m_logger.error((Object) "Exception", (Throwable) e);
   }
   final ByteBuffer bb = ByteBuffer.allocate(31 + presize);
   bb.putInt(this.m_id);
   bb.put(this.m_type);
   bb.put(this.m_userType);
   bb.put((byte) (this.m_autoTrigger ? 1 : 0));
   bb.put((byte) (this.m_isChallenge ? 1 : 0));
   bb.put((byte) (this.m_isChaos ? 1 : 0));
   bb.putShort(this.m_duration);
   bb.putShort(this.m_minUsers);
   bb.putShort(this.m_maxUsers);
   if (this.m_expirationDate != null) {
     bb.putLong(this.m_expirationDate.toLong());
   } else {
     bb.putLong(0L);
   }
   try {
     if (this.m_params != null) {
       final byte[] bytes = this.m_params.getBytes("UTF-8");
       bb.putInt(bytes.length);
       bb.put(bytes);
     } else {
       bb.putInt(0);
     }
   } catch (Exception e2) {
     ScenarioBinaryStorable.m_logger.error((Object) "Exception", (Throwable) e2);
   }
   try {
     bb.putInt(this.m_varMapping.length);
     for (final String var2 : this.m_varMapping) {
       final byte[] bytes2 = var2.getBytes("UTF-8");
       bb.putInt(bytes2.length);
       bb.put(bytes2);
     }
   } catch (Exception e2) {
     ScenarioBinaryStorable.m_logger.error((Object) "Exception", (Throwable) e2);
   }
   try {
     if (this.m_joinCriterion != null) {
       final byte[] bytes = this.m_joinCriterion.getBytes("UTF-8");
       bb.putInt(bytes.length);
       bb.put(bytes);
     } else {
       bb.putInt(0);
     }
     if (this.m_rewardEligibilityCriterion != null) {
       final byte[] bytes = this.m_rewardEligibilityCriterion.getBytes("UTF-8");
       bb.putInt(bytes.length);
       bb.put(bytes);
     } else {
       bb.putInt(0);
     }
   } catch (Exception e2) {
     ScenarioBinaryStorable.m_logger.error((Object) "Exception", (Throwable) e2);
   }
   bb.putInt(binGroups.size());
   for (final byte[] gdata : binGroups) {
     bb.putInt(gdata.length);
     bb.put(gdata);
   }
   bb.putInt(binRewars.size());
   for (final byte[] rdata : binRewars) {
     bb.putInt(rdata.length);
     bb.put(rdata);
   }
   return bb.array();
 }