Skip to content

Commit

Permalink
Fixed splitting items between storages
Browse files Browse the repository at this point in the history
The storage limit was ignored when splitting new item stacks into a full warehouse, as reported by @Yoress (thx).
This also affected other storage types.
  • Loading branch information
neon-dev committed Sep 21, 2024
1 parent 81dbf2a commit 82f91b0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 118 deletions.
133 changes: 15 additions & 118 deletions game-server/src/com/aionemu/gameserver/model/items/storage/IStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.aionemu.gameserver.model.gameobjects.Item;
import com.aionemu.gameserver.model.gameobjects.Persistable;
import com.aionemu.gameserver.model.gameobjects.player.Player;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE;
import com.aionemu.gameserver.questEngine.model.QuestStatus;
import com.aionemu.gameserver.services.item.ItemPacketService.ItemAddType;
import com.aionemu.gameserver.services.item.ItemPacketService.ItemDeleteType;
Expand All @@ -18,84 +19,35 @@
*/
public interface IStorage extends Persistable {

/**
* @param player
*/
void setOwner(Player player);

/**
* @return current kinah count
*/
long getKinah();

/**
* @return kinah item or null if storage never had kinah
*/
Item getKinahItem();

/**
* @return
*/
StorageType getStorageType();

/**
* @param amount
*/
void increaseKinah(long amount);

/**
* @param amount
* @param updateType
*/
void increaseKinah(long amount, ItemUpdateType updateType);

/**
* @param amount
* @return
*/
boolean tryDecreaseKinah(long amount);

boolean tryDecreaseKinah(long amount, ItemUpdateType updateType);

/**
* @param amount
*/
void decreaseKinah(long amount);

/**
* @param amount
* @param updateType
*/
void decreaseKinah(long amount, ItemUpdateType updateType);

/**
* @param item
* @param count
* @return
*/
long increaseItemCount(Item item, long count);

/**
* @param item
* @param count
* @param updateType
* @return
*/
long increaseItemCount(Item item, long count, ItemUpdateType updateType);

/**
* @param item
* @param count
* @return
*/
long decreaseItemCount(Item item, long count);

/**
* @param item
* @param count
* @param updateType
* @return
*/
long decreaseItemCount(Item item, long count, ItemUpdateType updateType);

long decreaseItemCount(Item item, long count, ItemUpdateType updateType, QuestStatus questStatus);
Expand All @@ -112,115 +64,60 @@ public interface IStorage extends Persistable {
*/
Item put(Item item);

/**
* @param item
* @return
*/
Item remove(Item item);

/**
* @param item
* @return
*/
Item delete(Item item);

/**
* @param item
* @param deleteType
* @return
*/
Item delete(Item item, ItemDeleteType deleteType);

/**
* @param itemId
* @param count
* @return
*/
boolean decreaseByItemId(int itemId, long count);

boolean decreaseByItemId(int itemId, long count, QuestStatus questStatus);

/**
* @param itemObjId
* @param count
* @return
*/
boolean decreaseByObjectId(int itemObjId, long count);

/**
* @param itemObjId
* @param count
* @param updateType
* @return
*/
boolean decreaseByObjectId(int itemObjId, long count, ItemUpdateType updateType);

boolean decreaseByObjectId(int itemObjId, long count, QuestStatus questStatus);

/**
* @param itemId
* @return
*/
Item getFirstItemByItemId(int itemId);

/**
* @return
*/
List<Item> getItemsWithKinah();

/**
* @return
*/
List<Item> getItems();

/**
* @param itemId
* @return
*/
List<Item> getItemsByItemId(int itemId);

/**
* @param itemObjId
* @return
*/
Item getItemByObjId(int itemObjId);

/**
* @param itemId
* @return
*/
long getItemCountByItemId(int itemId);

/**
* @return
*/
boolean isFull();

/**
* @return
*/
int getFreeSlots();

/**
* @return
*/
int getLimit();

int getRowLength();

/**
* @return
*/
int size();

/**
* @return
*/
Queue<Item> getDeletedItems();

/**
* @param item
*/
void onLoadHandler(Item item);

default SM_SYSTEM_MESSAGE getStorageIsFullMessage() {
return switch (getStorageType()) {
case CUBE -> SM_SYSTEM_MESSAGE.STR_WAREHOUSE_FULL_INVENTORY();
case REGULAR_WAREHOUSE, ACCOUNT_WAREHOUSE, LEGION_WAREHOUSE -> SM_SYSTEM_MESSAGE.STR_WAREHOUSE_DEPOSIT_FULL_BASKET();
case PET_BAG_6, PET_BAG_12, PET_BAG_18, PET_BAG_24, CASH_PET_BAG_12, CASH_PET_BAG_18, CASH_PET_BAG_30, CASH_PET_BAG_24, PET_BAG_30,
CASH_PET_BAG_26, CASH_PET_BAG_32, CASH_PET_BAG_34 -> SM_SYSTEM_MESSAGE.STR_WAREHOUSE_TOO_MANY_ITEMS_TOYPET_WAREHOUSE();
case HOUSE_STORAGE_01, HOUSE_STORAGE_02, HOUSE_STORAGE_03, HOUSE_STORAGE_04, HOUSE_STORAGE_05, HOUSE_STORAGE_06, HOUSE_STORAGE_07,
HOUSE_STORAGE_08, HOUSE_STORAGE_09, HOUSE_STORAGE_10, HOUSE_STORAGE_11, HOUSE_STORAGE_12, HOUSE_STORAGE_13, HOUSE_STORAGE_14,
HOUSE_STORAGE_15, HOUSE_STORAGE_16, HOUSE_STORAGE_17, HOUSE_STORAGE_18, HOUSE_STORAGE_19, HOUSE_STORAGE_20 ->
SM_SYSTEM_MESSAGE.STR_HOUSING_WAREHOUSE_TOO_MANY_ITEMS_WAREHOUSE();
case BROKER -> SM_SYSTEM_MESSAGE.STR_VENDOR_FULL_ITEM();
case MAILBOX -> SM_SYSTEM_MESSAGE.STR_MAIL_SEND_FULL_BASKET();
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25269,6 +25269,13 @@ public static SM_SYSTEM_MESSAGE STR_MSG_HOUSING_SEQUESTRATE() {
return new SM_SYSTEM_MESSAGE(1401227);
}

/**
* The cabinet is full.
*/
public static SM_SYSTEM_MESSAGE STR_HOUSING_WAREHOUSE_TOO_MANY_ITEMS_WAREHOUSE() {
return new SM_SYSTEM_MESSAGE(1401239);
}

/**
* Only house owners and their friends may enter.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public static final void splitItem(Player player, int itemObjId, int destination
}

if (targetItem == null) {
if (destStorage.isFull()) {
PacketSendUtility.sendPacket(player, destStorage.getStorageIsFullMessage());
return;
}
long oldItemCount = sourceItem.getItemCount() - splitAmount;
if (sourceItem.getItemCount() < splitAmount || oldItemCount == 0) {
return;
Expand Down

0 comments on commit 82f91b0

Please sign in to comment.