OSDN Git Service

[Refactor] #37353 「死を欺く処理」を dungeon.c から cheat_death() に分離。 / Separate cheat_death...
authorDeskull <deskull@users.sourceforge.jp>
Sat, 12 Jan 2019 13:31:29 +0000 (22:31 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Sat, 12 Jan 2019 13:31:29 +0000 (22:31 +0900)
src/dungeon.c
src/externs.h
src/wizard2.c

index 3589969..72d7956 100644 (file)
@@ -6111,7 +6111,6 @@ void play_game(bool new_game)
                /* Process the level */
                dungeon(load_game);
 
-
                /* Hack -- prevent "icky" message */
                character_xtra = TRUE;
 
@@ -6168,106 +6167,7 @@ void play_game(bool new_game)
                                /* Mega-Hack -- Allow player to cheat death */
                                if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? ")))
                                {
-                                       /* Mark social class, reset age, if needed */
-                                       if (p_ptr->sc) p_ptr->sc = p_ptr->age = 0;
-
-                                       /* Increase age */
-                                       p_ptr->age++;
-
-                                       /* Mark savefile */
-                                       p_ptr->noscore |= 0x0001;
-
-                                       msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
-                                       msg_print(NULL);
-
-                                       (void)life_stream(FALSE, FALSE);
-
-                                       if (p_ptr->pclass == CLASS_MAGIC_EATER)
-                                       {
-                                               int magic_idx;
-                                               for (magic_idx = 0; magic_idx < EATER_EXT*2; magic_idx++)
-                                               {
-                                                       p_ptr->magic_num1[magic_idx] = p_ptr->magic_num2[magic_idx]*EATER_CHARGE;
-                                               }
-                                               for (; magic_idx < EATER_EXT*3; magic_idx++)
-                                               {
-                                                       p_ptr->magic_num1[magic_idx] = 0;
-                                               }
-                                       }
-
-                                       /* Restore spell points */
-                                       p_ptr->csp = p_ptr->msp;
-                                       p_ptr->csp_frac = 0;
-
-                                       /* Hack -- cancel recall */
-                                       if (p_ptr->word_recall)
-                                       {
-                                               msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
-                                               msg_print(NULL);
-
-                                               /* Hack -- Prevent recall */
-                                               p_ptr->word_recall = 0;
-                                               p_ptr->redraw |= (PR_STATUS);
-                                       }
-
-                                       /* Hack -- cancel alter */
-                                       if (p_ptr->alter_reality)
-                                       {
-                                               /* Hack -- Prevent alter */
-                                               p_ptr->alter_reality = 0;
-                                               p_ptr->redraw |= (PR_STATUS);
-                                       }
-
-                                       /* Note cause of death */
-                                       (void)strcpy(p_ptr->died_from, _("死の欺き", "Cheating death"));
-
-                                       /* Do not die */
-                                       p_ptr->is_dead = FALSE;
-
-                                       /* Hack -- Prevent starvation */
-                                       (void)set_food(PY_FOOD_MAX - 1);
-
-                                       dun_level = 0;
-                                       p_ptr->inside_arena = FALSE;
-                                       p_ptr->inside_battle = FALSE;
-                                       leaving_quest = 0;
-                                       p_ptr->inside_quest = 0;
-                                       if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
-                                       dungeon_type = 0;
-                                       if (lite_town || vanilla_town)
-                                       {
-                                               p_ptr->wilderness_y = 1;
-                                               p_ptr->wilderness_x = 1;
-                                               if (vanilla_town)
-                                               {
-                                                       p_ptr->oldpy = 10;
-                                                       p_ptr->oldpx = 34;
-                                               }
-                                               else
-                                               {
-                                                       p_ptr->oldpy = 33;
-                                                       p_ptr->oldpx = 131;
-                                               }
-                                       }
-                                       else
-                                       {
-                                               p_ptr->wilderness_y = 48;
-                                               p_ptr->wilderness_x = 5;
-                                               p_ptr->oldpy = 33;
-                                               p_ptr->oldpx = 131;
-                                       }
-
-                                       /* Leaving */
-                                       p_ptr->wild_mode = FALSE;
-                                       p_ptr->leaving = TRUE;
-
-                                       do_cmd_write_nikki(NIKKI_BUNSHOU, 1, 
-                                                               _("                            しかし、生き返った。", 
-                                                                 "                            but revived."));
-
-                                       /* Prepare next floor */
-                                       leave_floor();
-                                       wipe_m_list();
+                                       cheat_death(p_ptr);
                                }
                        }
                }
index 1ed9778..24b1890 100644 (file)
@@ -1476,6 +1476,7 @@ extern void spoil_random_artifact(cptr fname);
 extern void strip_name(char *buf, KIND_OBJECT_IDX k_idx);
 extern void do_cmd_rerate_aux(void);
 extern void do_cmd_rerate(bool display);
+extern void cheat_death(player_type *creature_ptr);
 
 /* avatar.c */
 extern bool compare_virtue(int type, int num, int tekitou);
index 63bf2b0..72e7f67 100644 (file)
@@ -2104,6 +2104,111 @@ void do_cmd_debug(void)
        }
 }
 
+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);
+
+       dun_level = 0;
+       creature_ptr->inside_arena = FALSE;
+       creature_ptr->inside_battle = FALSE;
+       leaving_quest = 0;
+       creature_ptr->inside_quest = 0;
+       if (dungeon_type) creature_ptr->recall_dungeon = dungeon_type;
+       dungeon_type = 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;
+       }
+
+       /* Leaving */
+       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