Skip to content

Commit

Permalink
[Refactor] hengband#4569 describe_flavor() を呼び出しでポインタを参照へ変えられる箇所を変えた …
Browse files Browse the repository at this point in the history
…(フォルダの頭文字:w)
  • Loading branch information
Hourier committed Nov 21, 2024
1 parent 397dc15 commit b5fa503
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 28 deletions.
14 changes: 7 additions & 7 deletions src/window/display-sub-windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ static void display_equipment(PlayerType *player_ptr, const ItemTester &item_tes
break;
}

auto o_ptr = &player_ptr->inventory_list[i];
auto do_disp = player_ptr->select_ring_slot ? is_ring_slot(i) : item_tester.okay(o_ptr);
const auto &item = player_ptr->inventory_list[i];
auto do_disp = player_ptr->select_ring_slot ? is_ring_slot(i) : item_tester.okay(&item);
std::string tmp_val = " ";

if (do_disp) {
Expand All @@ -334,17 +334,17 @@ static void display_equipment(PlayerType *player_ptr, const ItemTester &item_tes
item_name = _("(武器を両手持ち)", "(wielding with two-hands)");
attr = TERM_WHITE;
} else {
item_name = describe_flavor(player_ptr, *o_ptr, 0);
attr = tval_to_attr[enum2i(o_ptr->bi_key.tval()) % 128];
item_name = describe_flavor(player_ptr, item, 0);
attr = tval_to_attr[enum2i(item.bi_key.tval()) % 128];
}

int n = item_name.length();
if (o_ptr->timeout) {
if (item.timeout) {
attr = TERM_L_DARK;
}

if (show_item_graph) {
term_queue_bigchar(cur_col, cur_row, { o_ptr->get_symbol(), {} });
term_queue_bigchar(cur_col, cur_row, { item.get_symbol(), {} });
if (use_bigtile) {
cur_col++;
}
Expand All @@ -354,7 +354,7 @@ static void display_equipment(PlayerType *player_ptr, const ItemTester &item_tes

term_putstr(cur_col, cur_row, n, attr, item_name);
if (show_weights) {
int wgt = o_ptr->weight * o_ptr->number;
int wgt = item.weight * item.number;
tmp_val = format(_("%3d.%1d kg", "%3d.%1d lb"), _(lb_to_kg_integer(wgt), wgt / 10), _(lb_to_kg_fraction(wgt), wgt % 10));
prt(tmp_val, cur_row, wid - (show_labels ? 28 : 9));
}
Expand Down
17 changes: 8 additions & 9 deletions src/window/main-window-equipments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ COMMAND_CODE show_equipment(PlayerType *player_ptr, int target_item, BIT_FLAGS m
{
COMMAND_CODE i;
int j, k, l;
ItemEntity *o_ptr;
COMMAND_CODE out_index[23]{};
TERM_COLOR out_color[23]{};
std::array<std::string, 23> out_desc{};
Expand All @@ -43,8 +42,8 @@ COMMAND_CODE show_equipment(PlayerType *player_ptr, int target_item, BIT_FLAGS m
const auto &[wid, hgt] = term_get_size();
auto len = wid - col - 1;
for (k = 0, i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
o_ptr = &player_ptr->inventory_list[i];
auto only_slot = !(player_ptr->select_ring_slot ? is_ring_slot(i) : (item_tester.okay(o_ptr) || any_bits(mode, USE_FULL)));
const auto &item = player_ptr->inventory_list[i];
auto only_slot = !(player_ptr->select_ring_slot ? is_ring_slot(i) : (item_tester.okay(&item) || any_bits(mode, USE_FULL)));
auto is_any_hand = (i == INVEN_MAIN_HAND) && can_attack_with_sub_hand(player_ptr);
is_any_hand |= (i == INVEN_SUB_HAND) && can_attack_with_main_hand(player_ptr);
auto is_two_handed = is_any_hand && has_two_handed_weapons(player_ptr);
Expand All @@ -53,17 +52,17 @@ COMMAND_CODE show_equipment(PlayerType *player_ptr, int target_item, BIT_FLAGS m
continue;
}

const auto item_name = describe_flavor(player_ptr, *o_ptr, 0);
const auto item_name = describe_flavor(player_ptr, item, 0);
if (is_two_handed) {
out_desc[k] = _("(武器を両手持ち)", "(wielding with two-hands)");
out_color[k] = TERM_WHITE;
} else {
out_desc[k] = item_name;
out_color[k] = tval_to_attr[enum2i(o_ptr->bi_key.tval()) % 128];
out_color[k] = tval_to_attr[enum2i(item.bi_key.tval()) % 128];
}

out_index[k] = i;
if (o_ptr->timeout) {
if (item.timeout) {
out_color[k] = TERM_L_DARK;
}
l = out_desc[k].length() + (2 + _(1, 3));
Expand Down Expand Up @@ -91,7 +90,7 @@ COMMAND_CODE show_equipment(PlayerType *player_ptr, int target_item, BIT_FLAGS m
prepare_label_string(player_ptr, equip_label, USE_EQUIP, item_tester);
for (j = 0; j < k; j++) {
i = out_index[j];
o_ptr = &player_ptr->inventory_list[i];
const auto &item = player_ptr->inventory_list[i];
prt("", j + 1, col ? col - 2 : col);
std::string head;
if (use_menu && target_item) {
Expand All @@ -110,7 +109,7 @@ COMMAND_CODE show_equipment(PlayerType *player_ptr, int target_item, BIT_FLAGS m
put_str(head, j + 1, col);
int cur_col = col + 3;
if (show_item_graph) {
term_queue_bigchar(cur_col, j + 1, { o_ptr->get_symbol(), {} });
term_queue_bigchar(cur_col, j + 1, { item.get_symbol(), {} });
if (use_bigtile) {
cur_col++;
}
Expand All @@ -130,7 +129,7 @@ COMMAND_CODE show_equipment(PlayerType *player_ptr, int target_item, BIT_FLAGS m
continue;
}

int wgt = o_ptr->weight * o_ptr->number;
auto wgt = item.weight * item.number;
const auto weight = format(_("%3d.%1d kg", "%3d.%d lb"), _(lb_to_kg_integer(wgt), wgt / 10), _(lb_to_kg_fraction(wgt), wgt % 10));
prt(weight, j + 1, wid - 9);
}
Expand Down
10 changes: 5 additions & 5 deletions src/window/main-window-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ void print_map(PlayerType *player_ptr)
/*!
* @brief 短縮マップにおける自動拾い対象のアイテムを短縮表記する
* @param player_ptr プレイヤーへの参照ポインタ
* @param o_ptr アイテムへの参照ポインタ
* @param item アイテムへの参照
* @param y 表示する行番号
*/
static void display_shortened_item_name(PlayerType *player_ptr, ItemEntity *o_ptr, int y)
static void display_shortened_item_name(PlayerType *player_ptr, const ItemEntity &item, int y)
{
auto item_name = describe_flavor(player_ptr, *o_ptr, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NAME_ONLY));
auto attr = tval_to_attr[enum2i(o_ptr->bi_key.tval()) % 128];
auto item_name = describe_flavor(player_ptr, item, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NAME_ONLY));
auto attr = tval_to_attr[enum2i(item.bi_key.tval()) % 128];
if (player_ptr->effects()->hallucination().is_hallucinated()) {
attr = TERM_WHITE;
item_name = _("何か奇妙な物", "something strange");
Expand Down Expand Up @@ -270,7 +270,7 @@ void display_map(PlayerType *player_ptr, int *cy, int *cx)

term_putstr(0, y, 12, 0, " ");
if (match_autopick != -1) {
display_shortened_item_name(player_ptr, autopick_obj, y);
display_shortened_item_name(player_ptr, *autopick_obj, y);
}
}

Expand Down
13 changes: 6 additions & 7 deletions src/wizard/artifact-analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
#include <sstream>

/*!
* @brief アイテムの特定記述内容を返す /
* Acquire a "basic" description "The Cloak of Death [1,+10]"
* @param o_ptr 記述を得たいオブジェクトの参照ポインタ
* @brief アイテムの特定記述内容を返す
* @param item 記述を得たいアイテムへの参照
* @param desc_ptr 記述内容を返すための文字列参照ポインタ
*/
static std::string analyze_general(PlayerType *player_ptr, const ItemEntity *o_ptr)
static std::string analyze_general(PlayerType *player_ptr, const ItemEntity &item)
{
return describe_flavor(player_ptr, *o_ptr, OD_NAME_AND_ENCHANT | OD_STORE | OD_DEBUG);
return describe_flavor(player_ptr, item, OD_NAME_AND_ENCHANT | OD_STORE | OD_DEBUG);
}

/*!
Expand Down Expand Up @@ -255,7 +254,7 @@ static std::string analyze_misc(const ItemEntity *o_ptr)
ArtifactsDumpInfo object_analyze(PlayerType *player_ptr, const ItemEntity *o_ptr)
{
ArtifactsDumpInfo info{};
info.description = analyze_general(player_ptr, o_ptr);
info.description = analyze_general(player_ptr, *o_ptr);
info.pval_info.analyze(*o_ptr);
info.brands = analyze_brand(o_ptr);
info.slays = analyze_slay(o_ptr);
Expand All @@ -279,7 +278,7 @@ ArtifactsDumpInfo object_analyze(PlayerType *player_ptr, const ItemEntity *o_ptr
ArtifactsDumpInfo random_artifact_analyze(PlayerType *player_ptr, const ItemEntity *o_ptr)
{
ArtifactsDumpInfo info{};
info.description = analyze_general(player_ptr, o_ptr);
info.description = analyze_general(player_ptr, *o_ptr);
info.pval_info.analyze(*o_ptr);
info.brands = analyze_brand(o_ptr);
info.slays = analyze_slay(o_ptr);
Expand Down

0 comments on commit b5fa503

Please sign in to comment.