public void run() {
   long nextStart = System.currentTimeMillis();
   try {
     while (!dead) {
       long timeToSleep = nextStart - System.currentTimeMillis();
       if (timeToSleep > 10) Thread.sleep(timeToSleep);
       nextStart += Tickable.TIME_TICK;
       if ((CMProps.Bools.MUDSTARTED.property()) && (!CMLib.threads().isAllSuspended())) {
         globalTickCount++;
         for (Iterator<Exit> iter = exits.iterator(); iter.hasNext(); ) {
           Exit exit = iter.next();
           try {
             if (!exit.tick(globalTickCount)) exits.remove(exit);
           } catch (Exception e) {
             Log.errOut("ServiceEngine", e.toString());
           }
         }
         for (Iterator<TimeClock> iter = clocks.iterator(); iter.hasNext(); ) {
           TimeClock clock = iter.next();
           try {
             if (!clock.tick(globalTickCount)) clocks.remove(clock);
           } catch (Exception e) {
             Log.errOut("ServiceEngine", e.toString());
           }
         }
       }
     }
   } catch (InterruptedException e) {
   }
 }
Exemple #2
0
  @Override
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    if (!(CMLib.intermud().imc2online())) {
      mob.tell(L("IMC2 is unavailable."));
      return false;
    }
    commands.remove(0);
    if (commands.size() < 1) {
      IMC2Error(mob);
      return false;
    }
    final String str = (String) commands.get(0);
    if (!(CMLib.intermud().imc2online())) mob.tell(L("IMC2 is unavailable."));
    else if (str.equalsIgnoreCase("list")) CMLib.intermud().giveIMC2MudList(mob);
    else if (str.equalsIgnoreCase("locate"))
      CMLib.intermud().i3locate(mob, CMParms.combine(commands, 1));
    else if (str.equalsIgnoreCase("channels")
        && CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.IMC2))
      CMLib.intermud().giveIMC2ChannelsList(mob);
    else if (str.equalsIgnoreCase("info"))
      CMLib.intermud().imc2mudInfo(mob, CMParms.combine(commands, 1));
    else if (str.equalsIgnoreCase("restart")
        && CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.IMC2)) {
      try {
        mob.tell(CMLib.hosts().get(0).executeCommand("START IMC2"));
      } catch (final Exception e) {
        Log.errOut("IMC2Cmd", e);
      }
    } else IMC2Error(mob);

    return false;
  }
Exemple #3
0
 public Room getRandomGridChild() {
   int x = CMLib.dice().roll(1, xGridSize(), -1);
   int y = CMLib.dice().roll(1, yGridSize(), -1);
   Room R = getMakeGridRoom(x, y);
   if (R == null) Log.errOut("StdThinGrid", roomID() + " failed to get a random child!");
   return R;
 }
Exemple #4
0
 protected Vector loadRecipes() {
   String filename = parametersFile();
   Vector recipes = (Vector) Resources.getResource("PARSED: " + filename);
   if (recipes == null) {
     StringBuffer str =
         new CMFile(Resources.buildResourcePath("skills") + filename, null, true).text();
     recipes = loadList(str);
     if (recipes.size() == 0) Log.errOut("LeatherWorking", "Recipes not found!");
     else {
       Vector pleaseAdd1 = new Vector();
       Vector pleaseAdd2 = new Vector();
       for (int r = 0; r < recipes.size(); r++) {
         Vector V = (Vector) recipes.elementAt(r);
         if (V.size() > 0) {
           Vector V1 = (Vector) V.clone();
           Vector V2 = (Vector) V.clone();
           String name = (String) V.elementAt(RCP_FINALNAME);
           V1.setElementAt("Hard " + name, RCP_FINALNAME);
           V1.setElementAt("" + (CMath.s_int((String) V.elementAt(RCP_LEVEL)) + 5), RCP_LEVEL);
           V2.setElementAt("Studded " + name, RCP_FINALNAME);
           V2.setElementAt("" + (CMath.s_int((String) V.elementAt(RCP_LEVEL)) + 11), RCP_LEVEL);
           pleaseAdd1.addElement(V1);
           pleaseAdd2.addElement(V2);
         }
       }
       for (int i = 0; i < pleaseAdd1.size(); i++) recipes.addElement(pleaseAdd1.elementAt(i));
       for (int i = 0; i < pleaseAdd2.size(); i++) recipes.addElement(pleaseAdd2.elementAt(i));
     }
     Resources.submitResource("PARSED: " + filename, recipes);
   }
   return recipes;
 }
