From e829709047e394bdd75dba5dfe6d7800791414f1 Mon Sep 17 00:00:00 2001 From: Hourier Date: Fri, 20 Aug 2021 10:18:08 +0900 Subject: [PATCH] [Refactor] #1370 Moved drop_thrown_item() from cmd-throw.cpp to throw-util.cpp/h --- src/action/throw-util.cpp | 11 +++++++++++ src/action/throw-util.h | 1 + src/cmd-item/cmd-throw.cpp | 13 +------------ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/action/throw-util.cpp b/src/action/throw-util.cpp index cec722776..6f2b36dd4 100644 --- a/src/action/throw-util.cpp +++ b/src/action/throw-util.cpp @@ -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) { diff --git a/src/action/throw-util.h b/src/action/throw-util.h index ae763f46f..246c63d73 100644 --- a/src/action/throw-util.h +++ b/src/action/throw-util.h @@ -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; diff --git a/src/cmd-item/cmd-throw.cpp b/src/cmd-item/cmd-throw.cpp index 7d8382dfe..c9716e0b9 100644 --- a/src/cmd-item/cmd-throw.cpp +++ b/src/cmd-item/cmd-throw.cpp @@ -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; } -- 2.11.0