OSDN Git Service

Revert "Merge branch 'master' of git.osdn.net:/gitroot/hengband/hengband"
[hengband/hengband.git] / src / wizard2.c
index d81a3f2..c395224 100644 (file)
  */
 
 #include "angband.h"
-#include "core.h"
-#include "term.h"
-
-#include "dungeon.h"
-#include "cmd-dump.h"
-#include "util.h"
-#include "birth.h"
 #include "selfinfo.h"
 #include "patron.h"
 #include "mutation.h"
 #include "quest.h"
 #include "artifact.h"
 #include "player-status.h"
-#include "player-effects.h"
-#include "player-skill.h"
-#include "player-class.h"
-#include "player-inventory.h"
 
 #include "spells.h"
 #include "spells-object.h"
 #include "spells-world.h"
 #include "spells-floor.h"
 
-#include "object-flavor.h"
 #include "object-hook.h"
 #include "monster-status.h"
 
 #include "floor.h"
 #include "floor-save.h"
-#include "grid.h"
-#include "dungeon-file.h"
-#include "files.h"
-#include "monster-spell.h"
-#include "bldg.h"
-#include "objectkind.h"
-#include "targeting.h"
-#include "view-mainwindow.h"
-#include "world.h"
 
 #ifdef ALLOW_WIZARD
 
@@ -62,7 +41,7 @@ static bool wiz_dimension_door(void)
 {
        POSITION x = 0, y = 0;
        if (!tgt_pt(&x, &y)) return FALSE;
-       teleport_player_to(p_ptr, y, x, TELEPORT_NONMAGICAL);
+       teleport_player_to(y, x, TELEPORT_NONMAGICAL);
        return (TRUE);
 }
 
@@ -83,6 +62,7 @@ static void wiz_create_named_art(void)
        if(a_idx < 0) a_idx = 0;
        if(a_idx >= max_a_idx) a_idx = 0; 
 
+       /* Create the artifact */
        (void)create_named_art(a_idx, p_ptr->y, p_ptr->x);
 
        /* All done */
@@ -235,7 +215,7 @@ static void prt_alloc(OBJECT_TYPE_VALUE tval, OBJECT_SUBTYPE_VALUE sval, TERM_LE
  * @return なし
  * @todo 魔法領域の再選択などがまだ不完全、要実装。
  */
-static void do_cmd_wiz_reset_class(player_type *creature_ptr)
+static void do_cmd_wiz_reset_class(void)
 {
        int tmp_int;
        char tmp_val[160];
@@ -245,7 +225,7 @@ static void do_cmd_wiz_reset_class(player_type *creature_ptr)
        sprintf(ppp, "Class (0-%d): ", MAX_CLASS - 1);
 
        /* Default */
-       sprintf(tmp_val, "%d", creature_ptr->pclass);
+       sprintf(tmp_val, "%d", p_ptr->pclass);
 
        /* Query */
        if (!get_string(ppp, tmp_val, 2)) return;
@@ -257,13 +237,13 @@ 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;
+       p_ptr->pclass = (byte_hack)tmp_int;
 
        /* Redraw inscription */
-       creature_ptr->window |= (PW_PLAYER);
+       p_ptr->window |= (PW_PLAYER);
 
-       /* {.} and {$} effect creature_ptr->warning and TRC_TELEPORT_SELF */
-       creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
+       /* {.} and {$} effect p_ptr->warning and TRC_TELEPORT_SELF */
+       p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
 
        handle_stuff();
 }
@@ -279,7 +259,7 @@ static void do_cmd_wiz_bamf(void)
        if (!target_who) return;
 
        /* Teleport to the target */
-       teleport_player_to(p_ptr, target_row, target_col, TELEPORT_NONMAGICAL);
+       teleport_player_to(target_row, target_col, TELEPORT_NONMAGICAL);
 }
 
 
@@ -288,7 +268,7 @@ static void do_cmd_wiz_bamf(void)
  * Aux function for "do_cmd_wiz_change()".     -RAK-
  * @return なし
  */
