changeset 2092:a869b0376b48

enums and BLV_UpdateDoors()
author Ritor1
date Thu, 12 Dec 2013 13:55:42 +0600
parents 75edfa36c4de
children 52415f8bf7c2
files DecalBuilder.cpp Game.cpp Indoor.cpp Indoor.h Outdoor.cpp Outdoor.h Render.cpp UI/Books/UIMapBook.cpp UI/UICharacter.cpp UI/UIPopup.cpp UI/UIShops.cpp UI/UiGame.cpp stru10.cpp
diffstat 13 files changed, 335 insertions(+), 535 deletions(-) [+]
line wrap: on
line diff
--- a/DecalBuilder.cpp	Thu Dec 12 09:28:05 2013 +0600
+++ b/DecalBuilder.cpp	Thu Dec 12 13:55:42 2013 +0600
@@ -456,9 +456,7 @@
   
   BLVFace* pFace = &pIndoor->pFaces[uFaceID];
 
-  if (pFace->uAttributes & 0x400000)
-    return true;
-  if (pFace->Fluid())
+  if ( pFace->Indoor_sky() || pFace->Fluid() )
     return true;
   for (uint i = 0; i < pBloodsplatContainer->std__vector_pBloodsplats_size; ++i)
   {
@@ -495,7 +493,7 @@
 
 	this->uNumDecals = 0;
 	v10 = pBloodsplatContainer->std__vector_pBloodsplats_size;
-	if ( !(pFace->uAttributes & 0x400000) && !(pFace->uAttributes & 0x10) )
+	if ( !pFace->Indoor_sky() && !pFace->Fluid() )
 	{
 		for(int i = 0; i < pBloodsplatContainer->std__vector_pBloodsplats_size; i++ )
 		{
--- a/Game.cpp	Thu Dec 12 09:28:05 2013 +0600
+++ b/Game.cpp	Thu Dec 12 13:55:42 2013 +0600
@@ -2965,7 +2965,7 @@
             if ( uCurrentlyLoadedLevelType != 1 )
             {
               pODMFace = &pOutdoor->pBModels[v44 >> 9].pFaces[v46 & 0x3F];
-              if ( !(pODMFace->uAttributes & 0x02000000) || !pODMFace->sCogTriggeredID )
+              if ( !pODMFace->Clickable() || !pODMFace->sCogTriggeredID )
                 continue;
               v44 = uNumSeconds;
               pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C;
@@ -2982,7 +2982,7 @@
               continue;
             }
             pBLVFace = &pIndoor->pFaces[v46];
-            if ( !(BYTE3(pBLVFace->uAttributes) & 2) )
+            if ( !pBLVFace->Clickable() )
               continue;
             v48 = pIndoor->pFaceExtras[pBLVFace->uFaceExtraID].uEventID == 0;
           }
--- a/Indoor.cpp	Thu Dec 12 09:28:05 2013 +0600
+++ b/Indoor.cpp	Thu Dec 12 13:55:42 2013 +0600
@@ -554,7 +554,7 @@
           stru_F7B60C.face_plane.dist = pFace->pFacePlane.dist;
         }
 
-        if (stru_F8AD28.uNumLightsApplied > 0 && !(pFace->uAttributes & FACE_INDOOR_SKY))
+        if (stru_F8AD28.uNumLightsApplied > 0 && !pFace->Indoor_sky())
           pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0);
 
         if (pDecalBuilder->uNumDecals > 0)
@@ -578,7 +578,7 @@
             v27 = pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID];
           }
         }
-        else if (pFace->uAttributes & 0x4000)
+        else if (pFace->uAttributes & FACE_TEXTURE_FRAME)
           v27 = pBitmaps_LOD->pHardwareTextures[pTextureFrameTable->GetFrameTexture(pFace->uBitmapID, pBLVRenderParams->field_0_timer_)];
         else
         {
@@ -586,7 +586,7 @@
           v27 = pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID];
         }
 
-        if (pFace->uAttributes & FACE_INDOOR_SKY)
+        if (pFace->Indoor_sky())
           pRenderer->DrawIndoorSky(uNumVerticesa, uFaceID);
         else
           pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, pFace->GetTexture(), PID(OBJECT_BModel, uFaceID), v17, 0);
@@ -619,7 +619,7 @@
   }
   else
   {
-    if ( pIndoor->pFaces[uFaceID].uAttributes & 0x40 )
+    if ( pIndoor->pFaces[uFaceID].uAttributes & FACE_DONT_CACHE_TEXTURE )
       stru_F8AD28.pDeltaUV[0] += result & pBitmaps_LOD->GetTexture(pIndoor->pFaces[uFaceID].uBitmapID)->uWidthMinus1;
   }
   return result;
