Improved itemlink logic (#7532)

Fixed tags and separators for various packet versions.

If itemlink is disabled it will output the item name with the refine as prefix and the slots as suffix (if equipment)
It will also append [0] if the item is an equipment and has 0 slots (to make it easier to tell from non-equipment items)

Disabled feature on packet versions older than 2015-11-04 until proven otherwise

Fixes #7441

Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
This commit is contained in:
Lemon
2023-01-23 06:49:18 -03:00
committed by GitHub
parent f4ad5045a5
commit 7e62670882
12 changed files with 122 additions and 110 deletions

View File

@@ -4008,7 +4008,7 @@ ACMD_FUNC(idsearch)
for(const auto &result : item_array) {
std::shared_ptr<item_data> id = result.second;
sprintf(atcmd_output, msg_txt(sd,78), item_db.create_item_link( id->nameid ).c_str(), id->nameid); // %s: %u
sprintf(atcmd_output, msg_txt(sd,78), item_db.create_item_link( id ).c_str(), id->nameid); // %s: %u
clif_displaymessage(fd, atcmd_output);
}
sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
@@ -6656,7 +6656,7 @@ ACMD_FUNC(autolootitem)
return -1;
}
sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
sprintf(atcmd_output, msg_txt(sd,1192), item_data->name.c_str(), item_db.create_item_link( item_data->nameid ).c_str(), item_data->nameid); // Autolooting item: '%s'/'%s' {%u}
sprintf(atcmd_output, msg_txt(sd,1192), item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(), item_data->nameid); // Autolooting item: '%s'/'%s' {%u}
clif_displaymessage(fd, atcmd_output);
sd->state.autolooting = 1;
break;
@@ -6667,7 +6667,7 @@ ACMD_FUNC(autolootitem)
return -1;
}
sd->state.autolootid[i] = 0;
sprintf(atcmd_output, msg_txt(sd,1194), item_data->name.c_str(), item_db.create_item_link( item_data->nameid ).c_str(), item_data->nameid); // Removed item: '%s'/'%s' {%u} from your autolootitem list.
sprintf(atcmd_output, msg_txt(sd,1194), item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(), item_data->nameid); // Removed item: '%s'/'%s' {%u} from your autolootitem list.
clif_displaymessage(fd, atcmd_output);
ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
if (i == AUTOLOOTITEM_SIZE) {
@@ -6695,7 +6695,7 @@ ACMD_FUNC(autolootitem)
continue;
}
sprintf(atcmd_output, "'%s'/'%s' {%u}", item_data->name.c_str(), item_db.create_item_link( item_data->nameid ).c_str(), item_data->nameid);
sprintf(atcmd_output, "'%s'/'%s' {%u}", item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(), item_data->nameid);
clif_displaymessage(fd, atcmd_output);
}
}
@@ -7761,10 +7761,7 @@ ACMD_FUNC(mobinfo)
int droprate = mob_getdroprate( &sd->bl, mob, mob->dropitem[i].rate, drop_modifier );
if (id->slots)
sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_db.create_item_link( id->nameid ).c_str(), id->slots, (float)droprate / 100);
else
sprintf(atcmd_output2, " - %s %02.02f%%", item_db.create_item_link( id->nameid ).c_str(), (float)droprate / 100);
sprintf(atcmd_output2, " - %s %02.02f%%", item_db.create_item_link( id ).c_str(), (float)droprate / 100);
strcat(atcmd_output, atcmd_output2);
if (++j % 3 == 0) {
clif_displaymessage(fd, atcmd_output);
@@ -7801,15 +7798,9 @@ ACMD_FUNC(mobinfo)
if (mvppercent > 0) {
j++;
if (j == 1) {
if (id->slots)
sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_db.create_item_link( id->nameid ).c_str(), id->slots, mvppercent);
else
sprintf(atcmd_output2, " %s %02.02f%%", item_db.create_item_link( id->nameid ).c_str(), mvppercent);
sprintf(atcmd_output2, " %s %02.02f%%", item_db.create_item_link( id ).c_str(), mvppercent);
} else {
if (id->slots)
sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_db.create_item_link( id->nameid ).c_str(), id->slots, mvppercent);
else
sprintf(atcmd_output2, " - %s %02.02f%%", item_db.create_item_link( id->nameid ).c_str(), mvppercent);
sprintf(atcmd_output2, " - %s %02.02f%%", item_db.create_item_link( id ).c_str(), mvppercent);
}
strcat(atcmd_output, atcmd_output2);
}
@@ -8243,8 +8234,8 @@ ACMD_FUNC(iteminfo)
for (const auto &result : item_array) {
std::shared_ptr<item_data> item_data = result.second;
sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%u) Type: %s | Extra Effect: %s
item_data->name.c_str(), item_db.create_item_link( item_data->nameid ).c_str(),item_data->slots,item_data->nameid,
sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s' (%u) Type: %s | Extra Effect: %s
item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(),item_data->nameid,
(item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((e_ammo_type)item_data->subtype),
(item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
);
@@ -8301,7 +8292,7 @@ ACMD_FUNC(whodrops)
for (const auto &result : item_array) {
std::shared_ptr<item_data> id = result.second;
sprintf(atcmd_output, msg_txt(sd,1285), item_db.create_item_link( id->nameid ).c_str(), id->slots, id->nameid); // Item: '%s'[%d] (ID:%u)
sprintf(atcmd_output, msg_txt(sd,1285), item_db.create_item_link( id ).c_str(), id->nameid); // Item: '%s' (ID:%u)
clif_displaymessage(fd, atcmd_output);
if (id->mob[0].chance == 0) {
@@ -9249,7 +9240,7 @@ ACMD_FUNC(itemlist)
{
int i, j, count, counter;
const char* location;
const struct item* items;
struct item* items;
int size;
StringBuf buf;
@@ -9277,7 +9268,7 @@ ACMD_FUNC(itemlist)
count = 0; // total slots occupied
counter = 0; // total items found
for( i = 0; i < size; ++i ) {
const struct item* it = &items[i];
struct item* it = &items[i];
if( it->nameid == 0 )
continue;
@@ -9296,10 +9287,7 @@ ACMD_FUNC(itemlist)
StringBuf_Clear(&buf);
}
if( it->refine )
StringBuf_Printf(&buf, "%d %s %+d (%s, id: %u)", it->amount, item_db.create_item_link( it->nameid ).c_str(), it->refine, itd->name.c_str(), it->nameid);
else
StringBuf_Printf(&buf, "%d %s (%s, id: %u)", it->amount, item_db.create_item_link( it->nameid ).c_str(), itd->name.c_str(), it->nameid);
StringBuf_Printf(&buf, "%d %s (%s, id: %u)", it->amount, item_db.create_item_link( *it ).c_str(), itd->name.c_str(), it->nameid);
if( it->equip ) {
char equipstr[CHAT_SIZE_MAX];
@@ -9402,7 +9390,7 @@ ACMD_FUNC(itemlist)
if( counter2 != 1 )
StringBuf_AppendStr(&buf, ", ");
StringBuf_Printf(&buf, "#%d %s (id: %u)", counter2, item_db.create_item_link( card->nameid ).c_str(), card->nameid);
StringBuf_Printf(&buf, "#%d %s (id: %u)", counter2, item_db.create_item_link( card ).c_str(), card->nameid);
}
if( counter2 > 0 )