-static void do_cmd_wiz_change_aux(player_type *creature_ptr)
+static void do_cmd_wiz_change_aux(void)
 {
        int i, j;
        int tmp_int;
@@ -297,14 +277,15 @@ static void do_cmd_wiz_change_aux(player_type *creature_ptr)
        char tmp_val[160];
        char ppp[80];
 
+
        /* Query the stats */
        for (i = 0; i < A_MAX; i++)
        {
                /* Prompt */
-               sprintf(ppp, "%s (3-%d): ", stat_names[i], creature_ptr->stat_max_max[i]);
+               sprintf(ppp, "%s (3-%d): ", stat_names[i], p_ptr->stat_max_max[i]);
 
                /* Default */
-               sprintf(tmp_val, "%d", creature_ptr->stat_max[i]);
+               sprintf(tmp_val, "%d", p_ptr->stat_max[i]);
 
                /* Query */
                if (!get_string(ppp, tmp_val, 3)) return;
@@ -313,11 +294,11 @@ static void do_cmd_wiz_change_aux(player_type *creature_ptr)
                tmp_int = atoi(tmp_val);
 
                /* Verify */
-               if (tmp_int > creature_ptr->stat_max_max[i]) tmp_int = creature_ptr->stat_max_max[i];
+               if (tmp_int > p_ptr->stat_max_max[i]) tmp_int = p_ptr->stat_max_max[i];
                else if (tmp_int < 3) tmp_int = 3;
 
                /* Save it */
-               creature_ptr->stat_cur[i] = creature_ptr->stat_max[i] = (BASE_STATUS)tmp_int;
+               p_ptr->stat_cur[i] = p_ptr->stat_max[i] = (BASE_STATUS)tmp_int;
        }
 
 
@@ -338,24 +319,24 @@ static void do_cmd_wiz_change_aux(player_type *creature_ptr)
        {
                for (i = 0;i < 64;i++)
                {
-                       creature_ptr->weapon_exp[j][i] = tmp_s16b;
-                       if (creature_ptr->weapon_exp[j][i] > s_info[creature_ptr->pclass].w_max[j][i]) creature_ptr->weapon_exp[j][i] = s_info[creature_ptr->pclass].w_max[j][i];
+                       p_ptr->weapon_exp[j][i] = tmp_s16b;
+                       if (p_ptr->weapon_exp[j][i] > s_info[p_ptr->pclass].w_max[j][i]) p_ptr->weapon_exp[j][i] = s_info[p_ptr->pclass].w_max[j][i];
                }
        }
 
        for (j = 0; j < 10; j++)
        {
-               creature_ptr->skill_exp[j] = tmp_s16b;
-               if (creature_ptr->skill_exp[j] > s_info[creature_ptr->pclass].s_max[j]) creature_ptr->skill_exp[j] = s_info[creature_ptr->pclass].s_max[j];
+               p_ptr->skill_exp[j] = tmp_s16b;
+               if (p_ptr->skill_exp[j] > s_info[p_ptr->pclass].s_max[j]) p_ptr->skill_exp[j] = s_info[p_ptr->pclass].s_max[j];
        }
 
        for (j = 0; j < 32; j++)
-               creature_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_MASTER ? SPELL_EXP_MASTER : tmp_s16b);
+               p_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_MASTER ? SPELL_EXP_MASTER : tmp_s16b);
        for (; j < 64; j++)
-               creature_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_EXPERT ? SPELL_EXP_EXPERT : tmp_s16b);
+               p_ptr->spell_exp[j] = (tmp_s16b > SPELL_EXP_EXPERT ? SPELL_EXP_EXPERT : tmp_s16b);
 
        /* Default */
-       sprintf(tmp_val, "%ld", (long)(creature_ptr->au));
+       sprintf(tmp_val, "%ld", (long)(p_ptr->au));
 
        /* Query */
        if (!get_string("Gold: ", tmp_val, 9)) return;
@@ -367,10 +348,10 @@ static void do_cmd_wiz_change_aux(player_type *creature_ptr)
        if (tmp_long < 0) tmp_long = 0L;
 
        /* Save */
-       creature_ptr->au = tmp_long;
+       p_ptr->au = tmp_long;
 
        /* Default */
-       sprintf(tmp_val, "%ld", (long)(creature_ptr->max_exp));
+       sprintf(tmp_val, "%ld", (long)(p_ptr->max_exp));
 
        /* Query */
        if (!get_string("Experience: ", tmp_val, 9)) return;
@@ -381,14 +362,14 @@ static void do_cmd_wiz_change_aux(player_type *creature_ptr)
        /* Verify */
        if (tmp_long < 0) tmp_long = 0L;
 
-       if (creature_ptr->prace != RACE_ANDROID)
+       if (p_ptr->prace != RACE_ANDROID)
        {
                /* Save */
-               creature_ptr->max_exp = tmp_long;
-               creature_ptr->exp = tmp_long;
+               p_ptr->max_exp = tmp_long;
+               p_ptr->exp = tmp_long;
 
                /* Update */
-               check_experience(creature_ptr);
+               check_experience();
        }
 }
 
@@ -398,11 +379,11 @@ static void do_cmd_wiz_change_aux(player_type *creature_ptr)
  * Change various "permanent" player variables.
  * @return なし
  */
-static void do_cmd_wiz_change(player_type *creature_ptr)
+static void do_cmd_wiz_change(void)
 {
        /* Interact */
-       do_cmd_wiz_change_aux(creature_ptr);
-       do_cmd_redraw(creature_ptr);
+       do_cmd_wiz_change_aux();
+       do_cmd_redraw();
 }
 
 
@@ -436,7 +417,7 @@ static void do_cmd_wiz_change(player_type *creature_ptr)
  *     thus accepting the default-values for the remaining values.
  *     pval comes first now, since it is most important.
  * - wiz_reroll_item()
- *     apply some magic to the item or turn it into an artifact.
+ *     apply some magic to the item or current_world_ptr->game_turn it into an artifact.
  * - wiz_roll_item()
  *     Get some statistics about the rarity of an item:
  *     We create a lot of fake items and see if they are of the
@@ -610,18 +591,36 @@ static tval_desc tvals[] =
 
 
 /*!
- * 選択処理用キーコード /
- * Global array for converting numbers to a logical list symbol
+ * @brief nameバッファ内からベースアイテム名を返す / Strip an "object name" into a buffer
+ * @param buf ベースアイテム格納先の参照ポインタ
+ * @param k_idx ベースアイテムID
+ * @return なし
  */