Exemple #5
0
 @Override
 public void destroy() {
   try {
     CharStats savedCStats = charStats;
     if (charStats == baseCharStats)
       savedCStats = (CharStats) CMClass.getCommon("DefaultCharStats");
     PhyStats savedPStats = phyStats;
     if (phyStats == basePhyStats) savedPStats = (PhyStats) CMClass.getCommon("DefaultPhyStats");
     final CharState savedCState = curState;
     if ((curState == baseState) || (curState == maxState))
       curState = (CharState) CMClass.getCommon("DefaultCharState");
     super.destroy();
     removeFromGame = false;
     charStats = savedCStats;
     phyStats = savedPStats;
     curState = savedCState;
     baseCharStats.reset();
     basePhyStats.reset();
     baseState.reset();
     maxState.reset();
     curState.reset();
     phyStats.reset();
     charStats.reset();
     finalize();
   } catch (final Throwable t) {
     Log.errOut(ID(), t);
   }
 }
 @Override
 public void setAllValues(int def) {
   if ((def > Short.MAX_VALUE) || (def < Short.MIN_VALUE))
     Log.errOut("Value out of range", new CMException("Value out of range: " + def + " for all"));
   for (final int i : CharStats.CODES.ALLCODES()) stats[i] = (short) def;
   unwearableBitmap = 0;
 }
Exemple #7
0
 @Override
 public CMObject newInstance() {
   try {
     return this.getClass().newInstance();
   } catch (final Exception e) {
     Log.errOut(ID(), e);
   }
   return new StdFactoryMOB();
 }
Exemple #8
0
 public static CM1Command newInstance(
     Class<? extends CM1Command> cls, RequestHandler req, String parms) {
   try {
     if (cls == null) return null;
     return cls.getConstructor(RequestHandler.class, String.class).newInstance(req, parms);
   } catch (Exception e) {
     Log.errOut("CM1Command", e);
     return null;
   }
 }
Exemple #9
0
 public void run() {
   try {
     req.sendMsg("[OK]");
     com.planet_ink.coffee_mud.application.MUD.globalShutdown(null, true, null);
     req.close();
   } catch (java.io.IOException ioe) {
     Log.errOut(className, ioe);
     req.close();
   }
 }
