From 4b32685d2d1220ec60c8290423c73c95737fe29a Mon Sep 17 00:00:00 2001 From: Venseer Date: Tue, 29 Oct 2024 19:21:48 -0300 Subject: [PATCH] Improved atCommand(mobinfo) --- src/map/atcommand.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/map/atcommand.c b/src/map/atcommand.c index e3fc633d86f..a192f0a3f69 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -7156,14 +7156,13 @@ ACMD(mobinfo) unsigned char msize[3][7] = {"Small", "Medium", "Large"}; unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"}; unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"}; - char atcmd_output2[CHAT_SIZE_MAX]; + StringBuf buf; struct item_data *item_data; struct mob_db *monster, *mob_array[MAX_SEARCH]; int count; int i, k; memset(atcmd_output, '\0', sizeof(atcmd_output)); - memset(atcmd_output2, '\0', sizeof(atcmd_output2)); if (!*message) { clif->message(fd, msg_fd(fd, MSGTBL_MOBINFO_USAGE)); // Please enter a monster name/ID (usage: @mobinfo ). @@ -7236,6 +7235,7 @@ ACMD(mobinfo) clif->message(fd, msg_fd(fd, MSGTBL_MOBINFO_DROPS_HEADER)); // Drops: strcpy(atcmd_output, " "); j = 0; + StrBuf->Init(&buf); for (i = 0; i < MAX_MOB_DROP; i++) { int droprate; @@ -7253,23 +7253,22 @@ ACMD(mobinfo) } #endif - if (item_data->slot) - snprintf(atcmd_output2, sizeof(atcmd_output2), " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100); - else - snprintf(atcmd_output2, sizeof(atcmd_output2), " - %s %02.02f%%", item_data->jname, (float)droprate / 100); - - strcat(atcmd_output, atcmd_output2); - + struct item link_item = { 0 }; + link_item.nameid = monster->dropitem[i].nameid; + StrBuf->AppendStr(&buf, " - "); + clif->format_itemlink(&buf, &link_item); + StrBuf->Printf(&buf, " %02.02f%%", (float)droprate / 100); if (++j % 3 == 0) { - clif->message(fd, atcmd_output); - strcpy(atcmd_output, " "); + clif->message(fd, StrBuf->Value(&buf)); + StrBuf->Clear(&buf); } } if (j == 0) clif->message(fd, msg_fd(fd, MSGTBL_MOBINFO_NO_DROPS)); // This monster has no drops. else if (j % 3 != 0) - clif->message(fd, atcmd_output); + clif->message(fd, StrBuf->Value(&buf)); + StrBuf->Clear(&buf); // mvp if (monster->mexp) { snprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, MSGTBL_MOBINFO_MVP_BONUS_EXP), monster->mexp); // MVP Bonus EXP:%u @@ -7282,13 +7281,16 @@ ACMD(mobinfo) continue; if (monster->mvpitem[i].p > 0) { j++; - if(item_data->slot) - snprintf(atcmd_output2, sizeof(atcmd_output2), " %s%s[%d] %02.02f%%", j != 1 ? "- " : "", item_data->jname, item_data->slot, (float)monster->mvpitem[i].p / 100); - else - snprintf(atcmd_output2, sizeof(atcmd_output2), " %s%s %02.02f%%", j != 1 ? "- " : "", item_data->jname, (float)monster->mvpitem[i].p / 100); - strcat(atcmd_output, atcmd_output2); + struct item link_item = { 0 }; + link_item.nameid = monster->mvpitem[i].nameid; + StrBuf->AppendStr(&buf, j != 1 ? "- " : ""); + clif->format_itemlink(&buf, &link_item); + StrBuf->Printf(&buf, " %02.02f%%", (float)monster->mvpitem[i].p / 100); + strcat(atcmd_output, StrBuf->Value(&buf)); + StrBuf->Clear(&buf); } } + StrBuf->Destroy(&buf); if (j == 0) clif->message(fd, msg_fd(fd, MSGTBL_MOBINFO_NO_MVP_PRIZES)); // This monster has no MVP prizes. else