changeset 1602:96a1f5e0b6cd

Merge
author Grumpy7
date Thu, 12 Sep 2013 09:55:20 +0200
parents 5ac59bcb68e9 (current diff) 43d3536a20f7 (diff)
children c58916c53d8e
files Items.h UI/UIPopup.cpp
diffstat 9 files changed, 275 insertions(+), 306 deletions(-) [+]
line wrap: on
line diff
--- a/Items.h	Thu Sep 12 09:53:41 2013 +0200
+++ b/Items.h	Thu Sep 12 09:55:20 2013 +0200
@@ -61,12 +61,22 @@
   ITEM_WAND_FIRE = 135,
   ITEM_WAND_STUN = 138,
   ITEM_WAND_INCENERATION = 0x9F,
+  ITEM_REAGENT_WIDOWSWEEP_BERRIES = 200,
   ITEM_TROLL_BLOOD = 0xCA,
   ITEM_DRAGON_EYE = 0xCC,
   ITEM_HARPY_FEATHER = 0xCF,
   ITEM_DEVIL_ICHOR = 0xD6,
   ITEM_OOZE_ECTOPLASM_BOTTLE = 0xD9,
-  ITEM_POTION_BOTTLE = 0xDC,
+  ITEM_REAGENT_PHILOSOPHERS_STONE = 219,
+  ITEM_POTION_BOTTLE = 220,
+  ITEM_POTION_CATALYST = 221,
+  ITEM_POTION_RECHARGE_ITEM = 233,
+  ITEM_POTION_HARDEN_ITEM = 236,
+  ITEM_POTION_ACCURACY_BOOST = 245,
+  ITEM_POTION_FLAMING_POTION = 246,
+  ITEM_POTION_SWIFT_POTION = 250,
+  ITEM_POTION_SLAYING_POTION = 263,
+  ITEM_POTION_REJUVENATION = 271,
   ITEM_SPELLBOOK_TORCHLIGHT = 400,//0x190
   ITEM_SPELLBOOK_FIRE_STRIKE = 401,//0x191,
   ITEM_SPELLBOOK_AIR_FEATHER_FALL = 0x19C,
--- a/Render.cpp	Thu Sep 12 09:53:41 2013 +0200
+++ b/Render.cpp	Thu Sep 12 09:55:20 2013 +0200
@@ -6701,8 +6701,11 @@
 
   auto ecx0 = this;
   v3 = 0;
-  if ( ecx0->pRenderD3D )
-  {
+
+  if (!this->pRenderD3D)
+    __debugbreak(); // sw render
+
+  //{
     v4 = a3;
     if ( a3 <= 1.0 )
     {
@@ -6713,6 +6716,7 @@
     {
       v4 = 1.0;
     }
+    __debugbreak(); // banker's rounding again
     a3 = v4 * 255.0;
     v39 = a3 + 6.7553994e15;
     LODWORD(v40) = LODWORD(v39);
@@ -6774,7 +6778,7 @@
     ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
     ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE));
     ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS));
-  }
+  /*}
   else
   {
     v40 = (1.0 - a3) * 65536.0;
@@ -6800,7 +6804,7 @@
 
     if ( pRenderer->uTargetGBits == 6 )
     {
-      v17 = _42690D_colors_cvt(this_);
+      v17 = sr_42690D_colors_cvt(this_);
       v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F);
       this_ = (((65536 - LODWORD(a3)) * (unsigned __int16)(v17 & 0xF800) & 0xF800FFFF | v18 & 0x1F0000 | (65536 - LODWORD(a3)) * (v17 & 0x7E0) & 0x7E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (unsigned __int16)(v17 & 0xF800) & 0xF800FFFF | v18 & 0x1F0000 | (65536 - LODWORD(a3)) * (v17 & 0x7E0) & 0x7E00000u) >> 16);
       v19 = v40;
@@ -6831,7 +6835,7 @@
     }
     else
     {
-      v24 = _4268E3_smthn_to_a1r5g5b5(this_);
+      v24 = sr_4268E3_smthn_to_a1r5g5b5(this_);
       v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F);
       this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3))
                                                                                     * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16);
@@ -6860,7 +6864,7 @@
       }
       while ( v32 != 1 );
     }
-  }
+  }*/
   return result;
 }
 
