OSDN Git Service

[Refactor] #1370 Moved drop_thrown_item() from cmd-throw.cpp to throw-util.cpp/h
authorHourier <grapefox.whitelucifer.0408@gmail.com>
Fri, 20 Aug 2021 01:18:08 +0000 (10:18 +0900)
committerHourier <grapefox.whitelucifer.0408@gmail.com>
Fri, 20 Aug 2021 01:18:08 +0000 (10:18 +0900)
src/action/throw-util.cpp
src/action/throw-util.h
src/cmd-item/cmd-throw.cpp

index cec7227..6f2b36d 100644 (file)
@@ -295,6 +295,17 @@ void it_type::process_boomerang_back()
     }
 }
 
+void it_type::drop_thrown_item()
+{
+    if (!this->do_drop)
+        return;
+
+    if (cave_has_flag_bold(this->creature_ptr->current_floor_ptr, this->y, this->x, FF_PROJECT))
+        (void)drop_near(this->creature_ptr, this->q_ptr, this->corruption_possibility, this->y, this->x);
+    else
+        (void)drop_near(this->creature_ptr, this->q_ptr, this->corruption_possibility, this->prev_y, this->prev_x);
+}
+
 bool it_type::check_what_throw()
 {
     if (this->shuriken >= 0) {
index ae763f4..246c63d 100644 (file)
@@ -64,6 +64,7 @@ public:
     void display_potion_throw();
     void check_boomerang_throw();
     void process_boomerang_back();
+    void drop_thrown_item();
 
 private:
     player_type *creature_ptr;
index 7d8382d..c9716e0 100644 (file)
@@ -70,17 +70,6 @@ ThrowCommand::ThrowCommand(player_type* creature_ptr)
 {
 }
 
-static void drop_thrown_item(player_type *creature_ptr, it_type *it_ptr)
-{
-    if (!it_ptr->do_drop)
-        return;
-
-    if (cave_has_flag_bold(creature_ptr->current_floor_ptr, it_ptr->y, it_ptr->x, FF_PROJECT))
-        (void)drop_near(creature_ptr, it_ptr->q_ptr, it_ptr->corruption_possibility, it_ptr->y, it_ptr->x);
-    else
-        (void)drop_near(creature_ptr, it_ptr->q_ptr, it_ptr->corruption_possibility, it_ptr->prev_y, it_ptr->prev_x);
-}
-
 /*!
  * @brief 投射処理メインルーチン /
  * Throw an object from the pack or floor.
@@ -135,6 +124,6 @@ bool ThrowCommand::do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
     it_ptr->display_potion_throw();
     it_ptr->check_boomerang_throw();
     it_ptr->process_boomerang_back();
-    drop_thrown_item(this->creature_ptr, it_ptr);
+    it_ptr->drop_thrown_item();
     return true;
 }