Exemple #10
0
  public void startCharacter(MOB mob, boolean isBorrowedClass, boolean verifyOnly) {
    if (!loaded()) {
      setLoaded(true);
      LinkedList<CharClass> charClassesOrder = new LinkedList<CharClass>();
      HashSet<String> names = new HashSet<String>();
      for (Enumeration<CharClass> c = CMClass.charClasses(); c.hasMoreElements(); ) {
        CharClass C = c.nextElement();
        if (C.baseClass().equals(C.ID())
            && (!C.baseClass().equalsIgnoreCase("Archon"))
            && (!C.baseClass().equalsIgnoreCase("PlayerClass"))
            && (!C.baseClass().equalsIgnoreCase("Qualifier"))
            && (!C.baseClass().equalsIgnoreCase("StdCharClass"))) {
          names.add(C.ID());
          charClassesOrder.add(C);
        }
      }
      for (Enumeration<CharClass> c = CMClass.charClasses(); c.hasMoreElements(); ) {
        CharClass C = c.nextElement();
        if (!names.contains(C.ID()) && names.contains(C.baseClass())) charClassesOrder.add(C);
      }
      for (Enumeration<CharClass> c = CMClass.charClasses(); c.hasMoreElements(); ) {
        CharClass C = c.nextElement();
        if (C.baseClass().equals("Commoner") && (!names.contains(C.ID()))) charClassesOrder.add(C);
      }

      for (CharClass C : charClassesOrder) {
        LinkedList<List<String>> prevSets = new LinkedList<List<String>>();
        for (int lvl = 1; lvl < CMProps.getIntVar(CMProps.Int.LASTPLAYERLEVEL); lvl++) {
          List<String> curSet = CMLib.ableMapper().getLevelListings(C.ID(), false, lvl);
          for (String ID : curSet) {
            String defaultParam = CMLib.ableMapper().getDefaultParm(C.ID(), true, ID);
            if (CMLib.ableMapper().getQualifyingLevel(ID(), false, ID) < 0) {
              Ability A = CMClass.getAbility(ID);
              if (A == null) {
                Log.errOut("Unknonwn class: " + ID);
                continue;
              }
              List<String> reqSet = makeRequirements(prevSets, A);
              if (reqSet.size() > 0) reqSet = new XVector<String>(CMParms.toStringList(reqSet));
              int level = 0;
              if (!this.leveless() && (!CMSecurity.isDisabled(DisFlag.LEVELS)))
                level = CMLib.ableMapper().lowestQualifyingLevel(A.ID());
              if (level < 0) level = 0;
              CMLib.ableMapper()
                  .addCharAbilityMapping(ID(), 0, ID, 0, defaultParam, false, false, reqSet, "");
            }
          }
          if (curSet.size() > 0) prevSets.add(curSet);
        }
      }
    }
    super.startCharacter(mob, false, verifyOnly);
  }
 @Override
 public void setNonBaseStatsFromString(String str) {
   final List<String> V = CMParms.parseSemicolons(str, false);
   final CharStats.CODES C = CharStats.CODES.instance();
   for (final int x : C.all()) {
     if ((!C.isBase(x)) && (x != CharStats.STAT_GENDER) && (V.size() > 0)) {
       final long val = CMath.s_long(V.remove(0));
       if ((val > Short.MAX_VALUE) || (val < Short.MIN_VALUE))
         Log.errOut(
             "Value out of range", "Value out of range: " + val + " for " + x + " from " + str);
       stats[x] = (short) val;
     }
   }
 }