-static const char listsym[] =
+void strip_name(char *buf, KIND_OBJECT_IDX k_idx)
 {
-       '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
-       'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
-       'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
-       'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
-       'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
-       '\0'
-};
+       char *t;
+
+       object_kind *k_ptr = &k_info[k_idx];
+
+       concptr str = (k_name + k_ptr->name);
+
+
+       /* Skip past leading characters */
+       while ((*str == ' ') || (*str == '&')) str++;
+
+       /* Copy useful chars */
+       for (t = buf; *str; str++)
+       {
+#ifdef JP
+               if (iskanji(*str)) {*t++ = *str++; *t++ = *str; continue;}
+#endif
+               if (*str != '~') *t++ = *str;
+       }
+
+       /* Terminate the new name */
+       *t = '\0';
+}
+
 
 /*!
  * @brief ベースアイテムのウィザード生成のために大項目IDと小項目IDを取得する /
@@ -735,6 +734,7 @@ static void wiz_tweak_item(object_type *o_ptr)
        concptr p;
        char tmp_val[80];
 
+       /* Hack -- leave artifacts alone */
        if (object_is_artifact(o_ptr)) return;
 
        p = "Enter new 'pval' setting: ";
@@ -765,22 +765,29 @@ static void wiz_tweak_item(object_type *o_ptr)
 
 /*!
  * @brief アイテムの質を選択して再生成する /
- * Apply magic to an item or turn it into an artifact. -Bernd-
+ * Apply magic to an item or current_world_ptr->game_turn it into an artifact. -Bernd-
  * @param o_ptr 再生成の対象となるアイテム情報の参照ポインタ
  * @return なし
  */
-static void wiz_reroll_item(player_type *owner_ptr, object_type *o_ptr)
+static void wiz_reroll_item(object_type *o_ptr)
 {
        object_type forge;
        object_type *q_ptr;
+
        char ch;
+
        bool changed = FALSE;
 
+
+       /* Hack -- leave artifacts alone */
        if (object_is_artifact(o_ptr)) return;
 
        q_ptr = &forge;
+
+       /* Copy the object */
        object_copy(q_ptr, o_ptr);
 
+
        /* Main loop. Ask for magification and artifactification */
        while (TRUE)
        {
@@ -821,45 +828,45 @@ static void wiz_reroll_item(player_type *owner_ptr, object_type *o_ptr)
                        case 'w': case 'W':
                        {
                                object_prep(q_ptr, o_ptr->k_idx);
-                               apply_magic(q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT | AM_CURSED);
+                               apply_magic(q_ptr, current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT | AM_CURSED);
                                break;
                        }
                        /* Apply bad magic, but first clear object */
                        case 'c': case 'C':
                        {
                                object_prep(q_ptr, o_ptr->k_idx);
-                               apply_magic(q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_CURSED);
+                               apply_magic(q_ptr, current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_CURSED);
                                break;
                        }
                        /* Apply normal magic, but first clear object */
                        case 'n': case 'N':
                        {
                                object_prep(q_ptr, o_ptr->k_idx);
-                               apply_magic(q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART);
+                               apply_magic(q_ptr, current_floor_ptr->dun_level, AM_NO_FIXED_ART);
                                break;
                        }
                        /* Apply good magic, but first clear object */
                        case 'g': case 'G':
                        {
                                object_prep(q_ptr, o_ptr->k_idx);
-                               apply_magic(q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD);
+                               apply_magic(q_ptr, current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD);
                                break;
                        }
                        /* Apply great magic, but first clear object */
                        case 'e': case 'E':
                        {
                                object_prep(q_ptr, o_ptr->k_idx);
-                               apply_magic(q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT);
+                               apply_magic(q_ptr, current_floor_ptr->dun_level, AM_NO_FIXED_ART | AM_GOOD | AM_GREAT);
                                break;
                        }
                        /* Apply special magic, but first clear object */
                        case 's': case 'S':
                        {
                                object_prep(q_ptr, o_ptr->k_idx);
-                               apply_magic(q_ptr, owner_ptr->current_floor_ptr->dun_level, AM_GOOD | AM_GREAT | AM_SPECIAL);
+                               apply_magic(q_ptr, current_floor_ptr->dun_level, AM_GOOD | AM_GREAT | AM_SPECIAL);
 
                                /* Failed to create artifact; make a random one */
-                               if (!object_is_artifact(q_ptr)) become_random_artifact(q_ptr, FALSE);
+                               if (!object_is_artifact(q_ptr)) create_artifact(q_ptr, FALSE);
                                break;
                        }
                }
@@ -869,13 +876,16 @@ static void wiz_reroll_item(player_type *owner_ptr, object_type *o_ptr)
                q_ptr->marked = o_ptr->marked;
        }
 
+
        /* Notice change */
        if (changed)
        {
+               /* Apply changes */
                object_copy(o_ptr, q_ptr);
-               owner_ptr->update |= (PU_BONUS);
-               owner_ptr->update |= (PU_COMBINE | PU_REORDER);
-               owner_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
+               p_ptr->update |= (PU_BONUS);
+               p_ptr->update |= (PU_COMBINE | PU_REORDER);
+
+               p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
        }
 }
 
@@ -953,7 +963,7 @@ static void wiz_statistics(object_type *o_ptr)
 
                /* Let us know what we are doing */
                msg_format("Creating a lot of %s items. Base level = %d.",
-                                         quality, p_ptr->current_floor_ptr->dun_level);
+                                         quality, current_floor_ptr->dun_level);
                msg_print(NULL);
 
                /* Set counters to zero */
@@ -1088,7 +1098,7 @@ static void wiz_quantity_item(object_type *o_ptr)
  * debug command for blue mage
  * @return なし
  */
