OSDN Git Service

[Refactor] #40560 Separated exe_destroy_item() from do_cmd_destory()
authorHourier <hourier@users.sourceforge.jp>
Thu, 20 Aug 2020 07:00:02 +0000 (16:00 +0900)
committerHourier <hourier@users.sourceforge.jp>
Thu, 20 Aug 2020 07:00:02 +0000 (16:00 +0900)
src/cmd-item/cmd-destroy.c

index 8a5f322..fce562a 100644 (file)
@@ -172,6 +172,21 @@ static void process_destroy_magic_book(player_type *creature_ptr, destroy_type *
         chg_virtue(creature_ptr, V_SACRIFICE, 1);
 }
 
+static void exe_destroy_item(player_type *creature_ptr, destroy_type *destroy_ptr)
+{
+    object_copy(destroy_ptr->q_ptr, destroy_ptr->o_ptr);
+    msg_format(_("%s\82ð\89ó\82µ\82½\81B", "You destroy %s."), destroy_ptr->o_name);
+    sound(SOUND_DESTITEM);
+    reduce_charges(destroy_ptr->o_ptr, destroy_ptr->amt);
+    vary_item(creature_ptr, destroy_ptr->item, -destroy_ptr->amt);
+    process_destroy_magic_book(creature_ptr, destroy_ptr);
+    if ((destroy_ptr->q_ptr->to_a != 0) || (destroy_ptr->q_ptr->to_d != 0) || (destroy_ptr->q_ptr->to_h != 0))
+        chg_virtue(creature_ptr, V_HARMONY, 1);
+
+    if (destroy_ptr->item >= INVEN_RARM)
+        calc_android_exp(creature_ptr);
+}
+
 /*!
  * @brief \83A\83C\83e\83\80\82ð\94j\89ó\82·\82é\83R\83}\83\93\83h\82Ì\83\81\83C\83\93\83\8b\81[\83`\83\93 / Destroy an item
  * @param creature_ptr \83v\83\8c\81[\83\84\81[\82Ö\82Ì\8eQ\8fÆ\83|\83C\83\93\83^
@@ -202,15 +217,5 @@ void do_cmd_destroy(player_type *creature_ptr)
         return;
     }
 
-    object_copy(destroy_ptr->q_ptr, destroy_ptr->o_ptr);
-    msg_format(_("%s\82ð\89ó\82µ\82½\81B", "You destroy %s."), destroy_ptr->o_name);
-    sound(SOUND_DESTITEM);
-    reduce_charges(destroy_ptr->o_ptr, destroy_ptr->amt);
-    vary_item(creature_ptr, destroy_ptr->item, -destroy_ptr->amt);
-    process_destroy_magic_book(creature_ptr, destroy_ptr);
-    if ((destroy_ptr->q_ptr->to_a != 0) || (destroy_ptr->q_ptr->to_d != 0) || (destroy_ptr->q_ptr->to_h != 0))
-        chg_virtue(creature_ptr, V_HARMONY, 1);
-
-    if (destroy_ptr->item >= INVEN_RARM)
-        calc_android_exp(creature_ptr);
+    exe_destroy_item(creature_ptr, destroy_ptr);
 }