Exemple #12
0
  protected final Map<String, Double> getRatesFor(final Environmental affecting, String currency) {
    if (spaceMaxCut <= 0.0) return rates;
    currency = currency.toUpperCase();
    if (rates.containsKey(currency)) return rates;
    String myCurrency = CMLib.beanCounter().getCurrency(affecting);
    if (myCurrency.equalsIgnoreCase(currency)) {
      rates.put(currency, Double.valueOf(cut));
      return rates;
    }
    SpaceObject homeO = CMLib.map().getSpaceObject(affecting, false);
    if (homeO != null) {
      myCurrency = CMLib.beanCounter().getCurrency(homeO);
      if (myCurrency.equalsIgnoreCase(currency)) {
        rates.put(currency, Double.valueOf(cut));
        return rates;
      }
    } else {
      // no space object, wtf? this SHOULD fail
      if (!complainedAboutSpaceError) {
        complainedAboutSpaceError = true;
        Log.errOut(
            "MoneyChanger", affecting.Name() + " is not on a planet, so space rates cannot apply!");
      }
      return rates;
    }
    for (Enumeration<Area> a = CMLib.map().spaceAreas(); a.hasMoreElements(); ) {
      Area A = a.nextElement();
      if ((A != null) && (A != homeO)) {
        myCurrency = CMLib.beanCounter().getCurrency(A);
        if (myCurrency.equalsIgnoreCase(currency)) {
          SpaceObject oA = (SpaceObject) A;
          long distance = CMLib.map().getDistanceFrom(homeO, oA);
          if ((distance < 0) || (distance > spaceMaxDistance)) {
            rates.put(currency, Double.valueOf(spaceMaxCut));
          } else {
            double pct = CMath.div(distance, spaceMaxDistance);
            double amt = spaceMaxCut * pct;
            if (amt < cut) amt = cut;
            rates.put(currency, Double.valueOf(cut));
          }
          return rates;
        }
      }
    }

    return rates;
  }
 @Override
 protected List<List<String>> loadRecipes() {
   final String filename = parametersFile();
   @SuppressWarnings("unchecked")
   List<List<String>> recipes =
       (List<List<String>>) Resources.getResource("PARSED_RECIPE: " + filename);
   if (recipes == null) {
     final StringBuffer str =
         new CMFile(Resources.buildResourcePath("skills") + filename, null, CMFile.FLAG_LOGERRORS)
             .text();
     recipes = loadList(str);
     if (recipes.size() == 0) Log.errOut("LeatherWorking", "Recipes not found!");
     else {
       final List<List<String>> newRecipes = new Vector<List<String>>();
       for (int r = 0; r < recipes.size(); r++) {
         final List<String> V = recipes.get(r);
         if (V.size() > 0) {
           final String name = V.get(RCP_FINALNAME);
           final int baseLevel = CMath.s_int(V.get(RCP_LEVEL)) + 2;
           for (final Stage s : Stage.values()) {
             final List<String> V1 = new XVector<String>(V);
             V1.set(RCP_FINALNAME, s.name() + " " + name);
             final int level = baseLevel + s.recipeLevel;
             V1.set(RCP_LEVEL, "" + level);
             for (int i = 0; i <= newRecipes.size(); i++) {
               if (newRecipes.size() == i) {
                 newRecipes.add(V1);
                 break;
               } else if (CMath.s_int(newRecipes.get(i).get(RCP_LEVEL)) > level) {
                 newRecipes.add(i, V1);
                 break;
               }
             }
           }
         }
       }
       recipes.clear();
       recipes = newRecipes;
     }
     Resources.submitResource("PARSED_RECIPE: " + filename, recipes);
   }
   return recipes;
 }
 public List<DatabaseEngine.AckRecord> DBReadAbilities() {
   DBConnection D = null;
   Vector<DatabaseEngine.AckRecord> rows = new Vector<DatabaseEngine.AckRecord>();
   try {
     D = DB.DBFetch();
     ResultSet R = D.query("SELECT * FROM CMGAAC");
     while (R.next())
       rows.addElement(
           new DatabaseEngine.AckRecord(
               DBConnections.getRes(R, "CMGAID"),
               DBConnections.getRes(R, "CMGAAT"),
               DBConnections.getRes(R, "CMGACL")));
   } catch (Exception sqle) {
     Log.errOut("DataLoader", sqle);
   } finally {
     DB.DBDone(D);
   }
   // log comment
   return rows;
 }
 @Override
 public void setRacialStat(final int abilityCode, final int racialMax) {
   if ((!CharStats.CODES.isBASE(abilityCode)) || (getStat(abilityCode) == VALUE_ALLSTATS_DEFAULT))
     setPermanentStat(abilityCode, racialMax);
   else {
     final int baseMax = CMProps.getIntVar(CMProps.Int.BASEMAXSTAT);
     int currMax = getStat(CharStats.CODES.toMAXBASE(abilityCode)) + baseMax;
     if (currMax <= 0) currMax = 1;
     int curStat = getStat(abilityCode);
     if (curStat > currMax * 7) {
       final String errorMsg =
           "Detected mob with "
               + curStat
               + "/"
               + currMax
               + " "
               + CharStats.CODES.ABBR(abilityCode);
       @SuppressWarnings({"unchecked", "rawtypes"})
       Set<String> errs = (Set) Resources.getResource("SYSTEM_DEFCHARSTATS_ERRORS");
       if (errs == null) {
         errs = new TreeSet<String>();
         Resources.submitResource("SYSTEM_DEFCHARSTATS_ERRORS", errs);
       }
       if (!errs.contains(errorMsg)) {
         errs.add(errorMsg);
         final StringBuilder str = new StringBuilder(errorMsg);
         // ByteArrayOutputStream stream=new ByteArrayOutputStream();
         // new Exception().printStackTrace(new PrintStream(stream));
         // str.append("\n\r"+new String(stream.toByteArray()));
         Log.errOut("DefCharStats", str.toString());
       }
       curStat = currMax * 7;
     }
     final int pctOfMax = Math.round(((float) curStat / (float) currMax) * racialMax);
     final int stdMaxAdj =
         Math.round((((float) (currMax - VALUE_ALLSTATS_DEFAULT)) / (float) currMax) * racialMax);
     final int racialStat = pctOfMax + stdMaxAdj;
     setStat(abilityCode, ((racialStat < 1) && (racialMax > 0)) ? 1 : racialStat);
     setStat(CharStats.CODES.toMAXBASE(abilityCode), racialMax - baseMax);
   }
 }
