changeset 1563:0311debb684c

splitting Player::WearsItem into two functions
author Grumpy7
date Sun, 08 Sep 2013 02:41:10 +0200
parents c44db078127d
children 461c2eca401b
files Conditions.cpp Player.cpp Player.h mm7_3.cpp
diffstat 4 files changed, 32 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/Conditions.cpp	Sun Sep 08 01:23:37 2013 +0200
+++ b/Conditions.cpp	Sun Sep 08 02:41:10 2013 +0200
@@ -54,9 +54,19 @@
     }
     ITEM_TYPE itemId = thisProc->m_equipmentPairs[i * 2].m_ItemId;
     ITEM_EQUIP_TYPE slot = thisProc->m_equipmentPairs[i * 2 + 1].m_EquipSlot;
-    if (inPlayer->WearsItem(itemId, slot))
+    if (slot == EQIUP_ANY)
     {
-      return false;
+      if (inPlayer->WearsItemAnyWhere(itemId))
+      {
+        return false;
+      }
+    }
+    else
+    {
+      if (inPlayer->WearsItem(itemId, slot))
+      {
+        return false;
+      }
     }
   }
   return true;
--- a/Player.cpp	Sun Sep 08 01:23:37 2013 +0200
+++ b/Player.cpp	Sun Sep 08 02:41:10 2013 +0200
@@ -1996,7 +1996,6 @@
   {
     if (HasItemEquipped((ITEM_EQUIP_TYPE)i) &&
       pOwnItems[pEquipment.pIndices[i]-1].uSpecEnchantmentType == uEnchantment)
-      //  *(int *)&this->field_1F6[36 * pEquipment[i] + 6] != uEnchantment)
       return true;
   }
   return false;
@@ -2004,25 +2003,20 @@
 
 //----- (0048D709) --------------------------------------------------------
 bool Player::WearsItem( int item_id, ITEM_EQUIP_TYPE equip_type )
-    {
-
-  int v6; // esi@5
-
-  if ( equip_type >= 16 )
-  {
-    v6 = 0;
-    while ( !HasItemEquipped((ITEM_EQUIP_TYPE)v6)
-         || pInventoryItemList[pEquipment.pIndices[v6] - 1].uItemID != item_id )
-    {
-      ++v6;
-      if ( (signed int)v6 >= 16 )
-        return 0;
-    }
-    return 1;
-  }
-  if ( HasItemEquipped(equip_type) && pInventoryItemList[pEquipment.pIndices[equip_type - 1]].uItemID == item_id )
-    return 1;
-  return 0;
+{
+  return ( HasItemEquipped(equip_type) && pInventoryItemList[pEquipment.pIndices[equip_type - 1]].uItemID == item_id );
+}
+
+bool Player::WearsItemAnyWhere(int item_id)
+{
+  for (int i = 0; i < 16; i++)
+  {
+    if (WearsItem(item_id, (ITEM_EQUIP_TYPE) i))
+    {
+      return true;
+    }
+  }
+  return false;
 }
 
 //----- (0048D76C) --------------------------------------------------------
--- a/Player.h	Sun Sep 08 01:23:37 2013 +0200
+++ b/Player.h	Sun Sep 08 02:41:10 2013 +0200
@@ -583,6 +583,7 @@
 
   unsigned int GetMultiplierForSkillLevel(unsigned int skillValue, int mult1, int mult2, int mult3, int mult4);
   int CalculateMeleeDmgToEnemyWithWeapon( ItemGen * weapon, unsigned int uTargetActorID , bool addOneDice);
+  bool WearsItemAnyWhere(int item_id);
 
   bool IsWeak();
   bool IsDead();
--- a/mm7_3.cpp	Sun Sep 08 01:23:37 2013 +0200
+++ b/mm7_3.cpp	Sun Sep 08 02:41:10 2013 +0200
@@ -1590,10 +1590,10 @@
   if (!pParty->FeatherFallActive())
   {
     bFeatherFall = false;
-    if (!pParty->pPlayers[0].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY) &&  // grants feather fall
-        !pParty->pPlayers[1].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY) &&
-        !pParty->pPlayers[2].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY) &&
-        !pParty->pPlayers[3].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY))
+    if (!pParty->pPlayers[0].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT) &&  // grants feather fall
+        !pParty->pPlayers[1].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT) &&
+        !pParty->pPlayers[2].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT) &&
+        !pParty->pPlayers[3].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT))
     {
       fall_start = pParty->uFallStartY;
     }
@@ -2168,7 +2168,7 @@
   {
     bFeatherFall = 0;
     for (int i = 0; i < 4; ++i)
-      if (pParty->pPlayers[i].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY))  // seems like flying boots
+      if (pParty->pPlayers[i].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT))  // seems like flying boots
       {
         bFeatherFall = 1;
         break;