-static void do_cmd_wiz_blue_mage(player_type *caster_ptr)
+static void do_cmd_wiz_blue_mage(void)
 {
        int i = 0;
        int j = 0;
@@ -1100,15 +1110,15 @@ static void do_cmd_wiz_blue_mage(player_type *caster_ptr)
 
                for (i = 0; i < 32; i++)
                {
-                       if ((0x00000001 << i) & f4) caster_ptr->magic_num2[i] = 1;
+                       if ((0x00000001 << i) & f4) p_ptr->magic_num2[i] = 1;
                }
                for (; i < 64; i++)
                {
-                       if ((0x00000001 << (i - 32)) & f5) caster_ptr->magic_num2[i] = 1;
+                       if ((0x00000001 << (i - 32)) & f5) p_ptr->magic_num2[i] = 1;
                }
                for (; i < 96; i++)
                {
-                       if ((0x00000001 << (i - 64)) & f6) caster_ptr->magic_num2[i] = 1;
+                       if ((0x00000001 << (i - 64)) & f6) p_ptr->magic_num2[i] = 1;
                }
        }
 }
@@ -1124,7 +1134,7 @@ static void do_cmd_wiz_blue_mage(player_type *caster_ptr)
  *   - Change properties (via wiz_tweak_item)<br>
  *   - Change the number of items (via wiz_quantity_item)<br>
  */
-static void do_cmd_wiz_play(player_type *creature_ptr)
+static void do_cmd_wiz_play(void)
 {
        OBJECT_IDX item;
        object_type     forge;
@@ -1137,7 +1147,7 @@ static void do_cmd_wiz_play(player_type *creature_ptr)
        q = "Play with which object? ";
        s = "You have nothing to play with.";
 
-       o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
 
        if (!o_ptr) return;
        
@@ -1176,7 +1186,7 @@ static void do_cmd_wiz_play(player_type *creature_ptr)
 
                if (ch == 'r' || ch == 'r')
                {
-                       wiz_reroll_item(creature_ptr, q_ptr);
+                       wiz_reroll_item(q_ptr);
                }
 
                if (ch == 't' || ch == 'T')
@@ -1201,17 +1211,17 @@ static void do_cmd_wiz_play(player_type *creature_ptr)
                /* Recalcurate object's weight */
                if (item >= 0)
                {
-                       creature_ptr->total_weight += (q_ptr->weight * q_ptr->number)
+                       p_ptr->total_weight += (q_ptr->weight * q_ptr->number)
                                - (o_ptr->weight * o_ptr->number);
                }
 
                /* Change */
                object_copy(o_ptr, q_ptr);
 
-               creature_ptr->update |= (PU_BONUS);
-               creature_ptr->update |= (PU_COMBINE | PU_REORDER);
+               p_ptr->update |= (PU_BONUS);
+               p_ptr->update |= (PU_COMBINE | PU_REORDER);
 
-               creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
+               p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
        }
 
        /* Ignore change */
@@ -1275,7 +1285,7 @@ static void wiz_create_item(void)
        q_ptr = &forge;
        object_prep(q_ptr, k_idx);
 
-       apply_magic(q_ptr, p_ptr->current_floor_ptr->dun_level, AM_NO_FIXED_ART);
+       apply_magic(q_ptr, current_floor_ptr->dun_level, AM_NO_FIXED_ART);
 
        /* Drop the object from heaven */
        (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
@@ -1290,11 +1300,11 @@ static void wiz_create_item(void)
  * Cure everything instantly
  * @return なし
  */
-static void do_cmd_wiz_cure_all(player_type *creature_ptr)
+static void do_cmd_wiz_cure_all(void)
 {
-       (void)life_stream(creature_ptr, FALSE, FALSE);
-       (void)restore_mana(creature_ptr, TRUE);
-       (void)set_food(creature_ptr, PY_FOOD_MAX - 1);
+       (void)life_stream(FALSE, FALSE);
+       (void)restore_mana(TRUE);
+       (void)set_food(PY_FOOD_MAX - 1);
 }
 
 
@@ -1303,7 +1313,7 @@ static void do_cmd_wiz_cure_all(player_type *creature_ptr)
  * Go to any level
  * @return なし
  */
-static void do_cmd_wiz_jump(player_type *creature_ptr)
+static void do_cmd_wiz_jump(void)
 {
        /* Ask for level */
        if (command_arg <= 0)
@@ -1316,20 +1326,20 @@ static void do_cmd_wiz_jump(player_type *creature_ptr)
                sprintf(ppp, "Jump which dungeon : ");
 
                /* Default */
-               sprintf(tmp_val, "%d", creature_ptr->dungeon_idx);
+               sprintf(tmp_val, "%d", p_ptr->dungeon_idx);
 
                /* Ask for a level */
                if (!get_string(ppp, tmp_val, 2)) return;
 
                tmp_dungeon_type = (DUNGEON_IDX)atoi(tmp_val);
-               if (!d_info[tmp_dungeon_type].maxdepth || (tmp_dungeon_type > current_world_ptr->max_d_idx)) tmp_dungeon_type = DUNGEON_ANGBAND;
+               if (!d_info[tmp_dungeon_type].maxdepth || (tmp_dungeon_type > max_d_idx)) tmp_dungeon_type = DUNGEON_ANGBAND;
 
                /* Prompt */
                sprintf(ppp, "Jump to level (0, %d-%d): ",
                        (int)d_info[tmp_dungeon_type].mindepth, (int)d_info[tmp_dungeon_type].maxdepth);
 
                /* Default */
-               sprintf(tmp_val, "%d", (int)p_ptr->current_floor_ptr->dun_level);
+               sprintf(tmp_val, "%d", (int)current_floor_ptr->dun_level);
 
                /* Ask for a level */
                if (!get_string(ppp, tmp_val, 10)) return;
@@ -1337,10 +1347,10 @@ static void do_cmd_wiz_jump(player_type *creature_ptr)
                /* Extract request */
                command_arg = (COMMAND_ARG)atoi(tmp_val);
 
-               creature_ptr->dungeon_idx = tmp_dungeon_type;
+               p_ptr->dungeon_idx = tmp_dungeon_type;
        }
-       if (command_arg < d_info[creature_ptr->dungeon_idx].mindepth) command_arg = 0;
-       if (command_arg > d_info[creature_ptr->dungeon_idx].maxdepth) command_arg = (COMMAND_ARG)d_info[creature_ptr->dungeon_idx].maxdepth;
+       if (command_arg < d_info[p_ptr->dungeon_idx].mindepth) command_arg = 0;
+       if (command_arg > d_info[p_ptr->dungeon_idx].maxdepth) command_arg = (COMMAND_ARG)d_info[p_ptr->dungeon_idx].maxdepth;
 
        /* Accept request */
        msg_format("You jump to dungeon level %d.", command_arg);
@@ -1348,30 +1358,30 @@ static void do_cmd_wiz_jump(player_type *creature_ptr)
        if (autosave_l) do_cmd_save_game(TRUE);
 
        /* Change level */
-       p_ptr->current_floor_ptr->dun_level = command_arg;
+       current_floor_ptr->dun_level = command_arg;
 
        prepare_change_floor_mode(CFM_RAND_PLACE);
 
-       if (!p_ptr->current_floor_ptr->dun_level) creature_ptr->dungeon_idx = 0;
-       creature_ptr->inside_arena = FALSE;
-       creature_ptr->wild_mode = FALSE;
+       if (!current_floor_ptr->dun_level) p_ptr->dungeon_idx = 0;
+       p_ptr->inside_arena = FALSE;
+       p_ptr->wild_mode = FALSE;
 
        leave_quest_check();
 
-       if (record_stair) exe_write_diary(creature_ptr, NIKKI_WIZ_TELE,0,NULL);
+       if (record_stair) do_cmd_write_nikki(NIKKI_WIZ_TELE,0,NULL);
 
-       creature_ptr->inside_quest = 0;
-       free_turn(creature_ptr);
+       p_ptr->inside_quest = 0;
+       free_turn(p_ptr);
 
        /* Prevent energy_need from being too lower than 0 */
-       creature_ptr->energy_need = 0;
+       p_ptr->energy_need = 0;
 
        /*
         * Clear all saved floors
         * and create a first saved floor
         */
        prepare_change_floor_mode(CFM_FIRST_FLOOR);
-       creature_ptr->leaving = TRUE;
+       p_ptr->leaving = TRUE;
 }
 
 