@@ -942,7 +942,7 @@
 {
   unsigned int v1; // ecx@2
 
-  if ( uAttributes & 0x4000 )
+  if ( uAttributes & FACE_TEXTURE_FRAME )
     v1 = pTextureFrameTable->GetFrameTexture(this->uBitmapID, pBLVRenderParams->field_0_timer_);
   else
     v1 = uBitmapID;
@@ -1826,7 +1826,7 @@
     strncpy(pTexName, pData, 10);
     pData += 10;
 
-    if (pFace->uAttributes & 0x4000)
+    if (pFace->uAttributes & FACE_TEXTURE_FRAME)
     {
       pFace->uBitmapID = pTextureFrameTable->FindTextureByName(pTexName);
       if (pFace->uBitmapID)
@@ -1834,7 +1834,7 @@
       else
       {
         pFace->uBitmapID = pBitmaps_LOD->LoadTexture(pTexName);
-        pFace->uAttributes &= ~0x4000;
+        pFace->uAttributes &= ~FACE_TEXTURE_FRAME;
       }
     }
     else
@@ -2579,70 +2579,77 @@
 
 
 //----- (00498A41) --------------------------------------------------------
-char BLVFace::_get_normals(Vec3_int_ *a2, Vec3_int_ *a3)
+void BLVFace::_get_normals(Vec3_int_ *a2, Vec3_int_ *a3)
 {
-  BLVFace *v3; // ebx@1
-  int v4; // eax@1
-  signed __int64 v5; // qax@2
-  double v6; // st7@8
   Vec3_float_ a1; // [sp+Ch] [bp-Ch]@8
 
-  v3 = this;
-  LOBYTE(v4) = this->uPolygonType;
-  if ( (char)v4 == POLYGON_VerticalWall )
+  if ( this->uPolygonType == POLYGON_VerticalWall )
   {
     a2->x = -this->pFacePlane_old.vNormal.y;
-    LODWORD(v5) = this->pFacePlane_old.vNormal.x;
-LABEL_9:
-    a2->y = v5;
-    v4 = 0;
+    a2->y = this->pFacePlane_old.vNormal.x;
     a2->z = 0;
+
+    a3->x = 0;
     a3->y = 0;
     a3->z = 0xFFFF0000u;
-LABEL_11:
-    a3->x = v4;
+
     goto LABEL_12;
   }
-  if ( (char)v4 == POLYGON_Floor || (char)v4 == POLYGON_Ceiling )
-  {
-LABEL_10:
-    v4 = 0;
+  if ( this->uPolygonType == POLYGON_Floor || this->uPolygonType == POLYGON_Ceiling )
+  {
     a2->x = 0x10000u;
+    a2->y = 0;
     a2->z = 0;
-    a2->y = 0;
+
+    a3->x = 0;
     a3->y = 0xFFFF0000u;
     a3->z = 0;
-    goto LABEL_11;
-  }
-  if ( (char)v4 == POLYGON_InBetweenFloorAndWall || (char)v4 == POLYGON_InBetweenCeilingAndWall )
+
+    goto LABEL_12;
+  }
+  if ( this->uPolygonType == POLYGON_InBetweenFloorAndWall || this->uPolygonType == POLYGON_InBetweenCeilingAndWall )
   {
     if ( abs(this->pFacePlane_old.vNormal.z) < 46441 )
     {
-      a1.x = (double)-v3->pFacePlane_old.vNormal.y;
-      a1.y = (double)v3->pFacePlane_old.vNormal.x;
+      a1.x = (double)-this->pFacePlane_old.vNormal.y;
+      a1.y = (double)this->pFacePlane_old.vNormal.x;
       a1.z = 0.0;
       a1.Normalize();
-      v6 = a1.y * 65536.0;
+
       a2->x = (signed __int64)(a1.x * 65536.0);
-      v5 = (signed __int64)v6;
-      goto LABEL_9;
+      a2->y = (signed __int64)(a1.y * 65536.0);
+      a2->z = 0;
+
+      a3->y = 0;
+      a3->z = 0xFFFF0000u;
+      a3->x = 0;
+
+      goto LABEL_12;
     }
-    goto LABEL_10;
+    a2->x = 0x10000u;
+    a2->y = 0;
+    a2->z = 0;
+
+    a3->x = 0;
+    a3->y = 0xFFFF0000u;
+    a3->z = 0;
+
+    goto LABEL_12;
   }
 LABEL_12:
-  if ( BYTE2(v3->uAttributes) & 0x80 )
+  if ( BYTE2(this->uAttributes) & 0x80 )
   {
     a2->x = -a2->x;
     a2->y = -a2->y;
     a2->z = -a2->z;
   }
-  if ( BYTE3(v3->uAttributes) & 1 )
+  if ( BYTE3(this->uAttributes) & 1 )
   {
     a3->x = -a3->x;
     a3->y = -a3->y;
     a3->z = -a3->z;
   }
-  return v4;
+  return;
 }
 
 //----- (0044C23B) --------------------------------------------------------
@@ -2675,40 +2682,19 @@
 //----- (0046F228) --------------------------------------------------------
 void  BLV_UpdateDoors()
 {
-  //int v0; // ebx@1
-  //int v1; // edi@1
-  //BLVDoor *v2; // esi@3
-  //unsigned __int16 v3; // ax@3
-  //unsigned int v4; // ecx@5
-  //int v5; // eax@8
-  //int v6; // ecx@8
-  //int v7; // eax@12
-  //int v8; // eax@16
-  //unsigned __int8 v9; // zf@18
-  //char v10; // sf@18
-  //unsigned __int8 v11; // of@18
-  //int v12; // edi@19
-  //int v13; // ecx@19
-  //__int16 v14; // ax@19
-  BLVFace *v15; // ebx@24
-  //unsigned __int16 *v16; // ecx@24
+  BLVFace *face; // ebx@24
   Vec3_short_ *v17; // esi@24
   int v18; // eax@24
   int v19; // edx@24
   signed int v20; // eax@24
-  //Vec3_short_ *v21; // ecx@24
-  //double v22; // st7@24
-  //double v23; // st6@24
   int v24; // esi@25
   int v25; // eax@25
-  //BLVDoor *v26; // edi@25
   signed __int64 v27; // qtt@27
   BLVFaceExtra *v28; // esi@32
   int v29; // ecx@34
   int v30; // edx@34
   unsigned __int64 v31; // qax@34
   int v32; // eax@34
-  //unsigned __int16 *v33; // eax@35
   Vec3_short_ *v34; // eax@35
   int v35; // ecx@35
   int v36; // edx@35
@@ -2716,381 +2702,187 @@
   signed int v38; // edx@35
   int v39; // eax@35
   int v40; // edx@35
-  //unsigned __int8 v41; // cf@35
-  //unsigned __int16 *v42; // edi@36
   Vec3_short_ *v43; // edi@36
-  //int v44; // ecx@36
-  //int v45; // edi@36
-  //int v46; // ecx@36
-  //__int16 *v47; // edx@44
-  //int v48; // ecx@44
   unsigned int v49; // ecx@46
   unsigned __int16 v50; // ax@48
   unsigned int v51; // eax@51
   unsigned __int16 v52; // ax@54
   int v53; // ecx@57
-  //int v54; // edx@57
   unsigned __int64 v55; // qax@57
   int v56; // ecx@58
   int v57; // eax@58
-  //int v58; // eax@59
-  //SoundID v59; // [sp-24h] [bp-88h]@12
-  //signed int v60; // [sp-20h] [bp-84h]@12
-  //unsigned int v61; // [sp-1Ch] [bp-80h]@12
-  //signed int v62; // [sp-18h] [bp-7Ch]@12
-  //signed int v63; // [sp-14h] [bp-78h]@12
-  //int v64; // [sp-10h] [bp-74h]@12
-  //unsigned int v65; // [sp-Ch] [bp-70h]@12
-  //int v66; // [sp-8h] [bp-6Ch]@12
   Vec3_int_ v67;
-  //int v67; // [sp+8h] [bp-5Ch]@31
-  //int v68; // [sp+Ch] [bp-58h]@34
-  //int v69; // [sp+10h] [bp-54h]@34
   Vec3_int_ v70;
-  //int v70; // [sp+14h] [bp-50h]@31
-  //int v71; // [sp+18h] [bp-4Ch]@34
-  //int v72; // [sp+1Ch] [bp-48h]@34
   int v73; // [sp+20h] [bp-44h]@24
-  //__int16 v74; // [sp+24h] [bp-40h]@24
   int v75; // [sp+28h] [bp-3Ch]@36
   int v76; // [sp+2Ch] [bp-38h]@36
   int v77; // [sp+30h] [bp-34h]@36
-  //int v78; // [sp+34h] [bp-30h]@36
-  //int v79; // [sp+38h] [bp-2Ch]@19
-  //unsigned int v80; // [sp+3Ch] [bp-28h]@2
-  //int v81; // [sp+40h] [bp-24h]@1
   int v82; // [sp+44h] [bp-20h]@35
   int v83; // [sp+48h] [bp-1Ch]@34
   int v84; // [sp+4Ch] [bp-18h]@34
   int v85; // [sp+50h] [bp-14h]@19
   SoundID eDoorSoundID; // [sp+54h] [bp-10h]@1
-  //BLVDoor *v87; // [sp+58h] [bp-Ch]@3
   int v88; // [sp+5Ch] [bp-8h]@18
   int v89; // [sp+60h] [bp-4h]@6
 
-  //v0 = 0;
-  //v1 = 0;
   eDoorSoundID = (SoundID)pDoorSoundIDsByLocationID[dword_6BE13C_uCurrentlyLoadedLocationID];
-  //v81 = 0;
-  //if ( pIndoor->uNumDoors > 0 )
   for (uint i = 0; i < pIndoor->uNumDoors; ++i)
   {
     BLVDoor* door = &pIndoor->pDoors[i];
-    //v80 = 0;
-    //do
-    //{
-      //v2 = &pIndoor->pDoors[v80 / 0x50];
-      //v87 = &pIndoor->pDoors[v80 / 0x50];
-      //v3 = door->uState;
-      if (door->uState == BLVDoor::Closed || door->uState == BLVDoor::Open)
+    if (door->uState == BLVDoor::Closed || door->uState == BLVDoor::Open)
+    {
+      door->uAttributes &= 0xFFFFFFFDu;
+      continue;
+    }
+    door->uTimeSinceTriggered += pEventTimer->uTimeElapsed;
+    if (door->uState == BLVDoor::Opening)
+    {
+      v89 = (signed int)(door->uTimeSinceTriggered * door->uCloseSpeed) / 128;
+      if ( v89 >= door->uMoveLength )
+      {
+        v89 = door->uMoveLength;
+        door->uState = BLVDoor::Open;
+        if ( !(door->uAttributes & 6) && door->uNumVertices != 0)
+          pAudioPlayer->PlaySound((SoundID)((int)eDoorSoundID + 1), PID(OBJECT_BLVDoor,i), 0, -1, 0, 0, 0, 0);
+        goto LABEL_18;
+      }
+    }
+    else
+    {
+      signed int v5 = (signed int)(door->uTimeSinceTriggered * door->uOpenSpeed) / 128;
+      if ( v5 >= door->uMoveLength)
       {
-        door->uAttributes &= 0xFFFFFFFDu;
-        goto LABEL_62;
+        v89 = 0;
+        door->uState = BLVDoor::Closed;
+        if ( !(door->uAttributes & 6) && door->uNumVertices != 0)
+          pAudioPlayer->PlaySound((SoundID)((int)eDoorSoundID + 1), PID(OBJECT_BLVDoor,i), 0, -1, 0, 0, 0, 0);
+        goto LABEL_18;
       }
-      door->uTimeSinceTriggered += pEventTimer->uTimeElapsed;
-      //v4 = door->uTimeSinceTriggered;
-      if (door->uState == BLVDoor::Opening)
+      v89 = door->uMoveLength - v5;
+    }
+    if ( !(door->uAttributes & 6) && door->uNumVertices)
+      pAudioPlayer->PlaySound(eDoorSoundID, PID(OBJECT_BLVDoor,i), 1, -1, 0, 0, 0, 0);
+LABEL_18:
+    for (uint j = 0; j < door->uNumVertices; ++j)
+    {
+      pIndoor->pVertices[door->pVertexIDs[j]].x = ((unsigned int)(door->vDirection.x * v89) >> 16) + door->pXOffsets[j];
+      pIndoor->pVertices[door->pVertexIDs[j]].y = ((unsigned int)(door->vDirection.y * v89) >> 16) + door->pYOffsets[j];
+      pIndoor->pVertices[door->pVertexIDs[j]].z = ((unsigned int)(door->vDirection.z * v89) >> 16) + door->pZOffsets[j];
+    }
+    for ( v88 = 0; v88 < door->uNumFaces; ++v88 )
+    {
+      face = &pIndoor->pFaces[door->pFaceIDs[v88]];
+      v17 = &pIndoor->pVertices[face->pVertexIDs[0]];
+      v18 = face->pFacePlane_old.vNormal.y;
+      v73 = *(int *)&v17->x;
+      v19 = face->pFacePlane_old.vNormal.z;
+      v20 = -(v19 * (int)v17->z + (signed __int16)v73 * face->pFacePlane_old.vNormal.x + SHIWORD(v73) * v18);
+      face->pFacePlane_old.dist = v20;
+      face->pFacePlane.dist = -((double)v17->z * face->pFacePlane.vNormal.z
+                             + (double)v17->y * face->pFacePlane.vNormal.y
+                             + (double)v17->x * face->pFacePlane.vNormal.x);
+      if ( v19 )
       {
-        v89 = (signed int)(door->uTimeSinceTriggered * door->uCloseSpeed) / 128;
-        if ( v89 >= door->uMoveLength )
-        {
-          v89 = door->uMoveLength;
-          door->uState = BLVDoor::Open;
-LABEL_10:
-          if ( !(door->uAttributes & 6) && door->uNumVertices != 0)
-          {
-            //v66 = 0;
-            //v65 = 0;
-            //v64 = 0;
-            //v7 = PID(OBJECT_BLVDoor,i);
-            //v63 = 0;
-            //v62 = -1;
-            //LOBYTE(v7) = PID(OBJECT_BLVDoor,i);
-            //v61 = 0;
-            //v60 = PID(OBJECT_BLVDoor,i);
-            //v59 = (SoundID)((int)eDoorSoundID + 1);
-//LABEL_17:
-            pAudioPlayer->PlaySound((SoundID)((int)eDoorSoundID + 1), PID(OBJECT_BLVDoor,i), 0, -1, 0, 0, 0, 0);
-            //goto LABEL_18;
-          }
-          goto LABEL_18;
-        }
+        v24 = abs(v20 >> 15);
+        v25 = abs(face->pFacePlane_old.vNormal.z);
+        if ( v24 > v25 )
+          Error("Door Error\ndoor id: %i\nfacet no: %i\n\nOverflow dividing facet->d [%i] by facet->nz [%i]",
+            door->uDoorID, door->pFaceIDs[v88], face->pFacePlane_old.dist, face->pFacePlane_old.vNormal.z);
+        LODWORD(v27) = face->pFacePlane_old.dist << 16;
+        HIDWORD(v27) = face->pFacePlane_old.dist >> 16;
+        face->zCalc3 = -v27 / face->pFacePlane_old.vNormal.z;
+      }
+      if ( face->uAttributes & FACE_TEXTURE_FLOW || pRenderer->pRenderD3D )
+        face->_get_normals(&v70, &v67);
+      v28 = &pIndoor->pFaceExtras[face->uFaceExtraID];
+      if ( !pRenderer->pRenderD3D )
+      {
+        if ( !(face->uAttributes & FACE_TEXTURE_FLOW) )
+          continue;
+        v83 = (unsigned __int64)(door->vDirection.x * (signed __int64)v70.x) >> 16;
+        v85 = (unsigned __int64)(door->vDirection.y * (signed __int64)v70.y) >> 16;
+        v84 = (unsigned __int64)(door->vDirection.z * (signed __int64)v70.z) >> 16;
+        v29 = v89;
+        v28->sTextureDeltaU = -((v83 + v85 + v84) * (signed __int64)v89) >> 16;
+        v85 = (unsigned __int64)(door->vDirection.x * (signed __int64)v67.x) >> 16;
+        v83 = (unsigned __int64)(door->vDirection.y * (signed __int64)v67.y) >> 16;
+        v84 = (unsigned __int64)(door->vDirection.z * (signed __int64)v67.z) >> 16;
+        v31 = (v85 + v83 + v84) * (signed __int64)v29;
+        v32 = v31 >> 16;
+        goto LABEL_58;
       }
+      v28->sTextureDeltaU = 0;
+      v28->sTextureDeltaV = 0;
+      v34 = &pIndoor->pVertices[face->pVertexIDs[0]];
+      v35 = v34->z;
+      v36 = v34->y;
+      v82 = v34->x;
+      v37 = v70.x * v82 + v70.y * v36 + v70.z * v35;
+      v38 = v67.x * v82 + v67.y * v36 + v67.z * v35;
+      v39 = v37 >> 16;
+      *face->pVertexUIDs = v39;
+      v40 = v38 >> 16;
+      *face->pVertexVIDs = v40;
+      v84 = v39;
+      v82 = v40;
+      for (uint j = 1; j < face->uNumVertices; ++j)
+      {
+        v43 = &pIndoor->pVertices[face->pVertexIDs[j]];
+        v76 = ((__int64)v70.z * v43->z + (__int64)v70.x * v43->x + (__int64)v70.y * v43->y) >> 16;
+        v77 = ((__int64)v67.x * v43->x + (__int64)v67.y * v43->y + (__int64)v43->z * v67.z) >> 16;
+        if ( v76 < v39 )
+          v39 = v76;
+        if ( v77 < v40 )
+          v40 = v77;
+        if ( v76 > v84 )
+          v84 = v76;
+        if ( v77 > v82 )
+          v82 = v77;
+        face->pVertexUIDs[j] = v76;
+        face->pVertexVIDs[j] = v77;
+      }
+      if ( face->uAttributes & FACE_UNKNOW3 )
+        v28->sTextureDeltaU -= v39;
       else
       {
-        signed int v5 = (signed int)(door->uTimeSinceTriggered * door->uOpenSpeed) / 128;
-        //v6 = door->uMoveLength;
-        if ( v5 >= door->uMoveLength)
+        if ( SBYTE1(face->uAttributes) < 0 )
         {
-          v89 = 0;
-          door->uState = BLVDoor::Closed;
-          goto LABEL_10;
+          if ( face->uBitmapID != -1 )
+            v28->sTextureDeltaU -= v84 + pBitmaps_LOD->pTextures[face->uBitmapID].uTextureWidth;
         }
-        v89 = door->uMoveLength - v5;
-      }
-      if ( !(door->uAttributes & 6) && door->uNumVertices)
-      {
-        //v66 = 0;
-        //v65 = 0;
-        //v64 = 0;
-        //v8 = PID(OBJECT_BLVDoor,i);
-        //v63 = 0;
-        //v62 = -1;
-        //LOBYTE(v8) = 8 * v1 | 1;
-        //v61 = 1;
-        //v60 = PID(OBJECT_BLVDoor,i);
-        //v59 = eDoorSoundID;
-        pAudioPlayer->PlaySound(eDoorSoundID, PID(OBJECT_BLVDoor,i), 1, -1, 0, 0, 0, 0);
-        //goto LABEL_18;
       }
-LABEL_18:
-      //v11 = __OFSUB__(v2->uNumVertices, 0);
-      //v9 = v2->uNumVertices == 0;
-      //v10 = (signed __int16)(v2->uNumVertices - 0) < 0;
-      //v88 = 0;
-      //if (door->uNumVertices > 0)
-      for (uint j = 0; j < door->uNumVertices; ++j)
+      if ( face->uAttributes & 8 )
+        v28->sTextureDeltaV -= v40;
+      else
       {
-        //do
-        //{
-          //v12 = v88;
-          //v13 = door->pVertexIDs[v88];
-          //v85 = v89;
-          //v79 = door->vDirection.x;
-          //v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16;
-          //v13 *= 6;
-          pIndoor->pVertices[door->pVertexIDs[j]].x = ((unsigned int)(door->vDirection.x * v89) >> 16) + door->pXOffsets[j];
-          //v85 = v89;
-          //v79 = door->vDirection.y;
-          //v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16;
-          pIndoor->pVertices[door->pVertexIDs[j]].y = ((unsigned int)(door->vDirection.y * v89) >> 16) + door->pYOffsets[j];
-          //v85 = v89;
-          //v79 = door->vDirection.z;
-          //v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16;
-          //v14 = ((unsigned int)(door->vDirection.z * v89) >> 16) + door->pZOffsets[j];
-          pIndoor->pVertices[door->pVertexIDs[j]].z = ((unsigned int)(door->vDirection.z * v89) >> 16) + door->pZOffsets[j];
-          //++v88;
-        //}
-        //while ( v88 < door->uNumVertices );
-        //v1 = v81;
-      }
-      //v11 = __OFSUB__(v2->uNumFaces, 0);
-      //v9 = v2->uNumFaces == 0;
-      //v10 = (signed __int16)(v2->uNumFaces - 0) < 0;
-      v88 = 0;
-      if (door->uNumFaces > 0)
-      {
-        while ( 1 )
+        if ( face->uAttributes & 0x20000 )
         {
-          v15 = &pIndoor->pFaces[door->pFaceIDs[v88]];
-          //v16 = v15->pVertexIDs;
-          v17 = &pIndoor->pVertices[v15->pVertexIDs[0]];
-          v18 = v15->pFacePlane_old.vNormal.y;
-          v73 = *(int *)&v17->x;
-          //v74 = v17->z;
-          v19 = v15->pFacePlane_old.vNormal.z;
-          v20 = -(v19 * (int)v17->z + (signed __int16)v73 * v15->pFacePlane_old.vNormal.x + SHIWORD(v73) * v18);
-          v15->pFacePlane_old.dist = v20;
-          //v21 = &pIndoor->pVertices[v15->pVertexIDs[0]];
-          //v79 = v21->x;
-          //v22 = (double)v21->x;
-          //v23 = (double)v21->y;
-          //v79 = v21->z;
-          v15->pFacePlane.dist = -((double)v17->z * v15->pFacePlane.vNormal.z
-                                 + (double)v17->y * v15->pFacePlane.vNormal.y
-                                 + (double)v17->x * v15->pFacePlane.vNormal.x);
-          if ( v19 )
-          {
-            v24 = abs(v20 >> 15);
-            v25 = abs(v15->pFacePlane_old.vNormal.z);
-            //v26 = v87;
-            if ( v24 > v25 )
-              Error("Door Error\ndoor id: %i\nfacet no: %i\n\nOverflow dividing facet->d [%i] by facet->nz [%i]",
-                door->uDoorID,
-                door->pFaceIDs[v88],
-                v15->pFacePlane_old.dist,
-                v15->pFacePlane_old.vNormal.z);
-            //v79 = v15->pFacePlane_old.vNormal.z;
-            //v85 = v15->pFacePlane_old.dist;
-            LODWORD(v27) = v15->pFacePlane_old.dist << 16;
-            HIDWORD(v27) = v15->pFacePlane_old.dist >> 16;
-            //v85 = v27 / v15->pFacePlane_old.vNormal.z;
-            v15->zCalc3 = -v27 / v15->pFacePlane_old.vNormal.z;
-          }
-          /*else
-          {
-            v26 = v87;
-          }*/
-          if ( BYTE2(v15->uAttributes) & 4 || pRenderer->pRenderD3D )
-            v15->_get_normals(&v70, &v67);
-          v28 = &pIndoor->pFaceExtras[v15->uFaceExtraID];
-          if ( !pRenderer->pRenderD3D )
-          {
-            if ( !(BYTE2(v15->uAttributes) & 4) )
-              goto LABEL_59;
-            //v79 = door->vDirection.x;
-            v83 = (unsigned __int64)(door->vDirection.x * (signed __int64)v70.x) >> 16;
-            //v85 = v71;
-            //v79 = door->vDirection.y;
-            v85 = (unsigned __int64)(door->vDirection.y * (signed __int64)v70.y) >> 16;
-            //v84 = v72;
-            //v79 = door->vDirection.z;
-            v84 = (unsigned __int64)(door->vDirection.z * (signed __int64)v70.z) >> 16;
-            //v79 = v83 + v85 + v84;
-            v29 = v89;
-            //v83 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16;
-            v28->sTextureDeltaU = -((v83 + v85 + v84) * (signed __int64)v89) >> 16;
-            //v79 = door->vDirection.x;
-            v85 = (unsigned __int64)(door->vDirection.x * (signed __int64)v67.x) >> 16;
-            //v83 = v68;
-            //v79 = door->vDirection.y;
-            v83 = (unsigned __int64)(door->vDirection.y * (signed __int64)v67.y) >> 16;
-            //v84 = v69;
-            //v79 = door->vDirection.z;
-            v84 = (unsigned __int64)(door->vDirection.z * (signed __int64)v67.z) >> 16;
-            //v30 = v83 + v84;
-            //v79 = v85 + v30;
-            v31 = (v85 + v83 + v84) * (signed __int64)v29;
-            //v83 = v31 >> 16;
-            v32 = v31 >> 16;
-            goto LABEL_58;
-          }
-          v28->sTextureDeltaU = 0;
-          v28->sTextureDeltaV = 0;
-          //v33 = v15->pVertexIDs;
-          //v85 = 1;
-          v34 = &pIndoor->pVertices[v15->pVertexIDs[0]];
-          v35 = v34->z;
-          v36 = v34->y;
-          v82 = v34->x;
-          //v79 = v36;
-          v37 = v70.x * v82 + v70.y * v36 + v70.z * v35;
-          v38 = v67.x * v82 + v67.y * v36 + v67.z * v35;
-          v39 = v37 >> 16;
-          *v15->pVertexUIDs = v39;
-          v40 = v38 >> 16;
-          *v15->pVertexVIDs = v40;
-          //v41 = v15->uNumVertices < 1u;
-          //v9 = v15->uNumVertices == 1;
-          //v83 = v40;
-          v84 = v39;
-          v82 = v40;
-          //if (v15->uNumVertices > 1)
-          for (uint j = 1; j < v15->uNumVertices; ++j)
-          {
-            //do
-            //{
-              //v42 = v15->pVertexIDs;
-              //v75 = 2 * v85;
-              v43 = &pIndoor->pVertices[v15->pVertexIDs[j]];
-              //v79 = v43->z;
-              //v44 = v43->y;
-              //v45 = v43->x;
-              //v78 = v43->y;
-              v76 = ((__int64)v70.z * v43->z + (__int64)v70.x * v43->x + (__int64)v70.y * v43->y) >> 16;
-              //v46 = (v67 * v45 + v68 * v44 + v79 * v69) >> 16;
-              v77 = ((__int64)v67.x * v43->x + (__int64)v67.y * v43->y + (__int64)v43->z * v67.z) >> 16;
-              if ( v76 < v39 )
-                v39 = v76;
-              if ( v77 < v40 )
-                v40 = v77;
-              if ( v76 > v84 )
-                v84 = v76;
-              if ( v77 > v82 )
-                v82 = v77;
-              //v40 = v83;
-              //v47 = v15->pVertexUIDs;
-              //v48 = v75;
-              //++v85;
-              v15->pVertexUIDs[j] = v76;
-              v15->pVertexVIDs[j] = v77;
-            //}
-            //while ( v85 < v15->uNumVertices );
-            //v26 = v87;
-          }
-          v49 = v15->uAttributes;
-          if ( BYTE1(v49) & 0x10 )
-            goto LABEL_50;
-          if ( SBYTE1(v49) < 0 )
-          {
-            v50 = v15->uBitmapID;
-            if ( v50 != -1 )
-              break;
-          }
-LABEL_51:
-          v51 = v15->uAttributes;
-          if ( v51 & 8 )
-          {
-            v28->sTextureDeltaV -= v40;
-          }
-          else
-          {
-            if ( v51 & 0x20000 )
-            {
-              v52 = v15->uBitmapID;
-              if ( v52 != -1 )
-                v28->sTextureDeltaV -= v82 + pBitmaps_LOD->GetTexture(v52)->uTextureHeight;
-            }
-          }
-          if ( BYTE2(v15->uAttributes) & 4 )
-          {
-            //v75 = door->vDirection.x;
-            v84 = (unsigned __int64)(door->vDirection.x * (signed __int64)v70.x) >> 16;
-            //v82 = v71;
-            //v75 = door->vDirection.y;
-            v82 = (unsigned __int64)(door->vDirection.y * (signed __int64)v70.y) >> 16;
-            //v83 = v72;
-            //v75 = door->vDirection.z;
-            v83 = (unsigned __int64)(door->vDirection.z * (signed __int64)v70.z) >> 16;
-            v75 = v84 + v82 + v83;
-            v53 = v89;
-            v82 = (unsigned __int64)(v75 * (signed __int64)v89) >> 16;
-            v28->sTextureDeltaU = -v82;
-            //v75 = door->vDirection.x;
-            v84 = (unsigned __int64)(door->vDirection.x * (signed __int64)v67.x) >> 16;
-            //v82 = v68;
-            //v75 = door->vDirection.y;
-            v82 = (unsigned __int64)(door->vDirection.y * (signed __int64)v67.y) >> 16;
-            //v83 = v69;
-            //v75 = door->vDirection.z;
-            v83 = (unsigned __int64)(door->vDirection.z * (signed __int64)v67.z) >> 16;
-            //v54 = v82 + v83;
-            v75 = v84 + v82 + v83;
-            v55 = v75 * (signed __int64)v53;
-            //v82 = v55 >> 16;
-            v32 = v55 >> 16;
+          if ( face->uBitmapID != -1 )
+            v28->sTextureDeltaV -= v82 + pBitmaps_LOD->GetTexture(face->uBitmapID)->uTextureHeight;
+        }
+      }
+      if ( face->uAttributes & FACE_TEXTURE_FLOW )
+      {
+        v84 = (unsigned __int64)(door->vDirection.x * (signed __int64)v70.x) >> 16;
+        v82 = (unsigned __int64)(door->vDirection.y * (signed __int64)v70.y) >> 16;
+        v83 = (unsigned __int64)(door->vDirection.z * (signed __int64)v70.z) >> 16;
+        v75 = v84 + v82 + v83;
+        v53 = v89;
+        v82 = (unsigned __int64)(v75 * (signed __int64)v89) >> 16;
+        v28->sTextureDeltaU = -v82;
+        v84 = (unsigned __int64)(door->vDirection.x * (signed __int64)v67.x) >> 16;
+        v82 = (unsigned __int64)(door->vDirection.y * (signed __int64)v67.y) >> 16;
+        v83 = (unsigned __int64)(door->vDirection.z * (signed __int64)v67.z) >> 16;
+        v75 = v84 + v82 + v83;
+        v55 = v75 * (signed __int64)v53;
+        v32 = v55 >> 16;
 LABEL_58:
-            v56 = v88;
-            v57 = -v32;
-            v28->sTextureDeltaV = v57;
-            v28->sTextureDeltaU += door->pDeltaUs[v56];
-            v28->sTextureDeltaV = v57 + door->pDeltaVs[v56];
-          }
-LABEL_59:
-          //v58 = door->uNumFaces;
-          ++v88;
-          if ( v88 >= door->uNumFaces)
-          {
-            //v1 = v81;
-            //v0 = 0;
-            goto LABEL_62;
-          }
-          //v2 = v87;
-        }
-        LOWORD(v39) = v84;
-        if (v15->uBitmapID != -1)
-          LOWORD(v39) += pBitmaps_LOD->pTextures[v15->uBitmapID].uTextureWidth;
-LABEL_50:
-        v28->sTextureDeltaU -= v39;
-        goto LABEL_51;
+        v57 = -v32;
+        v28->sTextureDeltaV = v57;
+        v28->sTextureDeltaU += door->pDeltaUs[v88];
+        v28->sTextureDeltaV = v57 + door->pDeltaVs[v88];
       }
-LABEL_62:
-      ;
-      //v80 += 80;
-      //++v1;
-      //v81 = v1;
-    //}
-    //while ( v1 < pIndoor->uNumDoors );
+    }
   }
 }
 // 6BE13C: using guessed type int dword_6BE13C_uCurrentlyLoadedLocationID;