--- a/SpriteObject.cpp	Thu Sep 12 09:53:41 2013 +0200
+++ b/SpriteObject.cpp	Thu Sep 12 09:55:20 2013 +0200
@@ -82,11 +82,11 @@
     pSpriteObjects[v6].vVelocity.z = 0;
     if ( a4 )
     {
-      v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
-      a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
-      pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16;
-      pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16;
-      pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16;
+      v13 = fixpoint_sub0(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch));
+      a5a = fixpoint_sub0(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch));
+      pSpriteObjects[v6].vVelocity.x = fixpoint_sub0(v13, a4);
+      pSpriteObjects[v6].vVelocity.y = fixpoint_sub0(a5a, a4);
+      pSpriteObjects[v6].vVelocity.z = fixpoint_sub0(stru_5C6E00->Sin(pitch), a4);
     }
     else
     {
@@ -107,11 +107,11 @@
     pSpriteObjects[v6].vVelocity.z = 0;
     if ( a4 )
     {
-      v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
-      a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
-      pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16;
-      pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16;
-      pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16;
+      v13 = fixpoint_sub0(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch));
+      a5a = fixpoint_sub0(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch));
+      pSpriteObjects[v6].vVelocity.x = fixpoint_sub0(v13, a4);
+      pSpriteObjects[v6].vVelocity.y = fixpoint_sub0(a5a, a4);
+      pSpriteObjects[v6].vVelocity.z = fixpoint_sub0(stru_5C6E00->Sin(pitch), a4);
     }
     else
     {
@@ -132,11 +132,11 @@
     pSpriteObjects[v6].vVelocity.z = 0;
     if ( a4 )
     {
-      v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
-      a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
-      pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16;
-      pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16;
-      pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16;
+      v13 = fixpoint_sub0(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)) >> 16;
+      a5a = fixpoint_sub0(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)) >> 16;
+      pSpriteObjects[v6].vVelocity.x = fixpoint_sub0(v13, a4);
+      pSpriteObjects[v6].vVelocity.y = fixpoint_sub0(a5a, a4);
+      pSpriteObjects[v6].vVelocity.z = fixpoint_sub0(stru_5C6E00->Sin(pitch), a4);
     }
     else
     {
@@ -157,11 +157,11 @@
     pSpriteObjects[v6].vVelocity.z = 0;
     if ( a4 )
     {
-      v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
-      a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
-      pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16;
-      pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16;
-      pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16;
+      v13 = fixpoint_sub0(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch));
+      a5a = fixpoint_sub0(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch));
+      pSpriteObjects[v6].vVelocity.x = fixpoint_sub0(v13, a4);
+      pSpriteObjects[v6].vVelocity.y = fixpoint_sub0(a5a, a4);
+      pSpriteObjects[v6].vVelocity.z = fixpoint_sub0(stru_5C6E00->Sin(pitch), a4);
     }
     else
     {
@@ -182,11 +182,11 @@
     pSpriteObjects[v6].vVelocity.z = 0;
     if ( a4 )
     {
-      v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
-      a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16;
-      pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16;
-      pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16;
-      pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16;
+      v13 = fixpoint_sub0(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch));
+      a5a = fixpoint_sub0(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch));
+      pSpriteObjects[v6].vVelocity.x = fixpoint_sub0(v13, a4);
+      pSpriteObjects[v6].vVelocity.y = fixpoint_sub0(a5a, a4);
+      pSpriteObjects[v6].vVelocity.z = fixpoint_sub0(stru_5C6E00->Sin(pitch), a4);
     }
     else
     {
@@ -331,9 +331,9 @@
     if ( !(v2->uFlags & OBJECT_DESC_BOUNCE) || (v21 = -v1->vVelocity.z >> 1, v1->vVelocity.z = v21, (signed __int16)v21 < 10) )
       v1->vVelocity.z = 0;
 
-    v1->vVelocity.x = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)v1->vVelocity.x) >> 16);
-    v1->vVelocity.y = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)v1->vVelocity.y) >> 16);
-    v1->vVelocity.z = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)v1->vVelocity.z) >> 16);
+    v1->vVelocity.x = fixpoint_sub0(58500, v1->vVelocity.x);
+    v1->vVelocity.y = fixpoint_sub0(58500, v1->vVelocity.y);
+    v1->vVelocity.z = fixpoint_sub0(58500, v1->vVelocity.z);
 
     if ( (v1->vVelocity.y * v1->vVelocity.y + v1->vVelocity.x * v1->vVelocity.x) < 400 )
         {
@@ -620,12 +620,12 @@
   int v18; // eax@52
   int v19; // ecx@52
   Vec3_short_ *v20; // ecx@53
-  int v21; // ecx@57
+  //int v21; // ecx@57
   __int16 v22; // ax@57
   int v23; // edi@62
-  int v24; // edi@62
-  int v25; // eax@62
-  unsigned __int64 v26; // qax@62
+  //int v24; // edi@62
+  //int v25; // eax@62
+  //unsigned __int64 v26; // qax@62
   unsigned __int8 v27; // sf@64
   unsigned __int8 v28; // of@64
   __int16 v29; // di@67
@@ -641,7 +641,7 @@
   int v39; // [sp+80h] [bp-10h]@33
   Actor *v39b;
   int v40; // [sp+84h] [bp-Ch]@28
-  int v41; // [sp+88h] [bp-8h]@34
+  //int v41; // [sp+88h] [bp-8h]@34
   int v42; // [sp+8Ch] [bp-4h]@4
 
   //uLayingItemID_ = uLayingItemID;
@@ -791,7 +791,7 @@
       pSpriteObject->vPosition.y += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.y);
       //v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16;
       pSpriteObject->vPosition.z += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z);
-      pSpriteObject->uSectorID = LOWORD(stru_721530.uSectorID);
+      pSpriteObject->uSectorID = stru_721530.uSectorID;
       stru_721530.field_70 += stru_721530.field_7C;
       if ( pObject->uFlags & 0x40 && !_46BFFA_check_object_intercept(uLayingItemID, stru_721530.uFaceID) )
         return;
@@ -801,15 +801,8 @@
         v40 = integer_sqrt(pSpriteObject->vVelocity.x * pSpriteObject->vVelocity.x + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y);
         v23 = stru_5C6E00->Atan2(pSpriteObject->vPosition.x - pLevelDecorations[v15].vPosition.x,
                 pSpriteObject->vPosition.y - pLevelDecorations[v15].vPosition.y);
-        v42 = stru_5C6E00->Cos(v23);
-        v41 = (unsigned __int64)(v42 * (signed __int64)v40) >> 16;
-        v24 = v23;
-        pSpriteObject->vVelocity.x = (unsigned int)(v42 * v40) >> 16;
-        v25 = stru_5C6E00->Sin(v23);
-        v42 = v25;
-        v26 = v25 * (signed __int64)v40;
-        v41 = v26 >> 16;
-        pSpriteObject->vVelocity.y = WORD1(v26);
+        pSpriteObject->vVelocity.x = fixpoint_sub0(stru_5C6E00->Cos(v23), v40);
+        pSpriteObject->vVelocity.y = fixpoint_sub0(stru_5C6E00->Sin(v23), v40);
       }
       else
       {
@@ -823,25 +816,17 @@
                                                                     + v16->pFacePlane_old.vNormal.y * pSpriteObject->vVelocity.y) >> 16;
           if ( (stru_721530.speed >> 3) > v42 )
             v42 = stru_721530.speed >> 3;
-          v40 = v16->pFacePlane_old.vNormal.x;
-          v40 = (unsigned __int64)(v42 * (signed __int64)v40) >> 16;
-          v41 = v16->pFacePlane_old.vNormal.y;
-          v41 = (unsigned __int64)(v42 * (signed __int64)v41) >> 16;
-          v39 = v16->pFacePlane_old.vNormal.z;
-          v39 = (unsigned __int64)(v42 * (signed __int64)v39) >> 16;
-          pSpriteObject->vVelocity.x += 2 * v40;
-          pSpriteObject->vVelocity.y += 2 * v41;
+          pSpriteObject->vVelocity.x += 2 * fixpoint_sub0(v42, v16->pFacePlane_old.vNormal.x);
+          pSpriteObject->vVelocity.y += 2 * fixpoint_sub0(v42, v16->pFacePlane_old.vNormal.y);
+          v39 = fixpoint_sub0(v42, v16->pFacePlane_old.vNormal.z);
           if ( v16->pFacePlane_old.vNormal.z <= 32000 )
           {
             v22 = 2 * v39;
           }
           else
           {
-            v21 = v39;
-            v40 = 32000;
             pSpriteObject->vVelocity.z += v39;
-            v41 = (unsigned __int64)(v40 * (signed __int64)v21) >> 16;
-            v22 = (unsigned int)(v40 * v21) >> 16;
+            v22 = fixpoint_sub0(32000, v39);
           }
           pSpriteObject->vVelocity.z += v22;
           if ( BYTE3(v16->uAttributes) & 0x10 )