Exemple #16
0
 @Override
 public boolean execute(MOB mob, Vector<String> commands, int metaFlags) {
   String helpStr = CMParms.combine(commands, 1);
   if (CMLib.help().getArcHelpFile().size() == 0) {
     mob.tell("No archon help is available.");
     return false;
   }
   String thisTag = null;
   if (helpStr.length() == 0) {
     StringBuffer thisBuf = Resources.getFileResource("help/arc_help.txt", true);
     if (thisBuf != null) thisTag = thisBuf.toString();
   } else thisTag = CMLib.help().getHelpText(helpStr, CMLib.help().getArcHelpFile(), mob);
   if (thisTag == null) {
     mob.tell(
         "No archon help is available on "
             + helpStr
             + " .\r\nEnter 'COMMANDS' for a command list, or 'TOPICS' for a complete list.");
     Log.errOut("Help: " + mob.name() + " wanted archon help on " + helpStr);
   } else if (!mob.isMonster()) mob.session().wraplessPrintln(thisTag);
   return false;
 }
 public void startSpeaking(MOB mob) {
   Room mobHomeRoom = mob.getStartRoom();
   Area mobHomeArea = ((mobHomeRoom == null) ? null : mobHomeRoom.getArea());
   if (((lang != null) || (langStr.length() > 0))
       && (doPlayers || mob.isMonster())
       && ((!noMobs) || (!mob.isMonster()))
       && ((!homeOnly) || (homeRoom == null) || (mobHomeRoom == homeRoom))
       && ((!homeOnly) || (homeArea == null) || (mobHomeArea == homeArea))
       && (mob.fetchEffect(langStr) == null)
       && ((mobMask == null) || CMLib.masking().maskCheck(mobMask, mob, true))) {
     if (lang == null) lang = getLanguage();
     if (lang == null) {
       lang = (Language) CMClass.getAbility("Common");
       Log.errOut("Prop_LanguageSpeaker", "Unknown language " + langStr);
     }
     if (lang != null) {
       switch (affectedType) {
         case AREA:
           lang = (Language) lang.copyOf();
           break;
         case LOCALE:
           lang = (Language) lang.copyOf();
           break;
         case MOB:
           break;
         case EXIT:
           lang = (Language) lang.copyOf();
           break;
         default: // item
           break;
       }
       mob.addNonUninvokableEffect(lang);
       lang.setSavable(false);
       lang.invoke(mob, mob, false, 0);
     }
   }
 }
  /*
  	public void insertOrderDeathInOrder(DVector DV, long lastStart, String msg, Tick tock)
  	{
  		if(DV.size()>0)
  		for(int i=0;i<DV.size();i++)
  		{
  			if(((Long)DV.elementAt(i,0)).longValue()>lastStart)
  			{
  				DV.insertRowAt(i,Long.valueOf(lastStart),msg,tock);
  				return;
  			}
  		}
  		DV.addRow(Long.valueOf(lastStart),msg,tock);
  	}
  */
  public void checkHealth() {
    long lastDateTime = System.currentTimeMillis() - (5 * CoffeeTime.MILI_MINUTE);
    // long longerDateTime=System.currentTimeMillis()-(120*CoffeeTime.MILI_MINUTE);
    // thread.status("checking");

    ArrayList<TickArea> orderedDeaths = new ArrayList();
    thread.status("checking tick groups.");
    /*for(Iterator<Tick> e=ticks.iterator();e.hasNext();)
    {
    	Tick almostTock=e.next();
    	if((almostTock.awake)
    	&&(almostTock.lastStop<lastDateTime))
    	{
    		//insertOrderDeathInOrder(orderedDeaths,0,"LOCKED GROUP "+almostTock.tickObjectCounter+"! No further information.",almostTock);
    		delTickGroup(almostTock);
    		orderedDeaths.add(almostTock);	//"LOCKED GROUP "+almostTock.tickObjectCounter+"! No further information."
    		// no isDEBUGGING check -- just always let her rip.
    		Log.errOut(thread.getName(),"LOCKED TICK GROUP "+almostTock.tickObjectCounter);
    		thread.debugDumpStack(almostTock);
    	}
    }
    if(orderedDeaths.size()>0)
    {
    	thread.status("killing tick groups.");
    	for(int x=0;x<orderedDeaths.size();x++)
    	{
    		Tick almostTock=orderedDeaths.get(x);
    		ArrayList<TickActer> objs=new ArrayList();
    		try{
    			for(TickActer E : almostTock.tickers())
    				objs.add(E);
    		}catch(NoSuchElementException e){}
    		almostTock.shutdown();
    		//if(CMLib.threads() instanceof ServiceEngine)
    		//	((ServiceEngine)CMLib.threads()).
    		//delTickGroup(almostTock);
    		for(int i=0;i<objs.size();i++)
    			startTickDown(objs.get(i));
    	}
    	orderedDeaths.clear();
    }*/
    thread.status("checking areas.");
    for (Iterator<TickArea> e = areas.iterator(); e.hasNext(); ) {
      TickArea almostTock = e.next();
      if ((almostTock.awake) && (almostTock.lastStop < lastDateTime)) {
        delArea(almostTock);
        // orderedDeaths.add(almostTock);	//"LOCKED GROUP "+almostTock.tickObjectCounter+"! No
        // further information."
        almostTock.shutdown();
        Log.errOut(thread.getName(), "LOCKED TICK GROUP " + almostTock.tickObjectCounter);
        thread.debugDumpStack(almostTock);
        startArea(almostTock.clientObject, almostTock.TICK_TIME);
      }
    }
    /*
    		thread.status("Checking mud threads");
    		for(int m=0;m<CMLib.hosts().size();m++)
    		{
    			Vector badThreads=((MudHost)CMLib.hosts().elementAt(m)).getOverdueThreads();
    			if(badThreads.size()>0)
    			{
    				for(int b=0;b<badThreads.size();b++)
    				{
    					Thread T=(Thread)badThreads.elementAt(b);
    					String threadName=T.getName();
    					if(T instanceof Tickable)
    						threadName=((Tickable)T).ID()+" ("+((Tickable)T).ID()+"): "+((Tickable)T).getTickStatus();
    					thread.status("Killing "+threadName);
    					Log.errOut("Killing stray thread: "+threadName);
    					CMLib.killThread(T,100,1);
    				}
    			}
    		}
    		thread.status("Done checking threads");
    */
  }
