From d37c71dda283597976715e9ff76c5ba8e865e8b0 Mon Sep 17 00:00:00 2001 From: Emistry Haoyan Date: Wed, 2 Oct 2019 21:11:04 +0800 Subject: Update dropall atcommand - The correct amount of dropped items should be displayed. - Included skipped amount. --- src/map/atcommand.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/map/atcommand.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 145a5c95d..f57583cfc 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -5369,7 +5369,6 @@ ACMD(follow) ACMD(dropall) { int type = -1; - int count = 0; if (message[0] != '\0') { type = atoi(message); @@ -5380,25 +5379,32 @@ ACMD(dropall) } } + int count = 0, count_skipped = 0; for (int i = 0; i < sd->status.inventorySize; i++) { - if (sd->status.inventory[i].amount) { + if (sd->status.inventory[i].amount > 0) { struct item_data *item_data = itemdb->exists(sd->status.inventory[i].nameid); if (item_data == NULL) { ShowWarning("Non-existant item %d on dropall list (account_id: %d, char_id: %d)\n", sd->status.inventory[i].nameid, sd->status.account_id, sd->status.char_id); continue; } + if (!pc->candrop(sd, &sd->status.inventory[i])) continue; + if (type == -1 || type == item_data->type) { if (sd->status.inventory[i].equip != 0) pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC | PCUNEQUIPITEM_FORCE); - count += sd->status.inventory[i].amount; - pc->dropitem(sd, i, sd->status.inventory[i].amount); + + int amount = sd->status.inventory[i].amount; + if (pc->dropitem(sd, i, amount) != 0) + count += amount; + else + count_skipped += amount; } } } - sprintf(atcmd_output, msg_fd(fd, 1502), count); // %d items are dropped! + sprintf(atcmd_output, msg_fd(fd, 1502), count, count_skipped); // %d items are dropped (%d skipped)! clif->message(fd, atcmd_output); return true; } -- cgit v1.2.3-70-g09d2