@@ -876,20 +861,12 @@
 LABEL_63:
       //v2 = v37;
 LABEL_64:
-      v41 = pSpriteObject->vVelocity.x;
-      v40 = 58500;
-      v41 = (unsigned __int64)(58500i64 * v41) >> 16;
-      pSpriteObject->vVelocity.x = v41;
-      v41 = pSpriteObject->vVelocity.y;
-      v41 = (unsigned __int64)(v40 * (signed __int64)v41) >> 16;
-      v40 = 58500;
-      pSpriteObject->vVelocity.y = v41;
-      v41 = pSpriteObject->vVelocity.z;
-      v41 = (unsigned __int64)(v40 * (signed __int64)v41) >> 16;
+      pSpriteObject->vVelocity.x = fixpoint_sub0(58500, pSpriteObject->vVelocity.x);
+      pSpriteObject->vVelocity.y = fixpoint_sub0(58500, pSpriteObject->vVelocity.y);
+      pSpriteObject->vVelocity.z = fixpoint_sub0(58500, pSpriteObject->vVelocity.z);
       ++uFaceID;
       v28 = __OFSUB__(uFaceID, 100);
       v27 = uFaceID - 100 < 0;
-      pSpriteObject->vVelocity.z = v41;
       if ( !(v27 ^ v28) )
         return;
       v8 = 0;
@@ -916,18 +893,10 @@
         pSpriteObject->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
       v8 = 0;
     }
-    v42 = pSpriteObject->vVelocity.x;
-    uFaceID = 58500;
-    v42 = (unsigned __int64)(58500i64 * v42) >> 16;
-    pSpriteObject->vVelocity.x = v42;
-    v42 = pSpriteObject->vVelocity.y;
-    v42 = (unsigned __int64)(uFaceID * (signed __int64)v42) >> 16;
-    uFaceID = 58500;
-    pSpriteObject->vVelocity.y = v42;
-    v42 = pSpriteObject->vVelocity.z;
-    v42 = (unsigned __int64)(uFaceID * (signed __int64)v42) >> 16;
+    pSpriteObject->vVelocity.x = fixpoint_sub0(58500, pSpriteObject->vVelocity.x);
+    pSpriteObject->vVelocity.y = fixpoint_sub0(58500, pSpriteObject->vVelocity.y);
+    pSpriteObject->vVelocity.z = fixpoint_sub0(58500, pSpriteObject->vVelocity.z);
     v9 = pSpriteObject->vVelocity.x;
-    pSpriteObject->vVelocity.z = v42;
     if ( v9 * v9 + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y < 400 )
     {
       pSpriteObject->vVelocity.z = v8;
--- a/UI/UIPopup.cpp	Thu Sep 12 09:53:41 2013 +0200
+++ b/UI/UIPopup.cpp	Thu Sep 12 09:55:20 2013 +0200
@@ -1929,7 +1929,7 @@
             {
         case SCREEN_CASTING:
             {
-            identify_item();
+            OnInventoryItemRightClick();
             break;
             }
 
@@ -2097,7 +2097,7 @@
             {
             if ( (signed int)pX > 467 && pCurrentScreen != SCREEN_E )
                 {
-                identify_item();
+                OnInventoryItemRightClick();
                 }
             else if ( (signed int)pY >= 345 )
                 break;
@@ -2112,7 +2112,7 @@
             else
               {
                 if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 )//2DEvent - CharacerScreenInventory
-                  identify_item();
+                  OnInventoryItemRightClick();
               }
             break;
             }
--- a/_deleted.cpp	Thu Sep 12 09:53:41 2013 +0200
+++ b/_deleted.cpp	Thu Sep 12 09:55:20 2013 +0200
@@ -12319,7 +12319,6 @@
   }
   return 0;
 }
-
 //----- (0046271C) --------------------------------------------------------
 void CreateDefaultBLVLevel()
 {
@@ -12344,6 +12343,37 @@
   ofn.lpTemplateName = 0;
   ofn.lpstrFileTitle = pTmpBuf.data();
 }
+//----- (004268E3) --------------------------------------------------------
+int __fastcall sr_4268E3_smthn_to_a1r5g5b5(unsigned int uColor)
+{
+  unsigned int v1; // eax@1
+  unsigned int v2; // edx@1
+  int v3; // eax@1
+  int v4; // edx@1
+  unsigned int v5; // ecx@1
+
+  v1 = uColor >> 9;
+  v2 = uColor >> 6;
+  LOWORD(v1) = (uColor >> 9) & 0x7C00;
+  LOWORD(v2) = (uColor >> 6) & 0x3E0;
+  v3 = v2 | v1;
+  v4 = (unsigned __int8)uColor >> 3;
+  v5 = uColor >> 16;
+  LOWORD(v5) = v5 & 0x8000;
+  return v5 | v4 | v3;
+}
+//----- (0042690D) --------------------------------------------------------
+int __fastcall sr_42690D_colors_cvt(unsigned int a1)
+{
+  unsigned int v1; // eax@1
+  unsigned int v2; // edx@1
+
+  v1 = a1 >> 8;
+  v2 = a1 >> 5;
+  LOWORD(v1) = (a1 >> 8) & 0xF800;
+  LOWORD(v2) = (a1 >> 5) & 0x7E0;
+  return ((unsigned __int8)a1 >> 3) | v2 | v1;
+}
 
 const wchar_t *UIMessage2String(UIMessageType msg)
 {
--- a/mm7_5.cpp	Thu Sep 12 09:53:41 2013 +0200
+++ b/mm7_5.cpp	Thu Sep 12 09:55:20 2013 +0200
@@ -3242,11 +3242,14 @@
 }
 
 //----- (004356FF) --------------------------------------------------------
-void  back_to_game()
+void back_to_game()
 {
   dword_507BF0_is_there_popup_onscreen = 0;
   dword_4E455C = 1;
-  dword_50CDCC = 0;
+
+  extern int no_rightlick_in_inventory;
+  no_rightlick_in_inventory = false;
+
   if ( pGUIWindow_ScrollWindow )
     free_book_subwindow();
   if ( !pCurrentScreen && !pGUIWindow_Settings )
@@ -4903,23 +4906,24 @@
 }
 
 
