diff UI/UICharacter.cpp @ 1488:f62e6d06acac

UICharacter.cpp cleaning(continue) OnPaperdollLeftClick(4)
author Ritor1
date Fri, 30 Aug 2013 01:49:29 +0600
parents 58d43397b827
children ab6bf38b2940
line wrap: on
line diff
--- a/UI/UICharacter.cpp	Thu Aug 29 22:02:00 2013 +0600
+++ b/UI/UICharacter.cpp	Fri Aug 30 01:49:29 2013 +0600
@@ -2325,35 +2325,35 @@
   unsigned __int16 v5; // ax@7
   int v7; // esi@27
   int v8; // eax@29
-  int v10; // esi@34
-  int v12; // esi@38
-  char v14; // zf@38
-  int v15; // esi@42
+  //int v10; // esi@34
+  //int v12; // esi@38
+  //char v14; // zf@38
+  //int v15; // esi@42
   int v17; // eax@44
   unsigned int v18; // ecx@55
   unsigned int v19; // eax@55
-  int v20; // esi@60
+  //int v20; // esi@60
   unsigned int v22; // eax@61
   int v23; // eax@62
-  int v24; // esi@65
-  int v25; // eax@65
+  //int v24; // esi@65
+  //int v25; // eax@65
   int v26; // eax@69
-  int v27; // esi@81
-  int v28; // eax@81
-  int v29; // esi@84
-  int v30; // eax@84
-  int v31; // eax@85
+  //int v27; // esi@81
+  //int v28; // eax@81
+  //int v29; // esi@84
+  //int v30; // eax@84
+  //int v31; // eax@85
   unsigned int v32; // ecx@88
   unsigned int v33; // eax@88
   int v34; // esi@90
-  unsigned int v35; // eax@91
+  //unsigned int v35; // eax@91
   int v36; // esi@93
   int v37; // edi@93
   ItemGen *v38; // edi@93
-  __int16 v39; // dx@99
+  //__int16 v39; // dx@99
   ItemGen _this; // [sp+Ch] [bp-40h]@1
   unsigned int v48; // [sp+30h] [bp-1Ch]@88
-  unsigned int v49; // [sp+34h] [bp-18h]@57
+  //unsigned int v49; // [sp+34h] [bp-18h]@57
   unsigned int v50; // [sp+38h] [bp-14h]@50
   int v51; // [sp+3Ch] [bp-10h]@1
   int v52; // [sp+40h] [bp-Ch]@5
@@ -2365,7 +2365,7 @@
   v2 = pPlayers[uActiveCharacter]->pEquipment.uShield;
   //v54 = pPlayers[uActiveCharacter]->pEquipment.uShield;
   //v53 = v1;
-  if ( v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItemList[v1 - 1]].uEquipType == 1 )
+  if ( v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItemList[v1 - 1]].uEquipType == EQUIP_MAIN_HAND )
     v51 = v1;
   v3 = pParty->pPickedItem.uItemID;
   if ( pParty->pPickedItem.uItemID )
@@ -2389,7 +2389,7 @@
     {
       if ( (pSkillType == 8 || pSkillType == 1 || pSkillType == 2)
         && v1
-        && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItemList[v1-1]].uSkillType == 4 )
+        && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItemList[v1 - 1]].uSkillType == 4 )
       {
         LOBYTE(v5) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_SPEAR);
         if ( (signed int)SkillToMastery(v5) < 3 )
@@ -2422,7 +2422,7 @@
       case EQUIP_GAUNTLETS:
       case EQUIP_BOOTS:
       case EQUIP_AMULET:
-        if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) )
+        if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) )//нет навыка
         {
           pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0);
           return;
@@ -2436,8 +2436,8 @@
         if ( pParty->pPickedItem.uItemID == ITEM_WETSUIT )
           WetsuitOff(uActiveCharacter);
         return;
