Fixed inventory full now properly shown + loading GM with pet issue

Fixed issues related to "inventory full" messages not popping when
failing to pick-up items and when loading GM pets giving out exceptions.
This commit is contained in:
ronancpl
2017-05-18 14:45:46 -03:00
parent 39a53e88fd
commit 66a19d6fa6
5 changed files with 54 additions and 47 deletions

View File

@@ -36,7 +36,7 @@ import client.MapleClient;
/**
*
* @author Matze
* @author Matze, Ronan
*/
public final class ItemPickupHandler extends AbstractMaplePacketHandler {
@@ -57,8 +57,10 @@ public final class ItemPickupHandler extends AbstractMaplePacketHandler {
if(System.currentTimeMillis() - mapitem.getDropTime() < 900) {
c.announce(MaplePacketCreator.enableActions());
return;
}
if (mapitem.getItemId() == 4031865 || mapitem.getItemId() == 4031866 || mapitem.getMeso() > 0 || MapleItemInformationProvider.getInstance().isConsumeOnPickup(mapitem.getItemId()) || MapleInventoryManipulator.checkSpace(c, mapitem.getItemId(), mapitem.getItem().getQuantity(), mapitem.getItem().getOwner())) {
}
boolean hasSpaceInventory = true;
if (mapitem.getItemId() == 4031865 || mapitem.getItemId() == 4031866 || mapitem.getMeso() > 0 || MapleItemInformationProvider.getInstance().isConsumeOnPickup(mapitem.getItemId()) || (hasSpaceInventory = MapleInventoryManipulator.checkSpace(c, mapitem.getItemId(), mapitem.getItem().getQuantity(), mapitem.getItem().getOwner()))) {
if ((chr.getMapId() > 209000000 && chr.getMapId() < 209000016) || (chr.getMapId() >= 990000500 && chr.getMapId() <= 990000502)) {//happyville trees and guild PQ
if (!mapitem.isPlayerDrop() || mapitem.getDropper().getObjectId() == c.getPlayer().getObjectId()) {
if(mapitem.getMeso() > 0) {
@@ -90,8 +92,8 @@ public final class ItemPickupHandler extends AbstractMaplePacketHandler {
return;
}
if (mapitem.isPickedUp()) {
c.announce(MaplePacketCreator.getInventoryFull());
c.announce(MaplePacketCreator.getShowInventoryFull());
c.announce(MaplePacketCreator.showItemUnavailable());
c.announce(MaplePacketCreator.enableActions());
return;
}
if (mapitem.getMeso() > 0) {
@@ -134,7 +136,7 @@ public final class ItemPickupHandler extends AbstractMaplePacketHandler {
}
}
} else if(mapitem.getItemId() == 4031865 || mapitem.getItemId() == 4031866) {
// Add NX to account, show effect and make item disapear
// Add NX to account, show effect and make item disappear
chr.getCashShop().gainCash(1, mapitem.getItemId() == 4031865 ? 100 : 250);
} else if (useItem(c, mapitem.getItem().getItemId())) {
if (mapitem.getItem().getItemId() / 10000 == 238) {
@@ -151,6 +153,9 @@ public final class ItemPickupHandler extends AbstractMaplePacketHandler {
chr.getMap().broadcastMessage(MaplePacketCreator.removeItemFromMap(mapitem.getObjectId(), 2, chr.getId()), mapitem.getPosition());
chr.getMap().removeMapObject(ob);
}
} else if(!hasSpaceInventory) {
c.announce(MaplePacketCreator.getInventoryFull());
c.announce(MaplePacketCreator.getShowInventoryFull());
}
}
c.announce(MaplePacketCreator.enableActions());

View File

@@ -43,12 +43,15 @@ import constants.ServerConstants;
public final class PetLootHandler extends AbstractMaplePacketHandler {
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
MapleCharacter chr = c.getPlayer();
if(System.currentTimeMillis() - chr.getPetLootCd() < ServerConstants.PET_LOOT_UPON_ATTACK)
if(System.currentTimeMillis() - chr.getPetLootCd() < ServerConstants.PET_LOOT_UPON_ATTACK) {
c.announce(MaplePacketCreator.enableActions());
return;
}
MaplePet pet = chr.getPet(chr.getPetIndex(slea.readInt()));//why would it be an int...?
if (pet == null || !pet.isSummoned()) {
return;
c.announce(MaplePacketCreator.enableActions());
return;
}
slea.skip(13);
@@ -56,6 +59,7 @@ public final class PetLootHandler extends AbstractMaplePacketHandler {
MapleMapObject ob = chr.getMap().getMapObject(oid);
if (ob == null) {
c.announce(MaplePacketCreator.getInventoryFull());
c.announce(MaplePacketCreator.enableActions());
return;
}
if (ob instanceof MapleMapItem) {
@@ -66,21 +70,26 @@ public final class PetLootHandler extends AbstractMaplePacketHandler {
c.announce(MaplePacketCreator.enableActions());
return;
}
if(System.currentTimeMillis() - mapitem.getDropTime() < 900) {
c.announce(MaplePacketCreator.enableActions());
return;
}
if(System.currentTimeMillis() - mapitem.getDropTime() < 900) {
c.announce(MaplePacketCreator.enableActions());
return;
}
if (mapitem.isPickedUp()) {
c.announce(MaplePacketCreator.getInventoryFull());
c.announce(MaplePacketCreator.showItemUnavailable());
c.announce(MaplePacketCreator.enableActions());
return;
}
if (mapitem.getDropper() == c.getPlayer()) {
c.announce(MaplePacketCreator.enableActions());
return;
}
if (mapitem.getMeso() > 0) {
if (chr.getParty() != null) {
int mesosamm = mapitem.getMeso();
if (mesosamm > 50000 * chr.getMesoRate()) return;
if (mesosamm > 50000 * chr.getMesoRate()) {
c.announce(MaplePacketCreator.enableActions());
return;
}
int partynum = 0;
for (MaplePartyCharacter partymem : chr.getParty().getMembers()) {
if (partymem.isOnline() && partymem.getMapId() == chr.getMap().getId() && partymem.getChannel() == c.getChannel()) {
@@ -115,6 +124,7 @@ public final class PetLootHandler extends AbstractMaplePacketHandler {
if (chr.getInventory(MapleInventoryType.EQUIPPED).findById(1812007) != null) {
for (int i : chr.getExcluded()) {
if (mapitem.getItem().getItemId() == i) {
c.announce(MaplePacketCreator.enableActions());
return;
}
}
@@ -122,6 +132,7 @@ public final class PetLootHandler extends AbstractMaplePacketHandler {
chr.getMap().broadcastMessage(MaplePacketCreator.removeItemFromMap(mapitem.getObjectId(), 5, chr.getId(), true, chr.getPetIndex(pet)), mapitem.getPosition());
chr.getMap().removeMapObject(ob);
} else {
c.announce(MaplePacketCreator.enableActions());
return;
}
} else if (mapitem.getItem().getItemId() / 10000 == 243) {
@@ -138,20 +149,22 @@ public final class PetLootHandler extends AbstractMaplePacketHandler {
}
chr.getMap().broadcastMessage(MaplePacketCreator.removeItemFromMap(mapitem.getObjectId(), 5, chr.getId(), true, chr.getPetIndex(pet)), mapitem.getPosition());
chr.getMap().removeMapObject(ob);
} else if(mapitem.getItemId() == 4031865 || mapitem.getItemId() == 4031866) {
// Add NX to account, show effect and make item disapear
} else if(mapitem.getItemId() == 4031865 || mapitem.getItemId() == 4031866) {
// Add NX to account, show effect and make item disappear
chr.getCashShop().gainCash(1, mapitem.getItemId() == 4031865 ? 100 : 250);
chr.getMap().broadcastMessage(MaplePacketCreator.removeItemFromMap(mapitem.getObjectId(), 5, chr.getId(), true, chr.getPetIndex(pet)), mapitem.getPosition());
chr.getMap().removeMapObject(ob);
} else if (MapleInventoryManipulator.addFromDrop(c, mapitem.getItem(), true)) {
chr.getMap().broadcastMessage(MaplePacketCreator.removeItemFromMap(mapitem.getObjectId(), 5, chr.getId(), true, chr.getPetIndex(pet)), mapitem.getPosition());
chr.getMap().removeMapObject(ob);
} else {
} else {
c.announce(MaplePacketCreator.enableActions());
return;
}
mapitem.setPickedUp(true);
}
}
//c.announce(MaplePacketCreator.enableActions());
c.announce(MaplePacketCreator.enableActions());
}
}