Revamped buff system + skill cd/buff schedule rework
Completely rearranged buff system (system can smartly check for the best statup to take effect for it's duration, or the server can be flagged to act as usual). Refactored scheduling system for buffs expiration and cooldowns to use one single thread per player rather than one per instance.
This commit is contained in:
@@ -45,9 +45,10 @@ import java.util.HashSet;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import server.TimerManager;
|
||||
import net.server.CharacterAutosaverWorker;
|
||||
import net.server.MountTirednessWorker;
|
||||
import net.server.PetFullnessWorker;
|
||||
import server.maps.HiredMerchant;
|
||||
import net.server.worker.CharacterAutosaverWorker;
|
||||
import net.server.worker.MountTirednessWorker;
|
||||
import net.server.worker.PetFullnessWorker;
|
||||
import net.server.PlayerStorage;
|
||||
import net.server.Server;
|
||||
import net.server.channel.Channel;
|
||||
@@ -84,6 +85,10 @@ public class World {
|
||||
private ScheduledFuture<?> mountsSchedule;
|
||||
private long mountUpdate;
|
||||
|
||||
private Map<HiredMerchant, Byte> activeMerchants = new LinkedHashMap<>();
|
||||
private ScheduledFuture<?> MerchantsSchedule;
|
||||
private long merchantUpdate;
|
||||
|
||||
private ScheduledFuture<?> charactersSchedule;
|
||||
|
||||
public World(int world, int flag, String eventmsg, int exprate, int droprate, int mesorate, int bossdroprate) {
|
||||
@@ -773,6 +778,48 @@ public class World {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerHiredMerchant(HiredMerchant hm) {
|
||||
synchronized(activeMerchants) {
|
||||
byte initProc;
|
||||
if(System.currentTimeMillis() - merchantUpdate > 5 * 60 * 1000) initProc = 1;
|
||||
else initProc = 0;
|
||||
|
||||
activeMerchants.put(hm, initProc);
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterHiredMerchant(HiredMerchant hm) {
|
||||
synchronized(activeMerchants) {
|
||||
activeMerchants.remove(hm);
|
||||
}
|
||||
}
|
||||
|
||||
public void runHiredMerchantSchedule() {
|
||||
Map<HiredMerchant, Byte> deployedMerchants;
|
||||
synchronized(activeMerchants) {
|
||||
merchantUpdate = System.currentTimeMillis();
|
||||
deployedMerchants = Collections.unmodifiableMap(activeMerchants);
|
||||
}
|
||||
|
||||
for(Map.Entry<HiredMerchant, Byte> dm: deployedMerchants.entrySet()) {
|
||||
byte timeOn = dm.getValue();
|
||||
|
||||
if(timeOn <= 144) { // 1440 minutes == 24hrs
|
||||
synchronized(activeMerchants) {
|
||||
activeMerchants.put(dm.getKey(), (byte)(timeOn + 1));
|
||||
}
|
||||
} else {
|
||||
HiredMerchant hm = dm.getKey();
|
||||
hm.forceClose();
|
||||
this.getChannel(hm.getChannel()).removeHiredMerchant(hm.getOwnerId());
|
||||
|
||||
synchronized(activeMerchants) {
|
||||
activeMerchants.remove(dm.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setServerMessage(String msg) {
|
||||
for (Channel ch : channels) {
|
||||
|
||||
Reference in New Issue
Block a user