Skip to content

Commit 2615a40

Browse files
Merge pull request #3328 from Venseer/improved-atcommand-mobinfo
Improved atCommand(mobinfo)
2 parents 3056bce + 45004f9 commit 2615a40

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/map/atcommand.c

+19-18
Original file line numberDiff line numberDiff line change
@@ -7156,14 +7156,14 @@ ACMD(mobinfo)
71567156
unsigned char msize[3][7] = {"Small", "Medium", "Large"};
71577157
unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
71587158
unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
7159-
char atcmd_output2[CHAT_SIZE_MAX];
7159+
StringBuf buf;
71607160
struct item_data *item_data;
71617161
struct mob_db *monster, *mob_array[MAX_SEARCH];
71627162
int count;
71637163
int i, k;
71647164

71657165
memset(atcmd_output, '\0', sizeof(atcmd_output));
7166-
memset(atcmd_output2, '\0', sizeof(atcmd_output2));
7166+
StrBuf->Init(&buf);
71677167

71687168
if (!*message) {
71697169
clif->message(fd, msg_fd(fd, MSGTBL_MOBINFO_USAGE)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
@@ -7253,23 +7253,22 @@ ACMD(mobinfo)
72537253
}
72547254
#endif
72557255

7256-
if (item_data->slot)
7257-
snprintf(atcmd_output2, sizeof(atcmd_output2), " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
7258-
else
7259-
snprintf(atcmd_output2, sizeof(atcmd_output2), " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
7260-
7261-
strcat(atcmd_output, atcmd_output2);
7262-
7256+
struct item link_item = { 0 };
7257+
link_item.nameid = monster->dropitem[i].nameid;
7258+
StrBuf->AppendStr(&buf, " - ");
7259+
clif->format_itemlink(&buf, &link_item);
7260+
StrBuf->Printf(&buf, " %02.02f%%", (float)droprate / 100);
72637261
if (++j % 3 == 0) {
7264-
clif->message(fd, atcmd_output);
7265-
strcpy(atcmd_output, " ");
7262+
clif->message(fd, StrBuf->Value(&buf));
7263+
StrBuf->Clear(&buf);
72667264
}
72677265
}
72687266

72697267
if (j == 0)
72707268
clif->message(fd, msg_fd(fd, MSGTBL_MOBINFO_NO_DROPS)); // This monster has no drops.
72717269
else if (j % 3 != 0)
7272-
clif->message(fd, atcmd_output);
7270+
clif->message(fd, StrBuf->Value(&buf));
7271+
StrBuf->Clear(&buf);
72737272
// mvp
72747273
if (monster->mexp) {
72757274
snprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, MSGTBL_MOBINFO_MVP_BONUS_EXP), monster->mexp); // MVP Bonus EXP:%u
@@ -7282,19 +7281,21 @@ ACMD(mobinfo)
72827281
continue;
72837282
if (monster->mvpitem[i].p > 0) {
72847283
j++;
7285-
if(item_data->slot)
7286-
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);
7287-
else
7288-
snprintf(atcmd_output2, sizeof(atcmd_output2), " %s%s %02.02f%%", j != 1 ? "- " : "", item_data->jname, (float)monster->mvpitem[i].p / 100);
7289-
strcat(atcmd_output, atcmd_output2);
7284+
struct item link_item = { 0 };
7285+
link_item.nameid = monster->mvpitem[i].nameid;
7286+
StrBuf->AppendStr(&buf, j != 1 ? " - " : "");
7287+
clif->format_itemlink(&buf, &link_item);
7288+
StrBuf->Printf(&buf, " %02.02f%%", (float)monster->mvpitem[i].p / 100);
72907289
}
72917290
}
7291+
72927292
if (j == 0)
72937293
clif->message(fd, msg_fd(fd, MSGTBL_MOBINFO_NO_MVP_PRIZES)); // This monster has no MVP prizes.
72947294
else
7295-
clif->message(fd, atcmd_output);
7295+
clif->message(fd, StrBuf->Value(&buf));
72967296
}
72977297
}
7298+
StrBuf->Destroy(&buf);
72987299
return true;
72997300
}
73007301

0 commit comments

Comments
 (0)