OSDN Git Service

[feature] ソースファイルをC++に対応
[hengbandforosx/hengbandosx.git] / src / inventory / floor-item-getter.c
index e8d7c35..15c94da 100644 (file)
@@ -46,10 +46,11 @@ static bool check_floor_item_tag_aux(player_type *owner_ptr, fis_type *fis_ptr,
         return FALSE;
 
     if (*prev_tag && command_cmd) {
-        fis_ptr->floor_num = scan_floor_items(owner_ptr, fis_ptr->floor_list, owner_ptr->y, owner_ptr->x, 0x03, fis_ptr->tval);
+        fis_ptr->floor_num
+            = scan_floor_items(owner_ptr, fis_ptr->floor_list, owner_ptr->y, owner_ptr->x, SCAN_FLOOR_ITEM_TESTER | SCAN_FLOOR_ONLY_MARKED, fis_ptr->tval);
         if (get_tag_floor(owner_ptr->current_floor_ptr, &fis_ptr->k, *prev_tag, fis_ptr->floor_list, fis_ptr->floor_num)) {
             *fis_ptr->cp = 0 - fis_ptr->floor_list[fis_ptr->k];
-            fis_ptr->tval = 0;
+            fis_ptr->tval = TV_NONE;
             item_tester_hook = NULL;
             command_cmd = 0;
             return TRUE;
@@ -62,7 +63,7 @@ static bool check_floor_item_tag_aux(player_type *owner_ptr, fis_type *fis_ptr,
     if (!item_tester_okay(owner_ptr, &owner_ptr->current_floor_ptr->o_list[0 - (*fis_ptr->cp)], fis_ptr->tval) && ((fis_ptr->mode & USE_FULL) == 0))
         return FALSE;
 
-    fis_ptr->tval = 0;
+    fis_ptr->tval = TV_NONE;
     item_tester_hook = NULL;
     command_cmd = 0;
     return TRUE;
@@ -77,9 +78,6 @@ static bool check_floor_item_tag_aux(player_type *owner_ptr, fis_type *fis_ptr,
  */
 static bool get_floor_item_tag_inventory(player_type *owner_ptr, fis_type *fis_ptr, char *prev_tag)
 {
-    if ((*prev_tag == '\0') || !command_cmd)
-        return FALSE;
-
     bool flag = FALSE;
     item_use_flag use_flag = (*fis_ptr->cp >= INVEN_MAIN_HAND) ? USE_EQUIP : USE_INVEN;
 
@@ -91,7 +89,7 @@ static bool get_floor_item_tag_inventory(player_type *owner_ptr, fis_type *fis_p
     else
         flag |= !fis_ptr->equip;
 
-    if (!flag) {
+    if (flag) {
         *prev_tag = '\0';
         return FALSE;
     }
@@ -116,11 +114,11 @@ static bool check_floor_item_tag_inventory(player_type *owner_ptr, fis_type *fis
         && (!fis_ptr->equip || (*fis_ptr->cp < INVEN_MAIN_HAND) || (*fis_ptr->cp >= INVEN_TOTAL)))
         return FALSE;
 
-    if (get_floor_item_tag_inventory(owner_ptr, fis_ptr, prev_tag))
-        return TRUE;
+    if ((*prev_tag != '\0') && command_cmd)
+        return get_floor_item_tag_inventory(owner_ptr, fis_ptr, prev_tag);
 
     if (get_item_okay(owner_ptr, *fis_ptr->cp, fis_ptr->tval)) {
-        fis_ptr->tval = 0;
+        fis_ptr->tval = TV_NONE;
         item_tester_hook = NULL;
         command_cmd = 0;
         return TRUE;
@@ -142,7 +140,7 @@ static bool check_floor_item_tag(player_type *owner_ptr, fis_type *fis_ptr, char
         return FALSE;
 
     if (fis_ptr->force && (*fis_ptr->cp == INVEN_FORCE)) {
-        fis_ptr->tval = 0;
+        fis_ptr->tval = TV_NONE;
         item_tester_hook = NULL;
         command_cmd = 0;
         return TRUE;
@@ -191,7 +189,7 @@ static void test_equipment_floor(player_type *owner_ptr, fis_type *fis_ptr)
     if (!use_menu)
         return;
 
-    for (inventory_slot_type i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++)
+    for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++)
         if (owner_ptr->select_ring_slot ? is_ring_slot(i)
                                         : item_tester_okay(owner_ptr, &owner_ptr->inventory_list[i], fis_ptr->tval) || (fis_ptr->mode & USE_FULL))
             fis_ptr->max_equip++;
@@ -249,7 +247,8 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp
 
     fis_ptr->floor_num = 0;
     if (fis_ptr->floor)
-        fis_ptr->floor_num = scan_floor_items(owner_ptr, fis_ptr->floor_list, owner_ptr->y, owner_ptr->x, 0x03, fis_ptr->tval);
+        fis_ptr->floor_num
+            = scan_floor_items(owner_ptr, fis_ptr->floor_list, owner_ptr->y, owner_ptr->x, SCAN_FLOOR_ITEM_TESTER | SCAN_FLOOR_ONLY_MARKED, fis_ptr->tval);
 
     if ((mode & USE_INVEN) && (fis_ptr->i1 <= fis_ptr->i2))
         fis_ptr->allow_inven = TRUE;
@@ -306,7 +305,7 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp
             fis_ptr->toggle = !fis_ptr->toggle;
         }
 
-        owner_ptr->window |= (PW_INVEN | PW_EQUIP);
+        owner_ptr->window_flags |= (PW_INVEN | PW_EQUIP);
         handle_stuff(owner_ptr);
         COMMAND_CODE get_item_label = 0;
         if (command_wrk == USE_INVEN) {
@@ -331,8 +330,9 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp
         if (command_wrk == USE_INVEN) {
             sprintf(fis_ptr->out_val, _("持ち物:", "Inven:"));
             if (!use_menu) {
-                sprintf(fis_ptr->tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), index_to_label(fis_ptr->i1), index_to_label(fis_ptr->i2));
-                strcat(fis_ptr->out_val, fis_ptr->tmp_val);
+                char tmp_val[80];
+                sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), index_to_label(fis_ptr->i1), index_to_label(fis_ptr->i2));
+                strcat(fis_ptr->out_val, tmp_val);
             }
 
             if (!command_see && !use_menu)
@@ -358,8 +358,9 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp
         } else if (command_wrk == (USE_EQUIP)) {
             sprintf(fis_ptr->out_val, _("装備品:", "Equip:"));
             if (!use_menu) {
-                sprintf(fis_ptr->tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), index_to_label(fis_ptr->e1), index_to_label(fis_ptr->e2));
-                strcat(fis_ptr->out_val, fis_ptr->tmp_val);
+                char tmp_val[80];
+                sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), index_to_label(fis_ptr->e1), index_to_label(fis_ptr->e2));
+                strcat(fis_ptr->out_val, tmp_val);
             }
 
             if (!command_see && !use_menu)
@@ -385,8 +386,9 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp
         } else if (command_wrk == USE_FLOOR) {
             sprintf(fis_ptr->out_val, _("床上:", "Floor:"));
             if (!use_menu) {
-                sprintf(fis_ptr->tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), fis_ptr->n1, fis_ptr->n2);
-                strcat(fis_ptr->out_val, fis_ptr->tmp_val);
+                char tmp_val[80];
+                sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), fis_ptr->n1, fis_ptr->n2);
+                strcat(fis_ptr->out_val, tmp_val);
             }
 
             if (!command_see && !use_menu)
@@ -627,7 +629,8 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp
                 i = owner_ptr->current_floor_ptr->o_list[i].next_o_idx;
 
             owner_ptr->current_floor_ptr->o_list[i].next_o_idx = o_idx;
-            fis_ptr->floor_num = scan_floor_items(owner_ptr, fis_ptr->floor_list, owner_ptr->y, owner_ptr->x, 0x03, fis_ptr->tval);
+            fis_ptr->floor_num
+                = scan_floor_items(owner_ptr, fis_ptr->floor_list, owner_ptr->y, owner_ptr->x, SCAN_FLOOR_ITEM_TESTER | SCAN_FLOOR_ONLY_MARKED, fis_ptr->tval);
             if (command_see) {
                 screen_load();
                 screen_save();
@@ -837,12 +840,12 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp
         command_see = FALSE;
     }
 
-    fis_ptr->tval = 0;
+    fis_ptr->tval = TV_NONE;
     item_tester_hook = NULL;
     if (fis_ptr->toggle)
         toggle_inventory_equipment(owner_ptr);
 
-    owner_ptr->window |= (PW_INVEN | PW_EQUIP);
+    owner_ptr->window_flags |= (PW_INVEN | PW_EQUIP);
     handle_stuff(owner_ptr);
     prt("", 0, 0);
     if (fis_ptr->oops && str)
@@ -856,4 +859,4 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp
     }
 
     return fis_ptr->item;
-}
\ No newline at end of file
+}