OSDN Git Service

Merge branch 'master' of git.osdn.net:/gitroot/hengband/hengband
[hengband/hengband.git] / src / player / player-status-flags.c
index 942263b..646a478 100644 (file)
 #include "util/quarks.h"
 #include "util/string-processor.h"
 
-void have_kill_wall(player_type *creature_ptr)
+bool have_kill_wall(player_type *creature_ptr)
 {
-    creature_ptr->kill_wall = FALSE;
-
-    if (creature_ptr->mimic_form == MIMIC_DEMON_LORD) {
-        creature_ptr->kill_wall = TRUE;
-    }
-
-    if (music_singing(creature_ptr, MUSIC_WALL)) {
-        creature_ptr->kill_wall = TRUE;
+    if (creature_ptr->mimic_form == MIMIC_DEMON_LORD || music_singing(creature_ptr, MUSIC_WALL)) {
+        return TRUE;
     }
 
     if (creature_ptr->riding) {
         monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
         monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
         if (riding_r_ptr->flags2 & RF2_KILL_WALL)
-            creature_ptr->kill_wall = TRUE;
+            return TRUE;
     }
+
+       return FALSE;
 }
 
-void have_pass_wall(player_type *creature_ptr)
+bool have_pass_wall(player_type *creature_ptr)
 {
-    creature_ptr->pass_wall = FALSE;
+    bool pow = FALSE;
 
-    if (creature_ptr->wraith_form) {
-        creature_ptr->pass_wall = TRUE;
-    }
-
-    if (creature_ptr->tim_pass_wall) {
-        creature_ptr->pass_wall = TRUE;
-    }
-
-    if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_SPECTRE) {
-        creature_ptr->pass_wall = TRUE;
+    if (creature_ptr->wraith_form || creature_ptr->tim_pass_wall || (!creature_ptr->mimic_form && creature_ptr->prace == RACE_SPECTRE)) {
+        pow = TRUE;
     }
 
     if (creature_ptr->riding) {
         monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
         monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
         if (!(riding_r_ptr->flags2 & RF2_PASS_WALL))
-            creature_ptr->pass_wall = FALSE;
+            pow = FALSE;
     }
+
+       return pow;
 }
 
-void have_xtra_might(player_type *creature_ptr)
+BIT_FLAGS have_xtra_might(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
+    BIT_FLAGS result = 0L;
 
-    creature_ptr->xtra_might = FALSE;
-
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -89,23 +78,24 @@ void have_xtra_might(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_XTRA_MIGHT))
-            creature_ptr->xtra_might = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
-void have_esp_evil(player_type *creature_ptr)
+BIT_FLAGS have_esp_evil(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
-
-    creature_ptr->esp_evil = FALSE;
+    BIT_FLAGS result = 0L;
 
     if (creature_ptr->realm1 == REALM_HEX) {
         if (hex_spelling(creature_ptr, HEX_DETECT_EVIL))
-            creature_ptr->esp_evil = TRUE;
+            result |= 0x01 << FLAG_CAUSE_MAGIC_TIME_EFFECT;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -113,18 +103,19 @@ void have_esp_evil(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_ESP_EVIL))
-            creature_ptr->esp_evil = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
-void have_esp_animal(player_type *creature_ptr)
+BIT_FLAGS have_esp_animal(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
+    BIT_FLAGS result = 0L;
 
-    creature_ptr->esp_animal = FALSE;
-
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -132,18 +123,19 @@ void have_esp_animal(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_ESP_ANIMAL))
-            creature_ptr->esp_animal = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
-void have_esp_undead(player_type *creature_ptr)
+BIT_FLAGS have_esp_undead(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
+    BIT_FLAGS result = 0L;
 
-    creature_ptr->esp_undead = FALSE;
-
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -151,18 +143,19 @@ void have_esp_undead(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_ESP_UNDEAD))
-            creature_ptr->esp_undead = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
-void have_esp_demon(player_type *creature_ptr)
+BIT_FLAGS have_esp_demon(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
+    BIT_FLAGS result = 0L;
 
-    creature_ptr->esp_demon = FALSE;
-
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -170,18 +163,19 @@ void have_esp_demon(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_ESP_DEMON))
-            creature_ptr->esp_demon = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
-void have_esp_orc(player_type *creature_ptr)
+BIT_FLAGS have_esp_orc(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
+    BIT_FLAGS result = 0L;
 
-    creature_ptr->esp_orc = FALSE;
-
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -189,18 +183,19 @@ void have_esp_orc(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_ESP_ORC))
-            creature_ptr->esp_orc = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
-void have_esp_troll(player_type *creature_ptr)
+BIT_FLAGS have_esp_troll(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
+    BIT_FLAGS result = 0L;
 
-    creature_ptr->esp_troll = FALSE;
-
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -208,18 +203,19 @@ void have_esp_troll(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_ESP_TROLL))
-            creature_ptr->esp_troll = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
-void have_esp_giant(player_type *creature_ptr)
+BIT_FLAGS have_esp_giant(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
+    BIT_FLAGS result = 0L;
 
-    creature_ptr->esp_giant = FALSE;
-
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -227,18 +223,19 @@ void have_esp_giant(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_ESP_GIANT))
-            creature_ptr->esp_giant = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
-void have_esp_dragon(player_type *creature_ptr)
+BIT_FLAGS have_esp_dragon(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
+    BIT_FLAGS result = 0L;
 
-    creature_ptr->esp_dragon = FALSE;
-
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -246,8 +243,10 @@ void have_esp_dragon(player_type *creature_ptr)
         object_flags(creature_ptr, o_ptr, flgs);
 
         if (have_flag(flgs, TR_ESP_DRAGON))
-            creature_ptr->esp_dragon = TRUE;
+            result |= 0x01 << (i - INVEN_RARM);
     }
+
+       return result;
 }
 
 void have_esp_human(player_type *creature_ptr)
@@ -257,7 +256,7 @@ void have_esp_human(player_type *creature_ptr)
 
     creature_ptr->esp_human = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -276,7 +275,7 @@ void have_esp_good(player_type *creature_ptr)
 
     creature_ptr->esp_good = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -295,7 +294,7 @@ void have_esp_nonliving(player_type *creature_ptr)
 
     creature_ptr->esp_nonliving = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -314,7 +313,7 @@ void have_esp_unique(player_type *creature_ptr)
 
     creature_ptr->esp_unique = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -358,7 +357,7 @@ void have_esp_telepathy(player_type *creature_ptr)
         creature_ptr->telepathy = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -377,7 +376,7 @@ void have_bless_blade(player_type *creature_ptr)
 
     creature_ptr->bless_blade = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -396,7 +395,7 @@ void have_easy2_weapon(player_type *creature_ptr)
 
     creature_ptr->easy_2weapon = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -415,7 +414,7 @@ void have_down_saving(player_type *creature_ptr)
 
     creature_ptr->down_saving = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -434,7 +433,7 @@ void have_no_ac(player_type *creature_ptr)
 
     creature_ptr->yoiyami = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -493,7 +492,7 @@ void have_mighty_throw(player_type *creature_ptr)
 
     creature_ptr->mighty_throw = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -510,7 +509,7 @@ void have_dec_mana(player_type *creature_ptr)
 
     creature_ptr->xtra_might = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -555,7 +554,7 @@ void have_reflect(player_type *creature_ptr)
         creature_ptr->reflect = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -582,7 +581,7 @@ void have_warning(player_type *creature_ptr)
 
     creature_ptr->warning = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -603,7 +602,7 @@ void have_anti_magic(player_type *creature_ptr)
 
     creature_ptr->anti_magic = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -622,7 +621,7 @@ void have_anti_tele(player_type *creature_ptr)
 
     creature_ptr->anti_tele = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -666,7 +665,7 @@ void have_sh_fire(player_type *creature_ptr)
         creature_ptr->sh_fire = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -700,7 +699,7 @@ void have_sh_elec(player_type *creature_ptr)
         creature_ptr->sh_elec = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -731,7 +730,7 @@ void have_sh_cold(player_type *creature_ptr)
         creature_ptr->sh_cold = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -747,7 +746,7 @@ void have_easy_spell(player_type *creature_ptr)
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
     creature_ptr->easy_spell = FALSE;
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -763,7 +762,7 @@ void have_heavy_spell(player_type *creature_ptr)
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
     creature_ptr->heavy_spell = FALSE;
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -789,26 +788,23 @@ void have_hold_exp(player_type *creature_ptr)
         creature_ptr->hold_exp = TRUE;
     }
 