-
-      case EQUIP_RING://Кольца
+//------------------------dress rings(одевание колец)----------------------------------
+      case EQUIP_RING:
         if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) )
         {
           pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
@@ -2465,40 +2465,37 @@
         {
           v52 = pPlayers[uActiveCharacter]->pEquipment.uRings[5] - 1;
           memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
-          v10 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v52);
-          *(char *)(v10 + 556) = 0;
+          pPlayers[uActiveCharacter]->pInventoryItemList[v52].uBodyAnchor = 0;
           pParty->pPickedItem.Reset();
-          pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[v52]);//(ItemGen *)(v10 + 532)
+          pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[v52]);
           _this.uBodyAnchor = 16;
           memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v52], &_this, 0x24u);
-          pPlayers[uActiveCharacter]->pEquipment.uRings[6] = v52 + 1;
+          pPlayers[uActiveCharacter]->pEquipment.uRings[5] = v52 + 1;
         }
         return;
-
+//------------------dress shield(одеть щит)------------------------------------------------------
       case EQUIP_SHIELD://Щит
-        if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) )
+        if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) )//в акваланге
         {
           pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
           return;
         }
-        if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) )
+        if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) )//нет навыка
         {
           pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0);
           return;
         }
-        if ( v2 )
+        if ( v2 )//смена щита щитом
         {
           --v2;
           memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
-          v12 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2);
-          *(char *)(v12 + 556) = 0;
+          pPlayers[uActiveCharacter]->pInventoryItemList[v2].uBodyAnchor = 0;
           pParty->pPickedItem.Reset();
-          pParty->SetHoldingItem((ItemGen *)(v12 + 532));
+          pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[v2]);
           _this.uBodyAnchor = 1;
-          v14 = v51 == 0;
-          memcpy((void *)(v12 + 532), &_this, 0x24u);
+          memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v2], &_this, 0x24u);
           pPlayers[uActiveCharacter]->pEquipment.uShield = v2 + 1;
-          if ( v14 )
+          if ( v51 == EQUIP_OFF_HAND )
             return;
         }
         else
@@ -2506,26 +2503,27 @@
           v52 = pPlayers[uActiveCharacter]->FindFreeInventoryListSlot();
           if ( v52 < 0 )
             return;
-          if ( !v51 )
+          if ( !v51 )// обычная установка щита на пустую руку
           {
             pParty->pPickedItem.uBodyAnchor = 1;
             v17 = v52 + 1;
             memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v52], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v52]));
             pPlayers[uActiveCharacter]->pEquipment.uShield = v17;
             pMouse->RemoveHoldingItem();
-	        return;
-          }
+            return;
+          }//ставим щит когда держит двуручный меч
+          v1--;
           memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
-          v15 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v1 - 1));
-          *(char *)(v15 + 556) = 0;
+          pPlayers[uActiveCharacter]->pInventoryItemList[v1].uBodyAnchor = 0;
           pParty->pPickedItem.Reset();
-          pParty->SetHoldingItem((ItemGen *)(v15 + 532));
+          pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[v1]);
           _this.uBodyAnchor = 1;
           memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v52], &_this, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v52]));
           pPlayers[uActiveCharacter]->pEquipment.uShield = v52 + 1;
         }
         pPlayers[uActiveCharacter]->pEquipment.uMainHand = 0;
         return;
+//-------------------------taken in hand(взять в руку)-------------------------------------------
       case EQUIP_OFF_HAND:
       case EQUIP_WAND:
         if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter)
@@ -2546,7 +2544,6 @@
         {
           v18 = pMouse->uMouseClickX;
           v19 = pMouse->uMouseClickY;
-          v49 = v19;
           if ( (signed int)v18 >= 560 )
           {
             if ( !v51 )
@@ -2555,19 +2552,16 @@
               {
                 --v2;
                 memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
-                v20 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2);
-                *(char *)(v20 + 556) = 0;
+                pPlayers[uActiveCharacter]->pInventoryItemList[v2].uBodyAnchor = 0;
                 pParty->pPickedItem.Reset();
-                pParty->SetHoldingItem((ItemGen *)(v20 + 532));
+                pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[v2]);
                 _this.uBodyAnchor = 1;
-                v14 = pEquipType == EQUIP_WAND;
-                memcpy((void *)(v20 + 532), &_this, 0x24u);
+                memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v2], &_this, 0x24u);
                 pPlayers[uActiveCharacter]->pEquipment.uShield = v2 + 1;