@@ -7249,7 +7041,7 @@
             v1 = 0;
             v2 = 0;
           }
-          if ( pParty->floor_face_pid != PID_ID(stru_721530.uFaceID) && BYTE3(pFace->uAttributes) & 4 )
+          if ( pParty->floor_face_pid != PID_ID(stru_721530.uFaceID) && pFace->Pressure_Plate() )
             uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID;
         }
         else
@@ -7274,7 +7066,7 @@
               new_party_y += v52 * pFace->pFacePlane_old.vNormal.y >> 16;
               v87 += v52 * pFace->pFacePlane_old.vNormal.z >> 16;
             }
-            if ( pParty->floor_face_pid != PID_ID(stru_721530.uFaceID) && BYTE3(pFace->uAttributes) & 4 )
+            if ( pParty->floor_face_pid != PID_ID(stru_721530.uFaceID) && pFace->Pressure_Plate() )
               uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID;
           }
           if ( pFace->uPolygonType == POLYGON_InBetweenFloorAndWall )
@@ -7287,7 +7079,7 @@
             pParty->uFallSpeed += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.z) >> 16;
             if ( v2 * v2 + v1 * v1 >= 400 )
             {
-              if ( pParty->floor_face_pid != PID_ID(stru_721530.uFaceID) && BYTE3(pFace->uAttributes) & 4 )
+              if ( pParty->floor_face_pid != PID_ID(stru_721530.uFaceID) && pFace->Pressure_Plate() )
                 uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID;
             }
             else
