Clean slate counting Vicious Hammer + Scroll Handler patch

Improved clean slate, now taking Vicious Hammer slots into max upgrade slots account.
Solved some exploit cases within Scroll Handler.
This commit is contained in:
ronancpl
2019-05-02 13:48:49 -03:00
parent 615caa7937
commit 383495a7e9
3 changed files with 124 additions and 95 deletions

View File

@@ -49,6 +49,8 @@ public final class ScrollHandler extends AbstractMaplePacketHandler {
@Override @Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) { public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
if (c.tryacquireClient()) {
try {
slea.readInt(); // whatever... slea.readInt(); // whatever...
short slot = slea.readShort(); short slot = slea.readShort();
short dst = slea.readShort(); short dst = slea.readShort();
@@ -113,10 +115,26 @@ public final class ScrollHandler extends AbstractMaplePacketHandler {
} else if (scrolled.getLevel() > oldLevel || (ItemConstants.isCleanSlate(scroll.getItemId()) && scrolled.getUpgradeSlots() == oldSlots + 1) || ItemConstants.isFlagModifier(scroll.getItemId(), scrolled.getFlag())) { } else if (scrolled.getLevel() > oldLevel || (ItemConstants.isCleanSlate(scroll.getItemId()) && scrolled.getUpgradeSlots() == oldSlots + 1) || ItemConstants.isFlagModifier(scroll.getItemId(), scrolled.getFlag())) {
scrollSuccess = Equip.ScrollResult.SUCCESS; scrollSuccess = Equip.ScrollResult.SUCCESS;
} }
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, scroll.getPosition(), (short) 1, false);
useInventory.lockInventory();
try {
if (scroll.getQuantity() < 1) {
return;
}
if (whiteScroll && !ItemConstants.isCleanSlate(scroll.getItemId())) { if (whiteScroll && !ItemConstants.isCleanSlate(scroll.getItemId())) {
if (wscroll.getQuantity() < 1) {
return;
}
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, wscroll.getPosition(), (short) 1, false, false); MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, wscroll.getPosition(), (short) 1, false, false);
} }
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, scroll.getPosition(), (short) 1, false);
} finally {
useInventory.unlockInventory();
}
final List<ModifyInventory> mods = new ArrayList<>(); final List<ModifyInventory> mods = new ArrayList<>();
if (scrollSuccess == Equip.ScrollResult.CURSE) { if (scrollSuccess == Equip.ScrollResult.CURSE) {
if(!ItemConstants.isWeddingRing(toScroll.getItemId())) { if(!ItemConstants.isWeddingRing(toScroll.getItemId())) {
@@ -132,7 +150,14 @@ public final class ScrollHandler extends AbstractMaplePacketHandler {
inv.unlockInventory(); inv.unlockInventory();
} }
} else { } else {
chr.getInventory(MapleInventoryType.EQUIP).removeItem(toScroll.getPosition()); MapleInventory inv = chr.getInventory(MapleInventoryType.EQUIP);
inv.lockInventory();
try {
inv.removeItem(toScroll.getPosition());
} finally {
inv.unlockInventory();
}
} }
} else { } else {
scrolled = toScroll; scrolled = toScroll;
@@ -150,6 +175,10 @@ public final class ScrollHandler extends AbstractMaplePacketHandler {
if (dst < 0 && (scrollSuccess == Equip.ScrollResult.SUCCESS || scrollSuccess == Equip.ScrollResult.CURSE)) { if (dst < 0 && (scrollSuccess == Equip.ScrollResult.SUCCESS || scrollSuccess == Equip.ScrollResult.CURSE)) {
chr.equipChanged(); chr.equipChanged();
} }
} finally {
c.releaseClient();
}
}
} }
private static boolean canScroll(int scrollid, int itemid) { private static boolean canScroll(int scrollid, int itemid) {

View File

@@ -507,7 +507,7 @@ public final class UseCashItemHandler extends AbstractMaplePacketHandler {
int itemSlot = slea.readInt(); int itemSlot = slea.readInt();
slea.readInt(); slea.readInt();
final Equip equip = (Equip) player.getInventory(MapleInventoryType.EQUIP).getItem((short) itemSlot); final Equip equip = (Equip) player.getInventory(MapleInventoryType.EQUIP).getItem((short) itemSlot);
if (equip.getVicious() == 2 || player.getInventory(MapleInventoryType.CASH).findById(5570000) == null) { if (equip.getVicious() >= 2 || player.getInventory(MapleInventoryType.CASH).findById(5570000) == null) {
return; return;
} }
equip.setVicious(equip.getVicious() + 1); equip.setVicious(equip.getVicious() + 1);

View File

@@ -913,7 +913,7 @@ public class MapleItemInformationProvider {
public boolean canUseCleanSlate(Equip nEquip) { public boolean canUseCleanSlate(Equip nEquip) {
Map<String, Integer> eqstats = this.getEquipStats(nEquip.getItemId()); Map<String, Integer> eqstats = this.getEquipStats(nEquip.getItemId());
return ServerConstants.USE_ENHANCED_CLNSLATE || nEquip.getUpgradeSlots() < (byte) (eqstats.get("tuc") + nEquipe.getVicious()); // issue with clean slate found thanks to Masterrulax return ServerConstants.USE_ENHANCED_CLNSLATE || nEquip.getUpgradeSlots() < (byte) (eqstats.get("tuc") + nEquip.getVicious()); // issue with clean slate found thanks to Masterrulax, vicious added in the check thanks to Crypter (CrypterDEV)
} }
public Item scrollEquipWithId(Item equip, int scrollId, boolean usingWhiteScroll, int vegaItemId, boolean isGM) { public Item scrollEquipWithId(Item equip, int scrollId, boolean usingWhiteScroll, int vegaItemId, boolean isGM) {