changeset 984:d982fffb8b96

CharacterUI_InventoryTab_Draw cleaned.
author Nomad
date Sat, 11 May 2013 17:56:12 +0200
parents 1462a5f12b65
children b584c743cb47 c5d8ea1e6ccb
files GUIWindow.cpp GUIWindow.h Items.h Texture.cpp Texture.h UICharacter.cpp UIHouses.cpp mm7_1.cpp mm7_5.cpp mm7_6.cpp mm7_data.cpp mm7_data.h
diffstat 12 files changed, 166 insertions(+), 254 deletions(-) [+]
line wrap: on
line diff
--- a/GUIWindow.cpp	Sat May 11 17:00:43 2013 +0200
+++ b/GUIWindow.cpp	Sat May 11 17:56:12 2013 +0200
@@ -1112,7 +1112,7 @@
   pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pDialogueNPCPortraits[(signed int)v4]);
   if ( pCurrentScreen == SCREEN_E )
   {
-    CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+    CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
     if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic )
     {
       pRenderer->DrawTextureIndexed(556, 451, &pIcons_LOD->pTextures[uTextureID_x_x_u]);
--- a/GUIWindow.h	Sat May 11 17:00:43 2013 +0200
+++ b/GUIWindow.h	Sat May 11 17:56:12 2013 +0200
@@ -479,7 +479,7 @@
 char CharacterUI_StatsTab_Draw(unsigned int uPlayerID); // idb
 void CharacterUI_SkillsTab_Draw(Player *player);
 void CharacterUI_AwardsTab_Draw(unsigned int uPlayerID); // idb
-void CharacterUI_InventoryTab_Draw(unsigned int uPlayerID, char a2);
+void CharacterUI_InventoryTab_Draw(Player *player, bool a2);
 void CharacterUI_CharacterScreen_Draw(unsigned int uPlayerIdx); // idb
 
 
--- a/Items.h	Sat May 11 17:00:43 2013 +0200
+++ b/Items.h	Sat May 11 17:56:12 2013 +0200
@@ -10,6 +10,10 @@
   ITEM_IDENTIFIED = 0x1,
   ITEM_BROKEN = 0x2,
   ITEM_TEMP_BONUS = 0x8,
+  ITEM_AURA_EFFECT_RED = 0x10,
+  ITEM_AURA_EFFECT_BLUE = 0x20,
+  ITEM_AURA_EFFECT_GREEN = 0x40,
+  ITEM_AURA_EFFECT_PURPLE = 0x80,
   ITEM_STOLEN = 0x100,
   ITEM_ENCHANTED = 0x200,
 };
--- a/Texture.cpp	Sat May 11 17:00:43 2013 +0200
+++ b/Texture.cpp	Sat May 11 17:56:12 2013 +0200
@@ -128,7 +128,7 @@
 unsigned int uTextureID_ib_td5_A;
 unsigned int uTextureID_ib_td2_A; // weak
 unsigned int uTextureID_ib_td1_A;
-int uTextureID_507958; // weak
+int uTextureID_CharacterUI_InventoryBackground; // weak
 int uTextureID_50795C; // weak
 
 
--- a/Texture.h	Sat May 11 17:00:43 2013 +0200
+++ b/Texture.h	Sat May 11 17:56:12 2013 +0200
@@ -231,7 +231,7 @@
 extern unsigned int uTextureID_ib_td5_A;
 extern unsigned int uTextureID_ib_td2_A; // weak
 extern unsigned int uTextureID_ib_td1_A;
-extern int uTextureID_507958; // weak
+extern int uTextureID_CharacterUI_InventoryBackground; // weak
 extern int uTextureID_50795C; // weak
 
 
--- a/UICharacter.cpp	Sat May 11 17:00:43 2013 +0200
+++ b/UICharacter.cpp	Sat May 11 17:56:12 2013 +0200
@@ -314,195 +314,103 @@
 
 
 
-    //----- (0041A2C1) --------------------------------------------------------
-    unsigned int __fastcall GetSizeInInventorySlots(unsigned int uNumPixels)
-        {
-        if ( (signed int)uNumPixels < 14 )
-            uNumPixels = 14;
-        return ((signed int)(uNumPixels - 14) >> 5) + 1;
-        }
+//----- (0041A2C1) --------------------------------------------------------
+unsigned int __fastcall GetSizeInInventorySlots(unsigned int uNumPixels)
+{
+  if ( (signed int)uNumPixels < 14 )
+    uNumPixels = 14;
+  return ((signed int)(uNumPixels - 14) >> 5) + 1;
+}
 