--- a/Indoor.h	Thu Dec 12 09:28:05 2013 +0600
+++ b/Indoor.h	Thu Dec 12 13:55:42 2013 +0600
@@ -228,16 +228,21 @@
 #define FACE_CAN_SATURATE_COLOR 0x00000002
 #define FACE_FLUID              0x00000010 // wavy animated water or lava
 #define FACE_DONT_CACHE_TEXTURE 0x00000040 // do not load face texture if it isn't loaded already
+#define FACE_UNKNOW4            0x00000080
 #define FACE_XY_PLANE           0x00000100
 #define FACE_XZ_PLANE           0x00000200
 #define FACE_YZ_PLANE           0x00000400
+#define FACE_UNKNOW3            0x00001000
 #define FACE_INVISIBLE          0x00002000
 #define FACE_TEXTURE_FRAME      0x00004000 // Texture ID is a frameset from TextureFrameTable, otherwise BitmapID
 #define FACE_OUTLINED           0x00010000 // outline face edges
 #define FACE_TEXTURE_FLOW       0x00040000 // The texture moves slowly. For horizontal facets only.
+#define FACE_UNKNOW             0x00100000
 #define FACE_INDOOR_SKY         0x00400000
 #define FACE_CLICKABLE          0x02000000 // Event can be triggered by clicking on the facet.
 #define FACE_PRESSURE_PLATE     0x04000000 // Event can be triggered by stepping on the facet.
