diff options
author | Haru <haru@dotalux.com> | 2019-10-18 13:25:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-18 13:25:06 +0200 |
commit | 1e6580e56850adb241261c33bffca60f934294fb (patch) | |
tree | 77e93cc3b8728b1f607b43c8bae78dd2de97c40e /src | |
parent | 3b8f08eb483c2e7c4f5a8f2fb273899bc852eecb (diff) | |
parent | d37c71dda283597976715e9ff76c5ba8e865e8b0 (diff) | |
download | hercules-1e6580e56850adb241261c33bffca60f934294fb.tar.gz hercules-1e6580e56850adb241261c33bffca60f934294fb.tar.bz2 hercules-1e6580e56850adb241261c33bffca60f934294fb.tar.xz hercules-1e6580e56850adb241261c33bffca60f934294fb.zip |
Merge pull request #2545 from Emistry/atcommand_dropall
Update dropall atcommand
Diffstat (limited to 'src')
-rw-r--r-- | src/map/atcommand.c | 16 |
1 files changed, 11 insertions, 5 deletions
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; } |