From cb9827f048b4e8582ba3ead61141ef56af5b33c5 Mon Sep 17 00:00:00 2001 From: Hourier <66951241+Hourier@users.noreply.github.com> Date: Fri, 15 Oct 2021 19:33:33 +0900 Subject: [PATCH] [Refactor] #1437 Moved lbtokg() from h-define.h to locale/japanese.h --- src/cmd-item/cmd-equipment.cpp | 13 +++++++------ src/cmd-item/cmd-item.cpp | 4 ++++ src/floor/object-scanner.cpp | 10 +++++++--- src/locale/japanese.h | 4 ++++ src/mind/mind-info.cpp | 4 ++++ src/racial/mutation-racial-selector.cpp | 7 +++++-- src/system/h-define.h | 7 ------- src/view/display-inventory.cpp | 8 ++++++-- src/view/display-store.cpp | 4 ++++ src/window/display-sub-windows.cpp | 11 +++++++---- src/window/main-window-equipments.cpp | 16 ++++++++-------- src/wizard/artifact-analyzer.cpp | 16 ++++++++-------- 12 files changed, 64 insertions(+), 40 deletions(-) diff --git a/src/cmd-item/cmd-equipment.cpp b/src/cmd-item/cmd-equipment.cpp index bd9f9ffd1..c092ba007 100644 --- a/src/cmd-item/cmd-equipment.cpp +++ b/src/cmd-item/cmd-equipment.cpp @@ -31,8 +31,8 @@ #include "object/object-mark-types.h" #include "perception/object-perception.h" #include "player-base/player-class.h" -#include "player-info/samurai-data-type.h" #include "player-info/equipment-info.h" +#include "player-info/samurai-data-type.h" #include "player-status/player-energy.h" #include "player-status/player-hand-types.h" #include "player/attack-defense-types.h" @@ -49,6 +49,10 @@ #include "view/display-inventory.h" #include "view/display-messages.h" +#ifdef JP +#include "locale/japanese.h" +#endif + /*! * @brief 装備一覧を表示するコマンドのメインルーチン / Display equipment */ @@ -185,9 +189,7 @@ void do_cmd_wield(player_type *player_ptr) return; } - if (confirm_wear - && ((o_ptr->is_cursed() && o_ptr->is_known()) - || ((o_ptr->ident & IDENT_SENSE) && (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED)))) { + if (confirm_wear && ((o_ptr->is_cursed() && o_ptr->is_known()) || ((o_ptr->ident & IDENT_SENSE) && (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED)))) { char dummy[MAX_NLEN + 80]; describe_flavor(player_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); sprintf(dummy, _("本当に%s{呪われている}を使いますか?", "Really use the %s {cursed}? "), o_name); @@ -196,8 +198,7 @@ void do_cmd_wield(player_type *player_ptr) return; } - if ((o_ptr->name1 == ART_STONEMASK) && o_ptr->is_known() && (player_ptr->prace != PlayerRaceType::VAMPIRE) - && (player_ptr->prace != PlayerRaceType::ANDROID)) { + if ((o_ptr->name1 == ART_STONEMASK) && o_ptr->is_known() && (player_ptr->prace != PlayerRaceType::VAMPIRE) && (player_ptr->prace != PlayerRaceType::ANDROID)) { char dummy[MAX_NLEN + 100]; describe_flavor(player_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); sprintf(dummy, diff --git a/src/cmd-item/cmd-item.cpp b/src/cmd-item/cmd-item.cpp index ca69195f6..5f4a58da3 100644 --- a/src/cmd-item/cmd-item.cpp +++ b/src/cmd-item/cmd-item.cpp @@ -68,6 +68,10 @@ #include "view/display-inventory.h" #include "view/display-messages.h" +#ifdef JP +#include "locale/japanese.h" +#endif + /*! * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display inventory_list */ diff --git a/src/floor/object-scanner.cpp b/src/floor/object-scanner.cpp index d9f74c1c2..03f457848 100644 --- a/src/floor/object-scanner.cpp +++ b/src/floor/object-scanner.cpp @@ -1,6 +1,6 @@ #include "floor/object-scanner.h" -#include "floor/cave.h" #include "flavor/flavor-describer.h" +#include "floor/cave.h" #include "game-option/text-display-options.h" #include "inventory/inventory-util.h" #include "io/input-key-requester.h" @@ -13,6 +13,10 @@ #include "term/gameterm.h" #include "term/screen-processor.h" +#ifdef JP +#include "locale/japanese.h" +#endif + /*! * @brief 床に落ちているオブジェクトの数を返す / scan floor items * @param items オブジェクトのIDリストを返すための配列参照ポインタ @@ -28,7 +32,7 @@ * mode & 0x02 -- Marked items only * mode & 0x04 -- Stop after first */ -ITEM_NUMBER scan_floor_items(player_type *player_ptr, OBJECT_IDX *items, POSITION y, POSITION x, BIT_FLAGS mode, const ItemTester& item_tester) +ITEM_NUMBER scan_floor_items(player_type *player_ptr, OBJECT_IDX *items, POSITION y, POSITION x, BIT_FLAGS mode, const ItemTester &item_tester) { floor_type *floor_ptr = player_ptr->current_floor_ptr; if (!in_bounds(floor_ptr, y, x)) @@ -90,7 +94,7 @@ static void prepare_label_string_floor(floor_type *floor_ptr, char *label, FLOOR * @return 選択したアイテムの添え字 * @details */ -COMMAND_CODE show_floor_items(player_type *player_ptr, int target_item, POSITION y, POSITION x, TERM_LEN *min_width, const ItemTester& item_tester) +COMMAND_CODE show_floor_items(player_type *player_ptr, int target_item, POSITION y, POSITION x, TERM_LEN *min_width, const ItemTester &item_tester) { COMMAND_CODE i, m; int j, k, l; diff --git a/src/locale/japanese.h b/src/locale/japanese.h index 387a62ab6..dabf933d1 100644 --- a/src/locale/japanese.h +++ b/src/locale/japanese.h @@ -15,6 +15,10 @@ byte codeconv(char *str); bool iskanji2(concptr s, int x); void guess_convert_to_system_encoding(char *strbuf, int buflen); +#define lbtokg(x) ((int)((x)*5)) /*!< 変愚蛮怒基準のポンド→キログラム変換定義(全体) */ +#define lbtokg1(x) (lbtokg(x) / 100) /*!< 変愚蛮怒基準のポンド→キログラム変換定義(整数部) */ +#define lbtokg2(x) ((lbtokg(x) % 100) / 10) /*!< 変愚蛮怒基準のポンド→キログラム変換定義(少数部) */ + #ifdef EUC int utf8_to_euc(char *utf8_str, size_t utf8_str_len, char *euc_buf, size_t euc_buf_len); int euc_to_utf8(const char *euc_str, size_t euc_str_len, char *utf8_buf, size_t utf8_buf_len); diff --git a/src/mind/mind-info.cpp b/src/mind/mind-info.cpp index c6f45231d..aad9e1f5c 100644 --- a/src/mind/mind-info.cpp +++ b/src/mind/mind-info.cpp @@ -5,6 +5,10 @@ #include "player-info/equipment-info.h" #include "system/player-type-definition.h" +#ifdef JP +#include "locale/japanese.h" +#endif + static void switch_mind_mindcrafter(player_type *player_ptr, const PLAYER_LEVEL plev, const int power, char *p) { switch (power) { diff --git a/src/racial/mutation-racial-selector.cpp b/src/racial/mutation-racial-selector.cpp index 2f41a1fba..7b2343fd0 100644 --- a/src/racial/mutation-racial-selector.cpp +++ b/src/racial/mutation-racial-selector.cpp @@ -5,6 +5,10 @@ #include "system/player-type-definition.h" #include "util/enum-converter.h" +#ifdef JP +#include "locale/japanese.h" +#endif + void select_mutation_racial(player_type *player_ptr, rc_type *rc_ptr) { rpi_type rpi; @@ -238,8 +242,7 @@ void select_mutation_racial(player_type *player_ptr, rc_type *rc_ptr) if (player_ptr->muta.has(MUTA::EARTHQUAKE)) { rpi = rpi_type(_("地震", "Earthquake")); rpi.info = format("%s%d", KWD_SPHERE, 10); - rpi.text - = _("周囲のダンジョンを揺らし、壁と床をランダムに入れ変える。", "Shakes dungeon structure, and results in random swapping of floors and walls."); + rpi.text = _("周囲のダンジョンを揺らし、壁と床をランダムに入れ変える。", "Shakes dungeon structure, and results in random swapping of floors and walls."); rpi.min_level = 12; rpi.cost = 12; rpi.stat = A_STR; diff --git a/src/system/h-define.h b/src/system/h-define.h index 01639bb89..a9717dc04 100644 --- a/src/system/h-define.h +++ b/src/system/h-define.h @@ -9,13 +9,6 @@ #ifndef INCLUDED_H_DEFINE_H #define INCLUDED_H_DEFINE_H -/**** Simple "Macros" ****/ -#ifdef JP -#define lbtokg(x) ((int)((x)*5)) /*!< 変愚蛮怒基準のポンド→キログラム変換定義(全体) */ -#define lbtokg1(x) (lbtokg(x)/100) /*!< 変愚蛮怒基準のポンド→キログラム変換定義(整数部) */ -#define lbtokg2(x) ((lbtokg(x)%100)/10) /*!< 変愚蛮怒基準のポンド→キログラム変換定義(少数部) */ -#endif - /* * Refer to the member at offset of structure */ diff --git a/src/view/display-inventory.cpp b/src/view/display-inventory.cpp index 7af8cc451..66af6481e 100644 --- a/src/view/display-inventory.cpp +++ b/src/view/display-inventory.cpp @@ -15,6 +15,10 @@ #include "term/screen-processor.h" #include "term/term-color-types.h" +#ifdef JP +#include "locale/japanese.h" +#endif + /*! * @brief 所持アイテムの表示を行う / * Display the inventory. @@ -23,7 +27,7 @@ * @details * Hack -- do not display "trailing" empty slots */ -COMMAND_CODE show_inventory(player_type *player_ptr, int target_item, BIT_FLAGS mode, const ItemTester& item_tester) +COMMAND_CODE show_inventory(player_type *player_ptr, int target_item, BIT_FLAGS mode, const ItemTester &item_tester) { COMMAND_CODE i; int k, l, z = 0; @@ -126,7 +130,7 @@ COMMAND_CODE show_inventory(player_type *player_ptr, int target_item, BIT_FLAGS * @brief 所持アイテム一覧を表示する / * Choice window "shadow" of the "show_inven()" function */ -void display_inventory(player_type *player_ptr, const ItemTester& item_tester) +void display_inventory(player_type *player_ptr, const ItemTester &item_tester) { int i, n, z = 0; TERM_COLOR attr = TERM_WHITE; diff --git a/src/view/display-store.cpp b/src/view/display-store.cpp index e8a70ef46..502f482ee 100644 --- a/src/view/display-store.cpp +++ b/src/view/display-store.cpp @@ -19,6 +19,10 @@ #include "util/enum-converter.h" #include "util/int-char-converter.h" +#ifdef JP +#include "locale/japanese.h" +#endif + /*! * @brief プレイヤーの所持金を表示する / * Displays players gold -RAK- diff --git a/src/window/display-sub-windows.cpp b/src/window/display-sub-windows.cpp index 82c643bc4..59527cdbd 100644 --- a/src/window/display-sub-windows.cpp +++ b/src/window/display-sub-windows.cpp @@ -48,10 +48,14 @@ #include #include +#ifdef JP +#include "locale/japanese.h" +#endif + /*! サブウィンドウ表示用の ItemTester オブジェクト */ static std::unique_ptr fix_item_tester = std::make_unique(); -FixItemTesterSetter::FixItemTesterSetter(const ItemTester& item_tester) +FixItemTesterSetter::FixItemTesterSetter(const ItemTester &item_tester) { fix_item_tester = item_tester.clone(); } @@ -230,7 +234,7 @@ void fix_monster_list(player_type *player_ptr) * @brief 装備アイテム一覧を表示する / * Choice window "shadow" of the "show_equip()" function */ -static void display_equipment(player_type *player_ptr, const ItemTester& item_tester) +static void display_equipment(player_type *player_ptr, const ItemTester &item_tester) { if (!player_ptr || !player_ptr->inventory_list) return; @@ -259,8 +263,7 @@ static void display_equipment(player_type *player_ptr, const ItemTester& item_te term_erase(cur_col, cur_row, 255); term_putstr(0, cur_row, cur_col, TERM_WHITE, tmp_val); - if ((((i == INVEN_MAIN_HAND) && can_attack_with_sub_hand(player_ptr)) || ((i == INVEN_SUB_HAND) && can_attack_with_main_hand(player_ptr))) - && has_two_handed_weapons(player_ptr)) { + if ((((i == INVEN_MAIN_HAND) && can_attack_with_sub_hand(player_ptr)) || ((i == INVEN_SUB_HAND) && can_attack_with_main_hand(player_ptr))) && has_two_handed_weapons(player_ptr)) { strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)")); attr = TERM_WHITE; } else { diff --git a/src/window/main-window-equipments.cpp b/src/window/main-window-equipments.cpp index a2c3afe5b..6bd44502e 100644 --- a/src/window/main-window-equipments.cpp +++ b/src/window/main-window-equipments.cpp @@ -10,12 +10,16 @@ #include "object/item-use-flags.h" #include "object/object-info.h" #include "object/object-kind.h" +#include "player/player-status-flags.h" #include "system/object-type-definition.h" #include "system/player-type-definition.h" #include "term/gameterm.h" #include "term/screen-processor.h" #include "term/term-color-types.h" -#include "player/player-status-flags.h" + +#ifdef JP +#include "locale/japanese.h" +#endif /*! * @brief メインウィンドウの右上に装備アイテムの表示させる @@ -23,7 +27,7 @@ * @param target_item アイテムの選択処理を行うか否か。 * @return 選択したアイテムのタグ */ -COMMAND_CODE show_equipment(player_type *player_ptr, int target_item, BIT_FLAGS mode, const ItemTester& item_tester) +COMMAND_CODE show_equipment(player_type *player_ptr, int target_item, BIT_FLAGS mode, const ItemTester &item_tester) { COMMAND_CODE i; int j, k, l; @@ -41,15 +45,11 @@ COMMAND_CODE show_equipment(player_type *player_ptr, int target_item, BIT_FLAGS int len = wid - col - 1; for (k = 0, i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) { o_ptr = &player_ptr->inventory_list[i]; - if (!(player_ptr->select_ring_slot ? is_ring_slot(i) : item_tester.okay(o_ptr) || (mode & USE_FULL)) - && (!((((i == INVEN_MAIN_HAND) && can_attack_with_sub_hand(player_ptr)) || ((i == INVEN_SUB_HAND) && can_attack_with_main_hand(player_ptr))) - && has_two_handed_weapons(player_ptr)) - || (mode & IGNORE_BOTHHAND_SLOT))) + if (!(player_ptr->select_ring_slot ? is_ring_slot(i) : item_tester.okay(o_ptr) || (mode & USE_FULL)) && (!((((i == INVEN_MAIN_HAND) && can_attack_with_sub_hand(player_ptr)) || ((i == INVEN_SUB_HAND) && can_attack_with_main_hand(player_ptr))) && has_two_handed_weapons(player_ptr)) || (mode & IGNORE_BOTHHAND_SLOT))) continue; describe_flavor(player_ptr, o_name, o_ptr, 0); - if ((((i == INVEN_MAIN_HAND) && can_attack_with_sub_hand(player_ptr)) || ((i == INVEN_SUB_HAND) && can_attack_with_main_hand(player_ptr))) - && has_two_handed_weapons(player_ptr)) { + if ((((i == INVEN_MAIN_HAND) && can_attack_with_sub_hand(player_ptr)) || ((i == INVEN_SUB_HAND) && can_attack_with_main_hand(player_ptr))) && has_two_handed_weapons(player_ptr)) { (void)strcpy(out_desc[k], _("(武器を両手持ち)", "(wielding with two-hands)")); out_color[k] = TERM_WHITE; } else { diff --git a/src/wizard/artifact-analyzer.cpp b/src/wizard/artifact-analyzer.cpp index 5fcdbe03d..002966af4 100644 --- a/src/wizard/artifact-analyzer.cpp +++ b/src/wizard/artifact-analyzer.cpp @@ -12,6 +12,10 @@ #include "util/quarks.h" #include "wizard/spoiler-util.h" +#ifdef JP +#include "locale/japanese.h" +#endif + /*! * @brief アーティファクトの特性一覧を出力する / * Write a line to the spoiler file and then "underline" it with hypens @@ -69,11 +73,9 @@ static void analyze_pval(object_type *o_ptr, pval_info_type *pi_ptr) auto flgs = object_flags(o_ptr); affects_list = pi_ptr->pval_affects; sprintf(pi_ptr->pval_desc, "%s%d", o_ptr->pval >= 0 ? "+" : "", o_ptr->pval); - if (flgs.has(TR_STR) && flgs.has(TR_INT) && flgs.has(TR_WIS) && flgs.has(TR_DEX) && flgs.has(TR_CON) - && flgs.has(TR_CHR)) { + if (flgs.has(TR_STR) && flgs.has(TR_INT) && flgs.has(TR_WIS) && flgs.has(TR_DEX) && flgs.has(TR_CON) && flgs.has(TR_CHR)) { *affects_list++ = _("全能力", "All stats"); - } else if (flgs.has(TR_STR) || flgs.has(TR_INT) || flgs.has(TR_WIS) || flgs.has(TR_DEX) || flgs.has(TR_CON) - || flgs.has(TR_CHR)) { + } else if (flgs.has(TR_STR) || flgs.has(TR_INT) || flgs.has(TR_WIS) || flgs.has(TR_DEX) || flgs.has(TR_CON) || flgs.has(TR_CHR)) { affects_list = spoiler_flag_aux(flgs, stat_flags_desc, affects_list, N_ELEMENTS(stat_flags_desc)); } @@ -142,11 +144,9 @@ static void analyze_immune(object_type *o_ptr, concptr *immune_list) static void analyze_sustains(object_type *o_ptr, concptr *sustain_list) { auto flgs = object_flags(o_ptr); - if (flgs.has(TR_SUST_STR) && flgs.has(TR_SUST_INT) && flgs.has(TR_SUST_WIS) && flgs.has(TR_SUST_DEX) - && flgs.has(TR_SUST_CON) && flgs.has(TR_SUST_CHR)) { + if (flgs.has(TR_SUST_STR) && flgs.has(TR_SUST_INT) && flgs.has(TR_SUST_WIS) && flgs.has(TR_SUST_DEX) && flgs.has(TR_SUST_CON) && flgs.has(TR_SUST_CHR)) { *sustain_list++ = _("全能力", "All stats"); - } else if (flgs.has(TR_SUST_STR) || flgs.has(TR_SUST_INT) || flgs.has(TR_SUST_WIS) || flgs.has(TR_SUST_DEX) - || flgs.has(TR_SUST_CON) || flgs.has(TR_SUST_CHR)) { + } else if (flgs.has(TR_SUST_STR) || flgs.has(TR_SUST_INT) || flgs.has(TR_SUST_WIS) || flgs.has(TR_SUST_DEX) || flgs.has(TR_SUST_CON) || flgs.has(TR_SUST_CHR)) { sustain_list = spoiler_flag_aux(flgs, sustain_flags_desc, sustain_list, N_ELEMENTS(sustain_flags_desc)); } -- 2.11.0