OSDN Git Service

[WIP] [Refactor] #39963 Separated spells2.h from spells1.h
[hengband/hengband.git] / src / wizard2.c
index 7a339c9..b7fa5d6 100644 (file)
  */
 
 #include "angband.h"
-#include "core.h"
-#include "term.h"
+#include "core/angband-version.h"
+#include "core/stuff-handler.h"
+#include "gameterm.h"
 
 #include "dungeon.h"
-#include "cmd-dump.h"
+#include "io/write-diary.h"
+#include "cmd/cmd-draw.h"
+#include "cmd/cmd-dump.h"
+#include "cmd/cmd-help.h"
+#include "cmd/cmd-save.h"
 #include "util.h"
 #include "birth.h"
 #include "selfinfo.h"
@@ -29,7 +34,7 @@
 #include "player-class.h"
 #include "player-inventory.h"
 
-#include "spells.h"
+#include "spell/spells-util.h"
 #include "spells-object.h"
 #include "spells-summon.h"
 #include "spells-status.h"
 #include "dungeon-file.h"
 #include "files.h"
 #include "monster-spell.h"
-#include "bldg.h"
-#include "objectkind.h"
+#include "market/building.h"
+#include "object/object-kind.h"
 #include "targeting.h"
-#include "view-mainwindow.h"
+#include "view/display-main-window.h"
 #include "world.h"
+#include "spell/spells2.h"
 
 #define NUM_O_SET 8
 #define NUM_O_BIT 32
 
 extern void do_cmd_debug(player_type *creature_ptr);
 
-#ifdef ALLOW_WIZARD
-/*
-typedef struct debug_spell_commands1
-{
-       int type;
-       char *command;
-       bool(*spell_function_type1)(player_type *);
-} debug_spell_commands1;
-
-typedef struct debug_spell_commands2
-{
-       int type;
-       char *command;
-       bool(*spell_function_type2)(player_type *, floor_type *);
-} debug_spell_commands2;
-
-typedef struct debug_spell_commands3
-{
-       int type;
-       char *command;
-       bool(*spell_function_type3)(player_type *, HIT_POINT);
-} debug_spell_commands3;
-
-typedef union debug_spell_commands {
-       debug_spell_commands1 command1;
-       debug_spell_commands2 command2;
-       debug_spell_commands3 command3;
-} debug_spell_commands;
-
-debug_spell_commands debug_spell_commands_list[] =
-{
-       .command3 = {3, "true healing", true_healing}
-};
-*/
-
 typedef union spell_functions {
        struct debug_spell_type1 { bool(*spell_function)(player_type *, floor_type *); } spell1;
        struct debug_spell_type2 { bool(*spell_function)(player_type *); } spell2;
@@ -105,11 +76,12 @@ typedef struct debug_spell_command
        spell_functions command_function;
 } debug_spell_command;
 
-#define SPELL_MAX 2
+#define SPELL_MAX 3
 debug_spell_command debug_spell_commands_list[SPELL_MAX] =
 {
-       { 2, "vanish dungeon", {.spell2 = vanish_dungeon} },
-       { 3, "true healing", {.spell3 = true_healing} }
+       { 2, "vanish dungeon", {.spell2 = { vanish_dungeon } } },
+       { 3, "true healing", {.spell3 = { true_healing } } },
+       { 2, "drop weapons", {.spell2 = { drop_weapons } } }
 };
 
 /*!
@@ -121,7 +93,7 @@ static bool do_cmd_debug_spell(player_type *creature_ptr)
        char tmp_val[50] = "\0";
        int tmp_int;
 
-       if (!get_string("SPELL:", tmp_val, 32)) return FALSE;
+       if (!get_string("SPELL: ", tmp_val, 32)) return FALSE;
 
        for (int i = 0; i < SPELL_MAX; i++)
        {
@@ -131,18 +103,22 @@ static bool do_cmd_debug_spell(player_type *creature_ptr)
                {
                case 2:
                        (*(debug_spell_commands_list[i].command_function.spell2.spell_function))(creature_ptr);
+                       return TRUE;
                        break;
                case 3:
                        tmp_val[0] = '\0';
                        if (!get_string("POWER:", tmp_val, 32)) return FALSE;
                        tmp_int = atoi(tmp_val);
                        (*(debug_spell_commands_list[i].command_function.spell3.spell_function))(creature_ptr, tmp_int);
+                       return TRUE;
                        break;
                default:
                        break;
                }
        }
 
+       msg_format("Command not found.");
+
        return FALSE;
 }
 
@@ -197,7 +173,7 @@ static void do_cmd_summon_horde(player_type *caster_ptr)
        while (--attempts)
        {
                scatter(caster_ptr, &wy, &wx, caster_ptr->y, caster_ptr->x, 3, 0);
-               if (cave_empty_bold(caster_ptr->current_floor_ptr, wy, wx)) break;
+               if (is_cave_empty_bold(caster_ptr, wy, wx)) break;
        }
 
        (void)alloc_horde(caster_ptr, wy, wx);
@@ -345,7 +321,7 @@ static void do_cmd_wiz_reset_class(player_type *creature_ptr)
        if (tmp_int < 0 || tmp_int >= MAX_CLASS) return;
 
        /* Save it */