-    if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_HOBBIT) {
+    if (is_specific_player_race(creature_ptr, RACE_HOBBIT) || is_specific_player_race(creature_ptr, RACE_SKELETON) ||
+        is_specific_player_race(creature_ptr, RACE_ZOMBIE) || is_specific_player_race(creature_ptr, RACE_VAMPIRE) ||
+               is_specific_player_race(creature_ptr, RACE_SPECTRE) || is_specific_player_race(creature_ptr, RACE_BALROG) ||
+        is_specific_player_race(creature_ptr, RACE_ANDROID)) {
         creature_ptr->hold_exp = TRUE;
     }
 
-    if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_GOLEM) {
+    if (is_specific_player_race(creature_ptr, RACE_GOLEM)) {
         if (creature_ptr->lev > 34)
             creature_ptr->hold_exp = TRUE;
     }
 
-    if (!creature_ptr->mimic_form
-        && (creature_ptr->prace == RACE_SKELETON || creature_ptr->prace == RACE_ZOMBIE || creature_ptr->prace == RACE_VAMPIRE
-            || creature_ptr->prace == RACE_SPECTRE || creature_ptr->prace == RACE_BALROG || creature_ptr->prace == RACE_ANDROID)) {
-        creature_ptr->hold_exp = TRUE;
-    }
-
     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
         creature_ptr->hold_exp = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -861,7 +857,7 @@ void have_see_inv(player_type *creature_ptr)
         creature_ptr->see_inv = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -897,8 +893,8 @@ void have_free_act(player_type *creature_ptr)
         creature_ptr->free_act = TRUE;
     }
 