-    //----- (0041A2D1) --------------------------------------------------------
-    void CharacterUI_InventoryTab_Draw(unsigned int uPlayerID, char a2)
-        {
-        Player *pPlayer; // esi@1
-        char v3; // bl@1
-        unsigned int v4; // eax@2
-        ItemGen *pItem; // ebx@5
-        unsigned int v6; // eax@6
+//----- (0041A2D1) --------------------------------------------------------
+void CharacterUI_InventoryTab_Draw(Player *player, bool a2)
+{
         Texture *v7; // esi@6
-        __int16 v8; // ax@6
-        signed int v9; // edi@6
-        signed int v10; // ecx@6
         signed int v11; // edx@6
-        signed int v12; // eax@11
         int v13; // eax@13
         signed int v14; // edx@13
         int v15; // eax@13
-        unsigned int v16; // ebx@15
         unsigned int v17; // edi@15
         Texture *pTexture; // ebx@24
-        double v19; // st7@26
-        const char *v20; // [sp-8h] [bp-40h]@20
-        Player *pPlayer2; // [sp+14h] [bp-24h]@1
-        int uTextureId; // [sp+18h] [bp-20h]@6
-        int *v23; // [sp+1Ch] [bp-1Ch]@1
-        int v24; // [sp+20h] [bp-18h]@5
-        ItemGen *pItem2; // [sp+24h] [bp-14h]@5
-        int v26; // [sp+28h] [bp-10h]@3
-        unsigned int uCellID; // [sp+2Ch] [bp-Ch]@3
         unsigned int uCellX; // [sp+30h] [bp-8h]@5
         unsigned int uCellY; // [sp+34h] [bp-4h]@5
 
-        v23 = pRenderer->pActiveZBuffer;
-        pPlayer = pPlayers[uPlayerID];
-        v3 = a2;
-        pPlayer2 = pPlayers[uPlayerID];
-        pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_507958));
-        if ( v3 )
-            {
-            v4 = pIcons_LOD->LoadTexture("fr_strip", TEXTURE_16BIT_PALETTE);
-            pRenderer->DrawTextureIndexed(8u, 0x131u, pIcons_LOD->GetTexture(v4));
-            }
-        uCellID = 0;
-        v26 = (int)pPlayer->pInventoryIndices;
-        do
-            {
-            if ( *(int *)v26 > 0 )
-                {
-                v24 = *(int *)v26 - 1;
-                uCellY = 32 * (uCellID / 14) + 17;
-                pItem = &pPlayer->pInventoryItems[v24];
-                uCellX = 32 * (uCellID % 14) + 14;
-                pItem2 = pItem;
-                if ( pItem->uItemID )
-                    {
-                    v6 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pItem->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-                    uTextureId = v6;
-                    v7 = pIcons_LOD->GetTexture(v6);
-                    v8 = v7->uTextureWidth;
-                    v9 = v7->uTextureHeight;
-                    v10 = v7->uTextureWidth;
+  pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_CharacterUI_InventoryBackground));
+  if (a2)
+    pRenderer->DrawTextureIndexed(8, 305, pIcons_LOD->LoadTexturePtr("fr_strip", TEXTURE_16BIT_PALETTE));
+
+  int i = 0;
+  for (uint i = 0; i < 126; ++i)
+  {
+    int v26 = (int)(player->pInventoryIndices + i);
+
+    if (player->pInventoryIndices[i] <= 0)
+      continue;
+
+    int item_idx = player->pInventoryIndices[i];
+    auto item = &player->pInventoryItems[item_idx - 1];
+    if (!item->uItemID)
+      continue;
+
+    uCellY = 32 * (i / 14) + 17;
+    uCellX = 32 * (i % 14) + 14;
+
+    uint item_texture_id = pIcons_LOD->LoadTexture(pItemsTable->pItems[item->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
+    v7 = pIcons_LOD->GetTexture(item_texture_id);
+
                     v11 = v7->uTextureWidth;
-                    if ( v10 < 14 )
+                    if (v11 < 14)
                         v11 = 14;
-                    if ( (v11 - 14) >> 5 == 0 && v8 < 32 )
-                        uCellX += (32 - v10) / 2;
-                    v12 = v7->uTextureWidth;
-                    if ( v10 < 14 )
-                        v12 = 14;
-                    v13 = v12 - 14;
-                    v14 = v7->uTextureHeight;
+
+                    if ( (v11 - 14) / 32 == 0 && v7->uTextureWidth < 32)
+                        uCellX += (32 - v7->uTextureWidth) / 2;
+                    v13 = v11 - 14;
                     LOBYTE(v13) = v13 & 0xE0;
                     v15 = v13 + 32;
-                    if ( v9 < 14 )
+                    v14 = v7->uTextureHeight;
+                    if (v14 < 14 )
                         v14 = 14;
-                    v16 = pItem->uAttributes;
-                    v17 = uCellX + ((v15 - v10) >> 1) + pSRZBufferLineOffsets[uCellY + ((((v14 - 14) & 0xFFFFFFE0) - v9 + 32) >> 1)];
-                    if ( !(v16 & 0xF0) )
-                        {
-                        if (pItem->Identified() || pCurrentScreen != SCREEN_HOUSE )
-                            {
-                            if (pItem->Broken())
-                                pRenderer->DrawTransparentRedShade(uCellX, uCellY, v7);
-                            else
-                                pRenderer->DrawTextureTransparent(uCellX, uCellY, v7);
-                            }
-                        else
-                            {
-                            pRenderer->DrawTransparentGreenShade(uCellX, uCellY, v7);
-                            }
-                        ZBuffer_Fill(&v23[v17], uTextureId, v24 + 1);
-                        pPlayer = pPlayer2;
-                        //goto LABEL_34;
-                        ++uCellID;
-                        v26 += 4;
-                        continue;
-                        }
-                    if ( (unsigned __int8)(v16 & 0xF0) != 16 )
-                        {
-                        if ( (unsigned __int8)(v16 & 0xF0) == 32 )
-                            {
-                            v20 = "sp28a";
-                            pTexture = pIcons_LOD->LoadTexturePtr(v20, TEXTURE_16BIT_PALETTE);
-                            dword_50C9A8 -= pEventTimer->uTimeElapsed;
-                            if ( dword_50C9A8 <= 0 )
-                                {
-                                dword_50C9A8 = 0;
-                                LOBYTE(pItem2->uAttributes) &= 0xFu;
-                                ptr_50C9A4 = 0;
-                                }
-                            v19 = (double)GetTickCount() * 0.1;
-                            pRenderer->_4A63E6(uCellX, uCellY, v7, pTexture, (signed __int64)v19, 0, 255);
-                            ZBuffer_Fill(&v23[v17], uTextureId, v24 + 1);
-                            pPlayer = pPlayer2;
-                            //goto LABEL_34;
-                            ++uCellID;
-                            v26 += 4;
-                            continue;
-                            }
-                        if ( (unsigned __int8)(v16 & 0xF0) == 64 )
-                            {
-                            v20 = "sp30a";
-                            pTexture = pIcons_LOD->LoadTexturePtr(v20, TEXTURE_16BIT_PALETTE);
-                            dword_50C9A8 -= pEventTimer->uTimeElapsed;
-                            if ( dword_50C9A8 <= 0 )
-                                {
-                                dword_50C9A8 = 0;
-                                LOBYTE(pItem2->uAttributes) &= 0xFu;
-                                ptr_50C9A4 = 0;
-                                }
-                            v19 = (double)GetTickCount() * 0.1;
-                            pRenderer->_4A63E6(uCellX, uCellY, v7, pTexture, (signed __int64)v19, 0, 255);
-                            ZBuffer_Fill(&v23[v17], uTextureId, v24 + 1);
-                            pPlayer = pPlayer2;
-                            //goto LABEL_34;
-                            ++uCellID;
-                            v26 += 4;
-                            continue;
-                            }
-                        if ( (unsigned __int8)(v16 & 0xF0) == 128 )
-                            {
-                            v20 = "sp91a";
-                            pTexture = pIcons_LOD->LoadTexturePtr(v20, TEXTURE_16BIT_PALETTE);
-                            dword_50C9A8 -= pEventTimer->uTimeElapsed;
-                            if ( dword_50C9A8 <= 0 )
-                                {
-                                dword_50C9A8 = 0;
-                                LOBYTE(pItem2->uAttributes) &= 0xFu;
-                                ptr_50C9A4 = 0;
-                                }
-                            v19 = (double)GetTickCount() * 0.1;
-                            pRenderer->_4A63E6(uCellX, uCellY, v7, pTexture, (signed __int64)v19, 0, 255);
-                            ZBuffer_Fill(&v23[v17], uTextureId, v24 + 1);
-                            pPlayer = pPlayer2;
-                            //goto LABEL_34;
-                            ++uCellID;
-                            v26 += 4;
-                            continue;
-                            }
-                        }
-                    v20 = "sptext01";
-                    pTexture = pIcons_LOD->LoadTexturePtr(v20, TEXTURE_16BIT_PALETTE);
-                    dword_50C9A8 -= pEventTimer->uTimeElapsed;
-                    if ( dword_50C9A8 <= 0 )
-                        {
-                        dword_50C9A8 = 0;
-                        LOBYTE(pItem2->uAttributes) &= 0xFu;
-                        ptr_50C9A4 = 0;
-                        }
-                    v19 = (double)GetTickCount() * 0.1;
-                    pRenderer->_4A63E6(uCellX, uCellY, v7, pTexture, (signed __int64)v19, 0, 255);
-                    ZBuffer_Fill(&v23[v17], uTextureId, v24 + 1);
-                    pPlayer = pPlayer2;
-                    }
-                }
-            //LABEL_34:
-            ++uCellID;
-            v26 += 4;
-            }
-            while ( uCellID < 126 );
-        }
+                    v17 = uCellX + ((v15 - v7->uTextureWidth) >> 1) + pSRZBufferLineOffsets[uCellY + ((((v14 - 14) & 0xFFFFFFE0) - v7->uTextureHeight + 32) >> 1)];
+
+
+    if (!(item->uAttributes & 0xF0))
+    {
+      if (item->Identified() || pCurrentScreen != SCREEN_HOUSE)
+      {
+        if (item->Broken())
+          pRenderer->DrawTransparentRedShade(uCellX, uCellY, v7);
+        else
+          pRenderer->DrawTextureTransparent(uCellX, uCellY, v7);
+      }
+      else
+        pRenderer->DrawTransparentGreenShade(uCellX, uCellY, v7);
+
+      ZBuffer_Fill(&pRenderer->pActiveZBuffer[v17], item_texture_id, item_idx);
+      continue;
+    }
+    else
+    {
+      switch (item->uAttributes & 0xF0)
+      {
+        case ITEM_AURA_EFFECT_RED:    pTexture = pIcons_LOD->LoadTexturePtr("sptext01", TEXTURE_16BIT_PALETTE); break;
+        case ITEM_AURA_EFFECT_BLUE:   pTexture = pIcons_LOD->LoadTexturePtr("sp28a", TEXTURE_16BIT_PALETTE);    break;
+        case ITEM_AURA_EFFECT_GREEN:  pTexture = pIcons_LOD->LoadTexturePtr("sp30a", TEXTURE_16BIT_PALETTE);    break;
+        case ITEM_AURA_EFFECT_PURPLE: pTexture = pIcons_LOD->LoadTexturePtr("sp91a", TEXTURE_16BIT_PALETTE);    break;
+      }
+
+      _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
+      if (_50C9A8_item_enchantment_timer <= 0)
+      {
+        _50C9A8_item_enchantment_timer = 0;
+        LOBYTE(item->uAttributes) &= 0xF;
+        ptr_50C9A4 = 0;
+      }
+
+      pRenderer->_4A63E6(uCellX, uCellY, v7, pTexture, GetTickCount() * 0.1, 0, 255);
+      ZBuffer_Fill(&pRenderer->pActiveZBuffer[v17], item_texture_id, item_idx);
+    }
+  }
+}
 
 //----- (0041A556) --------------------------------------------------------
 void draw_leather()