+#define FACE_INDICATE           0x06000000 // Event can be triggered by indicating on the facet.
+#define FACE_UNKNOW2            0x10000000
 #define FACE_ETHEREAL           0x20000000 // Untouchable. You can pass through it.
 #define FACE_PICKED             0x80000000
 
@@ -257,7 +262,7 @@
     this->pXInterceptDisplacements = 0;
   }
 
-  char _get_normals(Vec3_int_ *a2, Vec3_int_ *a3);
+  void _get_normals(Vec3_int_ *a2, Vec3_int_ *a3);
   struct Texture *GetTexture();
   void FromODM(struct ODMFace *face);
 
@@ -265,7 +270,9 @@
   inline bool Visible() const   {return !Invisible();}
   inline bool Portal() const    {return (uAttributes & FACE_PORTAL) != 0;}
   inline bool Fluid() const     {return (uAttributes & FACE_FLUID) != 0;}
+  inline bool Indoor_sky() const     {return (uAttributes & FACE_INDOOR_SKY) != 0;}
   inline bool Clickable() const {return (uAttributes & FACE_CLICKABLE) != 0;}
+  inline bool Pressure_Plate() const {return (uAttributes & FACE_PRESSURE_PLATE) != 0;}
   inline bool Ethereal() const {return (uAttributes & FACE_ETHEREAL) != 0;}
 
   struct Plane_float_ pFacePlane;
--- a/Outdoor.cpp	Thu Dec 12 09:28:05 2013 +0600
+++ b/Outdoor.cpp	Thu Dec 12 13:55:42 2013 +0600
@@ -4383,7 +4383,7 @@
             v2 = 0;
             *(float *)&v128 = 0.0;
           }
-          if ( pParty->floor_face_pid != v45 && (pODMFace->uAttributes & FACE_PRESSURE_PLATE))
+          if ( pParty->floor_face_pid != v45 && pODMFace->Pressure_Plate() )
           {
             pParty->floor_face_pid = v45;
             v103 = pODMFace->sCogTriggeredID; //
@@ -4419,7 +4419,7 @@
             if ( !v119 )
               pZ = v122 + (pODMFace->pFacePlane.vNormal.z * v55 >> 16);
           }
-          if ( pParty->floor_face_pid != stru_721530.uFaceID && BYTE3(pODMFace->uAttributes) & 4 )
+          if ( pParty->floor_face_pid != stru_721530.uFaceID && pODMFace->Pressure_Plate() )
           {
             pParty->floor_face_pid = stru_721530.uFaceID;
             v103 = pODMFace->sCogTriggeredID; //
@@ -4440,7 +4440,7 @@
         pParty->uFallSpeed += (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.z) >> 16;
         if ( v2 * v2 + v128 * v128 >= 400 )
         {
-          if ( pParty->floor_face_pid != stru_721530.uFaceID && BYTE3(pODMFace->uAttributes) & 4 )
+          if ( pParty->floor_face_pid != stru_721530.uFaceID && pODMFace->Pressure_Plate() )
           {
             pParty->floor_face_pid = stru_721530.uFaceID;
             v103 = pODMFace->sCogTriggeredID; //
--- a/Outdoor.h	Thu Dec 12 09:28:05 2013 +0600
+++ b/Outdoor.h	Thu Dec 12 13:55:42 2013 +0600
@@ -88,7 +88,9 @@
   inline bool Visible() const   {return !Invisible();}
   inline bool Portal() const    {return (uAttributes & FACE_PORTAL) != 0;}
   inline bool Fluid() const     {return (uAttributes & FACE_FLUID) != 0;}
+  inline bool Indoor_sky() const {return (uAttributes & FACE_INDOOR_SKY) != 0;}
   inline bool Clickable() const {return (uAttributes & FACE_CLICKABLE) != 0;}
+  inline bool Pressure_Plate() const {return (uAttributes & FACE_PRESSURE_PLATE) != 0;}
   inline bool Ethereal() const {return (uAttributes & FACE_ETHEREAL) != 0;}
 
   struct Plane_int_ pFacePlane;
--- a/Render.cpp	Thu Dec 12 09:28:05 2013 +0600
+++ b/Render.cpp	Thu Dec 12 13:55:42 2013 +0600
@@ -3655,7 +3655,7 @@
       }
       v25 = 0;
 
-      __debugbreak(); //target sruface will most likely be 32bits/pixel, but this sub awaits 16 bits
+      //__debugbreak(); //target sruface will most likely be 32bits/pixel, but this sub awaits 16 bits
       v26 = (unsigned __int16 *)v35->pTargetSurface;
       if ( v26 )
       {
--- a/UI/Books/UIMapBook.cpp	Thu Dec 12 09:28:05 2013 +0600
+++ b/UI/Books/UIMapBook.cpp	Thu Dec 12 13:55:42 2013 +0600
@@ -415,13 +415,13 @@
     {
      for ( uint i = 0; i < pIndoor->pMapOutlines->uNumOutlines; ++i )
       {
-        if ( !(BYTE1(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace1ID].uAttributes) & 0x20 
-           || (BYTE1(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].uAttributes) & 0x20) ))
+        if ( !(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace1ID].Invisible() 
+           || (pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].Invisible()) ))
         {
           if ( !(pIndoor->pMapOutlines->pOutlines[i].uFlags & 1) )
           {
             if ( !(!(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace1ID].uAttributes & 0x80)
-                && !(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].uAttributes & 0x80u) ))
+                && !(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].uAttributes & 0x80) ))
             {
               pIndoor->pMapOutlines->pOutlines[i].uFlags = pIndoor->pMapOutlines->pOutlines[i].uFlags | 1;
               pIndoor->_visible_outlines[i >> 3] |= 1 << (7 - i % 8);
@@ -429,7 +429,7 @@
           }
           if ( (!(pIndoor->pMapOutlines->pOutlines[i].uFlags & 1) 
             && !(!(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace1ID].uAttributes & 0x80)
-            && !(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].uAttributes & 0x80u) ))
+            && !(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].uAttributes & 0x80) ))
             || pIndoor->pMapOutlines->pOutlines[i].uFlags & 1)
           {
             v93 = (unsigned __int16 *)(pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex1ID].x - viewparams->sViewCenterX);
