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) { } }
@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; }
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; }
@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; }
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; }
@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 CMObject newInstance() { try { return this.getClass().newInstance(); } catch (final Exception e) { Log.errOut(ID(), e); } return new StdFactoryMOB(); }
public void setXpCalculationFormulaStr(String newXpCalculationFormula) { if (newXpCalculationFormula == null) newXpCalculationFormula = ""; xpCalculationFormulaStr = newXpCalculationFormula; if (xpCalculationFormulaStr.trim().length() == 0) this.xpCalculationFormula = CMath.compileMathExpression(DEFAULT_XP_FORMULA); else try { this.xpCalculationFormula = CMath.compileMathExpression(xpCalculationFormulaStr); } catch (Exception e) { Log.errOut("DefaultClanGovernment", e.getMessage()); } }
protected List<List<String>> loadRecipes() { String filename = parametersFile(); List<List<String>> recipes = (List<List<String>>) Resources.getResource("PARSED_RECIPE: " + 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 { List<List<String>> pleaseAdd = new Vector(); for (int r = 0; r < recipes.size(); r++) { List<String> V = recipes.get(r); if (V.size() > 0) { String name = (String) V.get(RCP_FINALNAME); int baseLevel = CMath.s_int((String) V.get(RCP_LEVEL)) + 2; List<String> V1 = new XVector<String>(V); V1.set(RCP_FINALNAME, "Cuirbouli " + name); V1.set(RCP_LEVEL, "" + (baseLevel + 37)); pleaseAdd.add(V1); V1 = new XVector<String>(V); V1.set(RCP_FINALNAME, "Reinforced " + name); V1.set(RCP_LEVEL, "" + (baseLevel + 45)); pleaseAdd.add(V1); V1 = new XVector<String>(V); V1.set(RCP_FINALNAME, "Masterwork " + name); V1.set(RCP_LEVEL, "" + (baseLevel + 54)); pleaseAdd.add(V1); V1 = new XVector<String>(V); V1.set(RCP_FINALNAME, "Laminar " + name); V1.set(RCP_LEVEL, "" + (baseLevel + 63)); pleaseAdd.add(V1); V1 = new XVector<String>(V); V1.set(RCP_FINALNAME, "Battlemoulded " + name); V1.set(RCP_LEVEL, "" + (baseLevel + 72)); pleaseAdd.add(V1); V.set(RCP_FINALNAME, "Designer " + name); V.set(RCP_LEVEL, "" + (baseLevel + 30)); } } for (int i = 0; i < pleaseAdd.size(); i++) recipes.add(pleaseAdd.get(i)); } Resources.submitResource("PARSED_RECIPE: " + filename, recipes); } return recipes; }
@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; } } }
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; }
@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); } }
@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 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"); }
public void setStat(String code, String val) { int num = 0; int numDex = code.length(); while ((numDex > 0) && (Character.isDigit(code.charAt(numDex - 1)))) numDex--; if (numDex < code.length()) { num = CMath.s_int(code.substring(numDex)); code = code.substring(0, numDex); } final GOVT_STAT_CODES stat = getStatIndex(code); if (stat == null) { return; } switch (stat) { case NAME: name = val; break; case AUTOROLE: { ClanPosition P = getPosition(val); if (P != null) autoRole = P.getRoleID(); break; } case ACCEPTPOS: { ClanPosition P = getPosition(val); if (P != null) acceptPos = P.getRoleID(); break; } case SHORTDESC: shortDesc = val; break; case LONGDESC: longDesc = val; break; case XPLEVELFORMULA: setXpCalculationFormulaStr(val); break; case REQUIREDMASK: requiredMaskStr = val; break; case ISPUBLIC: isPublic = CMath.s_bool(val); break; case ISFAMILYONLY: isFamilyOnly = CMath.s_bool(val); break; case OVERRIDEMINMEMBERS: { if (val.length() == 0) overrideMinMembers = null; else overrideMinMembers = Integer.valueOf(CMath.s_int(val)); break; } case CONQUESTENABLED: conquestEnabled = CMath.s_bool(val); break; case CONQUESTITEMLOYALTY: conquestItemLoyalty = CMath.s_bool(val); break; case CONQUESTDEITYBASIS: conquestByWorship = CMath.s_bool(val); break; case MAXVOTEDAYS: maxVoteDays = CMath.s_int(val); break; case VOTEQUORUMPCT: voteQuorumPct = CMath.s_int(val); break; case AUTOPROMOTEBY: { Clan.AutoPromoteFlag flag = (Clan.AutoPromoteFlag) CMath.s_valueOf(Clan.AutoPromoteFlag.values(), val); if (flag != null) autoPromoteBy = flag; break; } case VOTEFUNCS: { final Vector<String> funcs = CMParms.parseCommas(val.toUpperCase().trim(), true); for (ClanPosition pos : positions) { for (int a = 0; a < Function.values().length; a++) if (pos.getFunctionChart()[a] == Authority.MUST_VOTE_ON) pos.getFunctionChart()[a] = Authority.CAN_NOT_DO; for (final String funcName : funcs) { Authority auth = (Authority) CMath.s_valueOf(Function.values(), funcName); if (auth != null) pos.getFunctionChart()[auth.ordinal()] = Authority.MUST_VOTE_ON; } } break; } case NUMRABLE: clanAbilityMap = null; if (CMath.s_int(val) == 0) { clanAbilityNames = null; clanAbilityProficiencies = null; clanAbilityQuals = null; clanAbilityLevels = null; } else { clanAbilityNames = new String[CMath.s_int(val)]; clanAbilityProficiencies = new int[CMath.s_int(val)]; clanAbilityQuals = new boolean[CMath.s_int(val)]; clanAbilityLevels = new int[CMath.s_int(val)]; } break; case GETRABLE: { if (clanAbilityNames == null) clanAbilityNames = new String[num + 1]; clanAbilityNames[num] = val; break; } case GETRABLEPROF: { if (clanAbilityProficiencies == null) clanAbilityProficiencies = new int[num + 1]; clanAbilityProficiencies[num] = CMath.s_parseIntExpression(val); break; } case GETRABLEQUAL: { if (clanAbilityQuals == null) clanAbilityQuals = new boolean[num + 1]; clanAbilityQuals[num] = CMath.s_bool(val); break; } case GETRABLELVL: { if (clanAbilityLevels == null) clanAbilityLevels = new int[num + 1]; clanAbilityLevels[num] = CMath.s_parseIntExpression(val); break; } case NUMREFF: clanEffectMap = null; if (CMath.s_int(val) == 0) { clanEffectNames = null; clanEffectParms = null; clanEffectLevels = null; } else { clanEffectNames = new String[CMath.s_int(val)]; clanEffectParms = new String[CMath.s_int(val)]; clanEffectLevels = new int[CMath.s_int(val)]; } break; case GETREFF: { if (clanEffectNames == null) clanEffectNames = new String[num + 1]; clanEffectNames[num] = val; break; } case GETREFFPARM: { if (clanEffectParms == null) clanEffectParms = new String[num + 1]; clanEffectParms[num] = val; break; } case GETREFFLVL: { if (clanEffectLevels == null) clanEffectLevels = new int[num + 1]; clanEffectLevels[num] = CMath.s_int(val); break; } default: Log.errOut("Clan", "setStat:Unhandled:" + stat.toString()); break; } }
public String getStat(String code) { int num = 0; int numDex = code.length(); while ((numDex > 0) && (Character.isDigit(code.charAt(numDex - 1)))) numDex--; if (numDex < code.length()) { num = CMath.s_int(code.substring(numDex)); code = code.substring(0, numDex); } final GOVT_STAT_CODES stat = getStatIndex(code); if (stat == null) { return ""; } switch (stat) { case NAME: return name; case AUTOROLE: return (autoRole < 0 || autoRole > positions.length) ? "" : positions[autoRole].getID(); case ACCEPTPOS: return (acceptPos < 0 || acceptPos > positions.length) ? "" : positions[acceptPos].getID(); case SHORTDESC: return shortDesc; case LONGDESC: return longDesc; case XPLEVELFORMULA: return xpCalculationFormulaStr == null ? "" : xpCalculationFormulaStr; case REQUIREDMASK: return requiredMaskStr; case ISPUBLIC: return Boolean.toString(isPublic); case ISFAMILYONLY: return Boolean.toString(isFamilyOnly); case OVERRIDEMINMEMBERS: return overrideMinMembers == null ? "" : overrideMinMembers.toString(); case CONQUESTENABLED: return Boolean.toString(conquestEnabled); case CONQUESTITEMLOYALTY: return Boolean.toString(conquestItemLoyalty); case CONQUESTDEITYBASIS: return Boolean.toString(conquestByWorship); case MAXVOTEDAYS: return Integer.toString(maxVoteDays); case VOTEQUORUMPCT: return Integer.toString(voteQuorumPct); case AUTOPROMOTEBY: return autoPromoteBy.toString(); case VOTEFUNCS: { final StringBuilder str = new StringBuilder(""); for (ClanPosition pos : positions) { for (int a = 0; a < Function.values().length; a++) if (pos.getFunctionChart()[a] == Authority.MUST_VOTE_ON) { if (str.length() > 0) str.append(","); str.append(Function.values()[a]); } break; } return str.toString(); } case NUMRABLE: return (clanAbilityNames == null) ? "0" : ("" + clanAbilityNames.length); case GETRABLE: return (clanAbilityNames == null) ? "" : ("" + clanAbilityNames[num]); case GETRABLEPROF: return (clanAbilityProficiencies == null) ? "0" : ("" + clanAbilityProficiencies[num]); case GETRABLEQUAL: return (clanAbilityQuals == null) ? "false" : ("" + clanAbilityQuals[num]); case GETRABLELVL: return (clanAbilityLevels == null) ? "0" : ("" + clanAbilityLevels[num]); case NUMREFF: return (clanEffectNames == null) ? "0" : ("" + clanEffectNames.length); case GETREFF: return (clanEffectNames == null) ? "" : ("" + clanEffectNames[num]); case GETREFFPARM: return (clanEffectParms == null) ? "0" : ("" + clanEffectParms[num]); case GETREFFLVL: return (clanEffectLevels == null) ? "0" : ("" + clanEffectLevels[num]); default: Log.errOut("Clan", "getStat:Unhandled:" + stat.toString()); break; } return ""; }
/* 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"); */ }