Skip to content

Commit

Permalink
Merge pull request #3329 from Venseer/improved-atcommand-iteminfo
Browse files Browse the repository at this point in the history
Improved atCommand(iteminfo)
  • Loading branch information
MishimaHaruna authored Oct 31, 2024
2 parents 2615a40 + b0340cd commit 5accb4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion conf/messages.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@

// @iteminfo
1276: Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
1277: Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s
1277: Item: '%s'/'%s' (%d) Type: %s | Extra Effect: %s
1278: None
1279: With script
1280: NPC Buy:%dz, Sell:%dz | Weight: %.1f
Expand Down
13 changes: 11 additions & 2 deletions src/map/atcommand.c
Original file line number Diff line number Diff line change
Expand Up @@ -7718,14 +7718,22 @@ ACMD(iteminfo)
clif->message(fd, atcmd_output);
count = MAX_SEARCH;
}
StringBuf buf;
StrBuf->Init(&buf);
for (i = 0; i < count; i++) {
struct item_data *item_data = item_array[i];
if (item_data != NULL) {
snprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, MSGTBL_ITEMINFO_DETAILS), // Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s
item_data->name, item_data->jname, item_data->slot, item_data->nameid,

struct item link_item = { 0 };
link_item.nameid = item_data->nameid;
clif->format_itemlink(&buf, &link_item);

snprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, MSGTBL_ITEMINFO_DETAILS), // Item: '%s'/'%s' (%d) Type: %s | Extra Effect: %s
item_data->name, StrBuf->Value(&buf), item_data->nameid,
itemdb->typename(item_data->type),
(item_data->script == NULL) ? msg_fd(fd, MSGTBL_ITEMINFO_NONE) : msg_fd(fd, MSGTBL_ITEMINFO_WITH_SCRIPT) // None / With script
);
StrBuf->Clear(&buf);
clif->message(fd, atcmd_output);

snprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, MSGTBL_ITEMINFO_NPC_DETAILS), item_data->value_buy, item_data->value_sell, item_data->weight / 10.); // NPC Buy:%dz, Sell:%dz | Weight: %.1f
Expand All @@ -7742,6 +7750,7 @@ ACMD(iteminfo)
clif->message(fd, atcmd_output);
}
}
StrBuf->Destroy(&buf);
return true;
}

Expand Down

0 comments on commit 5accb4b

Please sign in to comment.