-    if (heavy_armor(creature_ptr) && (!creature_ptr->inventory_list[INVEN_RARM].k_idx || creature_ptr->right_hand_weapon)
-        && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || creature_ptr->left_hand_weapon)) {
+    if (heavy_armor(creature_ptr) && (!creature_ptr->inventory_list[INVEN_RARM].k_idx || have_right_hand_weapon(creature_ptr))
+        && (!creature_ptr->inventory_list[INVEN_LARM].k_idx || have_left_hand_weapon(creature_ptr))) {
         if (creature_ptr->lev > 24)
             creature_ptr->free_act = TRUE;
     }
@@ -922,7 +918,7 @@ void have_free_act(player_type *creature_ptr)
         creature_ptr->free_act = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -949,7 +945,7 @@ void have_sustain_str(player_type *creature_ptr)
         creature_ptr->sustain_str = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -973,7 +969,7 @@ void have_sustain_int(player_type *creature_ptr)
         creature_ptr->sustain_int = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1000,7 +996,7 @@ void have_sustain_wis(player_type *creature_ptr)
         creature_ptr->sustain_wis = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1027,7 +1023,7 @@ void have_sustain_dex(player_type *creature_ptr)
         creature_ptr->sustain_dex = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1055,7 +1051,7 @@ void have_sustain_con(player_type *creature_ptr)
         creature_ptr->sustain_con = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1076,7 +1072,7 @@ void have_sustain_chr(player_type *creature_ptr)
         creature_ptr->sustain_chr = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1127,7 +1123,7 @@ void have_levitation(player_type *creature_ptr)
         creature_ptr->levitation = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1179,7 +1175,7 @@ void have_slow_digest(player_type *creature_ptr)
         creature_ptr->slow_digest = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1238,7 +1234,7 @@ void have_regenerate(player_type *creature_ptr)
         creature_ptr->regenerate = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1257,7 +1253,7 @@ void have_curses(player_type *creature_ptr)
     if (creature_ptr->pseikaku == PERSONALITY_SEXY)
         creature_ptr->cursed |= (TRC_AGGRAVATE);
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1331,7 +1327,7 @@ void have_impact(player_type *creature_ptr)
     creature_ptr->impact[0] = FALSE;
     creature_ptr->impact[1] = FALSE;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1347,7 +1343,7 @@ void have_extra_blow(player_type *creature_ptr)
     BIT_FLAGS flgs[TR_FLAG_SIZE];
     creature_ptr->extra_blows[0] = creature_ptr->extra_blows[1] = 0;
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1357,9 +1353,9 @@ void have_extra_blow(player_type *creature_ptr)
         if (have_flag(flgs, TR_INFRA))
             creature_ptr->see_infra += o_ptr->pval;
         if (have_flag(flgs, TR_BLOWS)) {
-            if ((i == INVEN_RARM || i == INVEN_RIGHT) && !creature_ptr->two_handed_weapon)
+            if ((i == INVEN_RARM || i == INVEN_RIGHT) && !have_two_handed_weapons(creature_ptr))
                 creature_ptr->extra_blows[0] += o_ptr->pval;
-            else if ((i == INVEN_LARM || i == INVEN_LEFT) && !creature_ptr->two_handed_weapon)
+            else if ((i == INVEN_LARM || i == INVEN_LEFT) && !have_two_handed_weapons(creature_ptr))
                 creature_ptr->extra_blows[1] += o_ptr->pval;
             else {
                 creature_ptr->extra_blows[0] += o_ptr->pval;
@@ -1395,7 +1391,7 @@ void have_resist_acid(player_type *creature_ptr)
         creature_ptr->resist_acid = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1431,7 +1427,7 @@ void have_resist_elec(player_type *creature_ptr)
         creature_ptr->resist_elec = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1471,7 +1467,7 @@ void have_resist_fire(player_type *creature_ptr)
         creature_ptr->resist_fire = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1516,7 +1512,7 @@ void have_resist_cold(player_type *creature_ptr)
         creature_ptr->resist_cold = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1562,7 +1558,7 @@ void have_resist_pois(player_type *creature_ptr)
         creature_ptr->resist_pois = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1603,7 +1599,7 @@ void have_resist_conf(player_type *creature_ptr)
         creature_ptr->resist_conf = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1633,7 +1629,7 @@ void have_resist_sound(player_type *creature_ptr)
         creature_ptr->resist_sound = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1659,7 +1655,7 @@ void have_resist_lite(player_type *creature_ptr)
         creature_ptr->resist_lite = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1691,7 +1687,7 @@ void have_resist_dark(player_type *creature_ptr)
         creature_ptr->resist_dark = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1723,7 +1719,7 @@ void have_resist_chaos(player_type *creature_ptr)
         creature_ptr->resist_chaos = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1752,7 +1748,7 @@ void have_resist_disen(player_type *creature_ptr)
         creature_ptr->resist_disen = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1777,7 +1773,7 @@ void have_resist_shard(player_type *creature_ptr)
         creature_ptr->resist_shard = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1803,7 +1799,7 @@ void have_resist_nexus(player_type *creature_ptr)
         creature_ptr->resist_nexus = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1836,7 +1832,7 @@ void have_resist_blind(player_type *creature_ptr)
         creature_ptr->resist_blind = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1870,7 +1866,7 @@ void have_resist_neth(player_type *creature_ptr)
         creature_ptr->resist_neth = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1892,7 +1888,7 @@ void have_resist_time(player_type *creature_ptr)
         creature_ptr->resist_time = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1961,7 +1957,7 @@ void have_resist_fear(player_type *creature_ptr)
         creature_ptr->resist_fear = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -1986,7 +1982,7 @@ void have_immune_acid(player_type *creature_ptr)
             creature_ptr->immune_acid = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -2007,7 +2003,7 @@ void have_immune_elec(player_type *creature_ptr)
             creature_ptr->immune_elec = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -2028,7 +2024,7 @@ void have_immune_fire(player_type *creature_ptr)
             creature_ptr->immune_fire = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -2049,7 +2045,7 @@ void have_immune_cold(player_type *creature_ptr)
             creature_ptr->immune_cold = TRUE;
     }
 
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+    for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
@@ -2060,11 +2056,10 @@ void have_immune_cold(player_type *creature_ptr)
     }
 }
 
