diff --git a/docs/changelog.txt b/docs/changelog.txt index e1ddf8d47c..e9713f8b9f 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -105,6 +105,7 @@ Template for new versions: - ``Buildings`` module: add ``getOwner`` (using the ``Units::get_cached_unit_by_global_id`` mechanic) to reflect changes in 51.11 - ``Units::teleport``: projectile information is now cleared for teleported units - ``Buildings::setOwner``: updated for changes in 51.11 +- ``Items::getDescription``: fixed display of quality levels, now displays ALL item designations (in correct order) and obeys SHOW_IMP_QUALITY ## Lua - ``dfhack.military.addToSquad``: expose Military API function diff --git a/library/modules/Items.cpp b/library/modules/Items.cpp index 36d1748c5b..a161bea8a2 100644 --- a/library/modules/Items.cpp +++ b/library/modules/Items.cpp @@ -49,6 +49,7 @@ distribution. #include "df/caravan_state.h" #include "df/creature_raw.h" #include "df/dfhack_material_category.h" +#include "df/d_init.h" #include "df/entity_buy_prices.h" #include "df/entity_buy_requests.h" #include "df/entity_raw.h" @@ -678,14 +679,54 @@ string Items::getDescription(df::item *item, int type, bool decorate) { item->getItemDescription(&tmp, type); if (decorate) { - addQuality(tmp, item->getQuality()); + // Special indicators get added in a specific order + // Innermost is at the top, and outermost is at the bottom - if (item->isImproved()) { + // First, figure out the quality levels we're going to display + int craftquality = item->getQuality(); + int craftquality_only_imps = item->getImprovementQuality(); + bool has_displayed_item_improvements = item->isImproved(); + if (!has_displayed_item_improvements && (craftquality < craftquality_only_imps)) + craftquality = craftquality_only_imps; + + // First, actual item quality + addQuality(tmp, craftquality); + + // Next, magic enchants + if (item->getMagic() != NULL) + tmp = '\x11' + tmp + '\x10'; // <| |> + + // Next, improvements + if (has_displayed_item_improvements) { tmp = '\xAE' + tmp + '\xAF'; // («) + tmp + (») - addQuality(tmp, item->getImprovementQuality()); + if (df::global::d_init->display.flags.is_set(d_init_flags1::SHOW_IMP_QUALITY)) + addQuality(tmp, craftquality_only_imps); + } + + // Dwarf mode only, forbid/foreign + if (*df::global::gamemode == game_mode::DWARF) { + if (item->flags.bits.forbid) + tmp = '{' + tmp + '}'; + if (item->flags.bits.foreign) + tmp = '(' + tmp + ')'; + } + + // Wear + switch (item->getWear()) + { + case 1: tmp = 'x' + tmp + 'x'; break; + case 2: tmp = 'X' + tmp + 'X'; break; + case 3: tmp = "XX" + tmp + "XX"; break; } - if (item->flags.bits.foreign) - tmp = "(" + tmp + ")"; + + // Fire + if (item->flags.bits.on_fire) + tmp = '\x13' + tmp + '\x13'; // !! !! + + // Finally, Adventure civzone + if ((*df::global::gamemode == game_mode::ADVENTURE) && + Items::getGeneralRef(item, general_ref_type::BUILDING_CIVZONE_ASSIGNED) != NULL) + tmp = '$' + tmp + '$'; } return tmp; } @@ -721,13 +762,6 @@ string Items::getReadableDescription(df::item *item) { CHECK_NULL_POINTER(item); auto desc = get_base_desc(item); - switch (item->getWear()) - { - case 1: desc = "x" + desc + "x"; break; // Worn - case 2: desc = "X" + desc + "X"; break; // Threadbare - case 3: desc = "XX" + desc + "XX"; break; // Tattered - } - if (auto gref = Items::getGeneralRef(item, general_ref_type::CONTAINS_UNIT)) { if (auto unit = gref->getUnit()) {