+int no_rightlick_in_inventory = false; // 0050CDCC
 //----- (00416196) --------------------------------------------------------
-void identify_item()
+void OnInventoryItemRightClick()
 {
-  Player *v0; // esi@2
-  POINT *v1; // edi@2
-  signed int v2; // ecx@5
-  signed int v3; // eax@5
-  int v4; // eax@5
-  char v5; // sf@5
-  int v6; // eax@5
+  //Player *v0; // esi@2
+  //POINT *v1; // edi@2
+  //signed int v2; // ecx@5
+  //signed int v3; // eax@5
+  //int v4; // eax@5
+  //char v5; // sf@5
+  //int v6; // eax@5
   int v7; // eax@7
-  unsigned __int16 v8; // ax@10
+  //unsigned __int16 v8; // ax@10
   int v9; // edi@10
   int v10; // eax@10
-  int v11; // edx@13
-  LONG v12; // edx@23
-  signed int v13; // edx@23
+  //int v11; // edx@13
+  //LONG v12; // edx@23
+  //signed int v13; // edx@23
   int v14; // edx@25
   unsigned int v15; // edi@25
   signed int v16; // edx@27
@@ -4934,140 +4938,147 @@
   int v25; // eax@80
   int v26; // eax@84
   ItemGen *v27; // esi@98
-  unsigned int v28; // eax@98
+  //unsigned int v28; // eax@98
   ItemGen *v29; // edi@98
   unsigned int v30; // ecx@103
   double v31; // st7@112
   unsigned __int64 v32; // qax@113
-  unsigned int v33; // ecx@117
+  //unsigned int v33; // ecx@117
   int v34; // eax@126
-  unsigned int v35; // ecx@127
+  //unsigned int v35; // ecx@127
   double v36; // st7@132
   signed __int64 v37; // qax@135
-  unsigned int v38; // eax@138
+  //unsigned int v38; // eax@138
   Vec3_int_ v39; // [sp-18h] [bp-A8h]@83
-  int *v40; // [sp-Ch] [bp-9Ch]@83
-  int *v41; // [sp-8h] [bp-98h]@83
-  int *v42; // [sp-4h] [bp-94h]@83
+  //int *v40; // [sp-Ch] [bp-9Ch]@83
+  //int *v41; // [sp-8h] [bp-98h]@83
+  //int *v42; // [sp-4h] [bp-94h]@83
   GUIWindow v43; // [sp+Ch] [bp-84h]@137
-  unsigned int pY; // [sp+60h] [bp-30h]@2
+  //unsigned int pY; // [sp+60h] [bp-30h]@2
   int v45; // [sp+64h] [bp-2Ch]@10
-  unsigned int pX; // [sp+68h] [bp-28h]@2
+  //unsigned int pX; // [sp+68h] [bp-28h]@2
   int v47; // [sp+6Ch] [bp-24h]@25
-  POINT y; // [sp+70h] [bp-20h]@2
+  //POINT y; // [sp+70h] [bp-20h]@2
   POINT a2; // [sp+78h] [bp-18h]@2
-  Vec3_int_ pOut; // [sp+80h] [bp-10h]@2
+  //Vec3_int_ pOut; // [sp+80h] [bp-10h]@2
   unsigned int v51; // [sp+8Ch] [bp-4h]@23
 
-  if ( dword_50CDCC )
+  if (no_rightlick_in_inventory)
+    return;
+
+  if (a2.x <= 13 || a2.x >= 462)
     return;
-  v0 = pPlayers[uActiveCharacter];
-  v1 = pMouse->GetCursorPos(&a2);
-  pOut.z = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&y)->y]] & 0xFFFF;
-  pMouse->GetClickPos(&pX, &pY);
-  if ( !pOut.z )
+
+  auto player = pPlayers[uActiveCharacter];
+
+  pMouse->GetCursorPos(&a2);
+  int item_pid = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF;
+  //pMouse->GetClickPos(&pX, &pY);
+  if (!item_pid)
   {
-    if ( (signed int)pX <= 13
-      || (signed int)pX >= 462
-      || (v2 = pX - 14,
-          v3 = pY - 17,
-          pX = v2,
-          pY = v3,
-          v4 = 14 * (v3 >> 5),
-          v2 >>= 5,
-          v5 = v2 + v4 < 0,
-          v6 = v2 + v4,
-          pOut.z = v6,
-          v5)
-      || v6 > 126
-      || (v7 = v0->GetItemIDAtInventoryIndex(&pOut.z)) == 0 )
+    int inventory_mouse_x = a2.x - 14;
+    int inventory_mouse_y = a2.y - 17;
+
+    int mouse_cell_x = inventory_mouse_x / 32;
+    int mouse_cell_y = inventory_mouse_y / 32;
+
+    if (mouse_cell_x + mouse_cell_y < 0)
+      return;
+
+    int inventory_idx = mouse_cell_x + 14 * mouse_cell_y;
+    if (inventory_idx > 126)
       return;
-    pOut.z = v7;
+
+    v7 = player->GetItemIDAtInventoryIndex(&inventory_idx);
+    if (v7 == 0)
+      return;
+
+    item_pid = v7;
   }
-  if ( !v0->CanAct() )
+
+  if (!player->CanAct())
   {
-    sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[427], v0->pName, pGlobalTXT_LocalizationStrings[541]);
+    sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[427], player->pName, pGlobalTXT_LocalizationStrings[541]);
     v43.Hint = pTmpBuf.data();
     v43.uFrameWidth = 384;
     v43.uFrameHeight = 180;
+    if (a2.x <= 320 )
+      v43.uFrameX = a2.x + 30;
+    else
+      v43.uFrameX = a2.x - 414;
     v43.uFrameY = 40;
-    if ( pMouse->GetCursorPos(&a2)->x <= 320 )
-      v38 = pMouse->GetCursorPos(&a2)->x + 30;
-    else
-      v38 = pMouse->GetCursorPos(&a2)->x - 414;
-    v43.uFrameX = v38;
     v43.DrawMessageBox(0);
     return;
   }
