OSDN Git Service

[FIx] 店で購入したアイテムに自動刻みしてからザックをまとめる
authorHabu <habu1010+github@gmail.com>
Wed, 19 May 2021 10:47:36 +0000 (19:47 +0900)
committerHabu <habu1010+github@gmail.com>
Wed, 19 May 2021 10:47:36 +0000 (19:47 +0900)
既存のコードでは店で購入したアイテムをザック内でまとめ直してから
自動刻みを行っているが、これだと元々持っていた銘の無いアイテムに
重なった場合にそのアイテムもろとも銘が刻まれてしまう。
アイテムを拾う時と同じように、先に銘を刻んでからザック内でまとめ
直すようにする。

src/store/purchase-order.cpp

index e365405..54e3bfc 100644 (file)
@@ -1,4 +1,6 @@
 #include "store/purchase-order.h"
+#include "autopick/autopick-finder.h"
+#include "autopick/autopick-util.h"
 #include "autopick/autopick.h"
 #include "core/asking-player.h"
 #include "core/stuff-handler.h"
@@ -308,13 +310,16 @@ void store_purchase(player_type *player_ptr)
     j_ptr->inscription = 0;
     j_ptr->feeling = FEEL_NONE;
     j_ptr->ident &= ~(IDENT_STORE);
+
+    const auto idx = find_autopick_list(player_ptr, j_ptr);
+    auto_inscribe_item(player_ptr, j_ptr, idx);
+
     item_new = store_item_to_inventory(player_ptr, j_ptr);
     handle_stuff(player_ptr);
 
     describe_flavor(player_ptr, o_name, &player_ptr->inventory_list[item_new], 0);
     msg_format(_("%s(%c)を手に入れた。", "You have %s (%c)."), o_name, index_to_label(item_new));
 
-    autopick_alter_item(player_ptr, item_new, FALSE);
     if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
         o_ptr->pval -= j_ptr->pval;