OSDN Git Service

easy_floorで、
authormogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Thu, 2 May 2002 19:42:03 +0000 (19:42 +0000)
committermogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Thu, 2 May 2002 19:42:03 +0000 (19:42 +0000)
- lookコマンド使用中や移動中に床上の23個を越えるアイテム山の数を正しく表示。
- 'x'で表示する床上のアイテムリストもリターンキーでスクロールするようにした。

src/externs.h
src/object1.c
src/xtra2.c

index ae5d694..63c44a9 100644 (file)
@@ -1432,8 +1432,8 @@ extern bool do_cmd_disarm_aux(int y, int x, int dir);
 #ifdef ALLOW_EASY_FLOOR /* TNB */
 
 /* object1.c */
-extern bool scan_floor(int *items, int *item_num, int y, int x, int mode);
-extern int  show_floor(int target_item, int y, int x);
+extern int scan_floor(int *items, int y, int x, int mode);
+extern int show_floor(int target_item, int y, int x, int *min_width);
 extern bool get_item_floor(int *cp, cptr pmt, cptr str, int mode);
 extern void py_pickup_floor(int pickup);
 
index 11f56a4..b8281a9 100644 (file)
@@ -5019,7 +5019,7 @@ bool can_get_item(void)
                if (item_tester_okay(&inventory[j]))
                        return TRUE;
 
-       (void)scan_floor(floor_list, &floor_num, py, px, 0x01);
+       floor_num = scan_floor(floor_list, py, px, 0x01);
        if (floor_num)
                return TRUE;
 