Exemple #19
0
    public CODES() {
      super();
      char c = Thread.currentThread().getThreadGroup().getName().charAt(0);
      if (insts == null) insts = new CODES[256];
      if (insts[c] == null) insts[c] = this;
      synchronized (this) {
        String[][] addExtra = CMProps.instance().getStrsStarting("ADDWEARLOC_");
        String[][] repExtra = CMProps.instance().getStrsStarting("REPLACEWEARLOC_");
        for (int i = 0; i < Wearable.DEFAULT_WORN_CODES.length; i++)
          add(
              DEFAULT_WORN_DESCS[i],
              DEFAULT_WORN_DEPENDENCYGRID[i],
              DEFAULT_WORN_WEIGHTS[i],
              CMParms.indexOf(DEFAULT_WORN_ORDER, DEFAULT_WORN_CODES[i]),
              DEFAULT_WORN_WEIGHT_POINTS[i][0],
              DEFAULT_WORN_WEIGHT_POINTS[i][1],
              DEFAULT_WORN_WEIGHT_POINTS[i][2]);
        // now, stupid as it is, I have to fix the worn orders
        allCodesInOrder =
            Arrays.copyOf(Wearable.DEFAULT_WORN_ORDER, Wearable.DEFAULT_WORN_ORDER.length);

        for (int i = 0; i < addExtra.length + repExtra.length; i++) {
          String[] array = (i >= addExtra.length) ? repExtra[i - addExtra.length] : addExtra[i];
          boolean replace = i >= addExtra.length;
          String stat = array[0].toLowerCase().trim().replace('_', ' ');
          String p = array[1];
          List<String> V = CMParms.parseCommas(p, false);
          if (V.size() != 6) {
            Log.errOut(
                "Wearable",
                "Bad coffeemud.ini wear loc row (requires 6 elements, separated by ,): " + p);
            continue;
          }
          String type = "ADD";
          int oldLocationCodeIndex = -1;
          if (replace) {
            int idx = CMParms.indexOf(DEFAULT_WORN_DESCS, stat);
            if (idx >= 0) {
              oldLocationCodeIndex = idx;
              type = "REPLACE";
            } else {
              Log.errOut("Wearable", "Bad replace worn loc in coffeemud.ini file: " + stat);
              continue;
            }
          }
          String dependencyMaskStr = ((String) V.get(0)).toLowerCase();
          long dependencyMask = 0;
          List<String> subLocs = CMParms.parseAny(dependencyMaskStr, '|', true);
          for (int s = 0; s < subLocs.size(); s++) {
            int idx = CMParms.indexOf(DEFAULT_WORN_DESCS, subLocs.get(s).toLowerCase());
            if (idx >= 0) dependencyMask |= DEFAULT_WORN_CODES[idx];
            else
              Log.errOut(
                  "Wearable",
                  "Bad dependency mask in coffeemud.ini file: " + subLocs.get(s).toLowerCase());
          }
          double armorStrength = CMath.s_double(V.get(1));
          int wornOrder = CMath.s_int(V.get(2));
          double clothWeight = CMath.s_double(V.get(3));
          double leatherWeight = CMath.s_double(V.get(4));
          double metalWeight = CMath.s_double(V.get(5));
          if (type.equalsIgnoreCase("ADD"))
            add(
                stat,
                dependencyMask,
                armorStrength,
                wornOrder,
                clothWeight,
                leatherWeight,
                metalWeight);
          else if (type.equalsIgnoreCase("REPLACE") && (oldLocationCodeIndex >= 0))
            replace(
                oldLocationCodeIndex,
                stat,
                dependencyMask,
                armorStrength,
                wornOrder,
                clothWeight,
                leatherWeight,
                metalWeight);
        }
      }
    }