@@ -1414,7 +1424,7 @@ static void do_cmd_wiz_summon(int num)
        int i;
        for (i = 0; i < num; i++)
        {
-               (void)summon_specific(0, p_ptr->y, p_ptr->x, p_ptr->current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
+               (void)summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE), '\0');
        }
 }
 
@@ -1428,9 +1438,9 @@ static void do_cmd_wiz_summon(int num)
  * @details
  * This function is rather dangerous
  */
-static void do_cmd_wiz_named(player_type *summoner_ptr, MONRACE_IDX r_idx)
+static void do_cmd_wiz_named(MONRACE_IDX r_idx)
 {
-       (void)summon_named_creature(0, summoner_ptr->y, summoner_ptr->x, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
+       (void)summon_named_creature(0, p_ptr->y, p_ptr->x, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
 }
 
 
@@ -1442,12 +1452,13 @@ static void do_cmd_wiz_named(player_type *summoner_ptr, MONRACE_IDX r_idx)
  * @details
  * This function is rather dangerous
  */
-static void do_cmd_wiz_named_friendly(player_type *summoner_ptr, MONRACE_IDX r_idx)
+static void do_cmd_wiz_named_friendly(MONRACE_IDX r_idx)
 {
-       (void)summon_named_creature(0, summoner_ptr->y, summoner_ptr->x, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP | PM_FORCE_PET));
+       (void)summon_named_creature(0, p_ptr->y, p_ptr->x, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP | PM_FORCE_PET));
 }
 
 
+
 /*!
  * @brief プレイヤー近辺の全モンスターを消去する /
  * Hack -- Delete all nearby monsters
@@ -1458,9 +1469,9 @@ static void do_cmd_wiz_zap(void)
        MONSTER_IDX i;
 
        /* Genocide everyone nearby */