-  --pOut.z;
-  LOBYTE(v8) = v0->GetActualSkillLevel(PLAYER_SKILL_ALCHEMY);
-  v9 = v8 & 0x3F;
-  v45 = v8 & 0x3F;
-  pOut.y = SkillToMastery(v8);
-  v10 = pOut.z;
+
+  --item_pid;
+  int alchemy_level = (int8_t)player->GetActualSkillLevel(PLAYER_SKILL_ALCHEMY);
+  v9 = alchemy_level & 0x3F;
+  //v45 = alchemy_level & 0x3F;
+  int alchemy_skill = SkillToMastery(alchemy_level);
+  v10 = item_pid;
   if ( pParty->pPickedItem.uItemID == ITEM_POTION_BOTTLE )
   {
 LABEL_116:
-    GameUI_DrawItemInfo(&v0->pInventoryItemList[v10]);
+    GameUI_DrawItemInfo(&player->pInventoryItemList[v10]);
     return;
   }
-  if ( (signed int)pParty->pPickedItem.uItemID < 200
-    || (signed int)pParty->pPickedItem.uItemID > 219
-    || (v11 = (int)((char *)v0 + 36 * pOut.z), *(int *)(v11 + 532) != 220) )
+
+  if (pParty->pPickedItem.uItemID < ITEM_REAGENT_WIDOWSWEEP_BERRIES ||
+      pParty->pPickedItem.uItemID > ITEM_REAGENT_PHILOSOPHERS_STONE ||
+      player->pInventoryItemList[item_pid].uItemID != ITEM_POTION_BOTTLE)
   {
-    if ( (signed int)pParty->pPickedItem.uItemID < 221
-      || (signed int)pParty->pPickedItem.uItemID > 271
-      || (v12 = (LONG)((char *)v0 + 36 * pOut.z), a2.y = v12, v13 = *(int *)(v12 + 532), v51 = v13, v13 < 221)
-      || v13 > 271 )
+    if (pParty->pPickedItem.uItemID < ITEM_POTION_CATALYST ||
+        pParty->pPickedItem.uItemID > ITEM_POTION_REJUVENATION ||
+        player->pInventoryItemList[item_pid].uItemID < ITEM_POTION_CATALYST ||
+        player->pInventoryItemList[item_pid].uItemID >= ITEM_POTION_REJUVENATION)
     {
-      if ( pParty->pPickedItem.uItemID != 236
-        && ((signed int)pParty->pPickedItem.uItemID < 246 || (signed int)pParty->pPickedItem.uItemID > 250)
-        && pParty->pPickedItem.uItemID != 263
-        && pParty->pPickedItem.uItemID != 233 )
+      if (pParty->pPickedItem.uItemID != ITEM_POTION_HARDEN_ITEM &&
+          (pParty->pPickedItem.uItemID < ITEM_POTION_FLAMING_POTION || pParty->pPickedItem.uItemID > ITEM_POTION_SWIFT_POTION) &&
+          pParty->pPickedItem.uItemID != ITEM_POTION_SLAYING_POTION &&
+          pParty->pPickedItem.uItemID != ITEM_POTION_RECHARGE_ITEM)
         goto LABEL_116;
-      v27 = &v0->pInventoryItemList[pOut.z];
-      v28 = v27->uItemID;
+
+      int a2_y;
+      v27 = &player->pInventoryItemList[item_pid];
       v51 = pItemsTable->pItems[v27->uItemID].uEquipType;
       v29 = (ItemGen *)(1800 * pParty->pPickedItem.uEnchantmentType);
-      if ( pParty->pPickedItem.uItemID != 233 )
+      if ( pParty->pPickedItem.uItemID != ITEM_POTION_RECHARGE_ITEM )
       {
-        if ( pParty->pPickedItem.uItemID == 236 )
+        if ( pParty->pPickedItem.uItemID == ITEM_POTION_HARDEN_ITEM )
         {
-          v35 = v27->uAttributes;
-          if ( v35 & 2 || (v51 & 0x80000000u) != 0 || (signed int)v51 > 12 || (signed int)v28 >= 500 )
+          if (v27->IsBroken() || v51 < EQUIP_OFF_HAND || v51 > EQUIP_WAND || v27->uItemID >= ITEM_ARTIFACT_PUCK )
 		  {
 			pMouse->RemoveHoldingItem();
-			dword_50CDCC = 1;
+			no_rightlick_in_inventory = true;
 			return;
 		  }
-          LOWORD(v35) = v35 | 0x210;
-          v27->uAttributes = v35;
+          v27->uAttributes |= ITEM_AURA_EFFECT_RED | ITEM_ENCHANTED;
         }
         else
         {
-          if ( (signed int)pParty->pPickedItem.uItemID <= 245 )
+          if (pParty->pPickedItem.uItemID <= ITEM_POTION_ACCURACY_BOOST )
 		  {
 			pMouse->RemoveHoldingItem();
-			dword_50CDCC = 1;
+			no_rightlick_in_inventory = true;
 			return;
 		  }
-          if ( (signed int)pParty->pPickedItem.uItemID <= 250 )
+          if (pParty->pPickedItem.uItemID <= ITEM_POTION_SWIFT_POTION)
           {
             v27->UpdateTempBonus(pParty->uTimePlayed);
-            v33 = v27->uItemID;
-            if ( (signed int)v27->uItemID >= 64 && (signed int)v33 <= 65
-              || (pOut.y = v27->uAttributes, pOut.y & 2)
+            if ( (signed int)v27->uItemID >= 64 && (signed int)v27->uItemID <= 65
+              || (alchemy_skill = v27->uAttributes, alchemy_skill & 2)
               || v27->uSpecEnchantmentType
               || v27->uEnchantmentType
               || v51 && v51 != 1 && v51 != 2
-              || (signed int)v33 >= 500 )
+              || (signed int)v27->uItemID >= 500 )
 			{
 				pMouse->RemoveHoldingItem();
-				dword_50CDCC = 1;
+				no_rightlick_in_inventory = 1;
 				return;
 			}
             v34 = *(int *)&aSbwb00[4 * pParty->pPickedItem.uItemID + 4];
-            a2.y = (int)v29 << 7;
+            a2_y = (int)v29 << 7;
             v31 = (double)(signed int)((int)v29 << 7);
             v27->uSpecEnchantmentType = v34;
           }
@@ -5076,30 +5087,30 @@
             if ( pParty->pPickedItem.uItemID != 263
               || (v27->UpdateTempBonus(pParty->uTimePlayed), v30 = v27->uItemID, (signed int)v27->uItemID >= 64)
               && (signed int)v30 <= 65
-              || (pOut.y = v27->uAttributes, pOut.y & 2)
+              || (alchemy_skill = v27->uAttributes, alchemy_skill & 2)
               || v27->uSpecEnchantmentType
               || v27->uEnchantmentType
               || v51 && v51 != 1 && v51 != 2
               || (signed int)v30 >= 500 )
 			{
 				pMouse->RemoveHoldingItem();
-				dword_50CDCC = 1;
+				no_rightlick_in_inventory = 1;
 				return;
 			}
-            a2.y = (int)v29 << 7;
+            a2_y = (int)v29 << 7;
             v27->uSpecEnchantmentType = 40;
-            v31 = (double)a2.y;
+            v31 = (double)a2_y;
           }
           v32 = pParty->uTimePlayed + (signed int)(signed __int64)(v31 * 0.033333335);
           LODWORD(v27->uExpireTime) = v32;
-          LODWORD(v32) = pOut.y;
-          LOBYTE(v32) = LOBYTE(pOut.y) | 0x18;
+          LODWORD(v32) = alchemy_skill;
+          LOBYTE(v32) = LOBYTE(alchemy_skill) | 0x18;
           HIDWORD(v27->uExpireTime) = HIDWORD(v32);
           v27->uAttributes = v32;
         }
         _50C9A8_item_enchantment_timer = 256;
 		pMouse->RemoveHoldingItem();
-		dword_50CDCC = 1;
+		no_rightlick_in_inventory = 1;
 		return;
       }
       v36 = (70.0 - (double)pParty->pPickedItem.uEnchantmentType) * 0.01;
@@ -5110,29 +5121,29 @@
         pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
         return;
       }