Exemple #20
0
 @Override
 public void clear() {
   Log.errOut("ReadOnlyVector", new UnsupportedOperationException());
 }
Exemple #21
0
 @Override
 public synchronized T remove(int index) {
   Log.errOut("ReadOnlyVector", new UnsupportedOperationException());
   return null;
 }
Exemple #22
0
 @Override
 public void add(int index, T element) {
   Log.errOut("ReadOnlyVector", new UnsupportedOperationException());
 }
Exemple #23
0
 @Override
 public boolean remove(Object o) {
   Log.errOut("ReadOnlyVector", new UnsupportedOperationException());
   return false;
 }
Exemple #24
0
 @Override
 public synchronized boolean removeElement(Object obj) {
   Log.errOut("ReadOnlyVector", new UnsupportedOperationException());
   return false;
 }
Exemple #25
0
 @Override
 public synchronized void removeElementAt(int index) {
   Log.errOut("ReadOnlyVector", new UnsupportedOperationException());
 }
Exemple #26
0
 @Override
 public synchronized void addElement(T t) {
   Log.errOut("ReadOnlyVector", new UnsupportedOperationException());
 }
Exemple #27
0
 @Override
 public synchronized boolean add(T t) {
   Log.errOut("ReadOnlyVector", new UnsupportedOperationException());
   return false;
 }
Exemple #28
0
 @Override
 public synchronized boolean addAll(int index, Collection<? extends T> c) {
   Log.errOut("ReadOnlyVector", new UnsupportedOperationException());
   return false;
 }
Exemple #29
0
 @Override
 public synchronized boolean removeAll(Collection<?> c) {
   Log.errOut("ReadOnlyVector", new UnsupportedOperationException());
   return false;
 }