-                if ( !v14 )
+                if ( pEquipType != EQUIP_WAND )
                   return;
-                v22 = _this.uItemID;
-                v50 = v22;
-                if ( v50 )
+                v50 = _this.uItemID;
+                if ( _this.uItemID )
                 {
                 __debugbreak();  // looks like offset in player's inventory and wand_lut much like case in 0042ECB5
                 stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9);
@@ -2582,7 +2576,7 @@
               memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v23], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v23]));
               pPlayers[uActiveCharacter]->pEquipment.uShield = v23 + 1;
               pMouse->RemoveHoldingItem();
-              if ( pEquipType != 12 )
+              if ( pEquipType != EQUIP_WAND )
                 return;
               v22 = *(int *)v50;
               v50 = v22;
@@ -2605,7 +2599,7 @@
           memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v26], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v26]));
           pPlayers[uActiveCharacter]->pEquipment.uMainHand = v26 + 1;
           pMouse->RemoveHoldingItem();
-          if ( pEquipType != 12 )
+          if ( pEquipType != EQUIP_WAND )
             return;
           v22 = *(int *)v50;
           v50 = v22;
@@ -2618,83 +2612,78 @@
         }
         --v1;
         memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
-        v24 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1);
-        *(char *)(v24 + 556) = 0;
+        pPlayers[uActiveCharacter]->pInventoryItemList[v1].uBodyAnchor = 0;
         pParty->pPickedItem.Reset();
-        pParty->SetHoldingItem((ItemGen *)(v24 + 532));
+        pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[v1]);
         _this.uBodyAnchor = 2;
-        v25 = v1 + 1;
-        v14 = pEquipType == 12;
-        memcpy((void *)(v24 + 532), &_this, 0x24u);
-        pPlayers[uActiveCharacter]->pEquipment.uMainHand = v25;
-        if ( v14 )
+        memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v1], &_this, 0x24u);
+        pPlayers[uActiveCharacter]->pEquipment.uMainHand = v1 + 1;
+        if ( pEquipType == EQUIP_WAND )
           v50 = _this.uItemID;
         if ( v51 )
           pPlayers[uActiveCharacter]->pEquipment.uShield = 0;
-        if ( v50 )
+        if ( v50 )//взять жезл
         {
                 __debugbreak();  // looks like offset in player's inventory and wand_lut much like case in 0042ECB5
           stru_A750F8[uActiveCharacter - 1]._494836( *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9);
         }
         break;
+//---------------------------take two hands(взять двумя руками)---------------------------------
       case EQUIP_MAIN_HAND:
         if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) )
-		{
-			pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
-			return;
-		}
+        {
+          pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
+          return;
+        }
         if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) )
         {
           pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0);
           return;
         }
-        if ( v1 )
+        if ( v1 )//взять двуручный меч кода нет щита(замещение оружия)
         {
           if ( v2 )
           {
-			pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
-			return;
+            pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
+            return;
           }
           --v1;
           memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
-          v27 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1);
-          *(char *)(v27 + 556) = 0;
+          pPlayers[uActiveCharacter]->pInventoryItemList[v1].uBodyAnchor = 0;
           pParty->pPickedItem.Reset();
-          pParty->SetHoldingItem((ItemGen *)(v27 + 532));
+          pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[v1]);
           _this.uBodyAnchor = 2;
-          v28 = v1 + 1;
-          memcpy((void *)(v27 + 532), &_this, 0x24u);
-          pPlayers[uActiveCharacter]->pEquipment.uMainHand = v28;
+          memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v1], &_this, 0x24u);
+          pPlayers[uActiveCharacter]->pEquipment.uMainHand = v1 + 1;
         }
         else
         {
           v52 = pPlayers[uActiveCharacter]->FindFreeInventoryListSlot();
           if ( v52 >= 0 )
           {
-            if ( v2 )
+            if ( v2 )//взять двуручный меч кода есть щит(замещение щитом)
             {
+              v2--;
               memcpy(&_this, &pParty->pPickedItem, sizeof(_this));
-              v29 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v2 - 1));
-              *(char *)(v29 + 556) = 0;
+              pPlayers[uActiveCharacter]->pInventoryItemList[v2].uBodyAnchor = 0;
               pParty->pPickedItem.Reset();
-              pParty->SetHoldingItem((ItemGen *)(v29 + 532));
+              pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[v2]);
               _this.uBodyAnchor = 2;
