diff --git a/src/Client.cc b/src/Client.cc index 2138d0fd..68efb6e8 100644 --- a/src/Client.cc +++ b/src/Client.cc @@ -1047,44 +1047,28 @@ void Client::use_character_bank(int8_t index) { } void Client::print_inventory(FILE* stream) const { + auto s = this->require_server_state(); auto p = this->character(); - shared_ptr name_index; - try { - name_index = this->require_server_state()->item_name_index(this->version()); - } catch (const runtime_error&) { - } fprintf(stream, "[PlayerInventory] Meseta: %" PRIu32 "\n", p->disp.stats.meseta.load()); fprintf(stream, "[PlayerInventory] %hhu items\n", p->inventory.num_items); for (size_t x = 0; x < p->inventory.num_items; x++) { const auto& item = p->inventory.items[x]; auto hex = item.data.hex(); - if (name_index) { - auto name = name_index->describe_item(item.data); - fprintf(stream, "[PlayerInventory] %2zu: [+%08" PRIX32 "] %s (%s)\n", x, item.flags.load(), hex.c_str(), name.c_str()); - } else { - fprintf(stream, "[PlayerInventory] %2zu: [+%08" PRIX32 "] %s\n", x, item.flags.load(), hex.c_str()); - } + auto name = s->describe_item(this->version(), item.data, false); + fprintf(stream, "[PlayerInventory] %2zu: [+%08" PRIX32 "] %s (%s)\n", x, item.flags.load(), hex.c_str(), name.c_str()); } } void Client::print_bank(FILE* stream) const { + auto s = this->require_server_state(); auto p = this->character(); - shared_ptr name_index; - try { - name_index = this->require_server_state()->item_name_index(this->version()); - } catch (const runtime_error&) { - } fprintf(stream, "[PlayerBank] Meseta: %" PRIu32 "\n", p->bank.meseta.load()); fprintf(stream, "[PlayerBank] %" PRIu32 " items\n", p->bank.num_items.load()); for (size_t x = 0; x < p->bank.num_items; x++) { const auto& item = p->bank.items[x]; const char* present_token = item.present ? "" : " (missing present flag)"; auto hex = item.data.hex(); - if (name_index) { - auto name = name_index->describe_item(item.data); - fprintf(stream, "[PlayerBank] %3zu: %s (%s) (x%hu)%s\n", x, hex.c_str(), name.c_str(), item.amount.load(), present_token); - } else { - fprintf(stream, "[PlayerBank] %3zu: %s (x%hu)%s\n", x, hex.c_str(), item.amount.load(), present_token); - } + auto name = s->describe_item(this->version(), item.data, false); + fprintf(stream, "[PlayerBank] %3zu: %s (%s) (x%hu)%s\n", x, hex.c_str(), name.c_str(), item.amount.load(), present_token); } } diff --git a/src/ItemNameIndex.cc b/src/ItemNameIndex.cc index 681a5052..31a07c5e 100644 --- a/src/ItemNameIndex.cc +++ b/src/ItemNameIndex.cc @@ -97,9 +97,7 @@ const array name_for_s_rank_special = { "King\'s", }; -std::string ItemNameIndex::describe_item( - const ItemData& item, - bool include_color_escapes) const { +std::string ItemNameIndex::describe_item(const ItemData& item, bool include_color_escapes) const { if (item.data1[0] == 0x04) { return string_printf("%s%" PRIu32 " Meseta", include_color_escapes ? "$C7" : "", item.data2d.load()); } diff --git a/src/ServerState.cc b/src/ServerState.cc index 98e5b016..7589fc4f 100644 --- a/src/ServerState.cc +++ b/src/ServerState.cc @@ -406,7 +406,13 @@ shared_ptr ServerState::item_name_index(Version version) co } string ServerState::describe_item(Version version, const ItemData& item, bool include_color_codes) const { - return this->item_name_index(version)->describe_item(item, include_color_codes); + if (is_v1(version)) { + ItemData encoded = item; + encoded.encode_for_version(version, this->item_parameter_table(version)); + return this->item_name_index(version)->describe_item(encoded, include_color_codes); + } else { + return this->item_name_index(version)->describe_item(item, include_color_codes); + } } ItemData ServerState::parse_item_description(Version version, const string& description) const { diff --git a/system/item-tables/ItemPMT-dc-v1.prs b/system/item-tables/ItemPMT-dc-v1.prs index a3fecfcc..369d1580 100644 Binary files a/system/item-tables/ItemPMT-dc-v1.prs and b/system/item-tables/ItemPMT-dc-v1.prs differ