@Override public String text() { if (CMProps.getBoolVar(CMProps.Bool.MOBCOMPRESS)) miscText = CMLib.encoder().compressString(CMLib.coffeeMaker().getPropertiesStr(this, false)); else miscText = CMLib.coffeeMaker().getPropertiesStr(this, false); return super.text(); }
@Override public void run() { nextTickTime = System.currentTimeMillis() + tickTime; // final String oldThreadName=Thread.currentThread().getName(); try { currentThread = Thread.currentThread(); lastStart = System.currentTimeMillis(); lastClient = null; final boolean allSuspended = CMLib.threads().isAllSuspended(); if ((CMProps.getBoolVar(CMProps.Bool.MUDSTARTED)) && (!allSuspended)) { for (final Iterator<TickClient> i = tickers(); i.hasNext(); ) { final TickClient client = i.next(); lastClient = client; // if(client.getCurrentTickDown()<=1) // currentThread.setName(oldThreadName+":"+getName()+":"+client.getName()); if (client.tickTicker(false)) { delTicker(client); // cant do i.remove, its an streeset } } } } finally { lastStop = System.currentTimeMillis(); milliTotal += (lastStop - lastStart); tickTotal++; currentThread = null; // Thread.currentThread().setName(oldThreadName); } if (tickers.size() == 0) { if (CMLib.threads() instanceof ServiceEngine) ((ServiceEngine) CMLib.threads()).delTickGroup(this); } }
// update lot, since its called by the savethread, ONLY worries about itself @Override public void updateLot(List optPlayerList) { if (affected instanceof Room) { Room R = (Room) affected; synchronized (("SYNC" + R.roomID()).intern()) { R = CMLib.map().getRoom(R); lastItemNums = updateLotWithThisData(R, this, false, scheduleReset, optPlayerList, lastItemNums); if ((lastDayDone != R.getArea().getTimeObj().getDayOfMonth()) && (CMProps.getBoolVar(CMProps.Bool.MUDSTARTED))) { lastDayDone = R.getArea().getTimeObj().getDayOfMonth(); if ((getOwnerName().length() > 0) && rentalProperty() && (R.roomID().length() > 0)) if (doRentalProperty(R.getArea(), R.roomID(), getOwnerName(), getPrice())) { setOwnerName(""); CMLib.database().DBUpdateRoom(R); lastItemNums = updateLotWithThisData(R, this, false, scheduleReset, optPlayerList, lastItemNums); } } scheduleReset = false; } } }
public static boolean doRentalProperty(Area A, String ID, String owner, int rent) { if (!CMProps.getBoolVar(CMProps.Bool.MUDSTARTED)) return false; final int month = A.getTimeObj().getMonth(); final int day = A.getTimeObj().getDayOfMonth(); final int year = A.getTimeObj().getYear(); final Object O = Resources.getResource("RENTAL INFO/" + owner); List<PlayerData> pDataV = null; if (O instanceof List) pDataV = (List<PlayerData>) O; else pDataV = CMLib.database().DBReadData(owner, "RENTAL INFO"); if (pDataV == null) pDataV = new Vector(); DatabaseEngine.PlayerData pData = null; if (pDataV.size() == 0) { pData = new DatabaseEngine.PlayerData(); pData.who = owner; pData.section = "RENTAL INFO"; pData.key = "RENTAL INFO/" + owner; pData.xml = ID + "|~>|" + day + " " + month + " " + year + "|~;|"; CMLib.database().DBCreateData(owner, "RENTAL INFO", "RENTAL INFO/" + owner, pData.xml); pDataV.add(pData); Resources.submitResource("RENTAL INFO/" + owner, pDataV); return false; } else if (pDataV.get(0) != null) { pData = pDataV.get(0); String parse = pData.xml; int x = parse.indexOf("|~;|"); final StringBuffer reparse = new StringBuffer(""); boolean changesMade = false; boolean needsToPay = false; while (x >= 0) { String thisOne = parse.substring(0, x); if (thisOne.startsWith(ID + "|~>|")) { thisOne = thisOne.substring((ID + "|~>|").length()); final Vector dateV = CMParms.parse(thisOne); if (dateV.size() == 3) { int lastYear = CMath.s_int((String) dateV.lastElement()); int lastMonth = CMath.s_int((String) dateV.elementAt(1)); final int lastDay = CMath.s_int((String) dateV.firstElement()); while (!needsToPay) { if (lastYear < year) needsToPay = true; else if ((lastYear == year) && (lastMonth < month) && (day >= lastDay)) needsToPay = true; if (needsToPay) { if (CMLib.beanCounter() .modifyLocalBankGold( A, owner, CMLib.utensils().getFormattedDate(A) + ":Withdrawal of " + rent + ": Rent for " + ID, CMLib.beanCounter().getCurrency(A), (-rent))) { lastMonth++; if (lastMonth > A.getTimeObj().getMonthsInYear()) { lastMonth = 1; lastYear++; } changesMade = true; needsToPay = false; } } else break; } if (changesMade) reparse.append(ID + "|~>|" + lastDay + " " + lastMonth + " " + lastYear + "|~;|"); if (needsToPay && (!changesMade)) return true; } } else reparse.append(thisOne + "|~;|"); parse = parse.substring(x + 4); x = parse.indexOf("|~;|"); } if (changesMade) { CMLib.database() .DBReCreateData(owner, "RENTAL INFO", "RENTAL INFO/" + owner, reparse.toString()); pData = new DatabaseEngine.PlayerData(); pData.who = owner; pData.section = "RENTAL INFO"; pData.key = "RENTAL INFO/" + owner; pData.xml = reparse.toString(); pDataV.set(0, pData); Resources.removeResource("RENTAL INFO/" + owner); Resources.submitResource("RENTAL INFO/" + owner, pDataV); } return needsToPay; } return false; }