Exemple #30
0
  public void checkHealth() {
    long lastDateTime = System.currentTimeMillis() - (5 * TimeManager.MILI_MINUTE);
    long longerDateTime = System.currentTimeMillis() - (120 * TimeManager.MILI_MINUTE);
    thread.status("checking");

    thread.status("checking tick groups.");
    DVector orderedDeaths = new DVector(3);
    try {
      Tick almostTock = null;
      for (Iterator<Tick> e = tickGroups(); e.hasNext(); ) {
        almostTock = e.next();
        if ((almostTock.awake) && (almostTock.lastStop < lastDateTime)) {
          TockClient client = almostTock.lastClient;
          if (client == null)
            insertOrderDeathInOrder(
                orderedDeaths,
                0,
                "LOCKED GROUP " + almostTock.getCounter() + "! No further information.",
                almostTock);
          else if ((!CMath.bset(client.tickID, Tickable.TICKID_LONGERMASK))
              || (almostTock.lastStop < longerDateTime)) {
            if (client.clientObject == null)
              insertOrderDeathInOrder(
                  orderedDeaths,
                  0,
                  "LOCKED GROUP "
                      + almostTock.getCounter()
                      + ": NULL @"
                      + CMLib.time().date2String(client.lastStart)
                      + ", tickID "
                      + client.tickID,
                  almostTock);
            else {
              StringBuffer str = null;
              Tickable obj = client.clientObject;
              long code = client.clientObject.getTickStatus();
              String codeWord = CMLib.threads().getTickStatusSummary(client.clientObject);
              String msg = null;
              if (obj instanceof Environmental)
                str =
                    new StringBuffer(
                        "LOCKED GROUP "
                            + almostTock.getCounter()
                            + " : "
                            + obj.name()
                            + " ("
                            + ((Environmental) obj).ID()
                            + ") @"
                            + CMLib.time().date2String(client.lastStart)
                            + ", status("
                            + code
                            + " ("
                            + codeWord
                            + "), tickID "
                            + client.tickID);
              else
                str =
                    new StringBuffer(
                        "LOCKED GROUP "
                            + almostTock.getCounter()
                            + ": "
                            + obj.name()
                            + ", status("
                            + code
                            + " ("
                            + codeWord
                            + ") @"
                            + CMLib.time().date2String(client.lastStart)
                            + ", tickID "
                            + client.tickID);

              if ((obj instanceof MOB) && (((MOB) obj).location() != null))
                msg = str.toString() + " in " + ((MOB) obj).location().roomID();
              else if ((obj instanceof Item)
                  && (((Item) obj).owner() != null)
                  && (((Item) obj).owner() instanceof Room))
                msg = str.toString() + " in " + ((Room) ((Item) obj).owner()).roomID();
              else if ((obj instanceof Item)
                  && (((Item) obj).owner() != null)
                  && (((Item) obj).owner() instanceof MOB))
                msg = str.toString() + " owned by " + ((MOB) ((Item) obj).owner()).name();
              else if (obj instanceof Room) msg = str.toString() + " is " + ((Room) obj).roomID();
              else msg = str.toString();
              insertOrderDeathInOrder(orderedDeaths, client.lastStart, msg, almostTock);
            }
          }
          // no isDEBUGGING check -- just always let her rip.
          thread.debugDumpStack(almostTock);
        }
      }
    } catch (java.util.NoSuchElementException e) {
    }
    for (int i = 0; i < orderedDeaths.size(); i++)
      Log.errOut(thread.getName(), (String) orderedDeaths.elementAt(i, 2));

    thread.status("killing tick groups.");
    for (int x = 0; x < orderedDeaths.size(); x++) {
      Tick almostTock = (Tick) orderedDeaths.elementAt(x, 3);
      Vector objs = new Vector();
      try {
        for (Iterator e = almostTock.tickers(); e.hasNext(); ) objs.addElement(e.next());
      } catch (NoSuchElementException e) {
      }
      almostTock.shutdown();
      if (CMLib.threads() instanceof ServiceEngine)
        ((ServiceEngine) CMLib.threads()).delTickGroup(almostTock);
      for (int i = 0; i < objs.size(); i++) {
        TockClient c = (TockClient) objs.elementAt(i);
        CMLib.threads().startTickDown(c.clientObject, c.tickID, c.reTickDown);
      }
    }

    thread.status("Checking mud threads");
    for (int m = 0; m < CMLib.hosts().size(); m++) {
      Vector badThreads = ((MudHost) CMLib.hosts().elementAt(m)).getOverdueThreads();
      if (badThreads.size() > 0) {
        for (int b = 0; b < badThreads.size(); b++) {
          Thread T = (Thread) badThreads.elementAt(b);
          String threadName = T.getName();
          if (T instanceof Tickable)
            threadName =
                ((Tickable) T).name()
                    + " ("
                    + ((Tickable) T).ID()
                    + "): "
                    + ((Tickable) T).getTickStatus();
          thread.status("Killing " + threadName);
          Log.errOut("Killing stray thread: " + threadName);
          CMLib.killThread(T, 100, 1);
        }
      }
    }

    thread.status("Done checking threads");
  }