@@ -749,7 +657,7 @@
       case WINDOW_CharacterWindow_Inventory:                                                        // inventory and other
         sub_4196A0();
         sub_419379();
-        CharacterUI_InventoryTab_Draw(uPlayerIdx, 0);
+        CharacterUI_InventoryTab_Draw(pPlayers[uPlayerIdx], false);
         v2 = pIcons_LOD->LoadTexture("ib-cd3-d", TEXTURE_16BIT_PALETTE);
         pTexture = pIcons_LOD->GetTexture(v2);
         pButton = pCharacterScreen_InventoryBtn;
@@ -978,10 +886,10 @@
         if ( (item_MainHand4->uAttributes & 0xF0) == 128 )
           v167 = "sp91a";
         v16 = pIcons_LOD->LoadTexturePtr(v167, TEXTURE_16BIT_PALETTE);
-        dword_50C9A8 -= pEventTimer->uTimeElapsed;
-        if ( dword_50C9A8 <= 0 )
+        _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
+        if ( _50C9A8_item_enchantment_timer <= 0 )
         {
-          dword_50C9A8 = 0;
+          _50C9A8_item_enchantment_timer = 0;
           item_MainHand4->uAttributes &= 0xFu;
           ptr_50C9A4 = 0;
         }
@@ -1025,10 +933,10 @@
         if ( (itemBow->uAttributes & 0xF0) == 128 )
           v168 = "sp91a";
         a2b = pIcons_LOD->LoadTexturePtr(v168, TEXTURE_16BIT_PALETTE);
