OSDN Git Service

[Refactor] #37353 コメント整理。 / Refactor comments.
[hengband/hengband.git] / src / autopick.c
index 06be3ff..685c7c3 100644 (file)
  */
 
 #include "angband.h"
-
+#include "store.h"
 
 #define MAX_LINELEN 1024
 
 /*
  * Macros for Keywords
  */
-#define FLG_ALL              
-#define FLG_UNAWARE         
-#define FLG_UNIDENTIFIED     
-#define FLG_IDENTIFIED      
-#define FLG_STAR_IDENTIFIED  
-#define FLG_COLLECTING      
-#define FLG_ARTIFACT        
+#define FLG_ALL                                0
+#define FLG_UNAWARE                    1
+#define FLG_UNIDENTIFIED       2
+#define FLG_IDENTIFIED         3
+#define FLG_STAR_IDENTIFIED    4
+#define FLG_COLLECTING         5
+#define FLG_ARTIFACT           6
 #define FLG_EGO                     7 
 #define FLG_GOOD            10
-#define FLG_NAMELESS        11
+#define FLG_NAMELESS    11
 #define FLG_AVERAGE         12
-#define FLG_WORTHLESS       13
+#define FLG_WORTHLESS   13
 #define FLG_RARE            14
 #define FLG_COMMON          15
 #define FLG_BOOSTED         16
-#define FLG_MORE_DICE       17
-#define FLG_MORE_BONUS      18 
+#define FLG_MORE_DICE   17
+#define FLG_MORE_BONUS  18
 #define FLG_WANTED          19
 #define FLG_UNIQUE          20
 #define FLG_HUMAN           21
-#define FLG_UNREADABLE      22
+#define FLG_UNREADABLE  22
 #define FLG_REALM1          23
 #define FLG_REALM2          24
 #define FLG_FIRST           25
@@ -1577,7 +1577,7 @@ static void auto_destroy_item(object_type *o_ptr, int autopick_idx)
 
        /* Now decided to destroy */
 
-       disturb(0,0);
+       disturb(FALSE, FALSE);
 
        /* Artifact? */
        if (!can_player_destroy_object(o_ptr))
@@ -1587,10 +1587,8 @@ static void auto_destroy_item(object_type *o_ptr, int autopick_idx)
                /* Describe the object (with {terrible/special}) */
                object_desc(o_name, o_ptr, 0);
 
-               /* Message */
                msg_format(_("%sは破壊不能だ。", "You cannot auto-destroy %s."), o_name);
 
-               /* Done */
                return;
        }
 
@@ -1608,7 +1606,7 @@ static void auto_destroy_item(object_type *o_ptr, int autopick_idx)
 /*
  *  Auto-destroy marked item
  */
-static void autopick_delayed_alter_aux(int item)
+static void autopick_delayed_alter_aux(INVENTORY_IDX item)
 {
        object_type *o_ptr;
 
@@ -1638,7 +1636,6 @@ static void autopick_delayed_alter_aux(int item)
                        delete_object_idx(0 - item);
                }
 
-               /* Print a message */
                msg_format(_("%sを自動破壊します。", "Auto-destroying %s."), o_name);
        }
 }