--- a/UI/UICharacter.cpp	Thu Dec 12 09:28:05 2013 +0600
+++ b/UI/UICharacter.cpp	Thu Dec 12 13:55:42 2013 +0600
@@ -792,27 +792,27 @@
         v166 = "item64v1";
       else
         v166 = item->GetIconName();
-      if ( !( item->uAttributes & 0xF0 ) )
+      if ( !( item->uAttributes & ITEM_ENCHANT_ANIMATION ) )
       {
-        if ( item->uAttributes & 2 )
+        if ( item->uAttributes & ITEM_BROKEN )
           pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v166, TEXTURE_16BIT_PALETTE)));
         else
         {
-          if ( item->uAttributes & 1 )
+          if ( item->uAttributes & ITEM_IDENTIFIED )
             pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v166, TEXTURE_16BIT_PALETTE)));
           else
             pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v166, TEXTURE_16BIT_PALETTE)));
         }
       }
-      if ( item->uAttributes & 0xF0 )
+      if ( item->uAttributes & ITEM_ENCHANT_ANIMATION )
       {
-        if ( ( item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED )
+        if ( ( item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_RED )
           container = "sptext01";
-        if ( ( item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE )
+        if ( ( item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_BLUE )
           container = "sp28a";
-        if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN )
+        if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_GREEN )
           container = "sp30a";
-        if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE )
+        if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_PURPLE )
           container = "sp91a";
         _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
         if ( _50C9A8_item_enchantment_timer <= 0 )
@@ -836,13 +836,13 @@
       item = player->GetBowItem();
       item_X = pPaperdoll_BodyX + paperdoll_Weapon[pBodyComplection][2][0] - pItemsTable->pItems[item->uItemID].uEquipX;
       item_Y = pPaperdoll_BodyY + paperdoll_Weapon[pBodyComplection][2][1] - pItemsTable->pItems[item->uItemID].uEquipY;
-      if ( !(item->uAttributes & 0xF0) )// если не применён закл
+      if ( !(item->uAttributes & ITEM_ENCHANT_ANIMATION) )// если не применён закл
       {
-        if ( item->uAttributes & 2 )
+        if ( item->uAttributes & ITEM_BROKEN )
           pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(item->GetIconName(), TEXTURE_16BIT_PALETTE)));
         else
         {
-          if ( !(item->uAttributes & 1) )//не опознанный лук зелёный
+          if ( !(item->uAttributes & ITEM_IDENTIFIED) )//не опознанный лук зелёный
             pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(item->GetIconName(), TEXTURE_16BIT_PALETTE)));
           else // опознанный лук
             pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(item->GetIconName(), TEXTURE_16BIT_PALETTE)));
@@ -850,13 +850,13 @@
       }
       else
       {
-        if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED )
+        if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_RED )
           container = "sptext01";
-        if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE )
+        if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_BLUE )
           container = "sp28a";
-        if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN )
+        if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_GREEN )
           container = "sp30a";
-        if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE )
+        if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_PURPLE )
           container = "sp91a";
         _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
         if ( _50C9A8_item_enchantment_timer <= 0 )
@@ -902,22 +902,22 @@
       {
         item_X = pPaperdoll_BodyX + paperdoll_Cloak[pBodyComplection][index][0];
         item_Y = pPaperdoll_BodyY + paperdoll_Cloak[pBodyComplection][index][1];
-        if ( !(item->uAttributes & 0xF0) )
+        if ( !(item->uAttributes & ITEM_ENCHANT_ANIMATION) )
         {
-          if ( item->uAttributes & 2 )
+          if ( item->uAttributes & ITEM_BROKEN )
             pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_texture[pBodyComplection][index]));
           else
             pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_texture[pBodyComplection][index]));
         }
         else
         {
-          if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED )
+          if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_RED )
             container = "sptext01";
-          if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE )
+          if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_BLUE )
             container = "sp28a";
-          if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN )
+          if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_GREEN )
             container = "sp30a";
-          if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE )
+          if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_PURPLE )
             container = "sp91a";
           _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
           if ( _50C9A8_item_enchantment_timer <= 0 )
@@ -962,13 +962,13 @@
       {
         item_X = pPaperdoll_BodyX + paperdoll_Armor_Coord[pBodyComplection][index][0];
         item_Y = pPaperdoll_BodyY + paperdoll_Armor_Coord[pBodyComplection][index][1];
-        if ( !(item->uAttributes & 0xF0) )
+        if ( !(item->uAttributes & ITEM_ENCHANT_ANIMATION) )
         {
-          if ( item->uAttributes & 2 )
+          if ( item->uAttributes & ITEM_BROKEN )
             pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][0]));
           else
           {
-            if ( !(item->uAttributes & 1) )
+            if ( !(item->uAttributes & ITEM_IDENTIFIED) )
               pRenderer->DrawTransparentGreenShade(item_X, item_Y, &pIcons_LOD->pTextures[paperdoll_armor_texture[pBodyComplection][index][0]]);
             else
               pRenderer->DrawTextureTransparent(item_X, item_Y, &pIcons_LOD->pTextures[paperdoll_armor_texture[pBodyComplection][index][0]]);
@@ -976,13 +976,13 @@
         }
         else
         {
-          if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED )
+          if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_RED )
             container = "sptext01";
-          if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE )
+          if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_BLUE )
             container = "sp28a";
-          if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN )
+          if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_GREEN )
             container = "sp30a";
-          if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE )
+          if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_PURPLE )
             container = "sp91a";
           _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
           if ( _50C9A8_item_enchantment_timer <= 0 )
@@ -1024,13 +1024,13 @@
       {
         item_X = pPaperdoll_BodyX + paperdoll_Boot[pBodyComplection][index][0];
         item_Y = pPaperdoll_BodyY + paperdoll_Boot[pBodyComplection][index][1];
-        if ( !(item->uAttributes & 0xF0) )
+        if ( !(item->uAttributes & ITEM_ENCHANT_ANIMATION) )
         {
-          if ( item->uAttributes & 2 )
+          if ( item->uAttributes & ITEM_BROKEN )
             pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(v59));
           else
           {
-            if ( item->uAttributes & 1 )
+            if ( item->uAttributes & ITEM_IDENTIFIED )
               pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(v59));
             else
               pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(v59));
@@ -1038,13 +1038,13 @@
         }
         else
         {
-          if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED )
+          if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_RED )
             container = "sptext01";
-          if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE )
+          if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_BLUE )
             container = "sp28a";
-          if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN )
+          if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_GREEN )
             container = "sp30a";
-          if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE )
+          if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_PURPLE )
             container = "sp91a";
           _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
           if ( _50C9A8_item_enchantment_timer <= 0 )
@@ -1091,13 +1091,13 @@
             v75 = paperdoll_belt_texture[pBodyComplection][index];
           else
             v75 = paperdoll_belt_texture[pBodyComplection - 2][index];
-          if ( !(item->uAttributes & 0xF0) )
+          if ( !(item->uAttributes & ITEM_ENCHANT_ANIMATION) )
           {
-            if ( item->uAttributes & 2 )
+            if ( item->uAttributes & ITEM_BROKEN )
               pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(v75));
             else
             {
-              if ( item->uAttributes & 1 )
+              if ( item->uAttributes & ITEM_IDENTIFIED )
                 pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(v75));
               else
                 pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(v75));
@@ -1107,13 +1107,13 @@
           }
           else
           {
-            if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED )
+            if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_RED )
               container = "sptext01";
-            if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE )
+            if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_BLUE )
               container = "sp28a";
-            if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN )
+            if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_GREEN )
               container = "sp30a";
-            if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE )
+            if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_PURPLE )
               container = "sp91a";
             _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
             if ( _50C9A8_item_enchantment_timer <= 0 )
@@ -1179,13 +1179,13 @@
             }
             if ( v94 != pIcons_LOD->FindTextureByName("pending") )
             {
-              if ( !(item->uAttributes & 0xF0) )
+              if ( !(item->uAttributes & ITEM_ENCHANT_ANIMATION) )
               {
-                if ( item->uAttributes & 2 )
+                if ( item->uAttributes & ITEM_BROKEN )
                   pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(v94));
                 else
                 {
-                  if ( item->uAttributes & 1 )
+                  if ( item->uAttributes & ITEM_IDENTIFIED )
                     pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(v94));
                   else
                     pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(v94));
@@ -1195,15 +1195,15 @@
               {
                 if ( paperdoll_armor_texture[pBodyComplection][index][2] != pIcons_LOD->FindTextureByName("pending") )
                 {
-                  if ( item->uAttributes & 0xF0 )
+                  if ( item->uAttributes & ITEM_ENCHANT_ANIMATION )
                   {
-                    if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED )
+                    if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_RED )
                       container = "sptext01";
-                    if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE )
+                    if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_BLUE )
                       container = "sp28a";