-        dword_50C9A8 -= pEventTimer->uTimeElapsed;
-        if ( dword_50C9A8 <= 0 )
+        _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
+        if ( _50C9A8_item_enchantment_timer <= 0 )
         {
-          dword_50C9A8 = 0;
+          _50C9A8_item_enchantment_timer = 0;
           itemBow->uAttributes &= 0xFu;
           ptr_50C9A4 = 0;
         }
@@ -1087,10 +995,10 @@
           if ( (item_Cloak->uAttributes & 0xF0) == 128 )
             v169 = "sp91a";
           v39 = pIcons_LOD->LoadTexturePtr(v169, TEXTURE_16BIT_PALETTE);
-          dword_50C9A8 -= pEventTimer->uTimeElapsed;
-          if ( dword_50C9A8 <= 0 )
+          _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
+          if ( _50C9A8_item_enchantment_timer <= 0 )
           {
-            dword_50C9A8 = 0;
+            _50C9A8_item_enchantment_timer = 0;
             item_Cloak->uAttributes &= 0xFu;
             ptr_50C9A4 = 0;
           }
@@ -1155,10 +1063,10 @@
           if ( (item_Armor->uAttributes & 0xF0) == 128 )
             v170 = "sp91a";
           v51 = pIcons_LOD->LoadTexturePtr(v170, TEXTURE_16BIT_PALETTE);