-       for (i = 1; i < p_ptr->current_floor_ptr->m_max; i++)
+       for (i = 1; i < m_max; i++)
        {
-               monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[i];
+               monster_type *m_ptr = &current_floor_ptr->m_list[i];
                if (!monster_is_valid(m_ptr)) continue;
 
                /* Skip the mount */
@@ -1474,7 +1485,7 @@ static void do_cmd_wiz_zap(void)
                                GAME_TEXT m_name[MAX_NLEN];
 
                                monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
-                               exe_write_diary(p_ptr, NIKKI_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
+                               do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
                        }
 
                        delete_monster_idx(i);
@@ -1486,28 +1497,27 @@ static void do_cmd_wiz_zap(void)
 /*!
  * @brief フロアに存在する全モンスターを消去する /
  * Hack -- Delete all monsters
- * @param caster_ptr 術者の参照ポインタ
  * @return なし
  */
-static void do_cmd_wiz_zap_all(player_type *caster_ptr)
+static void do_cmd_wiz_zap_all(void)
 {
        MONSTER_IDX i;
 
        /* Genocide everyone */
-       for (i = 1; i < caster_ptr->current_floor_ptr->m_max; i++)
+       for (i = 1; i < m_max; i++)
        {
-               monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
+               monster_type *m_ptr = &current_floor_ptr->m_list[i];
                if (!monster_is_valid(m_ptr)) continue;
 
                /* Skip the mount */
-               if (i == caster_ptr->riding) continue;
+               if (i == p_ptr->riding) continue;
 
                if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
                {
                        GAME_TEXT m_name[MAX_NLEN];
 
                        monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
-                       exe_write_diary(caster_ptr, NIKKI_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
+                       do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);
                }
 
                /* Delete this monster */
@@ -1521,19 +1531,19 @@ static void do_cmd_wiz_zap_all(player_type *caster_ptr)
  * Create desired feature
  * @return なし
  */
-static void do_cmd_wiz_create_feature(player_type *creature_ptr)
+static void do_cmd_wiz_create_feature(void)
 {
        static int   prev_feat = 0;
        static int   prev_mimic = 0;
        grid_type    *g_ptr;
        feature_type *f_ptr;
        char         tmp_val[160];
-       FEAT_IDX          tmp_feat, tmp_mimic;
+       IDX          tmp_feat, tmp_mimic;
        POSITION y, x;
 
        if (!tgt_pt(&x, &y)) return;
 
-       g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+       g_ptr = &current_floor_ptr->grid_array[y][x];
 
        /* Default */
        sprintf(tmp_val, "%d", prev_feat);
@@ -1542,7 +1552,7 @@ static void do_cmd_wiz_create_feature(player_type *creature_ptr)
        if (!get_string(_("地形: ", "Feature: "), tmp_val, 3)) return;
 
        /* Extract */
-       tmp_feat = (FEAT_IDX)atoi(tmp_val);
+       tmp_feat = (IDX)atoi(tmp_val);
        if (tmp_feat < 0) tmp_feat = 0;
        else if (tmp_feat >= max_f_idx) tmp_feat = max_f_idx - 1;
 
@@ -1553,7 +1563,7 @@ static void do_cmd_wiz_create_feature(player_type *creature_ptr)
        if (!get_string(_("地形 (mimic): ", "Feature (mimic): "), tmp_val, 3)) return;
 
        /* Extract */
-       tmp_mimic = (FEAT_IDX)atoi(tmp_val);
+       tmp_mimic = (IDX)atoi(tmp_val);
        if (tmp_mimic < 0) tmp_mimic = 0;
        else if (tmp_mimic >= max_f_idx) tmp_mimic = max_f_idx - 1;
 
@@ -1570,7 +1580,7 @@ static void do_cmd_wiz_create_feature(player_type *creature_ptr)
 
        note_spot(y, x);
        lite_spot(y, x);
-       creature_ptr->update |= (PU_FLOW);
+       p_ptr->update |= (PU_FLOW);
 
        prev_feat = tmp_feat;
        prev_mimic = tmp_mimic;
@@ -1591,10 +1601,14 @@ static void do_cmd_dump_options(void)
        FILE *fff;
        char buf[1024];
        int  **exist;
+
+       /* Build the filename */
        path_build(buf, sizeof buf, ANGBAND_DIR_USER, "opt_info.txt");
 
        /* File type is "TEXT" */
        FILE_TYPE(FILE_TYPE_TEXT);
+
+       /* Open the file */
        fff = my_fopen(buf, "a");
 
        if (!fff)
@@ -1648,10 +1662,23 @@ static void do_cmd_dump_options(void)
        msg_format(_("オプションbit使用状況をファイル %s に書き出しました。", "Option bits usage dump saved to file %s."), buf);
 }
 
+
+#ifdef ALLOW_SPOILERS
+
+/*
+ * External function
+ */
+extern void do_cmd_spoilers(void);
+
+#endif /* ALLOW_SPOILERS */
+
+
+
 /*
  * Hack -- declare external function
  */
-extern void do_cmd_debug(player_type *creature_ptr);
+extern void do_cmd_debug(void);
+
 
 
 /*!
@@ -1660,7 +1687,7 @@ extern void do_cmd_debug(player_type *creature_ptr);
  * The "command_arg" may have been set.
  * @return なし
  */
-void do_cmd_debug(player_type *creature_ptr)
+void do_cmd_debug(void)
 {
        int     x, y;
        char    cmd;
@@ -1694,12 +1721,12 @@ void do_cmd_debug(player_type *creature_ptr)
 
        /* Cure all maladies */
        case 'a':
-               do_cmd_wiz_cure_all(creature_ptr);
+               do_cmd_wiz_cure_all();
                break;
 
        /* Know alignment */
        case 'A':
-               msg_format("Your alignment is %d.", creature_ptr->align);
+               msg_format("Your alignment is %d.", p_ptr->align);
                break;
 
        /* Teleport to target */
@@ -1708,7 +1735,7 @@ void do_cmd_debug(player_type *creature_ptr)
                break;
 
        case 'B':
-               update_gambling_monsters();
+               battle_monsters();
                break;
 
        /* Create any object */
@@ -1733,14 +1760,14 @@ void do_cmd_debug(player_type *creature_ptr)
 
        /* Edit character */
        case 'e':
-               do_cmd_wiz_change(creature_ptr);
+               do_cmd_wiz_change();
                break;
 
        /* Blue Mage Only */
        case 'E':
-               if (creature_ptr->pclass == CLASS_BLUE_MAGE)
+               if (p_ptr->pclass == CLASS_BLUE_MAGE)
                {
-                       do_cmd_wiz_blue_mage(creature_ptr);
+                       do_cmd_wiz_blue_mage();
                }
                break;
 
@@ -1751,18 +1778,18 @@ void do_cmd_debug(player_type *creature_ptr)
 
        /* Create desired feature */
        case 'F':
-               do_cmd_wiz_create_feature(creature_ptr);
+               do_cmd_wiz_create_feature();
                break;
 
        /* Good Objects */
        case 'g':
                if (command_arg <= 0) command_arg = 1;
-               acquirement(creature_ptr->y, creature_ptr->x, command_arg, FALSE, FALSE, TRUE);
+               acquirement(p_ptr->y, p_ptr->x, command_arg, FALSE, FALSE, TRUE);
                break;
 
        /* Hitpoint rerating */
        case 'h':
-               roll_hitdice(creature_ptr, SPOP_DISPLAY_MES | SPOP_DEBUG);
+               roll_hitdice(p_ptr, SPOP_DISPLAY_MES | SPOP_DEBUG);
                break;
 
        case 'H':
@@ -1776,12 +1803,12 @@ void do_cmd_debug(player_type *creature_ptr)
 
        /* Go up or down in the dungeon */
        case 'j':
-               do_cmd_wiz_jump(creature_ptr);
+               do_cmd_wiz_jump();
                break;
 
        /* Self-Knowledge */
        case 'k':
-               self_knowledge(creature_ptr);
+               self_knowledge();
                break;
 
        /* Learn about objects */
@@ -1796,27 +1823,27 @@ void do_cmd_debug(player_type *creature_ptr)
 
        /* Mutation */
        case 'M':
-               (void)gain_mutation(creature_ptr, command_arg);
+               (void)gain_mutation(p_ptr, command_arg);
                break;
 
        /* Reset Class */
        case 'R':
-               (void)do_cmd_wiz_reset_class(creature_ptr);
+               (void)do_cmd_wiz_reset_class();
                break;
 
        /* Specific reward */
        case 'r':
-               (void)gain_level_reward(creature_ptr, command_arg);
+               (void)gain_level_reward(command_arg);
                break;
 
        /* Summon _friendly_ named monster */
        case 'N':
-               do_cmd_wiz_named_friendly(creature_ptr, command_arg);
+               do_cmd_wiz_named_friendly(command_arg);
                break;
 
        /* Summon Named Monster */
        case 'n':
-               do_cmd_wiz_named(creature_ptr, command_arg);
+               do_cmd_wiz_named(command_arg);
                break;
 
        /* Dump option bits usage */
@@ -1826,7 +1853,7 @@ void do_cmd_debug(player_type *creature_ptr)
 
        /* Object playing routines */
        case 'o':
-               do_cmd_wiz_play(creature_ptr);
+               do_cmd_wiz_play();
                break;
 
        /* Phase Door */
@@ -1849,20 +1876,20 @@ void do_cmd_debug(player_type *creature_ptr)
                        if(tmp_int < 0) break;
                        if(tmp_int >= max_q_idx) break;
 
-                       creature_ptr->inside_quest = (QUEST_IDX)tmp_int;
+                       p_ptr->inside_quest = (QUEST_IDX)tmp_int;
                        process_dungeon_file("q_info.txt", 0, 0, 0, 0);
                        quest[tmp_int].status = QUEST_STATUS_TAKEN;
-                       creature_ptr->inside_quest = 0;
+                       p_ptr->inside_quest = 0;
                }
                break;
 
        /* Complete a Quest -KMW- */
        case 'q':
-               if(creature_ptr->inside_quest)
+               if(p_ptr->inside_quest)
                {
-                       if (quest[creature_ptr->inside_quest].status == QUEST_STATUS_TAKEN)
+                       if (quest[p_ptr->inside_quest].status == QUEST_STATUS_TAKEN)
                        {
-                               complete_quest(creature_ptr->inside_quest);
+                               complete_quest(p_ptr->inside_quest);
                                break;
                        }
                }
@@ -1875,14 +1902,14 @@ void do_cmd_debug(player_type *creature_ptr)
 
        /* Make every dungeon square "known" to test streamers -KMW- */
        case 'u':
-               for (y = 0; y < p_ptr->current_floor_ptr->height; y++)
+               for (y = 0; y < current_floor_ptr->height; y++)
                {
-                       for (x = 0; x < p_ptr->current_floor_ptr->width; x++)
+                       for (x = 0; x < current_floor_ptr->width; x++)
                        {
-                               p_ptr->current_floor_ptr->grid_array[y][x].info |= (CAVE_GLOW | CAVE_MARK);
+                               current_floor_ptr->grid_array[y][x].info |= (CAVE_GLOW | CAVE_MARK);
                        }
                }
-               wiz_lite(creature_ptr, FALSE);
+               wiz_lite(FALSE);
                break;
 
        /* Summon Random Monster(s) */
@@ -1894,7 +1921,7 @@ void do_cmd_debug(player_type *creature_ptr)
        /* Special(Random Artifact) Objects */
        case 'S':
                if (command_arg <= 0) command_arg = 1;
-               acquirement(creature_ptr->y, creature_ptr->x, command_arg, TRUE, TRUE, TRUE);
+               acquirement(p_ptr->y, p_ptr->x, command_arg, TRUE, TRUE, TRUE);
                break;
 
        /* Teleport */
@@ -1911,17 +1938,17 @@ void do_cmd_debug(player_type *creature_ptr)
        /* Very Good Objects */
        case 'v':
                if (command_arg <= 0) command_arg = 1;
-               acquirement(creature_ptr->y, creature_ptr->x, command_arg, TRUE, FALSE, TRUE);
+               acquirement(p_ptr->y, p_ptr->x, command_arg, TRUE, FALSE, TRUE);
                break;
 
        /* Wizard Light the Level */
        case 'w':
-               wiz_lite(creature_ptr, (bool)(creature_ptr->pclass == CLASS_NINJA));
+               wiz_lite((bool)(p_ptr->pclass == CLASS_NINJA));
                break;
 
        /* Increase Experience */
        case 'x':
-               gain_exp(creature_ptr, command_arg ? command_arg : (creature_ptr->exp + 1));
+               gain_exp(command_arg ? command_arg : (p_ptr->exp + 1));
                break;
 
        /* Zap Monsters (Genocide) */
@@ -1931,7 +1958,7 @@ void do_cmd_debug(player_type *creature_ptr)
 
        /* Zap Monsters (Omnicide) */
        case 'Z':
-               do_cmd_wiz_zap_all(creature_ptr);
+               do_cmd_wiz_zap_all();
                break;
 
        /* Hack -- whatever I desire */
@@ -1945,14 +1972,14 @@ void do_cmd_debug(player_type *creature_ptr)
                INVENTORY_IDX i;
                for(i = INVEN_TOTAL - 1; i >= 0; i--)
                {
-                       if(creature_ptr->inventory_list[i].k_idx) inven_drop(i, 999);
+                       if(inventory[i].k_idx) inven_drop(i, 999);
                }
-               player_outfit(creature_ptr);
+               player_outfit();
                break;
        }
 
        case 'V':
-               do_cmd_wiz_reset_class(creature_ptr);
+               do_cmd_wiz_reset_class();
                break;
 
        /* Not a Wizard Command */
@@ -1962,6 +1989,109 @@ void do_cmd_debug(player_type *creature_ptr)
        }
 }
 