-       creature_ptr->pclass = (byte_hack)tmp_int;
+       creature_ptr->pclass = (byte)tmp_int;
 
        /* Redraw inscription */
        creature_ptr->window |= (PW_PLAYER);
@@ -496,6 +472,7 @@ static void do_cmd_wiz_change(player_type *creature_ptr)
 /*!
  * @brief アイテムの詳細ステータスを表示する /
  * Change various "permanent" player variables.
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @param o_ptr 詳細を表示するアイテム情報の参照ポインタ
  * @return なし
  * @details
@@ -556,7 +533,7 @@ static void do_cmd_wiz_change(player_type *creature_ptr)
  * Originally by David Reeve Sward <sward+@CMU.EDU>
  * Verbose item flags by -Bernd-
  */
-static void wiz_display_item(object_type *o_ptr)
+static void wiz_display_item(player_type *player_ptr, object_type *o_ptr)
 {
        BIT_FLAGS flgs[TR_FLAG_SIZE];
        object_flags(o_ptr, flgs);
@@ -569,7 +546,7 @@ static void wiz_display_item(object_type *o_ptr)
 
        /* Describe fully */
        char buf[256];
-       object_desc(buf, o_ptr, OD_STORE);
+       object_desc(player_ptr, buf, o_ptr, OD_STORE);
 
        prt(buf, 2, j);
 
@@ -812,10 +789,11 @@ static KIND_OBJECT_IDX wiz_create_itemtype(void)
 
 /*!
  * @briefアイテムの基礎能力値を調整する / Tweak an item
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @param o_ptr 調整するアイテムの参照ポインタ
  * @return なし
  */
-static void wiz_tweak_item(object_type *o_ptr)
+static void wiz_tweak_item(player_type *player_ptr, object_type *o_ptr)
 {
        if (object_is_artifact(o_ptr)) return;
 
@@ -824,25 +802,25 @@ static void wiz_tweak_item(object_type *o_ptr)
        sprintf(tmp_val, "%d", o_ptr->pval);
        if (!get_string(p, tmp_val, 5)) return;
        o_ptr->pval = (s16b)atoi(tmp_val);
-       wiz_display_item(o_ptr);
+       wiz_display_item(player_ptr, o_ptr);
 
        p = "Enter new 'to_a' setting: ";
        sprintf(tmp_val, "%d", o_ptr->to_a);
        if (!get_string(p, tmp_val, 5)) return;
        o_ptr->to_a = (s16b)atoi(tmp_val);
-       wiz_display_item(o_ptr);
+       wiz_display_item(player_ptr, o_ptr);
 
        p = "Enter new 'to_h' setting: ";
        sprintf(tmp_val, "%d", o_ptr->to_h);
        if (!get_string(p, tmp_val, 5)) return;
        o_ptr->to_h = (s16b)atoi(tmp_val);
-       wiz_display_item(o_ptr);
+       wiz_display_item(player_ptr, o_ptr);
 
        p = "Enter new 'to_d' setting: ";
        sprintf(tmp_val, "%d", (int)o_ptr->to_d);
        if (!get_string(p, tmp_val, 5)) return;
        o_ptr->to_d = (s16b)atoi(tmp_val);
-       wiz_display_item(o_ptr);
+       wiz_display_item(player_ptr, o_ptr);
 }
 
 
@@ -867,7 +845,7 @@ static void wiz_reroll_item(player_type *owner_ptr, object_type *o_ptr)
        while (TRUE)
        {
                /* Display full item debug information */
-               wiz_display_item(q_ptr);
+               wiz_display_item(owner_ptr, q_ptr);
 
                /* Ask wizard what to do. */
                if (!get_com("[a]ccept, [w]orthless, [c]ursed, [n]ormal, [g]ood, [e]xcellent, [s]pecial? ", &ch, FALSE))
@@ -998,7 +976,7 @@ static void wiz_statistics(player_type *caster_ptr, object_type *o_ptr)
                concptr pmt = "Roll for [n]ormal, [g]ood, or [e]xcellent treasure? ";
 
                /* Display item */
-               wiz_display_item(o_ptr);
+               wiz_display_item(caster_ptr, o_ptr);
 
                /* Get choices */
                if (!get_com(pmt, &ch, FALSE)) break;
@@ -1146,7 +1124,7 @@ static void wiz_quantity_item(object_type *o_ptr)
                if (tmp_int > 99) tmp_int = 99;
 
                /* Accept modifications */
-               o_ptr->number = (byte_hack)tmp_int;
+               o_ptr->number = (byte)tmp_int;
        }
 
        if (o_ptr->tval == TV_ROD)
@@ -1221,7 +1199,7 @@ static void do_cmd_wiz_play(player_type *creature_ptr)
        while (TRUE)
        {
                /* Display the item */
-               wiz_display_item(q_ptr);
+               wiz_display_item(creature_ptr, q_ptr);
 
                /* Get choice */
                if (!get_com("[a]ccept [s]tatistics [r]eroll [t]weak [q]uantity? ", &ch, FALSE))
@@ -1248,7 +1226,7 @@ static void do_cmd_wiz_play(player_type *creature_ptr)
 
                if (ch == 't' || ch == 'T')
                {
-                       wiz_tweak_item(q_ptr);
+                       wiz_tweak_item(creature_ptr, q_ptr);
                }
 
                if (ch == 'q' || ch == 'Q')
@@ -1725,12 +1703,10 @@ void do_cmd_debug(player_type *creature_ptr)
        case '\r':
                break;
 
-#ifdef ALLOW_SPOILERS
                /* Hack -- Generate Spoilers */
        case '"':
                do_cmd_spoilers(creature_ptr);
                break;
-#endif /* ALLOW_SPOILERS */
 
                /* Hack -- Help */
        case '?':
@@ -1791,7 +1767,7 @@ void do_cmd_debug(player_type *creature_ptr)
 
                /* View item info */
        case 'f':
-               identify_fully(creature_ptr, FALSE);
+               identify_fully(creature_ptr, FALSE, 0);
                break;
 
                /* Create desired feature */
@@ -1816,7 +1792,7 @@ void do_cmd_debug(player_type *creature_ptr)
 
                /* Identify */
        case 'i':
-               (void)ident_spell(creature_ptr, FALSE);
+               (void)ident_spell(creature_ptr, FALSE, 0);
                break;
 
                /* Go up or down in the dungeon */
@@ -1876,7 +1852,7 @@ void do_cmd_debug(player_type *creature_ptr)
 
                /* Phase Door */
        case 'p':
-               teleport_player(creature_ptr, 10, 0L);
+               teleport_player(creature_ptr, 10, TELEPORT_SPONTANEOUS);
                break;
 
                /* Take a Quests */
@@ -1947,7 +1923,7 @@ void do_cmd_debug(player_type *creature_ptr)
 
                /* Teleport */
        case 't':
-               teleport_player(creature_ptr, 100, 0L);
+               teleport_player(creature_ptr, 100, TELEPORT_SPONTANEOUS);
                break;
 
                /* Game Time Setting */
@@ -2011,11 +1987,3 @@ void do_cmd_debug(player_type *creature_ptr)
                break;
        }
 }
-
-#else
-
-#ifdef MACINTOSH
-static int i = 0;
-#endif
-
-#endif