Skip to content

Commit

Permalink
Merge pull request #354 from RedSparr0w/banking-fixes
Browse files Browse the repository at this point in the history
Banking fixes
  • Loading branch information
SchauweM authored Oct 6, 2021
2 parents be8a77f + 10e1e47 commit 074374a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/engine/world/items/item-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { filestore } from '@server/game/game-server';
import { hasValueNotNull } from '@engine/util/data';
import { findItem } from '@engine/config/config-handler';
import { logger } from '@runejs/core';
import { fromNote } from '@engine/world/items/item';


export interface ContainerUpdateEvent {
Expand Down Expand Up @@ -308,7 +309,7 @@ export class ItemContainer {
if(!itemDefinition) {
throw new Error(`Item ID ${ item.itemId } not found!`);
}
if(itemDefinition.stackable || everythingStacks) {
if(itemDefinition.stackable || everythingStacks || fromNote(item) > -1) {
if(this.has(item.itemId)) {
const invItem = this.items[this.findIndex(item.itemId)];
return invItem.amount + item.amount <= 2147483647;
Expand Down
12 changes: 10 additions & 2 deletions src/plugins/objects/bank/bank.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@ export const withdrawItem: itemInteractionActionHandler = (details) => {
}

let itemIdToAdd: number = details.itemId;
let stackable: boolean = details.itemDetails.stackable;
if (details.player.settings.bankWithdrawNoteMode) {
const toNoteId: number = toNote(details.itemId);
if (toNoteId > -1) {
itemIdToAdd = toNoteId;
stackable = true;
} else {
details.player.sendMessage('This item can not be withdrawn as a note.');
}
Expand Down Expand Up @@ -154,7 +156,7 @@ export const withdrawItem: itemInteractionActionHandler = (details) => {
countToRemove = itemAmount;
}

if (!details.itemDetails.stackable) {
if (!stackable) {
const slots = playerInventory.getOpenSlotCount();
if (slots < countToRemove) {
countToRemove = slots;
Expand All @@ -170,7 +172,13 @@ export const withdrawItem: itemInteractionActionHandler = (details) => {
amount: removeFromContainer(playerBank, details.itemId, countToRemove)
};

playerInventory.add({ itemId: itemToAdd.itemId, amount: itemToAdd.amount });
if (stackable) {
playerInventory.add({ itemId: itemToAdd.itemId, amount: itemToAdd.amount });
} else {
for(let count = 0; count < itemToAdd.amount; count++) {
playerInventory.add({ itemId: itemToAdd.itemId, amount: 1 });
}
}

updateBankingInterface(details.player);
};
Expand Down

0 comments on commit 074374a

Please sign in to comment.