Exemplo n.º 1
0
  /** Find objects that are in visibility range. */
  protected void findVisibleObjects() {
    if (owner == null || !owner.isSpawned()) {
      return;
    }

    MapRegion[] regions = owner.getActiveRegion().getNeighbours();
    for (int i = 0; i < regions.length; i++) {
      MapRegion r = regions[i];
      FastMap<Integer, VisibleObject> objects = r.getObjects();
      for (FastMap.Entry<Integer, VisibleObject> e = objects.head(), mapEnd = objects.tail();
          (e = e.getNext()) != mapEnd; ) {
        VisibleObject newObject = e.getValue();
        if (newObject == owner || newObject == null) {
          continue;
        }

        if (!isAwareOf(newObject)) {
          continue;
        }
        if (knownObjects.containsKey(newObject.getObjectId())) {
          continue;
        }

        if (!checkObjectInRange(newObject)
            && !newObject.getKnownList().checkReversedObjectInRange(owner)) {
          continue;
        }

        /** New object is not known. */
        if (add(newObject)) {
          newObject.getKnownList().add(owner);
        }
      }
    }
  }
Exemplo n.º 2
0
 public void doOnAllObjects(Visitor<VisibleObject> visitor) {
   try {
     for (FastMap.Entry<Integer, VisibleObject> e = knownObjects.head(),
             mapEnd = knownObjects.tail();
         (e = e.getNext()) != mapEnd; ) {
       VisibleObject newObject = e.getValue();
       if (newObject != null) {
         visitor.visit(newObject);
       }
     }
   } catch (Exception ex) {
     // log.error("Exception when running visitor on all objects" + ex);
   }
 }
Exemplo n.º 3
0
 public void doOnAllPlayers(Visitor<Player> visitor) {
   if (knownPlayers == null) {
     return;
   }
   try {
     for (FastMap.Entry<Integer, Player> e = knownPlayers.head(), mapEnd = knownPlayers.tail();
         (e = e.getNext()) != mapEnd; ) {
       Player player = e.getValue();
       if (player != null) {
         visitor.visit(player);
       }
     }
   } catch (Exception ex) {
     // log.error("Exception when running visitor on all players" + ex);
   }
 }
Exemplo n.º 4
0
 public int doOnAllNpcs(Visitor<Npc> visitor, int iterationLimit) {
   int counter = 0;
   try {
     for (FastMap.Entry<Integer, VisibleObject> e = knownObjects.head(),
             mapEnd = knownObjects.tail();
         (e = e.getNext()) != mapEnd; ) {
       VisibleObject newObject = e.getValue();
       if (newObject instanceof Npc) {
         if ((++counter) == iterationLimit) {
           break;
         }
         visitor.visit((Npc) newObject);
       }
     }
   } catch (Exception ex) {
     // log.error("Exception when running visitor on all npcs" + ex);
   }
   return counter;
 }
Exemplo n.º 5
0
  @Override
  public void start() {
    this.persistFile.clear();

    if (persistDir != null) {
      this.persistFile
          .append(persistDir)
          .append(File.separator)
          .append(this.name)
          .append("_")
          .append(PERSIST_FILE_NAME);
    } else {
      persistFile
          .append(
              System.getProperty(SCCP_MANAGEMENT_PERSIST_DIR_KEY, System.getProperty(USER_DIR_KEY)))
          .append(File.separator)
          .append(this.name)
          .append("_")
          .append(PERSIST_FILE_NAME);
    }

    logger.info(
        String.format("SCCP Management configuration file path %s", persistFile.toString()));

    try {
      this.load();
    } catch (FileNotFoundException e) {
      logger.warn(
          String.format(
              "Failed to load the Sccp Management configuration file. \n%s", e.getMessage()));
    }

    this.messageFactory = new MessageFactoryImpl(this);

    this.sccpProvider = new SccpProviderImpl(this);

    super.sccpManagement = new SccpManagementProxy(this.getName(), sccpProvider, this);
    super.sccpRoutingControl = new SccpRoutingControl(sccpProvider, this);

    super.sccpManagement.setSccpRoutingControl(sccpRoutingControl);
    super.sccpRoutingControl.setSccpManagement(sccpManagement);

    this.router = new RouterImpl(this.getName(), this);
    this.router.setPersistDir(this.getPersistDir());
    this.router.start();

    this.sccpResource = new SccpResourceImpl(this.getName());
    this.sccpResource.setPersistDir(this.getPersistDir());
    this.sccpResource.start();

    this.sccpRoutingControl.start();
    this.sccpManagement.start();
    // layer3exec.execute(new MtpStreamHandler());

    this.timerExecutors = Executors.newScheduledThreadPool(1);

    for (FastMap.Entry<Integer, Mtp3UserPart> e = this.mtp3UserParts.head(),
            end = this.mtp3UserParts.tail();
        (e = e.getNext()) != end; ) {
      Mtp3UserPart mup = e.getValue();
      mup.addMtp3UserPartListener(this);
    }
    // this.mtp3UserPart.addMtp3UserPartListener(this);

    this.state = State.RUNNING;
  }