-void have_right_hand_weapon(player_type *creature_ptr)
+bool have_right_hand_weapon(player_type *creature_ptr)
 {
-    creature_ptr->right_hand_weapon = FALSE;
     if (has_melee_weapon(creature_ptr, INVEN_RARM))
-        creature_ptr->right_hand_weapon = TRUE;
+        return TRUE;
 
     if (can_two_hands_wielding(creature_ptr)) {
         switch (creature_ptr->pclass) {
@@ -2072,33 +2067,32 @@ void have_right_hand_weapon(player_type *creature_ptr)
         case CLASS_FORCETRAINER:
         case CLASS_BERSERKER:
             if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)) {
-                creature_ptr->right_hand_weapon = TRUE;
+                return TRUE;
             }
             break;
         }
     }
+
+       return FALSE;
 }
 
-void have_left_hand_weapon(player_type *creature_ptr)
+bool have_left_hand_weapon(player_type *creature_ptr)
 {
-    creature_ptr->left_hand_weapon = FALSE;
-    if (has_melee_weapon(creature_ptr, INVEN_LARM)) {
-        creature_ptr->left_hand_weapon = TRUE;
-    }
+    return has_melee_weapon(creature_ptr, INVEN_LARM);
 }
 
-void have_two_handed_weapons(player_type *creature_ptr)
+bool have_two_handed_weapons(player_type *creature_ptr)
 {
-    creature_ptr->two_handed_weapon = FALSE;
     if (can_two_hands_wielding(creature_ptr)) {
-        if (creature_ptr->right_hand_weapon && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM)
+        if (have_right_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM)
             && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) {
-            creature_ptr->two_handed_weapon = TRUE;
-        } else if (creature_ptr->left_hand_weapon && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM)
+            return TRUE;
+        } else if (have_left_hand_weapon(creature_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM)
             && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])) {
-            creature_ptr->two_handed_weapon = TRUE;
+            return TRUE;
         }
     }
