From 9dd6a67e8a80d3a67a5d507e714115c3bccab779 Mon Sep 17 00:00:00 2001 From: Hourier Date: Thu, 20 Aug 2020 13:35:09 +0900 Subject: [PATCH] [Refactor] #40650 Separated cmd-refill.c/h into cmd-item.c/h --- Hengband/Hengband/Hengband.vcxproj | 2 + Hengband/Hengband/Hengband.vcxproj.filters | 6 ++ src/Makefile.am | 1 + src/cmd-item/cmd-item.c | 97 ------------------------- src/cmd-item/cmd-item.h | 1 - src/cmd-item/cmd-refill.c | 110 +++++++++++++++++++++++++++++ src/cmd-item/cmd-refill.h | 5 ++ src/io/input-key-processor.c | 1 + 8 files changed, 125 insertions(+), 98 deletions(-) create mode 100644 src/cmd-item/cmd-refill.c create mode 100644 src/cmd-item/cmd-refill.h diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index 706c1a0d3..3ec6ce1d9 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -207,6 +207,7 @@ + @@ -816,6 +817,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index c0e06b8bf..b63970956 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -2087,6 +2087,9 @@ cmd-item + + cmd-item + @@ -4525,6 +4528,9 @@ cmd-item + + cmd-item + diff --git a/src/Makefile.am b/src/Makefile.am index bd814885d..5adb65bd9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -129,6 +129,7 @@ hengband_SOURCES = \ cmd-item/cmd-magiceat.c cmd-item/cmd-magiceat.h \ cmd-item/cmd-quaff.c cmd-item/cmd-quaff.h \ cmd-item/cmd-read.c cmd-item/cmd-read.h \ + cmd-item/cmd-refill.c cmd-item/cmd-refill.h \ cmd-item/cmd-smith.c cmd-item/cmd-smith.h \ cmd-item/cmd-throw.c cmd-item/cmd-throw.h \ cmd-item/cmd-usestaff.c cmd-item/cmd-usestaff.h \ diff --git a/src/cmd-item/cmd-item.c b/src/cmd-item/cmd-item.c index cb2ce8e23..a644271e5 100644 --- a/src/cmd-item/cmd-item.c +++ b/src/cmd-item/cmd-item.c @@ -41,7 +41,6 @@ #include "main/sound-of-music.h" #include "mind/snipe-types.h" #include "object-activation/activation-switcher.h" -#include "object-enchant/object-ego.h" #include "object-hook/hook-checker.h" #include "object-hook/hook-expendable.h" #include "object-hook/hook-magic.h" @@ -68,7 +67,6 @@ #include "realm/realm-types.h" #include "status/action-setter.h" #include "status/experience.h" -#include "sv-definition/sv-lite-types.h" #include "term/screen-processor.h" #include "util/int-char-converter.h" #include "util/quarks.h" @@ -365,101 +363,6 @@ void do_cmd_inscribe(player_type *creature_ptr) } /*! - * @brief ランタンに燃料を加えるコマンドのメインルーチン - * Refill the players lamp (from the pack or floor) - * @return なし - */ -static void do_cmd_refill_lamp(player_type *user_ptr) -{ - OBJECT_IDX item; - object_type *o_ptr; - object_type *j_ptr; - item_tester_hook = item_tester_refill_lantern; - concptr q = _("どの油つぼから注ぎますか? ", "Refill with which flask? "); - concptr s = _("油つぼがない。", "You have no flasks of oil."); - o_ptr = choose_object(user_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0); - if (!o_ptr) - return; - - take_turn(user_ptr, 50); - j_ptr = &user_ptr->inventory_list[INVEN_LITE]; - j_ptr->xtra4 += o_ptr->xtra4; - msg_print(_("ランプに油を注いだ。", "You fuel your lamp.")); - if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0)) { - j_ptr->xtra4 = 0; - msg_print(_("ランプが消えてしまった!", "Your lamp has gone out!")); - } else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS)) { - j_ptr->xtra4 = 0; - msg_print(_("しかしランプは全く光らない。", "Curiously, your lamp doesn't light.")); - } else if (j_ptr->xtra4 >= FUEL_LAMP) { - j_ptr->xtra4 = FUEL_LAMP; - msg_print(_("ランプの油は一杯だ。", "Your lamp is full.")); - } - - vary_item(user_ptr, item, -1); - user_ptr->update |= (PU_TORCH); -} - -/*! - * @brief 松明を束ねるコマンドのメインルーチン - * Refuel the players torch (from the pack or floor) - * @return なし - */ -static void do_cmd_refill_torch(player_type *creature_ptr) -{ - OBJECT_IDX item; - object_type *o_ptr; - object_type *j_ptr; - item_tester_hook = object_can_refill_torch; - concptr q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? "); - concptr s = _("他に松明がない。", "You have no extra torches."); - o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0); - if (!o_ptr) - return; - - take_turn(creature_ptr, 50); - j_ptr = &creature_ptr->inventory_list[INVEN_LITE]; - j_ptr->xtra4 += o_ptr->xtra4 + 5; - msg_print(_("松明を結合した。", "You combine the torches.")); - if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0)) { - j_ptr->xtra4 = 0; - msg_print(_("松明が消えてしまった!", "Your torch has gone out!")); - } else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS)) { - j_ptr->xtra4 = 0; - msg_print(_("しかし松明は全く光らない。", "Curiously, your torch doesn't light.")); - } else if (j_ptr->xtra4 >= FUEL_TORCH) { - j_ptr->xtra4 = FUEL_TORCH; - msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled.")); - } else - msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly.")); - - vary_item(creature_ptr, item, -1); - creature_ptr->update |= (PU_TORCH); -} - -/*! - * @brief 燃料を補充するコマンドのメインルーチン - * Refill the players lamp, or restock his torches - * @return なし - */ -void do_cmd_refill(player_type *creature_ptr) -{ - object_type *o_ptr; - o_ptr = &creature_ptr->inventory_list[INVEN_LITE]; - if (creature_ptr->special_defense & KATA_MUSOU) - set_action(creature_ptr, ACTION_NONE); - - if (o_ptr->tval != TV_LITE) - msg_print(_("光源を装備していない。", "You are not wielding a light.")); - else if (o_ptr->sval == SV_LITE_LANTERN) - do_cmd_refill_lamp(creature_ptr); - else if (o_ptr->sval == SV_LITE_TORCH) - do_cmd_refill_torch(creature_ptr); - else - msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled.")); -} - -/*! * @brief アイテムを汎用的に「使う」コマンドのメインルーチン / * Use an item * @return なし diff --git a/src/cmd-item/cmd-item.h b/src/cmd-item/cmd-item.h index db86b9973..cce4be3df 100644 --- a/src/cmd-item/cmd-item.h +++ b/src/cmd-item/cmd-item.h @@ -8,6 +8,5 @@ void do_cmd_destroy(player_type *creature_ptr); void do_cmd_observe(player_type *creature_ptr); void do_cmd_uninscribe(player_type *creature_ptr); void do_cmd_inscribe(player_type *creature_ptr); -void do_cmd_refill(player_type *creature_ptr); void do_cmd_use(player_type *creature_ptr); void do_cmd_activate(player_type *user_ptr); diff --git a/src/cmd-item/cmd-refill.c b/src/cmd-item/cmd-refill.c new file mode 100644 index 000000000..77ebd522c --- /dev/null +++ b/src/cmd-item/cmd-refill.c @@ -0,0 +1,110 @@ +#include "cmd-item/cmd-refill.h" +#include "core/player-redraw-types.h" +#include "core/player-update-types.h" +#include "floor/floor-object.h" +#include "inventory/inventory-object.h" +#include "inventory/inventory-slot-types.h" +#include "object-enchant/object-ego.h" +#include "object-hook/hook-expendable.h" +#include "object/item-tester-hooker.h" +#include "object/item-use-flags.h" +#include "player/attack-defense-types.h" +#include "player/special-defense-types.h" +#include "status/action-setter.h" +#include "sv-definition/sv-lite-types.h" +#include "view/display-messages.h" + +/*! + * @brief ƒ‰ƒ“ƒ^ƒ“‚É”R—¿‚ð‰Á‚¦‚éƒRƒ}ƒ“ƒh‚̃ƒCƒ“ƒ‹[ƒ`ƒ“ + * Refill the players lamp (from the pack or floor) + * @return ‚È‚µ + */ +static void do_cmd_refill_lamp(player_type *user_ptr) +{ + OBJECT_IDX item; + object_type *o_ptr; + object_type *j_ptr; + item_tester_hook = item_tester_refill_lantern; + concptr q = _("‚Ç‚Ì–û‚‚ڂ©‚璍‚¬‚Ü‚·‚©? ", "Refill with which flask? "); + concptr s = _("–û‚‚ڂª‚È‚¢B", "You have no flasks of oil."); + o_ptr = choose_object(user_ptr, &item, q, s, USE_INVEN | USE_FLOOR, 0); + if (!o_ptr) + return; + + take_turn(user_ptr, 50); + j_ptr = &user_ptr->inventory_list[INVEN_LITE]; + j_ptr->xtra4 += o_ptr->xtra4; + msg_print(_("ƒ‰ƒ“ƒv‚É–û‚𒍂¢‚¾B", "You fuel your lamp.")); + if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0)) { + j_ptr->xtra4 = 0; + msg_print(_("ƒ‰ƒ“ƒv‚ªÁ‚¦‚Ä‚µ‚Ü‚Á‚½I", "Your lamp has gone out!")); + } else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS)) { + j_ptr->xtra4 = 0; + msg_print(_("‚µ‚©‚µƒ‰ƒ“ƒv‚Í‘S‚­Œõ‚ç‚È‚¢B", "Curiously, your lamp doesn't light.")); + } else if (j_ptr->xtra4 >= FUEL_LAMP) { + j_ptr->xtra4 = FUEL_LAMP; + msg_print(_("ƒ‰ƒ“ƒv‚Ì–û‚͈ê”t‚¾B", "Your lamp is full.")); + } + + vary_item(user_ptr, item, -1); + user_ptr->update |= PU_TORCH; +} + +/*! + * @brief ¼–¾‚ð‘©‚Ë‚éƒRƒ}ƒ“ƒh‚̃ƒCƒ“ƒ‹[ƒ`ƒ“ + * Refuel the players torch (from the pack or floor) + * @return ‚È‚µ + */ +static void do_cmd_refill_torch(player_type *creature_ptr) +{ + OBJECT_IDX item; + object_type *o_ptr; + object_type *j_ptr; + item_tester_hook = object_can_refill_torch; + concptr q = _("‚ǂ̏¼–¾‚Å–¾‚©‚è‚ð‹­‚ß‚Ü‚·‚©? ", "Refuel with which torch? "); + concptr s = _("‘¼‚ɏ¼–¾‚ª‚È‚¢B", "You have no extra torches."); + o_ptr = choose_object(creature_ptr, &item, q, s, USE_INVEN | USE_FLOOR, 0); + if (!o_ptr) + return; + + take_turn(creature_ptr, 50); + j_ptr = &creature_ptr->inventory_list[INVEN_LITE]; + j_ptr->xtra4 += o_ptr->xtra4 + 5; + msg_print(_("¼–¾‚ðŒ‹‡‚µ‚½B", "You combine the torches.")); + if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0)) { + j_ptr->xtra4 = 0; + msg_print(_("¼–¾‚ªÁ‚¦‚Ä‚µ‚Ü‚Á‚½I", "Your torch has gone out!")); + } else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS)) { + j_ptr->xtra4 = 0; + msg_print(_("‚µ‚©‚µ¼–¾‚Í‘S‚­Œõ‚ç‚È‚¢B", "Curiously, your torch doesn't light.")); + } else if (j_ptr->xtra4 >= FUEL_TORCH) { + j_ptr->xtra4 = FUEL_TORCH; + msg_print(_("¼–¾‚ÌŽõ–½‚͏\•ª‚¾B", "Your torch is fully fueled.")); + } else + msg_print(_("¼–¾‚Í‚¢‚Á‚»‚¤–¾‚é‚­‹P‚¢‚½B", "Your torch glows more brightly.")); + + vary_item(creature_ptr, item, -1); + creature_ptr->update |= PU_TORCH; +} + +/*! + * @brief ”R—¿‚ð•â[‚·‚éƒRƒ}ƒ“ƒh‚̃ƒCƒ“ƒ‹[ƒ`ƒ“ + * Refill the players lamp, or restock his torches + * @return ‚È‚µ + */ +void do_cmd_refill(player_type *creature_ptr) +{ + object_type *o_ptr; + o_ptr = &creature_ptr->inventory_list[INVEN_LITE]; + if (creature_ptr->special_defense & KATA_MUSOU) + set_action(creature_ptr, ACTION_NONE); + + if (o_ptr->tval != TV_LITE) + msg_print(_("ŒõŒ¹‚ð‘•”õ‚µ‚Ä‚¢‚È‚¢B", "You are not wielding a light.")); + else if (o_ptr->sval == SV_LITE_LANTERN) + do_cmd_refill_lamp(creature_ptr); + else if (o_ptr->sval == SV_LITE_TORCH) + do_cmd_refill_torch(creature_ptr); + else + msg_print(_("‚±‚ÌŒõŒ¹‚ÍŽõ–½‚ð‰„‚Î‚¹‚È‚¢B", "Your light cannot be refilled.")); +} diff --git a/src/cmd-item/cmd-refill.h b/src/cmd-item/cmd-refill.h new file mode 100644 index 000000000..ff6af6f4b --- /dev/null +++ b/src/cmd-item/cmd-refill.h @@ -0,0 +1,5 @@ +#pragma once + +#include "system/angband.h" + +void do_cmd_refill(player_type *creature_ptr); diff --git a/src/io/input-key-processor.c b/src/io/input-key-processor.c index 1512cd122..30124d23b 100644 --- a/src/io/input-key-processor.c +++ b/src/io/input-key-processor.c @@ -38,6 +38,7 @@ #include "cmd-item/cmd-magiceat.h" #include "cmd-item/cmd-quaff.h" #include "cmd-item/cmd-read.h" +#include "cmd-item/cmd-refill.h" #include "cmd-item/cmd-smith.h" #include "cmd-item/cmd-throw.h" #include "cmd-item/cmd-usestaff.h" -- 2.11.0