-      a2.y = v27->uMaxCharges;
-      v37 = (signed __int64)((double)a2.y - v36 * (double)a2.y);
+      a2_y = v27->uMaxCharges;
+      v37 = (signed __int64)((double)a2_y - v36 * (double)a2_y);
       v27->uMaxCharges = v37;
       v27->uNumCharges = (unsigned __int8)v37;
 		pMouse->RemoveHoldingItem();
-		dword_50CDCC = 1;
+		no_rightlick_in_inventory = 1;
 		return;
     }
-    v14 = v13 - 222;
+    v14 = player->pInventoryItemList[item_pid].uItemID - 222;
     v15 = pParty->pPickedItem.uItemID - 222;
     v47 = v14;
-    y.y = 0;
-    if ( pParty->pPickedItem.uItemID == 221 || v51 == 221 )
+
+    if ( pParty->pPickedItem.uItemID == 221 || player->pInventoryItemList[item_pid].uItemID == 221 )
     {
       v16 = 5;
     }
     else
     {
       v16 = *(short *)&pItemsTable->field_EDE0[2 * (v14 + 50 * v15) + 388];
-      v10 = pOut.z;
+      v10 = item_pid;
     }
     v51 = v16;
-    if ( v45 )
+    if ( v9 )
     {
       if ( v16 < 225 || v16 > 227 )
       {
@@ -5140,7 +5151,7 @@
         {
           if ( v16 < 240 || v16 > 261 )
           {
-            if ( v16 >= 262 && pOut.y != 4 )
+            if ( v16 >= 262 && alchemy_level != 4 )
             {
 LABEL_53:
               v51 = 4;
@@ -5149,7 +5160,7 @@
           }
           else
           {
-            if ( pOut.y <= 2 )
+            if ( alchemy_level <= 2 )
             {
 LABEL_38:
               v51 = 3;
@@ -5159,7 +5170,7 @@
         }
         else
         {
-          if ( pOut.y == 1 )
+          if ( alchemy_level == 1 )
           {
 LABEL_35:
             v51 = 2;
@@ -5183,57 +5194,54 @@
         goto LABEL_53;
     }
 LABEL_54:
-    pOut.y = 0;
-    pOut.x = v10 + 1;
-    v17 = (int)v0->pInventoryMatrix;
-    while ( *(int *)v17 != pOut.x )
+    int pOut_y = 0;
+    int pOut_x = v10 + 1;
+    v17 = (int)player->pInventoryMatrix;
+    while ( *(int *)v17 != pOut_x )
     {
-      ++pOut.y;
+      ++pOut_y;
       v17 += 4;
-      if ( pOut.y >= 126 )
+      if ( pOut_y >= 126 )
       {
-        v18 = y.y;
+        v18 = pOut_y;
         goto LABEL_59;
       }
     }
-    v18 = pOut.y;
+    v18 = pOut_y;
 LABEL_59:
     if ( !v51 )
     {
 LABEL_115:
-      v10 = pOut.z;
+      v10 = item_pid;
       goto LABEL_116;
     }
     if ( v51 == 1 )
     {
-      v0->RemoveItemAtInventoryIndex(v18);
+      player->RemoveItemAtInventoryIndex(v18);
       v26 = rand();
-      v0->ReceiveDamage(v26 % 11 + 10, DMGT_FIRE);
+      player->ReceiveDamage(v26 % 11 + 10, DMGT_FIRE);
       pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
 
       pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
 
-      v42 = (int *)&a2.y;
-      v41 = (int *)&y.y;
-      v40 = (int *)&pOut;
       v39.z = pParty->vPosition.z + pParty->sEyelevel;
     }
     else
     {
       if ( v51 == 2 )
       {
-        v0->RemoveItemAtInventoryIndex(v18);
+        player->RemoveItemAtInventoryIndex(v18);
         v25 = rand();
-        v0->ReceiveDamage(v25 % 71 + 30, DMGT_FIRE);
+        player->ReceiveDamage(v25 % 71 + 30, DMGT_FIRE);
         v23 = 1;
       }
       else
       {
         if ( v51 == 3 )
         {
-          v0->RemoveItemAtInventoryIndex(v18);
+          player->RemoveItemAtInventoryIndex(v18);
           v24 = rand();
-          v0->ReceiveDamage(v24 % 201 + 50, DMGT_FIRE);
+          player->ReceiveDamage(v24 % 201 + 50, DMGT_FIRE);
           v23 = 5;
         }
         else
@@ -5242,76 +5250,77 @@
           {
             if ( v51 != 5 )
             {
-              v19 = v0->AddItem(-1, 0xDCu);
+              v19 = player->AddItem(-1, 0xDCu);
               if ( v19 )
                // *(int *)&v0->field_1F5[36 * v19 + 15] = 1;
-                 v0->pOwnItems[v19-1].uAttributes=ITEM_IDENTIFIED;
+                 player->pOwnItems[v19-1].uAttributes = ITEM_IDENTIFIED;
               v20 = v47 + 50 * v15;
-              v0->pInventoryItemList[pOut.z].uItemID = v51;
-              v0->pInventoryItemList[pOut.z].uEnchantmentType = (pParty->pPickedItem.uEnchantmentType
-                                                       + v0->pInventoryItemList[pOut.z].uEnchantmentType)
+              player->pInventoryItemList[item_pid].uItemID = v51;
+              player->pInventoryItemList[item_pid].uEnchantmentType = (pParty->pPickedItem.uEnchantmentType
+                                                       + player->pInventoryItemList[item_pid].uEnchantmentType)
                                                       / 2;
-              v0->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->potion_note[2 * v20 ]);//field_10168  + 388
+              player->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->potion_note[2 * v20 ]);//field_10168  + 388
 LABEL_74:
-              v22 = (int)((char *)v0 + 36 * pOut.z);
+              v22 = (int)((char *)player + 36 * item_pid);
               if ( !(pItemsTable->pItems[*(int *)(v22 + 532) ].uItemID_Rep_St) )
                 *(int *)(v22 + 552) |= 1u;
               if ( !dword_4E455C )
 			  {
 				pMouse->RemoveHoldingItem();
-				dword_50CDCC = 1;
+				no_rightlick_in_inventory = 1;
 				return;
 			  }
-              v0->PlaySound(SPEECH_16, 0);
+              player->PlaySound(SPEECH_16, 0);
 			  dword_4E455C = 0;
 			  pMouse->RemoveHoldingItem();
-			  dword_50CDCC = 1;
+			  no_rightlick_in_inventory = 1;
 			  return;
             }
-            if ( v45 )
+            if ( v9 )
             {
-              if ( *(int *)(a2.y + 532) == 221 )
-                *(int *)(a2.y + 532) = pParty->pPickedItem.uItemID;
+              if ( *(int *)(player + 36 * item_pid + 532) == 221 )
+                *(int *)(player + 36 * item_pid + 532) = pParty->pPickedItem.uItemID;
               else
-                *(int *)(a2.y + 536) = pParty->pPickedItem.uEnchantmentType;
-              v21 = v0->AddItem(-1, 0xDCu);
+                *(int *)(player + 36 * item_pid + 536) = pParty->pPickedItem.uEnchantmentType;
+              v21 = player->AddItem(-1, 0xDCu);
               if ( v21 )
                 //*(int *)&v0->field_1F5[36 * v21 + 15] = 1;
-                v0->pOwnItems[v21-1].uAttributes=ITEM_IDENTIFIED;
+                player->pOwnItems[v21-1].uAttributes=ITEM_IDENTIFIED;
               goto LABEL_74;
             }
             goto LABEL_115;
           }
-          v0->RemoveItemAtInventoryIndex(v18);
-          v0->SetCondition(0x10u, 0);
+          player->RemoveItemAtInventoryIndex(v18);
+          player->SetCondition(0x10u, 0);
           v23 = 0;
         }
       }
-      v0->ItemsEnchant(v23);
+      player->ItemsEnchant(v23);
       pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0);
 
       pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
 
-      v42 = (int *)&a2.y;
-      v41 = (int *)&y.y;
-      v40 = (int *)&pOut;
       v39.z = pParty->vPosition.z + pParty->sEyelevel;
     }
-    *(_QWORD *)&v39.x = *(_QWORD *)&pParty->vPosition.x;
-    Vec3_int_::Rotate(64, pParty->sRotationY, pParty->sRotationX, v39, v40, v41, v42);
-    sub_42F7EB_DropItemAt(0x41Bu, pOut.x, y.y, a2.y, 0, 1, 0, 0, 0);
+    v39.x = pParty->vPosition.x;
+    v39.y = pParty->vPosition.y;
+
+    int rot_x, rot_y, rot_z;
+    Vec3_int_::Rotate(64, pParty->sRotationY, pParty->sRotationX, v39, &rot_x, &rot_y, &rot_z);
+    sub_42F7EB_DropItemAt(0x41Bu, rot_x, rot_y, rot_z, 0, 1, 0, 0, 0);
     if ( dword_4E455C )
     {
-      if ( v0->CanAct() )
-        v0->PlaySound(SPEECH_17, 0);
+      if ( player->CanAct() )
+        player->PlaySound(SPEECH_17, 0);
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[444], 2u);
       dword_4E455C = 0;
     }
     pMouse->RemoveHoldingItem();
-    dword_50CDCC = 1;
+    no_rightlick_in_inventory = 1;
     return;
   }