+void cheat_death(player_type *creature_ptr)
+{
+       /* Mark social class, reset age, if needed */
+       if (creature_ptr->sc) creature_ptr->sc = creature_ptr->age = 0;
+
+       /* Increase age */
+       creature_ptr->age++;
+
+       /* Mark savefile */
+       creature_ptr->noscore |= 0x0001;
+
+       msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
+       msg_print(NULL);
+
+       (void)life_stream(FALSE, FALSE);
+
+       if (creature_ptr->pclass == CLASS_MAGIC_EATER)
+       {
+               int magic_idx;
+               for (magic_idx = 0; magic_idx < EATER_EXT * 2; magic_idx++)
+               {
+                       creature_ptr->magic_num1[magic_idx] = creature_ptr->magic_num2[magic_idx] * EATER_CHARGE;
+               }
+               for (; magic_idx < EATER_EXT * 3; magic_idx++)
+               {
+                       creature_ptr->magic_num1[magic_idx] = 0;
+               }
+       }
+
+       /* Restore spell points */
+       creature_ptr->csp = creature_ptr->msp;
+       creature_ptr->csp_frac = 0;
+
+       /* Hack -- cancel recall */
+       if (creature_ptr->word_recall)
+       {
+               msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
+               msg_print(NULL);
+
+               /* Hack -- Prevent recall */
+               creature_ptr->word_recall = 0;
+               creature_ptr->redraw |= (PR_STATUS);
+       }
+
+       /* Hack -- cancel alter */
+       if (creature_ptr->alter_reality)
+       {
+               /* Hack -- Prevent alter */
+               creature_ptr->alter_reality = 0;
+               creature_ptr->redraw |= (PR_STATUS);
+       }
+
+       /* Note cause of death */
+       (void)strcpy(creature_ptr->died_from, _("死の欺き", "Cheating death"));
+
+       /* Do not die */
+       creature_ptr->is_dead = FALSE;
+
+       /* Hack -- Prevent starvation */
+       (void)set_food(PY_FOOD_MAX - 1);
+
+       current_floor_ptr->dun_level = 0;
+       creature_ptr->inside_arena = FALSE;
+       creature_ptr->inside_battle = FALSE;
+       leaving_quest = 0;
+       creature_ptr->inside_quest = 0;
+       if (p_ptr->dungeon_idx) creature_ptr->recall_dungeon = p_ptr->dungeon_idx;
+       p_ptr->dungeon_idx = 0;
+       if (lite_town || vanilla_town)
+       {
+               creature_ptr->wilderness_y = 1;
+               creature_ptr->wilderness_x = 1;
+               if (vanilla_town)
+               {
+                       creature_ptr->oldpy = 10;
+                       creature_ptr->oldpx = 34;
+               }
+               else
+               {
+                       creature_ptr->oldpy = 33;
+                       creature_ptr->oldpx = 131;
+               }
+       }
+       else
+       {
+               creature_ptr->wilderness_y = 48;
+               creature_ptr->wilderness_x = 5;
+               creature_ptr->oldpy = 33;
+               creature_ptr->oldpx = 131;
+       }
+       creature_ptr->wild_mode = FALSE;
+       creature_ptr->leaving = TRUE;
+
+       do_cmd_write_nikki(NIKKI_BUNSHOU, 1,
+               _("                            しかし、生き返った。",
+                       "                            but revived."));
+
+       /* Prepare next floor */
+       leave_floor();
+       wipe_m_list();
+
+}
+
 
 #else