-          dword_50C9A8 -= pEventTimer->uTimeElapsed;
-          if ( dword_50C9A8 <= 0 )
+          _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
+          if ( _50C9A8_item_enchantment_timer <= 0 )
           {
-            dword_50C9A8 = 0;
+            _50C9A8_item_enchantment_timer = 0;
             item_Armor->uAttributes &= 0xFu;
             ptr_50C9A4 = 0;
           }
@@ -1211,10 +1119,10 @@
                 if ( (item_Armor->uAttributes & 0xF0) == 128 )
                   v173 = "sp91a";
                 v96 = (char *)pIcons_LOD->LoadTexturePtr(v173, TEXTURE_16BIT_PALETTE);
-                dword_50C9A8 -= pEventTimer->uTimeElapsed;
-                if ( dword_50C9A8 <= 0 )
+                _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
+                if ( _50C9A8_item_enchantment_timer <= 0 )
                 {
-                  dword_50C9A8 = 0;
+                  _50C9A8_item_enchantment_timer = 0;
                   item_Armor->uAttributes &= 0xFu;
                   ptr_50C9A4 = 0;
                 }
@@ -1256,10 +1164,10 @@
               if ( (item_Armor->uAttributes & 0xF0) == 128 )
                 v178 = "sp91a";
               v96 = (char *)pIcons_LOD->LoadTexturePtr(v178, TEXTURE_16BIT_PALETTE);
-              dword_50C9A8 -= pEventTimer->uTimeElapsed;
-              if ( dword_50C9A8 <= 0 )
+              _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
+              if ( _50C9A8_item_enchantment_timer <= 0 )
               {
-                dword_50C9A8 = 0;
+                _50C9A8_item_enchantment_timer = 0;
                 item_Armor->uAttributes &= 0xFu;
                 ptr_50C9A4 = 0;
               }
@@ -1320,10 +1228,10 @@
           if ( (item_Boot->uAttributes & 0xF0) == 128 )
             v171 = "sp91a";
           v63 = pIcons_LOD->LoadTexturePtr(v171, TEXTURE_16BIT_PALETTE);
-          dword_50C9A8 -= pEventTimer->uTimeElapsed;
-          if ( dword_50C9A8 <= 0 )
+          _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
+          if ( _50C9A8_item_enchantment_timer <= 0 )
           {
-            dword_50C9A8 = 0;
+            _50C9A8_item_enchantment_timer = 0;
             item_Boot->uAttributes &= 0xFu;
             ptr_50C9A4 = 0;
           }
@@ -1391,10 +1299,10 @@
             if ( (item_Belt->uAttributes & 0xF0) == 128 )
               v172 = "sp91a";
             v77 = pIcons_LOD->LoadTexturePtr(v172, TEXTURE_16BIT_PALETTE);
-            dword_50C9A8 -= pEventTimer->uTimeElapsed;
-            if ( dword_50C9A8 <= 0 )
+            _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
+            if ( _50C9A8_item_enchantment_timer <= 0 )
             {
-              dword_50C9A8 = 0;
+              _50C9A8_item_enchantment_timer = 0;
               item_Belt->uAttributes &= 0xFu;
               ptr_50C9A4 = 0;
             }
@@ -1466,10 +1374,10 @@
               if ( (item_CloakCollar->uAttributes & 0xF0) == 128 )
                 v179 = "sp91a";
               a2i = pIcons_LOD->LoadTexturePtr(v179, TEXTURE_16BIT_PALETTE);
-              dword_50C9A8 -= pEventTimer->uTimeElapsed;
-              if ( dword_50C9A8 <= 0 )
+              _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
+              if ( _50C9A8_item_enchantment_timer <= 0 )
               {
-                dword_50C9A8 = 0;
+                _50C9A8_item_enchantment_timer = 0;
                 item_CloakCollar->uAttributes &= 0xFu;
                 ptr_50C9A4 = 0;
               }
@@ -1530,10 +1438,10 @@
           if ( (item_Helm->uAttributes & 0xF0) == 128 )
             v180 = "sp91a";
           v129 = pIcons_LOD->LoadTexturePtr(v180, TEXTURE_16BIT_PALETTE);
