Login Purification + Optimized currenttime calls + Standardized WZ
Repelled ultimately the game-breaking issue that was introduced recently on the revamp of the login phase. Optimized the getcurrenttime calls to the OS. Made most of the handler calls fetch directly from the Server object instead, the Server itself delegated with periodically updating the current time value. The result is an slightly delayed currenttime, backed with realtime value update within minutes. Protected concurrently inventory sort handlers. Expected no more NullPointers from the sorting feature. Added a server flag to limit cash items being sold on player shops/hired merchants. Stabilized the MapleTV mechanics, and activities properly split by world. Normalized Character.wz: equipments supposed to have the "cash" property now implements it. Normalized String.wz: every item that doesn't have a "name" property now implements it. Normalized the XMLs that lost indentation on the last source update. New tool: MapleInvalidItemWithNoNameFetcher. Fetches and reports itemids throughout the XMLs that doesn't contain the "name" property and equipments that lacks "cash" property. Frolic Omniknight references aside, if you have run into any more issues regarding the new login system, please open an issue and show the steps you've done to reach the problem.
This commit is contained in:
@@ -40,6 +40,7 @@ import tools.locks.MonitoredReentrantLock;
|
||||
public abstract class BaseScheduler {
|
||||
private int idleProcs = 0;
|
||||
private List<SchedulerListener> listeners = new LinkedList<>();
|
||||
private final List<Lock> externalLocks;
|
||||
private Map<Object, Pair<Runnable, Long>> registeredEntries = new HashMap<>();
|
||||
|
||||
private ScheduledFuture<?> schedulerTask = null;
|
||||
@@ -53,16 +54,43 @@ public abstract class BaseScheduler {
|
||||
|
||||
protected BaseScheduler(MonitoredLockType lockType) {
|
||||
schedulerLock = new MonitoredReentrantLock(lockType, true);
|
||||
externalLocks = new LinkedList<>();
|
||||
}
|
||||
|
||||
// NOTE: practice EXTREME caution when adding external locks to the scheduler system, if you don't know what you're doing DON'T USE THIS.
|
||||
protected BaseScheduler(MonitoredLockType lockType, List<Lock> extLocks) {
|
||||
schedulerLock = new MonitoredReentrantLock(lockType, true);
|
||||
externalLocks = extLocks;
|
||||
}
|
||||
|
||||
protected void addListener(SchedulerListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
private void lockScheduler() {
|
||||
if(!externalLocks.isEmpty()) {
|
||||
for(Lock l : externalLocks) {
|
||||
l.lock();
|
||||
}
|
||||
}
|
||||
|
||||
schedulerLock.lock();
|
||||
}
|
||||
|
||||
private void unlockScheduler() {
|
||||
if(!externalLocks.isEmpty()) {
|
||||
for(Lock l : externalLocks) {
|
||||
l.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
schedulerLock.unlock();
|
||||
}
|
||||
|
||||
private void runBaseSchedule() {
|
||||
List<Object> toRemove;
|
||||
|
||||
schedulerLock.lock();
|
||||
lockScheduler();
|
||||
try {
|
||||
if(registeredEntries.isEmpty()) {
|
||||
idleProcs++;
|
||||
@@ -93,14 +121,14 @@ public abstract class BaseScheduler {
|
||||
registeredEntries.remove(mse);
|
||||
}
|
||||
} finally {
|
||||
schedulerLock.unlock();
|
||||
unlockScheduler();
|
||||
}
|
||||
|
||||
dispatchRemovedEntries(toRemove, true);
|
||||
}
|
||||
|
||||
protected void registerEntry(Object key, Runnable removalAction, long duration) {
|
||||
schedulerLock.lock();
|
||||
lockScheduler();
|
||||
try {
|
||||
idleProcs = 0;
|
||||
if(schedulerTask == null) {
|
||||
@@ -109,17 +137,17 @@ public abstract class BaseScheduler {
|
||||
|
||||
registeredEntries.put(key, new Pair<>(removalAction, System.currentTimeMillis() + duration));
|
||||
} finally {
|
||||
schedulerLock.unlock();
|
||||
unlockScheduler();
|
||||
}
|
||||
}
|
||||
|
||||
protected void interruptEntry(Object key) {
|
||||
schedulerLock.lock();
|
||||
lockScheduler();
|
||||
try {
|
||||
Pair<Runnable, Long> rm = registeredEntries.remove(key);
|
||||
if(rm != null) rm.getLeft().run();
|
||||
} finally {
|
||||
schedulerLock.unlock();
|
||||
unlockScheduler();
|
||||
}
|
||||
|
||||
dispatchRemovedEntries(Collections.singletonList(key), false);
|
||||
|
||||
Reference in New Issue
Block a user