-              v30 = v52 + 1;
               memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v52], &_this, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v52]));
               pPlayers[uActiveCharacter]->pEquipment.uShield = 0;
-              pPlayers[uActiveCharacter]->pEquipment.uMainHand = v30;
+              pPlayers[uActiveCharacter]->pEquipment.uMainHand = v52 + 1;
             }
             else
             {
               pParty->pPickedItem.uBodyAnchor = 2;
-              v31 = v52 + 1;
               memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v52], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v52]));
-              pPlayers[uActiveCharacter]->pEquipment.uMainHand = v31;
+              pPlayers[uActiveCharacter]->pEquipment.uMainHand = v52 + 1;
               pMouse->RemoveHoldingItem();
             }
           }
         }
         return;
+//-------------------------------------------------------------------------------
       default:
         pPlayers[uActiveCharacter]->UseItem_DrinkPotion_etc(uActiveCharacter, 0);
         return;
@@ -2702,19 +2691,16 @@
     return;
   }
 
-    v32 = pMouse->uMouseClickX;
-    v33 = pMouse->uMouseClickY;
-
+  v32 = pMouse->uMouseClickX;
+  v33 = pMouse->uMouseClickY;
   v34 = pRenderer->pActiveZBuffer[v32 + pSRZBufferLineOffsets[v33]] & 0xFFFF;
   if ( v34 )
   {
     v36 = v34 - 1;
     v37 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v36);
-    v50 = v37;
-    v38 = (ItemGen *)(v37 + 532);
-    v14 = v38->uItemID == ITEM_WETSUIT;
+    v38 = &pPlayers[uActiveCharacter]->pInventoryItemList[v36];
     pEquipType = pItemsTable->pItems[v38->uItemID].uEquipType;
-    if ( v14 )
+    if ( v38->uItemID == ITEM_WETSUIT )
     {
       if ( bUnderwater )
       {
@@ -2723,13 +2709,12 @@
       }
       WetsuitOff(uActiveCharacter);
     }
-    if ( unk_50C9A0 )
+    if ( unk_50C9A0 )//наложить закл на экипировку
     {
-      *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu;
+      *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu;//CastSpellInfo
       *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1;
-      v39 = pEquipType;
       *((int *)pGUIWindow_Settings->ptr_1C + 3) = v36;
-      *((short *)pGUIWindow_Settings->ptr_1C + 3) = v39;
+      *((short *)pGUIWindow_Settings->ptr_1C + 3) = pEquipType;
       ptr_50C9A4 = v38;
       unk_50C9A0 = 0;
       if ( pMessageQueue_50CBD0->uNumMessages )
@@ -2741,22 +2726,21 @@
     }
     else
     {
-      if ( !ptr_50C9A4 )
+      if ( !ptr_50C9A4 )//снять вещь
       {
         pParty->SetHoldingItem(v38);
-        *(&pPlayers[uActiveCharacter]->uBirthYear + *(char *)(v50 + 556)) = 0;
+        *(&pPlayers[uActiveCharacter]->uBirthYear + pPlayers[uActiveCharacter]->pInventoryItemList[v36].uBodyAnchor) = 0;// это pPlayers[uActiveCharacter]->pEquipment[pPlayers[uActiveCharacter]->pInventoryItemList[v36].uBodyAnchor]
         v38->Reset();
       }
     }
   }
-  else
+  else//снять лук
   {
-    v35 = pPlayers[uActiveCharacter]->pEquipment.uBow;
-    if ( v35 )
+    if ( pPlayers[uActiveCharacter]->pEquipment.uBow )
     {
-      auto _a = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItemList[v35 - 1];
-      pParty->SetHoldingItem(_a);
-      _a->Reset();
+      _this = pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->pEquipment.uBow - 1];
+      pParty->SetHoldingItem(&_this);
+      _this.Reset();
       pPlayers[uActiveCharacter]->pEquipment.uBow = 0;
     }
   }