-          dword_50C9A8 -= pEventTimer->uTimeElapsed;
-          if ( dword_50C9A8 <= 0 )
+          _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
+          if ( _50C9A8_item_enchantment_timer <= 0 )
           {
-            dword_50C9A8 = 0;
+            _50C9A8_item_enchantment_timer = 0;
             item_Helm->uAttributes &= 0xFu;
             ptr_50C9A4 = 0;
           }
@@ -1594,10 +1502,10 @@
         if ( (item_MainHand3->uAttributes & 0xF0) == 128 )
           v182 = "sp91a";
         v140 = pIcons_LOD->LoadTexturePtr(v182, TEXTURE_16BIT_PALETTE);
-        dword_50C9A8 -= pEventTimer->uTimeElapsed;
-        if ( dword_50C9A8 <= 0 )
+        _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
+        if ( _50C9A8_item_enchantment_timer <= 0 )
         {
-          dword_50C9A8 = 0;
+          _50C9A8_item_enchantment_timer = 0;
           item_MainHand3->uAttributes &= 0xFu;
           ptr_50C9A4 = 0;
         }
@@ -1666,10 +1574,10 @@
         if ( (item_Shield->uAttributes & 0xF0) == 128 )
           v183 = "sp91a";
         v157 = pIcons_LOD->LoadTexturePtr(v183, TEXTURE_16BIT_PALETTE);
-        dword_50C9A8 -= pEventTimer->uTimeElapsed;
-        if ( dword_50C9A8 <= 0 )
+        _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
+        if ( _50C9A8_item_enchantment_timer <= 0 )
         {
-          dword_50C9A8 = 0;
+          _50C9A8_item_enchantment_timer = 0;
           item_Shield->uAttributes &= 0xFu;
           ptr_50C9A4 = 0;
         }
@@ -1743,10 +1651,10 @@
         if ( (item->uAttributes & 0xF0) == 128 )
           spell_texture_name = "sp91a";
         spell_texture = pIcons_LOD->LoadTexturePtr(spell_texture_name, TEXTURE_16BIT_PALETTE);
-        dword_50C9A8 -= pEventTimer->uTimeElapsed;
-        if ( dword_50C9A8 <= 0 )
+        _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
+        if ( _50C9A8_item_enchantment_timer <= 0 )
         {
-          dword_50C9A8 = 0;
+          _50C9A8_item_enchantment_timer = 0;
           item->uAttributes &= 0xFu;
           ptr_50C9A4 = 0;
         }
@@ -1788,10 +1696,10 @@
       if ( (item->uAttributes & 0xF0) == 128 )
         spell_texture_name = "sp91a";
       spell_texture = pIcons_LOD->LoadTexturePtr(spell_texture_name, TEXTURE_16BIT_PALETTE);
-      dword_50C9A8 -= pEventTimer->uTimeElapsed;
-      if ( dword_50C9A8 <= 0 )
+      _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
+      if ( _50C9A8_item_enchantment_timer <= 0 )
       {
-        dword_50C9A8 = 0;
+        _50C9A8_item_enchantment_timer = 0;
         item->uAttributes &= 0xFu;
         ptr_50C9A4 = 0;
       }
@@ -1836,10 +1744,10 @@
     if ( (item->uAttributes & 0xF0) == 128 )
       spell_texture_name = "sp91a";
     spell_texture = pIcons_LOD->LoadTexturePtr(spell_texture_name, TEXTURE_16BIT_PALETTE);
-    dword_50C9A8 -= pEventTimer->uTimeElapsed;
-    if ( dword_50C9A8 <= 0 )
+    _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
+    if ( _50C9A8_item_enchantment_timer <= 0 )
     {
-      dword_50C9A8 = 0;
+      _50C9A8_item_enchantment_timer = 0;
       item->uAttributes &= 0xFu;
       ptr_50C9A4 = 0;
     }
--- a/UIHouses.cpp	Sat May 11 17:00:43 2013 +0200
+++ b/UIHouses.cpp	Sat May 11 17:56:12 2013 +0200
@@ -3017,7 +3017,7 @@
     case HOUSE_DIALOGUE_SHOP_SELL:
     {
       draw_leather();
-      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+      CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
       DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);
       if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
         return;
@@ -3036,7 +3036,7 @@
     case HOUSE_DIALOGUE_SHOP_IDENTIFY:
     {
       draw_leather();
-      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+      CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
       DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);
       if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
         return;
@@ -3064,7 +3064,7 @@
     case HOUSE_DIALOGUE_SHOP_REPAIR:
     {
       draw_leather();
-      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+      CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
       DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0);
       if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
             return;
@@ -3085,7 +3085,7 @@
     case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT:
     {
       draw_leather();
-      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+      CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
       pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];//sell
       pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];//identify
       pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];//repair
@@ -3575,7 +3575,7 @@
     case HOUSE_DIALOGUE_SHOP_SELL:
     {
       draw_leather();
-      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+      CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
       DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);
       if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
         return;