-  *(int *)(v11 + 536) = v9 + pItemsTable->pItems[pParty->pPickedItem.uItemID].uDamageDice;
+
+  player->pInventoryItemList[item_pid].uEnchantmentType = v9 + pItemsTable->pItems[pParty->pPickedItem.uItemID].uDamageDice;
   switch ( pParty->pPickedItem.uItemID )
   {
     case 0xC8u:
@@ -5319,37 +5328,37 @@
     case 0xCAu:
     case 0xCBu:
     case 0xCCu:
-      v0->pInventoryItemList[pOut.z].uItemID = 222;
+      player->pInventoryItemList[item_pid].uItemID = 222;
       break;
     case 0xCDu:
     case 0xCEu:
     case 0xCFu:
     case 0xD0u:
     case 0xD1u:
-      v0->pInventoryItemList[pOut.z].uItemID = 223;
+      player->pInventoryItemList[item_pid].uItemID = 223;
       break;
     case 0xD2u:
     case 0xD3u:
     case 0xD4u:
     case 0xD5u:
     case 0xD6u:
-      v0->pInventoryItemList[pOut.z].uItemID = 224;
+      player->pInventoryItemList[item_pid].uItemID = 224;
       break;
     case 0xD7u:
     case 0xD8u:
     case 0xD9u:
     case 0xDAu:
     case 0xDBu:
-      v0->pInventoryItemList[pOut.z].uItemID = 221;
+      player->pInventoryItemList[item_pid].uItemID = 221;
       break;
     default:
       break;
   }
   pMouse->RemoveHoldingItem();
