OSDN Git Service

Merge branch 'master' of git.osdn.net:/gitroot/hengband/hengband
[hengband/hengband.git] / src / autopick / autopick-util.c
index 789ec2a..59e3955 100644 (file)
@@ -1,5 +1,12 @@
-#include "angband.h"
-#include "autopick/autopick-util.h"
+#include "autopick/autopick-util.h"
+#include "autopick/autopick-menu-data-table.h"
+#include "core/player-update-types.h"
+#include "core/window-redrawer.h"
+#include "game-option/input-options.h"
+#include "main/sound-of-music.h"
+#include "monster-race/race-indice-types.h"
+#include "object-enchant/item-feeling.h"
+#include "util/quarks.h"
 
 /*
  * 自動拾い/破壊設定のリストに関する変数 / List for auto-picker/destroyer entries
@@ -26,3 +33,70 @@ void autopick_free_entry(autopick_type *entry)
        entry->name = NULL;
        entry->insc = NULL;
 }
+
+
+/*
+ * Free memory of lines_list.
+ */
+void free_text_lines(concptr *lines_list)
+{
+       for (int lines = 0; lines_list[lines]; lines++)
+       {
+               string_free(lines_list[lines]);
+       }
+
+       /* free list of pointers */
+       C_KILL(lines_list, MAX_LINES, concptr);
+}
+
+
+/*
+ * Find a command by 'key'.
+ */
+int get_com_id(char key)
+{
+       for (int i = 0; menu_data[i].name; i++)
+       {
+               if (menu_data[i].key == key)
+               {
+                       return menu_data[i].com_id;
+               }
+       }
+
+       return 0;
+}
+
+
+/*
+ * Auto inscription
+ */
+void auto_inscribe_item(player_type *player_ptr, object_type *o_ptr, int idx)
+{
+       if (idx < 0 || !autopick_list[idx].insc) return;
+
+       if (!o_ptr->inscription)
+               o_ptr->inscription = quark_add(autopick_list[idx].insc);
+
+       player_ptr->window |= (PW_EQUIP | PW_INVEN);
+       player_ptr->update |= (PU_BONUS);
+}
+
+
+/*
+ * Add one line to autopick_list[]
+ */
+void add_autopick_list(autopick_type *entry)
+{
+       if (max_autopick >= max_max_autopick)
+       {
+               int old_max_max_autopick = max_max_autopick;
+               autopick_type *old_autopick_list = autopick_list;
+               max_max_autopick += MAX_AUTOPICK_DEFAULT;
+               C_MAKE(autopick_list, max_max_autopick, autopick_type);
+               (void)C_COPY(autopick_list, old_autopick_list, old_max_max_autopick, autopick_type);
+               C_KILL(old_autopick_list, old_max_max_autopick, autopick_type);
+       }
+
+       autopick_list[max_autopick] = *entry;
+       max_autopick++;
+}