OSDN Git Service

[Refactor] #38862 Moved object*.c/h to object/
[hengband/hengband.git] / src / cmd / cmd-read.c
index 2e8e736..cfa79ac 100644 (file)
@@ -8,9 +8,10 @@
 
 #include "angband.h"
 #include "util.h"
+#include "main/sound-definitions-table.h"
 
-#include "object-flavor.h"
-#include "object-hook.h"
+#include "object/object-flavor.h"
+#include "object/object-hook.h"
 #include "artifact.h"
 #include "avatar.h"
 #include "player-status.h"
 #include "player-effects.h"
 #include "player-inventory.h"
 #include "rumor.h"
-#include "realm-hex.h"
+#include "realm/realm-hex.h"
 
-#include "spells.h"
 #include "spells-object.h"
 #include "spells-floor.h"
 #include "spells-summon.h"
 #include "spells-status.h"
 
-#include "cmd-basic.h"
+#include "cmd/cmd-basic.h"
+#include "core/show-file.h"
 #include "files.h"
-#include "floor.h"
-#include "objectkind.h"
-#include "realm-song.h"
-#include "view-mainwindow.h"
+#include "floor/floor.h"
+#include "object/object-kind.h"
+#include "view/display-main-window.h"
+#include "spell/spells-type.h"
+#include "spell/spells2.h"
+#include "spell/spells3.h"
 
 /*!
  * @brief 巻物を読むコマンドのサブルーチン
@@ -122,7 +125,7 @@ void exe_read(player_type *creature_ptr, INVENTORY_IDX item, bool known)
                {
                        for (k = 0; k < randint1(3); k++)
                        {
-                               if (summon_specific(0, creature_ptr->y, creature_ptr->x, creature_ptr->current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
+                               if (summon_specific(creature_ptr, 0, creature_ptr->y, creature_ptr->x, creature_ptr->current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
                                {
                                        ident = TRUE;
                                }
@@ -134,7 +137,7 @@ void exe_read(player_type *creature_ptr, INVENTORY_IDX item, bool known)
                {
                        for (k = 0; k < randint1(3); k++)
                        {
-                               if (summon_specific(0, creature_ptr->y, creature_ptr->x, creature_ptr->current_floor_ptr->dun_level, SUMMON_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
+                               if (summon_specific(creature_ptr, 0, creature_ptr->y, creature_ptr->x, creature_ptr->current_floor_ptr->dun_level, SUMMON_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
                                {
                                        ident = TRUE;
                                }
@@ -144,7 +147,7 @@ void exe_read(player_type *creature_ptr, INVENTORY_IDX item, bool known)
 
                case SV_SCROLL_SUMMON_PET:
                {
-                       if (summon_specific(-1, creature_ptr->y, creature_ptr->x, creature_ptr->current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_FORCE_PET)))
+                       if (summon_specific(creature_ptr, -1, creature_ptr->y, creature_ptr->x, creature_ptr->current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_FORCE_PET)))
                        {
                                ident = TRUE;
                        }
@@ -153,7 +156,7 @@ void exe_read(player_type *creature_ptr, INVENTORY_IDX item, bool known)
 
                case SV_SCROLL_SUMMON_KIN:
                {
-                       if (summon_kin_player(creature_ptr->lev, creature_ptr->y, creature_ptr->x, (PM_FORCE_PET | PM_ALLOW_GROUP)))
+                       if (summon_kin_player(creature_ptr, creature_ptr->lev, creature_ptr->y, creature_ptr->x, (PM_FORCE_PET | PM_ALLOW_GROUP)))
                        {
                                ident = TRUE;
                        }
@@ -168,14 +171,14 @@ void exe_read(player_type *creature_ptr, INVENTORY_IDX item, bool known)
 
                case SV_SCROLL_PHASE_DOOR:
                {
-                       teleport_player(creature_ptr, 10, 0L);
+                       teleport_player(creature_ptr, 10, TELEPORT_SPONTANEOUS);
                        ident = TRUE;
                        break;
                }
 
                case SV_SCROLL_TELEPORT:
                {
-                       teleport_player(creature_ptr, 100, 0L);
+                       teleport_player(creature_ptr, 100, TELEPORT_SPONTANEOUS);
                        ident = TRUE;
                        break;
                }
@@ -196,14 +199,14 @@ void exe_read(player_type *creature_ptr, INVENTORY_IDX item, bool known)
 
                case SV_SCROLL_IDENTIFY:
                {
-                       if (!ident_spell(creature_ptr, FALSE)) used_up = FALSE;
+                       if (!ident_spell(creature_ptr, FALSE, 0)) used_up = FALSE;
                        ident = TRUE;
                        break;
                }
 
                case SV_SCROLL_STAR_IDENTIFY:
                {
-                       if (!identify_fully(creature_ptr, FALSE)) used_up = FALSE;
+                       if (!identify_fully(creature_ptr, FALSE, 0)) used_up = FALSE;
                        ident = TRUE;
                        break;
                }
@@ -480,7 +483,7 @@ void exe_read(player_type *creature_ptr, INVENTORY_IDX item, bool known)
                {
                        msg_print(_("巻物にはメッセージが書かれている:", "There is message on the scroll. It says:"));
                        msg_print(NULL);
-                       display_rumor(TRUE);
+                       display_rumor(creature_ptr, TRUE);
                        msg_print(NULL);
                        msg_print(_("巻物は煙を立てて消え去った!", "The scroll disappears in a puff of smoke!"));
 
@@ -544,7 +547,7 @@ void exe_read(player_type *creature_ptr, INVENTORY_IDX item, bool known)
                q=format("book-%d_jp.txt",o_ptr->sval);
 
                /* Display object description */
-               object_desc(o_name, o_ptr, OD_NAME_ONLY);
+               object_desc(creature_ptr, o_name, o_ptr, OD_NAME_ONLY);
                path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, q);
 
                /* Peruse the help file */
@@ -554,7 +557,14 @@ void exe_read(player_type *creature_ptr, INVENTORY_IDX item, bool known)
                used_up=FALSE;
        }
 
-       creature_ptr->update |= (PU_COMBINE | PU_REORDER);
+       /*
+        * Store what may have to be updated for the inventory (including
+        * autodestroy if set by something else).  Then turn off those flags
+        * so that updates triggered by calling gain_exp() below do not
+        * rearrange the inventory before destroying the scroll in the pack.
+        */
+       BIT_FLAGS inventory_flags = (PU_COMBINE | PU_REORDER | (creature_ptr->update & PU_AUTODESTROY));
+       creature_ptr->update &= ~(PU_COMBINE | PU_REORDER | PU_AUTODESTROY);
 
        if (!(object_is_aware(o_ptr)))
        {
@@ -574,7 +584,7 @@ void exe_read(player_type *creature_ptr, INVENTORY_IDX item, bool known)
        }
 
        creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
-
+       creature_ptr->update |= inventory_flags;
 
        /* Hack -- allow certain scrolls to be "preserved" */
        if (!used_up)