-  dword_50CDCC = 1;
+  no_rightlick_in_inventory = 1;
   if ( dword_4E455C )
   {
-    v0->PlaySound(SPEECH_16, 0);
+    player->PlaySound(SPEECH_16, 0);
     dword_4E455C = 0;
   }
 }
@@ -5395,6 +5404,5 @@
     }
     break;
   }
-  assert(false);
-  return 0;
+  Error("Invalid player class: %u", uPlayerClass);
 }
\ No newline at end of file
--- a/mm7_6.cpp	Thu Sep 12 09:53:41 2013 +0200
+++ b/mm7_6.cpp	Thu Sep 12 09:55:20 2013 +0200
@@ -209,38 +209,6 @@
   return result;
 }
 
-//----- (004268E3) --------------------------------------------------------
-int __fastcall _4268E3_smthn_to_a1r5g5b5(unsigned int uColor)
-{
-  unsigned int v1; // eax@1
-  unsigned int v2; // edx@1
-  int v3; // eax@1
-  int v4; // edx@1
-  unsigned int v5; // ecx@1
-
-  v1 = uColor >> 9;
-  v2 = uColor >> 6;
-  LOWORD(v1) = (uColor >> 9) & 0x7C00;
-  LOWORD(v2) = (uColor >> 6) & 0x3E0;
-  v3 = v2 | v1;
-  v4 = (unsigned __int8)uColor >> 3;
-  v5 = uColor >> 16;
-  LOWORD(v5) = v5 & 0x8000;
-  return v5 | v4 | v3;
-}
-
-//----- (0042690D) --------------------------------------------------------
-int __fastcall _42690D_colors_cvt(unsigned int a1)
-{
-  unsigned int v1; // eax@1
-  unsigned int v2; // edx@1
-
-  v1 = a1 >> 8;
-  v2 = a1 >> 5;
-  LOWORD(v1) = (a1 >> 8) & 0xF800;
-  LOWORD(v2) = (a1 >> 5) & 0x7E0;
-  return ((unsigned __int8)a1 >> 3) | v2 | v1;
-}
 
 //----- (00426A5A) --------------------------------------------------------
 void stru319::LootActor(Actor *pActor)
@@ -1824,7 +1792,7 @@
 }
 
 //----- (0042FC4E) --------------------------------------------------------
-void  ProcessInputActions()
+void ProcessInputActions()
 {
   char v4; // al@9
   char v8; // bl@100
@@ -2139,7 +2107,7 @@
                   pMessageQueue_50CBD0->uNumMessages = 1;
                   pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
                   pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
-                  *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+                  pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].field_8 = 0;
                   ++pMessageQueue_50CBD0->uNumMessages;
                   break;
                 }
@@ -2151,10 +2119,7 @@
           case INPUT_CharCycle:
             if ( pCurrentScreen == SCREEN_SPELL_BOOK  )
               break;
-           /* dword_50C9EC[3 * dword_50C9E8] = 176;|| dword_50C9E8 >= 40
-            dword_50C9EC[3 * dword_50C9E8 + 1] = 0;
-            dword_50C9EC[3 * dword_50C9E8 + 2] = 0;
-            ++dword_50C9E8;*/
+
             pMessageQueue_50C9E8->AddMessage(UIMSG_CycleCharacters, 0, 0);
             break;
           case INPUT_LookUp:
@@ -2196,22 +2161,9 @@
             }
             break;
           case INPUT_ZoomIn:
-            /*if ( dword_50C9E8 >= 40 )
-              break;
-            dword_50C9EC[3 * dword_50C9E8] = 367;
-            dword_50C9EC[3 * dword_50C9E8 + 1] = 0;
-            dword_50C9EC[3 * dword_50C9E8 + 2] = 0;
-            ++dword_50C9E8;*/
               pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomOutBtn, 0, 0);
             break;
           case INPUT_ZoomOut:
-            /*if ( dword_50C9E8 < 40 )
-            {
-              dword_50C9EC[3 * dword_50C9E8] = 368;
-              dword_50C9EC[3 * dword_50C9E8 + 1] = 0;
-              dword_50C9EC[3 * dword_50C9E8 + 2] = 0;
-              ++dword_50C9E8;
-            }*/
               pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomInBtn, 0, 0);
             break;
           case INPUT_AlwaysRun:
--- a/mm7_data.cpp	Thu Sep 12 09:53:41 2013 +0200
+++ b/mm7_data.cpp	Thu Sep 12 09:55:20 2013 +0200
@@ -1006,7 +1006,6 @@
 //int dword_50C9E8; // idb
 //int dword_50C9EC[120]; // weak
 int dword_50CDC8;
-int dword_50CDCC; // weak
 int bProcessorIsNotIntel; // weak
 Vec3_int_ layingitem_vel_50FDFC;
 char pStartingMapName[32]; // idb
--- a/mm7_data.h	Thu Sep 12 09:53:41 2013 +0200
+++ b/mm7_data.h	Thu Sep 12 09:55:20 2013 +0200
@@ -654,7 +654,6 @@
 //extern int dword_50C9E8; // idb
 //extern int dword_50C9EC[]; // 50C9EC
 extern int dword_50CDC8;
-extern int dword_50CDCC; // weak
 extern int bProcessorIsNotIntel; // weak
 extern Vec3_int_ layingitem_vel_50FDFC;
 extern char pStartingMapName[32]; // idb
@@ -1094,7 +1093,7 @@
 void SetAttributeNames();
 void uGameUIFontMain_initialize();
 void uGameUIFontShadow_initialize();
-void identify_item();
+void OnInventoryItemRightClick();
 void sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(struct Vec2_int_ *_this);
 void UI_OnMouseLeftClick(int *pXY); // idb
 unsigned int UI_GetHealthManaAndOtherQualitiesStringColor(signed int current_pos, signed int base_pos);
@@ -1122,8 +1121,6 @@
 bool PortalFrustrum(int pNumVertices, struct BspRenderer_PortalViewportData *a2, struct BspRenderer_PortalViewportData *near_portal, int uFaceID);
 int sr_424CD7(unsigned int uVertexID); // idb
 int __fastcall sr_424EE0_MakeFanFromTriangle(unsigned int uVertexID); // idb
-int __fastcall _4268E3_smthn_to_a1r5g5b5(unsigned int uColor); // idb
-int __fastcall _42690D_colors_cvt(unsigned int a1);
 void __fastcall GivePartyExp(unsigned int pEXPNum);
 bool __fastcall sub_427769_spell(unsigned int uSpellID);
 void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6);