@@ -5930,16 +5930,14 @@ if (ver && !verify("
  *             mode & 0x02 -- Marked items only
  *             mode & 0x04 -- Stop after first
  */
-bool scan_floor(int *items, int *item_num, int y, int x, int mode)
+int scan_floor(int *items, int y, int x, int mode)
 {
        int this_o_idx, next_o_idx;
 
        int num = 0;
 
-       (*item_num) = 0;
-
        /* Sanity */
-       if (!in_bounds(y, x)) return (FALSE);
+       if (!in_bounds(y, x)) return 0;
 
        /* Scan all objects in the grid */
        for (this_o_idx = cave[y][x].o_idx; this_o_idx; this_o_idx = next_o_idx)
@@ -5959,26 +5957,24 @@ bool scan_floor(int *items, int *item_num, int y, int x, int mode)
                if ((mode & 0x02) && !o_ptr->marked) continue;
 
                /* Accept this item */
-               items[num++] = this_o_idx;
+               /* XXX Hack -- Enforce limit */
+               if (num <= 23)
+                       items[num] = this_o_idx;
+
+               num++;
 
                /* Only one */
                if (mode & 0x04) break;
-
-               /* XXX Hack -- Enforce limit */
-               if (num == 23) break;
        }
 
-       /* Number of items */
-       (*item_num) = num;
-
        /* Result */
-       return (num != 0);
+       return num;
 }
 
 /*
  * Display a list of the items on the floor at the given location.
  */
-int show_floor(int target_item, int y, int x)
+int show_floor(int target_item, int y, int x, int *min_width)
 {
        int i, j, k, l;
        int col, len, lim;
@@ -6001,7 +5997,7 @@ int show_floor(int target_item, int y, int x)
        Term_get_size(&wid, &hgt);
 
        /* Default length */
-       len = 20;
+       len = MAX((*min_width), 20);
 
        /* Maximum space allowed for descriptions */
        lim = wid - 4;
@@ -6010,10 +6006,10 @@ int show_floor(int target_item, int y, int x)
        if (show_weights) lim -= 9;
 
        /* Scan for objects in the grid, using item_tester_okay() */
-       (void) scan_floor(floor_list, &floor_num, y, x, 0x01);
+       floor_num = scan_floor(floor_list, y, x, 0x01);
 
        /* Display the inventory */
-       for (k = 0, i = 0; i < floor_num; i++)
+       for (k = 0, i = 0; i < floor_num && i < 23; i++)
        {
                o_ptr = &o_list[floor_list[i]];
 
@@ -6045,6 +6041,9 @@ int show_floor(int target_item, int y, int x)
                k++;
        }
 
+       /* Save width */
+       *min_width = len;
+
        /* Find the column to start in */
        col = (len > wid - 4) ? 0 : (wid - len - 1);
 
@@ -6131,6 +6130,7 @@ bool get_item_floor(int *cp, cptr pmt, cptr str, int mode)
        char out_val[160];
 
        int floor_num, floor_list[23], floor_top = 0;
+       int min_width = 0;
 
        extern bool select_spellbook;
        extern bool select_the_force;
@@ -6249,7 +6249,7 @@ bool get_item_floor(int *cp, cptr pmt, cptr str, int mode)
        if (floor)
        {
                /* Scan all objects in the grid */
-               (void) scan_floor(floor_list, &floor_num, py, px, 0x01);
+               floor_num = scan_floor(floor_list, py, px, 0x01);
        }
 
        /* Accept inventory */
@@ -6395,7 +6395,7 @@ bool get_item_floor(int *cp, cptr pmt, cptr str, int mode)
                        n2 = I2A(k - floor_top);
 
                        /* Redraw if needed */
-                       if (command_see) get_item_label = show_floor(menu_line, py, px);
+                       if (command_see) get_item_label = show_floor(menu_line, py, px, &min_width);
                }
 
                /* Viewing inventory */
@@ -6643,7 +6643,7 @@ if (!command_see && !use_menu) strcat(out_val, " '*'
                        if (command_see && !use_menu)
                        {
 #ifdef JP
-                               strcat(out_val, " RET ¼¡,");
+                               strcat(out_val, " Enter ¼¡,");
 #else
                                strcat(out_val, " Enter for scroll down,");
 #endif
@@ -6667,7 +6667,7 @@ if (!command_see && !use_menu) strcat(out_val, " '*'
                int max_line = 1;
                if (command_wrk == USE_INVEN) max_line = max_inven;
                else if (command_wrk == USE_EQUIP) max_line = max_equip;
-               else if (command_wrk == USE_FLOOR) max_line = floor_num;
+               else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
                switch (which)
                {
                        case ESCAPE:
@@ -6749,7 +6749,7 @@ if (!command_see && !use_menu) strcat(out_val, " '*'
                                /* Switch inven/equip */
                                if (command_wrk == USE_INVEN) max_line = max_inven;
                                else if (command_wrk == USE_EQUIP) max_line = max_equip;
-                               else if (command_wrk == USE_FLOOR) max_line = floor_num;
+                               else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
                                if (menu_line > max_line) menu_line = max_line;
 
                                /* Need to redraw */
@@ -6810,7 +6810,7 @@ if (!command_see && !use_menu) strcat(out_val, " '*'
                                /* Switch inven/equip */
                                if (command_wrk == USE_INVEN) max_line = max_inven;
                                else if (command_wrk == USE_EQUIP) max_line = max_equip;
-                               else if (command_wrk == USE_FLOOR) max_line = floor_num;
+                               else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
                                if (menu_line > max_line) menu_line = max_line;
 
                                /* Need to redraw */
@@ -6927,7 +6927,7 @@ if (!command_see && !use_menu) strcat(out_val, " '*'
                                o_list[i].next_o_idx = o_idx;
        
                                /* Re-scan floor list */ 
-                               scan_floor(floor_list, &floor_num, py, px, 0x01);
+                               floor_num = scan_floor(floor_list, py, px, 0x01);
 
                                /* Hack -- Fix screen */
                                if (command_see)
@@ -7210,7 +7210,7 @@ if (!command_see && !use_menu) strcat(out_val, " '*'
                                else if (command_wrk == USE_FLOOR)
                                {
                                        k = islower(which) ? A2I(which) : -1;
-                                       if (k < 0 || k >= floor_num)
+                                       if (k < 0 || k >= floor_num || k >= 23)
                                        {
                                                bell();
                                                break;
@@ -7415,13 +7415,12 @@ void py_pickup_floor(int pickup)
                }
 
                /* Remember this object index */
-               floor_list[floor_num] = this_o_idx;
+               if (floor_num <= 23)
+                       floor_list[floor_num] = this_o_idx;
 
                /* Count non-gold objects */
                floor_num++;
 
-               if (floor_num == 23) break;
-
                /* Remember this index */
                floor_o_idx = this_o_idx;
        }
index 88066d7..c6cc9ec 100644 (file)
@@ -3295,8 +3295,11 @@ s2 = "
                if (easy_floor)
                {
                        int floor_list[23], floor_num;
+                       int min_width = 0;
 
-                       if (scan_floor(floor_list, &floor_num, y, x, 0x02))
+                       floor_num = scan_floor(floor_list, y, x, 0x02);
+
+                       if (floor_num)
                        {
                                /* Not boring */
                                boring = FALSE;
@@ -3345,32 +3348,57 @@ s1, o_name, s2, s3, info);
                                        query = inkey();
 
                                        /* Display list of items (query == "el", not "won") */
-                                       if ((floor_num > 1) && (query == 'x'))
+                                       if (floor_num == 1 || query != 'x')
+                                       {
+                                               /* Stop */
+                                               break;
+                                       }
+                                       else while (1)
                                        {
+                                               int i, o_idx;
+                                               cave_type *c_ptr;
+
                                                /* Save screen */
                                                screen_save();
 
                                                /* Display */
-                                               (void)show_floor(0, y, x);
+                                               (void)show_floor(0, y, x, &min_width);
 
                                                /* Prompt */
 #ifdef JP
-prt("²¿¤«¥­¡¼¤ò²¡¤¹¤È¥²¡¼¥à¤ËÌá¤ê¤Þ¤¹", 0, 0);
+                                               prt("Enter¤Ç¼¡¤Ø¡¢Â¾¤Î¥­¡¼¤ò²¡¤¹¤È¥²¡¼¥à¤ËÌá¤ê¤Þ¤¹", 0, 0);
 #else
-                                               prt("Hit any key to continue", 0, 0);
+                                               prt("Hit Enter to scroll, Hit any other key to continue", 0, 0);
 #endif
 
-
                                                /* Wait */
-                                               (void) inkey();
+                                               query = inkey();
 
                                                /* Load screen */
                                                screen_load();
-                                       }
-                                       else
-                                       {
-                                               /* Stop */
-                                               break;
+
+                                               /* Exit unless 'Enter' */
+                                               if (query != '\n' && query != '\r') break;
+
+                                               /* Get the object being moved. */
+                                               c_ptr = &cave[y][x];
+                                               o_idx = c_ptr->o_idx;
+                                               /* Only rotate a pile of two or more objects. */
+                                               if (o_idx && o_list[o_idx].next_o_idx)
+                                               {
+
+                                                       /* Remove the first object from the list. */
+                                                       excise_object_idx(o_idx);
+       
+                                                       /* Find end of the list. */
+                                                       i = c_ptr->o_idx;
+                                                       while (o_list[i].next_o_idx)
+                                                               i = o_list[i].next_o_idx;
+       
+                                                       /* Add after the last object. */
+                                                       o_list[i].next_o_idx = o_idx;
+                                               }
                                        }
                                }