-                    if ( ( item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN )
+                    if ( ( item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_GREEN )
                       container = "sp30a";
-                    if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE )
+                    if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_PURPLE )
                       container = "sp91a";
                     _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
                     if ( _50C9A8_item_enchantment_timer <= 0 )
@@ -1226,13 +1226,13 @@
             {
               item_X = pPaperdoll_BodyX + paperdoll_shoulder_coord[pBodyComplection][index][0];
               item_Y = pPaperdoll_BodyY + paperdoll_shoulder_coord[pBodyComplection][index][1];
-              if ( !(item->uAttributes & 0xF0) )
+              if ( !(item->uAttributes & ITEM_ENCHANT_ANIMATION) )
               {
-                if ( item->uAttributes & 2 )
+                if ( item->uAttributes & ITEM_BROKEN )
                   pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][1]));
                 else
                 {
-                  if ( item->uAttributes & 1 )
+                  if ( item->uAttributes & ITEM_IDENTIFIED )
                     pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][1]));
                   else
                     pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][1]));
@@ -1240,13 +1240,13 @@
               }
               else
               {
-                if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED )
+                if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_RED )
                   container = "sptext01";
-                if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE )
+                if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_BLUE )
                   container = "sp28a";
-                if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN )
+                if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_GREEN )
                   container = "sp30a";
-                if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE )
+                if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_PURPLE )
                   container = "sp91a";
                 _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
                 if ( _50C9A8_item_enchantment_timer <= 0 )
@@ -1292,9 +1292,9 @@
           item_Y = pPaperdoll_BodyY + paperdoll_CloakCollar[pBodyComplection][index][1];
           if ( paperdoll_cloak_collar_texture[pBodyComplection][index] != pIcons_LOD->FindTextureByName("pending") )
           {
-            if ( !(item->uAttributes & 0xF0) )
+            if ( !(item->uAttributes & ITEM_ENCHANT_ANIMATION) )
             {
-              if ( item->uAttributes & 2 )
+              if ( item->uAttributes & ITEM_BROKEN )
                 pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_collar_texture[pBodyComplection][index]));
               else
                 pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_collar_texture[pBodyComplection][index]));
@@ -1304,13 +1304,13 @@
             }
             else
             {
-              if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED )
+              if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_RED )
                 container = "sptext01";
-              if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE )
+              if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_BLUE )
                 container = "sp28a";
-              if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN )
+              if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_GREEN )
                 container = "sp30a";
-              if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE )
+              if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_PURPLE )
                 container = "sp91a";
               _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
               if ( _50C9A8_item_enchantment_timer <= 0 )
@@ -1365,15 +1365,15 @@
           v127 = paperdoll_helm_texture[player->GetSexByVoice()][index];
         else
           v127 = papredoll_dbrds[11];
-        if ( item->uAttributes & 0xF0 )
+        if ( item->uAttributes & ITEM_ENCHANT_ANIMATION )
         {
-          if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED )
+          if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_RED )
             container = "sptext01";
-          if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE )
+          if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_BLUE )
             container = "sp28a";
-          if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN )
+          if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_GREEN )
             container = "sp30a";
-          if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE )
+          if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_PURPLE )
             container = "sp91a";
           _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
           if ( _50C9A8_item_enchantment_timer <= 0 )
@@ -1411,13 +1411,13 @@
         v181 = "item64v1";
       else
         v181 = item->GetIconName();
-      if ( !(item->uAttributes & 0xF0) )
+      if ( !(item->uAttributes & ITEM_ENCHANT_ANIMATION) )
       {
-        if ( item->uAttributes & 2 )
+        if ( item->uAttributes & ITEM_BROKEN )
           pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v181, TEXTURE_16BIT_PALETTE)));
         else
         {
-          if ( item->uAttributes & 1 )
+          if ( item->uAttributes & ITEM_IDENTIFIED )
             pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v181, TEXTURE_16BIT_PALETTE)));
           else
             pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v181, TEXTURE_16BIT_PALETTE)));
@@ -1425,13 +1425,13 @@
       }
       else
       {
-        if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED )
+        if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_RED )
           container = "sptext01";
-        if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE )
+        if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_BLUE )
           container = "sp28a";
-        if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN )
+        if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_GREEN )
            container = "sp30a";
-        if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE )
+        if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_PURPLE )
           container = "sp91a";
         _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
         if ( _50C9A8_item_enchantment_timer <= 0 )
@@ -1482,14 +1482,14 @@
         item_Y = pPaperdoll_BodyY + paperdoll_Weapon[pBodyComplection][0][1] - pItemsTable->pItems[item->uItemID].uEquipY;
       }
       v153 = pIcons_LOD->LoadTexture(item->GetIconName(), TEXTURE_16BIT_PALETTE);
-      if ( !(item->uAttributes & 0xF0) )
+      if ( !(item->uAttributes & ITEM_ENCHANT_ANIMATION) )
       {
-        if ( item->uAttributes & 2 )
+        if ( item->uAttributes & ITEM_BROKEN )
           pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(v153));
         else
         {
           //v160 = (char *)pIcons_LOD->GetTexture(v153);
-          if ( !(item->uAttributes & 1) )
+          if ( !(item->uAttributes & ITEM_IDENTIFIED) )
           pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(v153));
           else
             pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(v153));
@@ -1497,13 +1497,13 @@
       }
       else
       {
-        if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED )
+        if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_RED )
           container = "sptext01";
-        if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE )
+        if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_BLUE )
           container = "sp28a";
-        if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN )
+        if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_GREEN )
           container = "sp30a";
