Return map & MaplePacketEncoder & Quest status patch
Fixed null pointer issue when trying to use return scroll on maps such as Mu Lung. Fixed a critical deadlock issue with MaplePacketEncoder. Fixed a critical DB leak regarding player's quest status.
This commit is contained in:
@@ -2032,6 +2032,11 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
||||
ps.setInt(1, cid);
|
||||
ps.executeUpdate();
|
||||
}
|
||||
|
||||
try (PreparedStatement ps = con.prepareStatement("DELETE FROM queststatus WHERE characterid = ?")) {
|
||||
ps.setInt(1, cid);
|
||||
ps.executeUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteWhereCharacterId(Connection con, String sql) throws SQLException {
|
||||
@@ -3717,7 +3722,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
||||
MapleBuffStatValueHolder mbsvh = effects.get(statup.getKey());
|
||||
MapleBuffStatValueHolder statMbsvh = statup.getValue();
|
||||
|
||||
if(mbsvh == null || mbsvh.value < statMbsvh.value || (mbsvh.value == statMbsvh.value && mbsvh.effect.getStatups().size() < statMbsvh.effect.getStatups().size())) {
|
||||
if(mbsvh == null || mbsvh.value < statMbsvh.value || (mbsvh.value == statMbsvh.value && mbsvh.effect.getStatups().size() <= statMbsvh.effect.getStatups().size())) {
|
||||
toDeploy.put(statup.getKey(), statMbsvh);
|
||||
} else {
|
||||
if(!isSingletonStatup(statup.getKey())) {
|
||||
@@ -5969,7 +5974,6 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
||||
rs = ps.executeQuery();
|
||||
|
||||
Map<Integer, MapleQuestStatus> loadedQuestStatus = new LinkedHashMap<>();
|
||||
|
||||
while (rs.next()) {
|
||||
MapleQuest q = MapleQuest.getInstance(rs.getShort("quest"));
|
||||
MapleQuestStatus status = new MapleQuestStatus(q, MapleQuestStatus.Status.getById(rs.getInt("status")));
|
||||
@@ -6011,9 +6015,11 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
for(MapleQuestStatus mqs : loadedQuestStatus.values()) {
|
||||
mqs.resetUpdated();
|
||||
}
|
||||
*/
|
||||
|
||||
loadedQuestStatus.clear();
|
||||
|
||||
@@ -7071,8 +7077,6 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
||||
|
||||
synchronized (quests) {
|
||||
for (MapleQuestStatus q : quests.values()) {
|
||||
if(!q.wasUpdated()) continue;
|
||||
|
||||
ps.setInt(2, q.getQuest().getId());
|
||||
ps.setInt(3, q.getStatus().getId());
|
||||
ps.setInt(4, (int) (q.getCompletionTime() / 1000));
|
||||
|
||||
@@ -106,6 +106,7 @@ public class MapleClient {
|
||||
private byte gender = -1;
|
||||
private boolean disconnecting = false;
|
||||
private final Lock lock = new MonitoredReentrantLock(MonitoredLockType.CLIENT, true);
|
||||
private final Lock encoderLock = new MonitoredReentrantLock(MonitoredLockType.CLIENT, true);
|
||||
private static final Lock loginLock = new MonitoredReentrantLock(MonitoredLockType.CLIENT, true);
|
||||
private int votePoints;
|
||||
private int voteTime = -1;
|
||||
@@ -1142,6 +1143,14 @@ public class MapleClient {
|
||||
public void unlockClient() {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
public void lockEncoder() {
|
||||
encoderLock.lock();
|
||||
}
|
||||
|
||||
public void unlockEncoder() {
|
||||
encoderLock.unlock();
|
||||
}
|
||||
|
||||
private static class CharNameAndId {
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class MapleQuestStatus {
|
||||
}
|
||||
private short questID;
|
||||
private Status status;
|
||||
private boolean updated;
|
||||
//private boolean updated; //maybe this can be of use for someone?
|
||||
private final Map<Integer, String> progress = new LinkedHashMap<Integer, String>();
|
||||
private final List<Integer> medalProgress = new LinkedList<Integer>();
|
||||
private int npc;
|
||||
@@ -73,7 +73,7 @@ public class MapleQuestStatus {
|
||||
this.setStatus(status);
|
||||
this.completionTime = System.currentTimeMillis();
|
||||
this.expirationTime = 0;
|
||||
this.updated = true;
|
||||
//this.updated = true;
|
||||
if (status == Status.STARTED)
|
||||
registerMobs();
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class MapleQuestStatus {
|
||||
this.setNpc(npc);
|
||||
this.completionTime = System.currentTimeMillis();
|
||||
this.expirationTime = 0;
|
||||
this.updated = true;
|
||||
//this.updated = true;
|
||||
if (status == Status.STARTED) {
|
||||
registerMobs();
|
||||
}
|
||||
@@ -106,17 +106,19 @@ public class MapleQuestStatus {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/*
|
||||
public boolean wasUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
||||
public void setUpdated() {
|
||||
private void setUpdated() {
|
||||
this.updated = true;
|
||||
}
|
||||
|
||||
public void resetUpdated() {
|
||||
this.updated = false;
|
||||
}
|
||||
*/
|
||||
|
||||
public int getNpc() {
|
||||
return npc;
|
||||
@@ -130,13 +132,13 @@ public class MapleQuestStatus {
|
||||
for (int i : MapleQuest.getInstance(questID).getRelevantMobs()) {
|
||||
progress.put(i, "000");
|
||||
}
|
||||
this.setUpdated();
|
||||
//this.setUpdated();
|
||||
}
|
||||
|
||||
public boolean addMedalMap(int mapid) {
|
||||
if (medalProgress.contains(mapid)) return false;
|
||||
medalProgress.add(mapid);
|
||||
this.setUpdated();
|
||||
//this.setUpdated();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -153,7 +155,7 @@ public class MapleQuestStatus {
|
||||
int current = Integer.parseInt(progress.get(id));
|
||||
String str = StringUtil.getLeftPaddedStr(Integer.toString(current + 1), '0', 3);
|
||||
progress.put(id, str);
|
||||
this.setUpdated();
|
||||
//this.setUpdated();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -161,7 +163,7 @@ public class MapleQuestStatus {
|
||||
|
||||
public void setProgress(int id, String pr) {
|
||||
progress.put(id, pr);
|
||||
this.setUpdated();
|
||||
//this.setUpdated();
|
||||
}
|
||||
|
||||
public boolean madeProgress() {
|
||||
@@ -221,7 +223,7 @@ public class MapleQuestStatus {
|
||||
|
||||
public void setInfo(String newInfo) {
|
||||
progress.put(0, newInfo);
|
||||
this.setUpdated();
|
||||
//this.setUpdated();
|
||||
}
|
||||
|
||||
public void setForfeited(int forfeited) {
|
||||
|
||||
Reference in New Issue
Block a user