@@ -3593,7 +3593,7 @@
     case HOUSE_DIALOGUE_SHOP_IDENTIFY:
     {
       draw_leather();
-      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+      CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
       DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);
       if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
         return;
@@ -3619,7 +3619,7 @@
     case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT:
     {
       draw_leather();
-      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+      CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
       pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];
       pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];
       all_text_height = 0;
@@ -4173,7 +4173,7 @@
     case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT:
     {
       draw_leather();
-      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+      CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
       pShopOptions[0] = pGlobalTXT_LocalizationStrings[200]; //"Sell"
       pShopOptions[1] = pGlobalTXT_LocalizationStrings[113]; //"Identify"
       pShopOptions[2] = pGlobalTXT_LocalizationStrings[179]; //"Repair"
@@ -4211,7 +4211,7 @@
     case HOUSE_DIALOGUE_SHOP_SELL:
     {
       draw_leather();
-      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+      CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
       DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);//"Select the Item to Sell"
       if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
         return;
@@ -4231,7 +4231,7 @@
     case HOUSE_DIALOGUE_SHOP_IDENTIFY:
     {
       draw_leather();
-      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+      CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
       DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0); //"Select the Item to Identify"	
       if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
       {
@@ -4265,7 +4265,7 @@
     case HOUSE_DIALOGUE_SHOP_REPAIR:
     {
       draw_leather();
-      CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+      CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
       DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0);
       if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
         return;
@@ -5903,7 +5903,7 @@
   if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT )
   {
     draw_leather();
-    CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+    CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
     pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];// "Sell"
     pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];// "Identify"
     pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];// "Repair"
@@ -5942,7 +5942,7 @@
   if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_SELL)
   {
     draw_leather();
-    CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+    CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
     DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);// "Select the Item to Sell"
     if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()
       || (v11 = pMouse->GetCursorPos(&v107)->x - 14,
@@ -5962,7 +5962,7 @@
   if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_IDENTIFY)
   {
     draw_leather();
-    CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+    CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
     DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);// "Select the Item to Identify"
     if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
     {
@@ -5999,7 +5999,7 @@
   if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_REPAIR)
   {
     draw_leather();
-    CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+    CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
     DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0);// "Select the Item to Repair"
     if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()
       || (pTextHeight = pMouse->GetCursorPos(&v110)->x - 14,
--- a/mm7_1.cpp	Sat May 11 17:00:43 2013 +0200
+++ b/mm7_1.cpp	Sat May 11 17:56:12 2013 +0200
@@ -1360,7 +1360,7 @@
 
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-c", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc-c", 2);
-        pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven-c", 2);
+        pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_CharacterUI_InventoryBackground], "fr_inven-c", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B4], "cornr_ll-c", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B0], "cornr_lr-c", 2);
@@ -1400,7 +1400,7 @@
         uTextureID_PlayerBuff_Hammerhands = pIcons_LOD->LoadTexture("isg-03-c", TEXTURE_16BIT_PALETTE);
         uTextureID_PlayerBuff_PainReflection = pIcons_LOD->LoadTexture("isg-04-c", TEXTURE_16BIT_PALETTE);
         uTextureID_50795C = pIcons_LOD->LoadTexture("evtnpc-c", TEXTURE_16BIT_PALETTE);
-        uTextureID_507958 = pIcons_LOD->LoadTexture("fr_inven", TEXTURE_16BIT_PALETTE);
+        uTextureID_CharacterUI_InventoryBackground = pIcons_LOD->LoadTexture("fr_inven", TEXTURE_16BIT_PALETTE);
         pUIAnim_WizardEye->uIconID = pIconsFrameTable->FindIcon("wizeyeC");
         pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID);
         pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchC");
@@ -1445,7 +1445,7 @@
         pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-a", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc", 2);
-        pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven", 2);
+        pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_CharacterUI_InventoryBackground], "fr_inven", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B4], "cornr_ll", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B0], "cornr_lr", 2);
@@ -1485,7 +1485,7 @@
         uTextureID_PlayerBuff_Hammerhands = pIcons_LOD->LoadTexture("isg-03-a", TEXTURE_16BIT_PALETTE);
         uTextureID_PlayerBuff_PainReflection = pIcons_LOD->LoadTexture("isg-04-a", TEXTURE_16BIT_PALETTE);
         uTextureID_50795C = pIcons_LOD->LoadTexture("evtnpc", TEXTURE_16BIT_PALETTE);
-        uTextureID_507958 = pIcons_LOD->LoadTexture("fr_inven", TEXTURE_16BIT_PALETTE);
+        uTextureID_CharacterUI_InventoryBackground = pIcons_LOD->LoadTexture("fr_inven", TEXTURE_16BIT_PALETTE);
         pUIAnim_WizardEye->uIconID = pIconsFrameTable->FindIcon("wizeyeA");
         pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID);
         pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchA");
