summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-12-26 12:19:36 +0000
committerai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-12-26 12:19:36 +0000
commit7d1f1f18cce9dc4ec17e2f9f69e9ceb8b7eb323c (patch)
tree12e62f8c7c77959125faa06116cd8e00ecebfe27 /src
parentaacf1a365aced0d8aff2717330a5e72141a5b8b1 (diff)
downloadhercules-7d1f1f18cce9dc4ec17e2f9f69e9ceb8b7eb323c.tar.gz
hercules-7d1f1f18cce9dc4ec17e2f9f69e9ceb8b7eb323c.tar.bz2
hercules-7d1f1f18cce9dc4ec17e2f9f69e9ceb8b7eb323c.tar.xz
hercules-7d1f1f18cce9dc4ec17e2f9f69e9ceb8b7eb323c.zip
* Updated commands @delitem/#delitem.
- No longer deletes stackable items one by one (bugreport:1914). - Fixed pets not getting deleted when a pet egg was deleted. - Fixed outdated usage message (since r13403). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14626 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/map/atcommand.c88
1 files changed, 49 insertions, 39 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 5200d3ba6..277f770b8 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -8506,58 +8506,68 @@ ACMD_FUNC(stats)
ACMD_FUNC(delitem)
{
char item_name[100];
- int i, number = 0, item_id, item_position, count;
- struct item_data *item_data;
- char output[CHAT_SIZE_MAX];
+ int nameid, amount = 0, total, idx;
+ struct item_data* id;
nullpo_retr(-1, sd);
- memset(item_name, '\0', sizeof(item_name));
- memset(output, '\0', sizeof(output));
+ if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
+ {
+ clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).");
+ return -1;
+ }
- if (!message || !*message || (
- sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 2 &&
- sscanf(message, "%s %d", item_name, &number) < 2
- ) || number < 1) {
- clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: #delitem <item_name_or_ID> <quantity> <player>).");
+ if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
+ {
+ nameid = id->nameid;
+ }
+ else
+ {
+ clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
return -1;
}
- item_id = 0;
- if ((item_data = itemdb_searchname(item_name)) != NULL ||
- (item_data = itemdb_exists(atoi(item_name))) != NULL)
- item_id = item_data->nameid;
-
- if (item_id > 500) {
- item_position = pc_search_inventory(sd, item_id);
- if (item_position >= 0) {
- count = 0;
- for(i = 0; i < number && item_position >= 0; i++) {
+ total = amount;
- //Logs (A)dmins items [Lupus]
- if(log_config.enable_logs&0x400)
- log_pick_pc(sd, "A", sd->status.inventory[item_position].nameid, -1, &sd->status.inventory[item_position]);
+ // delete items
+ while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
+ {
+ int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
- pc_delitem(sd, item_position, 1, 0, 0);
- count++;
- item_position = pc_search_inventory(sd, item_id); // for next loop
- }
- sprintf(output, msg_txt(113), count); // %d item(s) removed by a GM.
- clif_displaymessage(sd->fd, output);
- if (number == count)
- sprintf(output, msg_txt(114), count); // %d item(s) removed from the player.
- else
- sprintf(output, msg_txt(115), count, count, number); // %d item(s) removed. Player had only %d on %d items.
- clif_displaymessage(fd, output);
- } else {
- clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
- return -1;
+ if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
+ {// delete pet
+ intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
}
+
+ //Logs (A)dmins items [Lupus]
+ if( log_config.enable_logs&0x400 )
+ {
+ log_pick_pc(sd, "A", nameid, -delamount, &sd->status.inventory[idx]);
+ }
+
+ pc_delitem(sd, idx, delamount, 0, 0);
+
+ amount-= delamount;
+ }
+
+ // notify target
+ sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM.
+ clif_displaymessage(sd->fd, atcmd_output);
+
+ // notify source
+ if( amount == total )
+ {
+ clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
+ }
+ else if( amount )
+ {
+ sprintf(atcmd_output, msg_txt(115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
+ clif_displaymessage(fd, atcmd_output);
}
else
{
- clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
- return -1;
+ sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player.
+ clif_displaymessage(fd, atcmd_output);
}
return 0;