Package marauroa.common.net.message

Examples of marauroa.common.net.message.MessageS2CPerception$CachedCompressedPerception$CacheKey


            MessageC2SKeepAlive msgAlive = new MessageC2SKeepAlive();
            netMan.addMessage(msgAlive);
          }

          logger.debug("Processing Message Perception");
          MessageS2CPerception msgPer = (MessageS2CPerception) msg;
          onPerception(msgPer);

          break;
        }
View Full Code Here


    if (perception == null) {
      /** Until player enters game perception is null */
      return;
    }

    MessageS2CPerception messages2cPerception = new MessageS2CPerception(entry.channel,
            perception);

    stats.add("Perceptions " + (perception.type == 0 ? "DELTA" : "SYNC"), 1);

    /*
     * The perception is build of two parts: the general information and the
     * private information about our object. This private information
     * consists only of attributes that are not visible to every player but
     * the owner, because visible attributes are already stored in the
     * perception.
     */

    if (perception.type == Perception.SYNC) {
      RPObject copy = new RPObject();
      copy.fill(playerObject);
      if (!playerObject.isHidden()) {
        copy.clearVisible(true);
      }
      messages2cPerception.setMyRPObject(copy, null);
    } else {
      RPObject added = new RPObject();
      RPObject deleted = new RPObject();

      try {
        playerObject.getDifferences(added, deleted);
        if (!playerObject.isHidden()) {
          added.clearVisible(false);
          deleted.clearVisible(false);
        }

        if (added.size() == 0) {
          added = null;
        }

        if (deleted.size() == 0) {
          deleted = null;
        }
      } catch (Exception e) {
        logger.error("Error getting object differences", e);
        logger.error(playerObject);
        added = null;
        deleted = null;
      }
      messages2cPerception.setMyRPObject(added, deleted);
    }

    messages2cPerception.setClientID(entry.clientid);
    messages2cPerception.setPerceptionTimestamp(entry.getPerceptionTimestamp());
    messages2cPerception.setProtocolVersion(entry.getProtocolVersion());

    netMan.sendMessage(messages2cPerception);
  }
View Full Code Here

   
    /*
     * Create the perception and serialize it.
     */
    Perception p=zone.getPerception(obj, Perception.SYNC);
    MessageS2CPerception msg=new MessageS2CPerception(null, p);
    Encoder enc=Encoder.get();
    byte[] data=enc.encode(msg);
   
    Decoder dec=Decoder.get();
    List<Message> msgs=dec.decode(null, data);
   
    /*
     * There should only be one message.
     */
    assertEquals(1, msgs.size());
   
    MessageS2CPerception recv=(MessageS2CPerception)msgs.get(0);
    assertTrue(recv.getModifiedAddedRPObjects().isEmpty());
    assertTrue(recv.getModifiedDeletedRPObjects().isEmpty());
    assertTrue(recv.getDeletedRPObjects().isEmpty());
   
    List<RPObject> added=recv.getAddedRPObjects();
    assertEquals(1, added.size());
   
    RPObject recreated=added.get(0);
    assertNotNull(recreated);
    recreatedZone.add(recreated);
   
    assertEquals(obj, recreated);
   
    /*
     * Let's move Zone to the next turn.
     */
    zone.nextTurn();
    recreatedZone.nextTurn();

    /*
     * Remove object from lhand.
     */
    RPSlot lhand = obj.getSlot("lhand");
    RPObject pocket=lhand.getFirst();
    RPObject removed=lhand.remove(pocket.getID());
   
    assertNotNull(removed);
    assertEquals(removed,pocket);
   
    zone.modify(obj);
   
    /*
     * Create the perception and serialize it.
     */
    p=zone.getPerception(obj, Perception.DELTA);
    msg=new MessageS2CPerception(null, p);
    data=enc.encode(msg);
   
    msgs=dec.decode(null, data);
   
    assertEquals("there should only be one message",1, msgs.size());
   
    recv=(MessageS2CPerception)msgs.get(0);
    assertTrue(recv.getAddedRPObjects().isEmpty());
    assertTrue(recv.getModifiedAddedRPObjects().isEmpty());
    assertFalse(recv.getModifiedDeletedRPObjects().isEmpty());
    assertTrue(recv.getDeletedRPObjects().isEmpty());
   
    List<RPObject> modifiedDeleted=recv.getModifiedDeletedRPObjects();
    assertEquals(1, modifiedDeleted.size());
   
    assertNotNull(modifiedDeleted.get(0));
    recreated.applyDifferences(null, modifiedDeleted.get(0));
   
View Full Code Here

       */
    } else {
      previousPerceptions.add(message);

      for (Iterator<MessageS2CPerception> it = previousPerceptions.iterator(); it.hasNext();) {
        MessageS2CPerception previousmessage = it.next();
        if (previousTimestamp + 1 == previousmessage.getPerceptionTimestamp()) {
          try {
            /** OnSync: Keep processing */
            previousTimestamp = previousmessage.getPerceptionTimestamp();

            applyPerceptionDeletedRPObjects(previousmessage, world_instance);
            applyPerceptionModifiedRPObjects(previousmessage, world_instance);
            applyPerceptionAddedRPObjects(previousmessage, world_instance);
            applyPerceptionMyRPObject(previousmessage, world_instance);
View Full Code Here

TOP

Related Classes of marauroa.common.net.message.MessageS2CPerception$CachedCompressedPerception$CacheKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.