-        if ( (item->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE )
+        if ( (item->uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_PURPLE )
           container = "sp91a";
         _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed;
         if ( _50C9A8_item_enchantment_timer <= 0 )
@@ -1573,10 +1573,10 @@
     if (pTexture->uTextureHeight < 14 )
       pTexture->uTextureHeight = 14;
     v17 = uCellX + ((v15 - pTexture->uTextureWidth) >> 1) + pSRZBufferLineOffsets[uCellY + (( (int)((pTexture->uTextureHeight - 14) & 0xFFFFFFE0) - pTexture->uTextureHeight + 32) >> 1)];   //added typecast. without it the value in the brackets got cat to unsigned which messed stuff up
-    if (player->pInventoryItemList[player->pInventoryMatrix[i] - 1].uAttributes & 0xF0)
+    if (player->pInventoryItemList[player->pInventoryMatrix[i] - 1].uAttributes & ITEM_ENCHANT_ANIMATION)
     {
       Texture *loadedTextureptr = nullptr;
-      switch (player->pInventoryItemList[player->pInventoryMatrix[i] - 1].uAttributes & 0xF0)
+      switch (player->pInventoryItemList[player->pInventoryMatrix[i] - 1].uAttributes & ITEM_ENCHANT_ANIMATION)
       {
         case ITEM_AURA_EFFECT_RED:    loadedTextureptr = pIcons_LOD->LoadTexturePtr("sptext01", TEXTURE_16BIT_PALETTE); break;
         case ITEM_AURA_EFFECT_BLUE:   loadedTextureptr = pIcons_LOD->LoadTexturePtr("sp28a", TEXTURE_16BIT_PALETTE);    break;
@@ -1615,10 +1615,10 @@
 {
   Texture* item_texture = pIcons_LOD->LoadTexturePtr(item->GetIconName(), TEXTURE_16BIT_PALETTE);
 
-  if (item->uAttributes & 0xF0) // enchant animation
+  if (item->uAttributes & ITEM_ENCHANT_ANIMATION) // enchant animation
   {
     Texture *enchantment_texture = nullptr;
-    switch (item->uAttributes & 0xF0)
+    switch (item->uAttributes & ITEM_ENCHANT_ANIMATION)
     {
       case ITEM_AURA_EFFECT_RED:    enchantment_texture = pIcons_LOD->LoadTexturePtr("sptext01", TEXTURE_16BIT_PALETTE); break;
       case ITEM_AURA_EFFECT_BLUE:   enchantment_texture = pIcons_LOD->LoadTexturePtr("sp28a", TEXTURE_16BIT_PALETTE);    break;
--- a/UI/UIPopup.cpp	Thu Dec 12 09:28:05 2013 +0600
+++ b/UI/UIPopup.cpp	Thu Dec 12 13:55:42 2013 +0600
@@ -314,7 +314,7 @@
                                      TEXTURE_16BIT_PALETTE)->uTextureHeight + v81 + 54;
   if ( (signed int)Str > (signed int)iteminfo_window.uFrameHeight )
     iteminfo_window.uFrameHeight = (unsigned int)Str;
-  if ( inspect_item->uAttributes & 8 && (inspect_item->uSpecEnchantmentType || inspect_item->uEnchantmentType) )
+  if ( inspect_item->uAttributes & ITEM_TEMP_BONUS && (inspect_item->uSpecEnchantmentType || inspect_item->uEnchantmentType) )
     iteminfo_window.uFrameHeight += LOBYTE(pFontComic->uFontHeight);
   v85 = 0;
   if ( pFontArrus->uFontHeight )
@@ -366,7 +366,7 @@
   }
   else
   {
-    if ( (inspect_item->uAttributes & 8) && (inspect_item->uSpecEnchantmentType || inspect_item->uEnchantmentType) )
+    if ( (inspect_item->uAttributes & ITEM_TEMP_BONUS) && (inspect_item->uSpecEnchantmentType || inspect_item->uEnchantmentType) )
     {
       init_summoned_item(&v67, inspect_item->uExpireTime - pParty->uTimePlayed);
       strcpy(pTmpBuf.data(), "Duration:");
@@ -393,11 +393,11 @@
     }
     sprintf(pTmpBuf.data(), "%s: %lu", pGlobalTXT_LocalizationStrings[465], inspect_item->GetValue());
     iteminfo_window.DrawText(pFontComic, 100, iteminfo_window.uFrameHeight - LOBYTE(pFontComic->uFontHeight), 0, pTmpBuf.data(), 0, 0, 0);
-    if ( BYTE1(inspect_item->uAttributes) & 1 )
+    if ( inspect_item->uAttributes & ITEM_STOLEN )
       pText = pGlobalTXT_LocalizationStrings[187]; //"Stolen"
     else
     {
-      if ( !(BYTE1(inspect_item->uAttributes) & 2) )
+      if ( !(inspect_item->uAttributes & ITEM_HARDENED) )
       {
         pRenderer->ResetTextureClipRect();
         if ( !areWeLoadingTexture )
--- a/UI/UIShops.cpp	Thu Dec 12 09:28:05 2013 +0600
+++ b/UI/UIShops.cpp	Thu Dec 12 13:55:42 2013 +0600
@@ -1355,7 +1355,7 @@
         if ( pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117) )
         {
           item = &pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117) - 1];
-          if ( item->uAttributes & 1 )
+          if ( item->uAttributes & ITEM_IDENTIFIED )
           {
             dialog_window.DrawTitleText(pFontArrus, 0, (212 - pFontArrus->CalcTextHeight(BuildDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0), &dialog_window, 0, 0)) / 2 + 101,
                Color16(255, 255, 255), BuildDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0), 3); 
@@ -1564,7 +1564,7 @@
         {
           uPriceItemService = pPlayers[uActiveCharacter]->GetPriceIdentification(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier);
           item = &pPlayers[uActiveCharacter]->pInventoryItemList[pItemID - 1];
-          if ( !(item->uAttributes & 1) )
+          if ( !(item->uAttributes & ITEM_IDENTIFIED) )
           {
             if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) )
             {
@@ -1572,7 +1572,7 @@
               {
                 dword_F8B1E4 = 1;
                 Party::TakeGold(uPriceItemService);
-                item->uAttributes |= 1;
+                item->uAttributes |= ITEM_IDENTIFIED;
                 pPlayers[uActiveCharacter]->PlaySound(SPEECH_73, 0);
                 ShowStatusBarString(pGlobalTXT_LocalizationStrings[569], 2);
                 return;
@@ -1604,7 +1604,7 @@
             pPriceMultiplier = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
             ItemGen* _v = &pPlayers[uActiveCharacter]->pInventoryItemList[pItemID - 1];
             uPriceItemService = pPlayers[uActiveCharacter]->GetPriceRepair(_v->GetValue(), pPriceMultiplier);
-            if ( item->uAttributes & 2 )
+            if ( item->uAttributes & ITEM_BROKEN )
             {
               if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) )
               {
--- a/UI/UiGame.cpp	Thu Dec 12 09:28:05 2013 +0600
+++ b/UI/UiGame.cpp	Thu Dec 12 13:55:42 2013 +0600
@@ -1152,7 +1152,6 @@
   signed int v18; // eax@55
   signed int v18b;
   signed int v19; // ecx@63
-  BLVFace *pFace; // eax@69
   const char *pText; // ecx@79
   char *v28; // esi@82
   enum UIMessageType pMessageType2; // esi@110
@@ -1260,7 +1259,7 @@
       {
         if ( HIWORD(v18) < interaction_distance_limit )
         {
-          if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
+          if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
           {
             v18b = (signed int)(unsigned __int16)v18 >> 9;
             if ( !pOutdoor->pBModels[v18b].pFaces[v19 & 0x3F].sCogTriggeredID
@@ -1284,29 +1283,31 @@
             uLastPointedObjectID = pMouse->uPointingObjectID;
             return;
           }
-          pFace = &pIndoor->pFaces[v19];
-          if ( BYTE3(pFace->uAttributes) & 6 )
+          if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
           {
-            if ( !pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID
-              || !GetEventHintString(pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID) )
+            if ( pIndoor->pFaces[v19].uAttributes & FACE_INDICATE )
             {
-              pMouse->uPointingObjectID = 0;
-              pFooterString[0] = 0;
-              bForceDrawFooter = 1;
-              uLastPointedObjectID = 0;
+              if ( !pIndoor->pFaceExtras[pIndoor->pFaces[v19].uFaceExtraID].uEventID
+               || !GetEventHintString(pIndoor->pFaceExtras[pIndoor->pFaces[v19].uFaceExtraID].uEventID) )
+              {
+                pMouse->uPointingObjectID = 0;
+                pFooterString[0] = 0;
+                bForceDrawFooter = 1;
+                uLastPointedObjectID = 0;
+                return;
+              }
+              GameUI_SetFooterString(GetEventHintString(pIndoor->pFaceExtras[pIndoor->pFaces[v19].uFaceExtraID].uEventID));
+              if ( pMouse->uPointingObjectID == 0 )
+              {
+                if ( uLastPointedObjectID != 0 )
+                {
+                  pFooterString[0] = 0;
+                  bForceDrawFooter = 1;
+                }
+              }
+              uLastPointedObjectID = pMouse->uPointingObjectID;
               return;
             }
-            GameUI_SetFooterString(GetEventHintString(pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID));
-            if ( pMouse->uPointingObjectID == 0 )
-            {
-              if ( uLastPointedObjectID != 0 )
-              {
-                pFooterString[0] = 0;
-                bForceDrawFooter = 1;
-              }
-            }
-            uLastPointedObjectID = pMouse->uPointingObjectID;
-            return;
           }
         }
         pMouse->uPointingObjectID = 0;
@@ -1973,7 +1974,7 @@
 LABEL_15:
       //v12 = &pIndoor->pFaces[pOutline->uFace1ID];
       if (bWizardEyeActive && uWizardEyeSkillLevel >= 3 &&
-          (pFace1->uAttributes & 0x2000 || pFace2->uAttributes & 0x2000) &&
+          (pFace1->Invisible() || pFace2->Invisible()) &&
           (pIndoor->pFaceExtras[pFace1->uFaceExtraID].uEventID || pIndoor->pFaceExtras[pFace2->uFaceExtraID].uEventID))
       {
         if (uNumBlueFacesInBLVMinimap < 49)
--- a/stru10.cpp	Thu Dec 12 09:28:05 2013 +0600
+++ b/stru10.cpp	Thu Dec 12 13:55:42 2013 +0600
@@ -118,7 +118,7 @@
     int c;
   } v46[40]; //[sp+0C];
 
-  if (pFace->uAttributes & 0x0100)
+  if (pFace->uAttributes & FACE_XY_PLANE)
   {
     for (uint i = 0; i < pFace->uNumVertices; ++i)
     {
@@ -127,7 +127,7 @@
       v46[i].c = i;
     }
   }
-  if (pFace->uAttributes & 0x0200)
+  if (pFace->uAttributes & FACE_XZ_PLANE)
   {
     for (uint i = 0; i < pFace->uNumVertices; ++i)
     {
@@ -136,7 +136,7 @@
       v46[i].c = i;
     }
   }
-  if (pFace->uAttributes & 0x0400)
+  if (pFace->uAttributes & FACE_YZ_PLANE)
   {
     for (uint i = 0; i < pFace->uNumVertices; ++i)
     {
@@ -282,7 +282,7 @@
   float a3;
   float var_8;
 
-  if (pFace->uAttributes & 0x0100)
+  if (pFace->uAttributes & FACE_XY_PLANE)
   {
     face_center_x = (pFaceLimits[0].vWorldPosition.x + pFaceLimits[2].vWorldPosition.x) / 2;
     face_center_y = (pFaceLimits[3].vWorldPosition.y + pFaceLimits[1].vWorldPosition.y) / 2;
@@ -291,7 +291,7 @@
     a3 = face_center_x - pFaceLimits[0].vWorldPosition.x;
     var_8 = face_center_y - pFaceLimits[1].vWorldPosition.y;
   }
-  if (pFace->uAttributes & 0x0200)
+  if (pFace->uAttributes & FACE_XZ_PLANE)
   {
     face_center_x = (pFaceLimits[0].vWorldPosition.x + pFaceLimits[2].vWorldPosition.x) / 2;// центр полигона
     face_center_y = (pFaceLimits[0].vWorldPosition.y + pFaceLimits[2].vWorldPosition.y) / 2;
@@ -303,7 +303,7 @@
     if (pFace->uPolygonType == POLYGON_VerticalWall)
       a3 /= a1.x;
   }
-  if (pFace->uAttributes & 0x0400)
+  if (pFace->uAttributes & FACE_YZ_PLANE)
   {
     face_center_x = (pFaceLimits[0].vWorldPosition.x + pFaceLimits[2].vWorldPosition.x) / 2;
     face_center_y = (pFaceLimits[0].vWorldPosition.y + pFaceLimits[2].vWorldPosition.y) / 2;