Fixed chair exploit & beholder issue + Mini-dungeon revamp

Fixed an (quite amusing) exploit with map chairs stacking "extra healing" schedules on certain conditions. Fixed mini-dungeon not disposing players properly in some cases. Refactored the mini-dungeon structure. Fixed an issue on CASH inventory merging same items when trying to swap them. Fixed Beholder crash issue when trying to enter Cash Shop.
This commit is contained in:
ronancpl
2017-10-16 15:13:42 -02:00
parent 1ec7487bd3
commit 57c29603d1
96 changed files with 632 additions and 434 deletions

View File

@@ -32,6 +32,8 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
@@ -60,9 +62,11 @@ import server.expeditions.MapleExpeditionType;
import server.maps.MapleHiredMerchant;
import server.maps.MapleMap;
import server.maps.MapleMapFactory;
import server.maps.MapleMiniDungeon;
import tools.MaplePacketCreator;
import client.MapleCharacter;
import constants.ServerConstants;
import server.maps.MapleMiniDungeonInfo;
public final class Channel {
@@ -75,9 +79,6 @@ public final class Channel {
private EventScriptManager eventSM;
private Map<Integer, MapleHiredMerchant> hiredMerchants = new HashMap<>();
private final Map<Integer, Integer> storedVars = new HashMap<>();
private ReentrantReadWriteLock merchant_lock = new ReentrantReadWriteLock(true);
private ReadLock merchRlock = merchant_lock.readLock();
private WriteLock merchWlock = merchant_lock.writeLock();
private List<MapleExpedition> expeditions = new ArrayList<>();
private List<MapleExpeditionType> expedType = new ArrayList<>();
private MapleEvent event;
@@ -87,6 +88,13 @@ public final class Channel {
private long[] dojoFinishTime;
private ScheduledFuture<?>[] dojoTask;
private Map<Integer, Integer> dojoParty = new HashMap<>();
private Map<Integer, MapleMiniDungeon> dungeons = new HashMap<>();
private ReentrantReadWriteLock merchant_lock = new ReentrantReadWriteLock(true);
private ReadLock merchRlock = merchant_lock.readLock();
private WriteLock merchWlock = merchant_lock.writeLock();
private Lock lock = new ReentrantLock();
public Channel(final int world, final int channel) {
this.world = world;
@@ -485,4 +493,37 @@ public final class Channel {
public long getDojoFinishTime(int dojoMapId) {
return dojoFinishTime[getDojoSlot(dojoMapId)];
}
public boolean addMiniDungeon(int dungeonid) {
lock.lock();
try {
if(dungeons.containsKey(dungeonid)) return false;
MapleMiniDungeonInfo mmdi = MapleMiniDungeonInfo.getDungeon(dungeonid);
MapleMiniDungeon mmd = new MapleMiniDungeon(mmdi.getBase(), 30); // all minidungeons timeouts on 30 mins
dungeons.put(dungeonid, mmd);
return true;
} finally {
lock.unlock();
}
}
public MapleMiniDungeon getMiniDungeon(int dungeonid) {
lock.lock();
try {
return dungeons.get(dungeonid);
} finally {
lock.unlock();
}
}
public void removeMiniDungeon(int dungeonid) {
lock.lock();
try {
dungeons.remove(dungeonid);
} finally {
lock.unlock();
}
}
}