@@ -1649,7 +1646,7 @@ static void autopick_delayed_alter_aux(int item)
  */
 void autopick_delayed_alter(void)
 {
-       int item;
+       INVENTORY_IDX item;
 
        /* 
         * Scan inventry in reverse order to prevent
@@ -1662,7 +1659,7 @@ void autopick_delayed_alter(void)
        item = cave[p_ptr->y][p_ptr->x].o_idx;
        while (item)
        {
-               int next = o_list[item].next_o_idx;
+               OBJECT_IDX next = o_list[item].next_o_idx;
                autopick_delayed_alter_aux(-item);
                item = next;
        }
@@ -1675,7 +1672,7 @@ void autopick_delayed_alter(void)
  * Auto-destroyer works only on inventory or on floor stack only when
  * requested.
  */
-void autopick_alter_item(int item, bool destroy)
+void autopick_alter_item(INVENTORY_IDX item, bool destroy)
 {
        object_type *o_ptr;
        int idx;
@@ -1703,15 +1700,13 @@ void autopick_alter_item(int item, bool destroy)
  */
 void autopick_pickup_items(cave_type *c_ptr)
 {
-       s16b this_o_idx, next_o_idx = 0;
+       OBJECT_IDX this_o_idx, next_o_idx = 0;
        
        /* Scan the pile of objects */
        for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                int idx;
-       
-               /* Acquire object */
-               object_type *o_ptr = &o_list[this_o_idx];
+                       object_type *o_ptr = &o_list[this_o_idx];
                
                /* Acquire next object */
                next_o_idx = o_ptr->next_o_idx;
@@ -1724,16 +1719,14 @@ void autopick_pickup_items(cave_type *c_ptr)
                if (idx >= 0 &&
                        (autopick_list[idx].action & (DO_AUTOPICK | DO_QUERY_AUTOPICK)))
                {
-                       disturb(0,0);
+                       disturb(FALSE, FALSE);
 
                        if (!inven_carry_okay(o_ptr))
                        {
                                char o_name[MAX_NLEN];
 
-                               /* Describe the object */
                                object_desc(o_name, o_ptr, 0);
 
-                               /* Message */
                                msg_format(_("ザックには%sを入れる隙間がない。", "You have no room for %s."), o_name);
                                /* Hack - remember that the item has given a message here. */
                                o_ptr->marked |= OM_NOMSG;
@@ -1751,7 +1744,6 @@ void autopick_pickup_items(cave_type *c_ptr)
                                        continue;
                                }
 
-                               /* Describe the object */
                                object_desc(o_name, o_ptr, 0);
 
                                sprintf(out_val, _("%sを拾いますか? ", "Pick up %s? "), o_name);
@@ -1936,10 +1928,8 @@ bool autopick_autoregister(object_type *o_ptr)
                /* Describe the object (with {terrible/special}) */
                object_desc(o_name, o_ptr, 0);
 
-               /* Message */
                msg_format(_("%sは破壊不能だ。", "You cannot auto-destroy %s."), o_name);
 
-               /* Done */
                return FALSE;
        }
 
@@ -2023,8 +2013,6 @@ bool autopick_autoregister(object_type *o_ptr)
        /* Add a line to the file */
        /* Don't kill "entry" */
        fprintf(pref_fff, "%s\n", autopick_line_from_entry(entry));
-
-       /* Close the file */
        fclose(pref_fff);
 
        return TRUE;
@@ -2784,17 +2772,10 @@ static cptr *read_text_lines(cptr filename)
 static void prepare_default_pickpref(void)
 {
        const cptr messages[] = {
-#ifdef JP
-               "あなたは「自動拾いエディタ」を初めて起動しました。",
-               "自動拾いのユーザー設定ファイルがまだ書かれていないので、",
-               "基本的な自動拾い設定ファイルをlib/pref/picktype.prfからコピーします。",
+               _("あなたは「自動拾いエディタ」を初めて起動しました。", "You have activated the Auto-Picker Editor for the first time."),
+               _("自動拾いのユーザー設定ファイルがまだ書かれていないので、", "Since user pref file for autopick is not yet created,"),
+               _("基本的な自動拾い設定ファイルをlib/pref/picktype.prfからコピーします。", "the default setting is loaded from lib/pref/pickpref.prf ."),
                NULL
-#else
-               "You have activated the Auto-Picker Editor for the first time.",
-               "Since user pref file for autopick is not yet created,",
-               "the default setting is loaded from lib/pref/pickpref.prf .",
-               NULL
-#endif
        };
 
        char buf[1024];
@@ -2932,7 +2913,7 @@ static void free_text_lines(cptr *lines_list)
 /*
  * Delete or insert string
  */
-static void toggle_keyword(text_body_type *tb, int flg)
+static void toggle_keyword(text_body_type *tb, BIT_FLAGS flg)
 {
        int by1, by2, y;
        bool add = TRUE;
@@ -3104,7 +3085,7 @@ static void toggle_command_letter(text_body_type *tb, byte flg)
 /*
  * Delete or insert string
  */
-static void add_keyword(text_body_type *tb, int flg)
+static void add_keyword(text_body_type *tb, BIT_FLAGS flg)
 {
        int by1, by2, y;
 
@@ -3256,37 +3237,14 @@ static bool insert_return_code(text_body_type *tb)
 /*
  * Choose an item and get auto-picker entry from it.
  */
-static object_type *choose_object(cptr q, cptr s)
-{
-       int item;
-
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP))) return NULL;
-
-       /* Get the item (in the pack) */
-       if (item >= 0) return &inventory[item];
-
-       /* Get the item (on the floor) */
-       else return &o_list[0 - item];
-}
-
-
-/*
- * Choose an item and get auto-picker entry from it.
- */
 static bool entry_from_choosed_object(autopick_type *entry)
 {
        object_type *o_ptr;
        cptr q, s;
 
-       /* Get an item */
-#ifdef JP
-       q = "どのアイテムを登録しますか? ";
-       s = "アイテムを持っていない。";
-#else
-       q = "Enter which item? ";
-       s = "You have nothing to enter.";
-#endif
-       o_ptr = choose_object(q, s);
+       q = _("どのアイテムを登録しますか? ", "Enter which item? ");
+       s = _("アイテムを持っていない。", "You have nothing to enter.");
+       o_ptr = choose_object(NULL, q, s, USE_INVEN | USE_FLOOR | USE_EQUIP);
        if (!o_ptr) return FALSE;
 
        autopick_entry_from_object(entry, o_ptr);
@@ -3303,15 +3261,9 @@ static byte get_object_for_search(object_type **o_handle, cptr *search_strp)
        object_type *o_ptr;
        cptr q, s;
 
-       /* Get an item */
-#ifdef JP
-       q = "どのアイテムを検索しますか? ";
-       s = "アイテムを持っていない。";
-#else
-       q = "Enter which item? ";
-       s = "You have nothing to enter.";
-#endif
-       o_ptr = choose_object(q, s);
+       q = _("どのアイテムを検索しますか? ", "Enter which item? ");
+       s = _("アイテムを持っていない。", "You have nothing to enter.");
+       o_ptr = choose_object(NULL, q, s, USE_INVEN | USE_FLOOR | USE_EQUIP);
        if (!o_ptr) return 0;
 
        *o_handle = o_ptr;
@@ -3460,7 +3412,6 @@ static byte get_string_for_search(object_type **o_handle, cptr *search_strp)
                        return (back ? -1 : 1);
 
                case KTRL('i'):
-                       /* Get an item */
                        return get_object_for_search(o_handle, search_strp);
 
                case KTRL('l'):
@@ -3803,11 +3754,11 @@ static void search_for_string(text_body_type *tb, cptr search_str, bool forward)
 /*
  * Editor command id's
  */
-#define EC_QUIT                1 
-#define EC_SAVEQUIT            2     
-#define EC_REVERT             3 
-#define EC_HELP                4 
-#define EC_RETURN             5        
+#define EC_QUIT            1
+#define EC_SAVEQUIT        2
+#define EC_REVERT             3
+#define EC_HELP            4
+#define EC_RETURN             5
 #define EC_LEFT                       6 
 #define EC_DOWN                       7 
 #define EC_UP                 8 
@@ -4459,7 +4410,6 @@ static void draw_text_editor(text_body_type *tb)
        int i;
        int by1 = 0, by2 = 0;
 
-       /* Get size */
        Term_get_size(&tb->wid, &tb->hgt);
 
        /*
@@ -4509,8 +4459,6 @@ static void draw_text_editor(text_body_type *tb)
        if (tb->dirty_flags & DIRTY_SCREEN)
        {
                tb->dirty_flags |= (DIRTY_ALL | DIRTY_MODE);
-
-               /* Clear screen */
                Term_clear();
        }
 
@@ -4883,7 +4831,6 @@ static bool insert_macro_line(text_body_type *tb)
        /* Terminate */
        buf[n] = '\0';
 
-       /* Flush */
        flush();
 
        /* Convert the trigger */
@@ -4929,7 +4876,7 @@ static bool insert_keymap_line(text_body_type *tb)
 {
        char tmp[1024];
        char buf[2];
-       int mode;
+       BIT_FLAGS mode;
        cptr act;
 
        /* Roguelike */
@@ -4944,14 +4891,12 @@ static bool insert_keymap_line(text_body_type *tb)
                mode = KEYMAP_MODE_ORIG;
        }
 
-       /* Flush */
        flush();
 
        /* Get a key */
        buf[0] = inkey();
        buf[1] = '\0';
 
-       /* Flush */
        flush();
 
        /* Convert the trigger */
@@ -6084,8 +6029,6 @@ void do_cmd_edit_autopick(void)
                        break;
                }
        }
-
-       /* Save the screen */
        screen_save();
 
        /* Process requests until done */
@@ -6169,8 +6112,6 @@ void do_cmd_edit_autopick(void)
 
                if (com_id) quit = do_editor_command(tb, com_id);
        } /* while (TRUE) */
-
-       /* Restore the screen */
        screen_load();
 
        /* Get the filename of preference */