Пример #1
0
 public boolean tick(Tickable ticking, int tickID) {
   if (!super.tick(ticking, tickID)) return false;
   if (CMath.bset(flags(), Area.FLAG_INSTANCE_CHILD)) return true;
   if ((--childCheckDown) <= 0) {
     childCheckDown = CHILD_CHECK_INTERVAL;
     synchronized (children) {
       for (int i = children.size() - 1; i >= 0; i--) {
         StdThinInstance childA = (StdThinInstance) children.elementAt(i, 2);
         if (childA.getAreaState() > Area.STATE_ACTIVE) {
           Vector V = (Vector) children.elementAt(i, 3);
           boolean anyInside = false;
           for (int v = 0; v < V.size(); v++) {
             MOB M = (MOB) V.elementAt(v);
             if (CMLib.flags().isInTheGame(M, true)
                 && (M.location() != null)
                 && (M.location().getArea() == childA)) anyInside = true;
           }
           if (!anyInside) {
             children.removeElementsAt(i);
             for (int v = 0; v < V.size(); v++) {
               MOB M = (MOB) V.elementAt(v);
               if ((M.location() != null) && (M.location().getArea() == this))
                 M.setLocation(M.getStartRoom());
             }
             MOB mob = CMClass.sampleMOB();
             for (Enumeration e = childA.getProperMap(); e.hasMoreElements(); ) {
               Room R = (Room) e.nextElement();
               R.executeMsg(mob, CMClass.getMsg(mob, R, null, CMMsg.MSG_EXPIRE, null));
             }
             CMLib.map().delArea(childA);
             childA.destroy();
           }
         }
       }
     }
   }
   return true;
 }
Пример #2
0
 public boolean okMessage(Environmental myHost, CMMsg msg) {
   if (!super.okMessage(myHost, msg)) return false;
   if (CMath.bset(flags(), Area.FLAG_INSTANCE_CHILD)) return true;
   setAreaState(Area.STATE_PASSIVE);
   if ((msg.sourceMinor() == CMMsg.TYP_ENTER)
       && (msg.target() instanceof Room)
       && (CMath.bset(flags(), Area.FLAG_INSTANCE_PARENT))
       && (isRoom((Room) msg.target()))
       && (!CMSecurity.isAllowed(msg.source(), (Room) msg.target(), "CMDAREAS"))
       && (((msg.source().getStartRoom() == null)
           || (msg.source().getStartRoom().getArea() != this)))) {
     synchronized (children) {
       int myDex = -1;
       for (int i = 0; i < children.size(); i++) {
         Vector V = (Vector) children.elementAt(i, 1);
         if (V.contains(msg.source())) {
           myDex = i;
           break;
         }
       }
       HashSet grp = msg.source().getGroupMembers(new HashSet());
       for (int i = 0; i < children.size(); i++) {
         if (i != myDex) {
           Vector V = (Vector) children.elementAt(i, 1);
           for (int v = V.size() - 1; v >= 0; v--) {
             MOB M = (MOB) V.elementAt(v);
             if (grp.contains(M)) {
               if (myDex < 0) {
                 myDex = i;
                 break;
               } else if ((CMLib.flags().isInTheGame(M, true))
                   && (M.location().getArea() != (Area) children.elementAt(i, 2))) {
                 V.remove(M);
                 ((Vector) children.elementAt(myDex, 1)).addElement(M);
               }
             }
           }
         }
       }
       StdThinInstance redirectA = null;
       if (myDex < 0) {
         StdThinInstance newA = (StdThinInstance) this.copyOf();
         newA.properRooms = new Vector(1);
         newA.properRoomIDSet = null;
         newA.metroRoomIDSet = null;
         newA.blurbFlags = new Vector(1);
         newA.setName((++instanceCounter) + "_" + Name());
         newA.flags |= Area.FLAG_INSTANCE_CHILD;
         for (Enumeration e = getProperRoomnumbers().getRoomIDs(); e.hasMoreElements(); )
           newA.addProperRoomnumber(newA.convertToMyArea((String) e.nextElement()));
         redirectA = newA;
         CMLib.map().addArea(newA);
         newA.setAreaState(Area.STATE_ACTIVE); // starts ticking
         children.addElement(CMParms.makeVector(msg.source()), redirectA);
       } else redirectA = (StdThinInstance) children.elementAt(myDex, 2);
       Room R =
           redirectA.getRoom(
               redirectA.convertToMyArea(CMLib.map().getExtendedRoomID((Room) msg.target())));
       if (R != null) msg.setTarget(R);
     }
   }
   return true;
 }