diff UICharacter.cpp @ 984:d982fffb8b96

CharacterUI_InventoryTab_Draw cleaned.
author Nomad
date Sat, 11 May 2013 17:56:12 +0200
parents 1462a5f12b65
children 087a9af8e0ec c5d8ea1e6ccb d5796c318653
line wrap: on
line diff
--- 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;
     }