@@ -1541,7 +1541,7 @@
       pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-b", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc-b", 2);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven-b", 2);
+      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_CharacterUI_InventoryBackground], "fr_inven-b", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B4], "cornr_ll-b", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_5076B0], "cornr_lr-b", 2);
--- a/mm7_5.cpp	Sat May 11 17:00:43 2013 +0200
+++ b/mm7_5.cpp	Sat May 11 17:56:12 2013 +0200
@@ -1036,7 +1036,7 @@
                       if ( ptr_50C9A4 && ptr_50C9A4->uItemID )
                       {
                         LOBYTE(ptr_50C9A4->uAttributes) &= 0xFu;
-                        dword_50C9A8 = 0;
+                        _50C9A8_item_enchantment_timer = 0;
                         ptr_50C9A4 = 0;
                       }
                       if ( pGUIWindow_Settings )
@@ -10282,7 +10282,7 @@
         {
           pRenderer->ClearZBuffer(0, 479);
           draw_leather();
-          CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+          CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
           pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uExitCancelTextureId));
         }
         continue;
@@ -10330,7 +10330,7 @@
       {
         pRenderer->ClearZBuffer(0, 479);
         draw_leather();
-        CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
+        CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true);
         CharacterUI_DrawPaperdoll(uActiveCharacter);
         pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uTextureID_x_x_u));
         continue;
@@ -10781,7 +10781,7 @@
           HIDWORD(v27->uExpireTime) = HIDWORD(v32);
           v27->uAttributes = v32;
         }
-        dword_50C9A8 = 256;
+        _50C9A8_item_enchantment_timer = 256;
         goto LABEL_92;
       }
       v36 = (70.0 - (double)pParty->pPickedItem.uEnchantmentType) * 0.01;
--- a/mm7_6.cpp	Sat May 11 17:00:43 2013 +0200
+++ b/mm7_6.cpp	Sat May 11 17:56:12 2013 +0200
@@ -3874,7 +3874,7 @@
 					v69->uAttributes |= 8u;
 				}
 				v69->uAttributes |= 0x10u;
-				dword_50C9A8 = 256;
+				_50C9A8_item_enchantment_timer = 256;
 				LODWORD(v727) = 1;
 				break;
 			}
@@ -4964,7 +4964,7 @@
 			continue;
 		}
 		*((int *)v243 + 5) |= 0x40u;
-					dword_50C9A8 = 256;
+					_50C9A8_item_enchantment_timer = 256;
 					LODWORD(v727) = 1;
 					break;
 			}
@@ -5034,7 +5034,7 @@
 LABEL_612:
 								_this->uItemID |= 0x20u;
 
-								dword_50C9A8 = 256;
+								_50C9A8_item_enchantment_timer = 256;
 								LODWORD(v727) = 1;
 								break;
 							}
@@ -5386,7 +5386,7 @@
 								+ rand() % 10;//(pItemsTable->field_116D8[19] - pItemsTable->field_116D8[18] + 1);
 		}
 		v294->uAttributes |= 0x20u;
-		dword_50C9A8 = 256;
+		_50C9A8_item_enchantment_timer = 256;
 		LODWORD(v727) = 1;
 		break;
 		}
@@ -7131,7 +7131,7 @@
 			*(int *)(v592 + 20) |= 8u;
 		}
 		*(char *)(v592 + 20) |= 0x80u;
-		dword_50C9A8 = 256;
+		_50C9A8_item_enchantment_timer = 256;
 		LODWORD(v727) = 1;
 		break;
 			}
--- a/mm7_data.cpp	Sat May 11 17:00:43 2013 +0200
+++ b/mm7_data.cpp	Sat May 11 17:56:12 2013 +0200
@@ -1604,7 +1604,7 @@
 int dword_50C998_turnbased_icon_1A; // weak
 int uSpriteID_Spell11; // idb
 _UNKNOWN unk_50C9A0; // weak
-int dword_50C9A8; // weak
+int _50C9A8_item_enchantment_timer; // weak
 int dword_50C9AC; // weak
 int dword_50C9D0; // weak
 int dword_50C9D4; // weak
--- a/mm7_data.h	Sat May 11 17:00:43 2013 +0200
+++ b/mm7_data.h	Sat May 11 17:56:12 2013 +0200
@@ -1032,7 +1032,7 @@
 extern int dword_50C998_turnbased_icon_1A; // weak
 extern int uSpriteID_Spell11; // idb
 extern _UNKNOWN unk_50C9A0; // weak
-extern int dword_50C9A8; // weak
+extern int _50C9A8_item_enchantment_timer; // weak
 extern int dword_50C9AC; // weak
 extern int dword_50C9D0; // weak
 extern int dword_50C9D4; // weak