+    return FALSE;
 }
 
 void have_lite(player_type *creature_ptr)
@@ -2135,43 +2129,43 @@ bool is_disable_two_handed_bonus(player_type *creature_ptr, int i)
     object_type *o_ptr;
     o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
     if (has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
-        if (creature_ptr->hold *= 2 >= o_ptr->weight / 10 && creature_ptr->two_handed_weapon && (creature_ptr->hold *= 2 < o_ptr->weight / 5))
+        if (calc_weapon_weight_limit(creature_ptr) * 2 >= o_ptr->weight / 10 && have_two_handed_weapons(creature_ptr) && (calc_weapon_weight_limit(creature_ptr) * 2 < o_ptr->weight / 5))
             return TRUE;
     }
     return FALSE;
 }
 
-void is_icky_wield_weapon(player_type *creature_ptr, int i)
+bool is_icky_wield_weapon(player_type *creature_ptr, int i)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
     o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
     object_flags(creature_ptr, o_ptr, flgs);
 
-    creature_ptr->icky_wield[i] = FALSE;
     if ((creature_ptr->pclass == CLASS_PRIEST) && (!(have_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
-        creature_ptr->icky_wield[i] = TRUE;
+        return TRUE;
     } else if (creature_ptr->pclass == CLASS_SORCERER) {
         if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
-            creature_ptr->icky_wield[i] = TRUE;
+            return TRUE;
         }
     }
     if (is_not_monk_weapon(creature_ptr, i) || is_not_ninja_weapon(creature_ptr, i)) {
-        creature_ptr->icky_wield[i] = TRUE;
+        return TRUE;
     }
+    return FALSE;
 }
 
-void is_riding_wield_weapon(player_type *creature_ptr, int i)
+bool is_riding_wield_weapon(player_type *creature_ptr, int i)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
     o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
     object_flags(creature_ptr, o_ptr, flgs);
-    creature_ptr->riding_wield[i] = FALSE;
     if (creature_ptr->riding != 0 && !(o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE))
         && !have_flag(flgs, TR_RIDING)) {
-        creature_ptr->riding_wield[i] = TRUE;
+        return TRUE;
     }
+    return FALSE;
 }
 
 bool is_not_ninja_weapon(player_type *creature_ptr, int i)