changeset 2095:577c081b8019

Merge
author Ritor1
date Thu, 12 Dec 2013 21:44:02 +0600
parents dbd8515924da (current diff) 52415f8bf7c2 (diff)
children 115373c2d1cd
files Indoor.cpp Outdoor.cpp
diffstat 22 files changed, 1407 insertions(+), 2176 deletions(-) [+]
line wrap: on
line diff
--- a/AudioPlayer.cpp	Thu Dec 12 21:42:18 2013 +0600
+++ b/AudioPlayer.cpp	Thu Dec 12 21:44:02 2013 +0600
@@ -321,30 +321,17 @@
 //----- (004A9D79) --------------------------------------------------------
 void SoundList::_4A9D79(int a2)
 {
-  SoundList *v2; // esi@1
-  int v3; // edi@1
-  signed int i; // ebx@1
-  SoundDesc *v5; // eax@2
-  SOUND_DESC_TYPE v6; // ecx@2
-  void *v7; // eax@5
-
-  v2 = this;
-  v3 = 0;
-  for ( i = 0; i < (signed int)v2->sNumSounds; ++v3 )
+  for ( int i = 0; i < (signed int)this->sNumSounds; ++i )
   {
-    v5 = &v2->pSounds[v3];
-    v6 = v5->eType;
-    if ( v6 != SOUND_DESC_SYSTEM && (a2 || v6 != SOUND_DESC_LOCK) )
+    if ( this->pSounds[i].eType != SOUND_DESC_SYSTEM && (a2 || this->pSounds[i].eType != SOUND_DESC_LOCK) )
     {
-      v7 = v5->pSoundData[0];
-      if ( v7 )
+      if ( this->pSounds[i].pSoundData[0] )
       {
-        ReleaseSoundData(v7);
-        v2->pSounds[v3].pSoundData[0] = 0;
+        ReleaseSoundData(this->pSounds[i].pSoundData[0]);
+        this->pSounds[i].pSoundData[0] = 0;
       }
-      v2->pSounds[v3].uFlags &= ~SOUND_DESC_SYSTEM;
+      this->pSounds[i].uFlags &= ~SOUND_DESC_SYSTEM;
     }
-    ++i;
   }
 }
 
@@ -373,19 +360,15 @@
 //----- (004A9E3D) --------------------------------------------------------
 void SoundList::ToFile()
 {
-  SoundList *v1; // esi@1
   FILE *v2; // eax@1
-  FILE *v3; // edi@1
 
-  v1 = this;
   v2 = fopen("data\\dsounds.bin", "wb");
-  v3 = v2;
   if ( !v2 )
     Error("Unable to save dsounds.bin!");
 
-  fwrite(v1, 4u, 1u, v2);
-  fwrite(v1->pSounds, 0x78u, v1->sNumSounds, v3);
-  fclose(v3);
+  fwrite(this, 4, 1, v2);
+  fwrite(this->pSounds, 0x78u, this->sNumSounds, v2);
+  fclose(v2);
 }
 
 //----- (004A9E89) --------------------------------------------------------
@@ -415,7 +398,6 @@
 //----- (004A9ED0) --------------------------------------------------------
 int SoundList::FromFileTxt(const char *Args)
 {
-  SoundList *v2; // ebx@1
   __int32 v3; // edi@1
   FILE *v4; // eax@1
   unsigned int v5; // esi@3
@@ -435,11 +417,10 @@
   FILE *File; // [sp+2F8h] [bp-4h]@1
   unsigned int Argsa; // [sp+304h] [bp+8h]@3
 
-  v2 = this;
   free(this->pSounds);
   v3 = 0;
-  v2->pSounds = 0;
-  v2->sNumSounds = 0;
+  this->pSounds = 0;
+  this->sNumSounds = 0;
   v4 = fopen(Args, "r");
   File = v4;
   if ( !v4 )
@@ -460,15 +441,15 @@
     v5 = Argsa;
     v3 = 0;
   }
-  v2->sNumSounds = v5;
+  this->sNumSounds = v5;
   v6 = malloc(120 * v5);
-  v2->pSounds = (SoundDesc *)v6;
+  this->pSounds = (SoundDesc *)v6;
   if ( v6 == (void *)v3 )
     Error("SoundListClass::load - Out of Memory!");
 
-  memset(v6, v3, 120 * v2->sNumSounds);
+  memset(v6, v3, 120 * this->sNumSounds);
   v7 = File;
-  v2->sNumSounds = v3;
+  this->sNumSounds = v3;
   fseek(v7, v3, v3);
   for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
   {
@@ -476,38 +457,34 @@
     memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19));
     if ( v19.uPropCount && *v19.pProperties[0] != 47 )
     {
-      sprintf(v2->pSounds[v2->sNumSounds].pSoundName, "%s", v19.pProperties[0]);
+      sprintf(this->pSounds[this->sNumSounds].pSoundName, "%s", v19.pProperties[0]);
       v9 = atoi(v19.pProperties[1]);
       v10 = v19.pProperties[2];
-      v2->pSounds[v2->sNumSounds].uSoundID = v9;
+      this->pSounds[this->sNumSounds].uSoundID = v9;
       if ( _stricmp(v10, "system") )
       {
         if ( _stricmp(v19.pProperties[2], "swap") )
         {
           v11 = _stricmp(v19.pProperties[2], "lock");
-          v12 = v2->pSounds;
+          v12 = this->pSounds;
           v13 = v11 == 0;
-          v14 = v2->sNumSounds;
+          v14 = this->sNumSounds;
           if ( v13 )
             v12[v14].eType = SOUND_DESC_LOCK;
           else
             v12[v14].eType = SOUND_DESC_LEVEL;
         }
         else
-        {
-          v2->pSounds[v2->sNumSounds].eType = SOUND_DESC_SWAP;
-        }
+          this->pSounds[this->sNumSounds].eType = SOUND_DESC_SWAP;
       }
       else
-      {
-        v2->pSounds[v2->sNumSounds].eType = SOUND_DESC_SYSTEM;
-      }
+        this->pSounds[this->sNumSounds].eType = SOUND_DESC_SYSTEM;
       if ( v19.uPropCount >= 4 && !_stricmp(v19.pProperties[3], "3D") )
       {
-        v15 = (int)&v2->pSounds[v2->sNumSounds].uFlags;
+        v15 = (int)&this->pSounds[this->sNumSounds].uFlags;
         *(int *)v15 |= SOUND_DESC_SWAP;
       }
-      ++v2->sNumSounds;
+      ++this->sNumSounds;
     }
   }
   fclose(File);
@@ -721,22 +698,42 @@
 
   int start_channel = 0,
       end_channel = 0;
-
+v62 = start_channel;
   assert(sound_id < pSoundList->sNumSounds);
-  SoundDesc* sound_desc = pSoundList->pSounds + sound_id;
+  SoundDesc* sound_desc = &pSoundList->pSounds[sound_id];
   if (!b3DSoundInitialized || sound_desc->Is3D())
   {
     if (!a3)  // generic sound like from UI
     {
       start_channel = 10;
       end_channel = 12;
-      goto LABEL_133;
+      for (v62 = start_channel; v62 <= end_channel; ++v62)
+      {
+        MixerChannel* channel = pMixerChannels + v62;
+        if (AIL_sample_status(channel->hSample) == AIL::Sample::Done)
+        {
+          AIL_end_sample(channel->hSample);
+          if (channel->uSourceTrackIdx)
+            FreeChannel(channel);
+          break;
+        }
+      }
     }
     else if (a3 == -1)  // exclusive sounds - can override
     {
       start_channel = 13;
       end_channel = 13;
-      goto LABEL_133;
+      for (v62 = start_channel; v62 <= end_channel; ++v62)
+      {
+        MixerChannel* channel = pMixerChannels + v62;
+        if (AIL_sample_status(channel->hSample) == AIL::Sample::Done)
+        {
+          AIL_end_sample(channel->hSample);
+          if (channel->uSourceTrackIdx)
+            FreeChannel(channel);
+          break;
+        }
+      }
     }
     else
     {
@@ -744,7 +741,17 @@
       {
         start_channel = 14;
         end_channel = 14;
-        goto LABEL_123;
+        for (uint i = 0; i < uMixerChannels; ++i)
+        {
+          MixerChannel* channel = &pMixerChannels[i];
+          if (channel->source_pid == a3 && AIL_sample_status(channel->hSample) == AIL::Sample::Playing)
+          {
+            if (channel->uSourceTrackIdx == sound_id)
+              return;                          // already playing the same sound from the same source - return
+            AIL_end_sample(channel->hSample);  // requested new sound from the same source - end & switch
+            FreeChannel(channel);
+          }
+        }
       }
       else
       {
@@ -757,7 +764,17 @@
           {
             start_channel = 10;
             end_channel = 12;
-            goto LABEL_133;
+            for (v62 = start_channel; v62 <= end_channel; ++v62)
+            {
+              MixerChannel* channel = pMixerChannels + v62;
+              if (AIL_sample_status(channel->hSample) == AIL::Sample::Done)
+              {
+                AIL_end_sample(channel->hSample);
+                if (channel->uSourceTrackIdx)
+                  FreeChannel(channel);
+                break;
+              }
+            }
           }
           break;
 
@@ -772,8 +789,19 @@
             sample_volume = GetSoundStrengthByDistanceFromParty(actor->vPosition.x, actor->vPosition.y, actor->vPosition.z);
             if (!sample_volume)
               return;
-            goto LABEL_123;
+            for (uint i = 0; i < uMixerChannels; ++i)
+            {
+              MixerChannel* channel = &pMixerChannels[i];
+              if (channel->source_pid == a3 && AIL_sample_status(channel->hSample) == AIL::Sample::Playing)
+              {
+                if (channel->uSourceTrackIdx == sound_id)
+                  return;                          // already playing the same sound from the same source - return
+                AIL_end_sample(channel->hSample);  // requested new sound from the same source - end & switch
+                FreeChannel(channel);
+              }
+            }
           }
+          break;
 
           case OBJECT_Decoration:
           {
@@ -786,7 +814,17 @@
             sample_volume = GetSoundStrengthByDistanceFromParty(decor->vPosition.x, decor->vPosition.y, decor->vPosition.z);
             if (!sample_volume)
               return;
-            goto LABEL_123;
+            for (uint i = 0; i < uMixerChannels; ++i)
+            {
+              MixerChannel* channel = &pMixerChannels[i];
+              if (channel->source_pid == a3 && AIL_sample_status(channel->hSample) == AIL::Sample::Playing)
+              {
+                if (channel->uSourceTrackIdx == sound_id)
+                  return;                          // already playing the same sound from the same source - return
+                AIL_end_sample(channel->hSample);  // requested new sound from the same source - end & switch
+                FreeChannel(channel);
+              }
+            }
           }
           break;
 
@@ -801,7 +839,17 @@
             sample_volume = GetSoundStrengthByDistanceFromParty(object->vPosition.x, object->vPosition.y, object->vPosition.z);
             if (!sample_volume)
               return;
-            goto LABEL_123;
+            for (uint i = 0; i < uMixerChannels; ++i)
+            {
+              MixerChannel* channel = &pMixerChannels[i];
+              if (channel->source_pid == a3 && AIL_sample_status(channel->hSample) == AIL::Sample::Playing)
+              {
+                if (channel->uSourceTrackIdx == sound_id)
+                  return;                          // already playing the same sound from the same source - return
+                AIL_end_sample(channel->hSample);  // requested new sound from the same source - end & switch
+                FreeChannel(channel);
+              }
+            }
           }
           break;
 
@@ -809,7 +857,17 @@
           {
             start_channel = 8;
             end_channel = 9;
-            goto LABEL_123;
+            for (uint i = 0; i < uMixerChannels; ++i)
+            {
+              MixerChannel* channel = &pMixerChannels[i];
+              if (channel->source_pid == a3 && AIL_sample_status(channel->hSample) == AIL::Sample::Playing)
+              {
+                if (channel->uSourceTrackIdx == sound_id)
+                  return;                          // already playing the same sound from the same source - return
+                AIL_end_sample(channel->hSample);  // requested new sound from the same source - end & switch
+                FreeChannel(channel);
+              }
+            }
           }
           break;
 
@@ -818,33 +876,6 @@
         }
       }
     }
-LABEL_123:
-    for (uint i = 0; i < uMixerChannels; ++i)
-    {
-      MixerChannel* channel = &pMixerChannels[i];
-      if (channel->source_pid == a3 &&
-          AIL_sample_status(channel->hSample) == AIL::Sample::Playing)
-      {
-        if (channel->uSourceTrackIdx == sound_id)
-          return;                          // already playing the same sound from the same source - return
-        AIL_end_sample(channel->hSample);  // requested new sound from the same source - end & switch
-        FreeChannel(channel);
-      }
-    }
-LABEL_133:
-      v62 = start_channel;
-      //pAudioPlayer4 = pAudioPlayer;
-      for (v62 = start_channel; v62 <= end_channel; ++v62)
-      {
-        MixerChannel* channel = pMixerChannels + v62;
-        if (AIL_sample_status(channel->hSample) == AIL::Sample::Done)
-        {
-          AIL_end_sample(channel->hSample);
-          if (channel->uSourceTrackIdx)
-            FreeChannel(channel);
-          break;
-        }
-      }
       /*if ( start_channel <= end_channel)
       {
         pMixerChannel2 = &pAudioPlayer->pMixerChannels[start_channel];
@@ -861,9 +892,9 @@
       }
 LABEL_140:*/
 
-      if (v62 > end_channel)  // no free channel - occupy the quitest one
+      if (start_channel > end_channel)  // no free channel - occupy the quitest one
       {
-        v62 = -1;
+        start_channel = -1;
 
         int min_volume = sample_volume;
         for (uint i = start_channel; i <= end_channel; ++i)
@@ -874,7 +905,7 @@
           if (volume < min_volume)
           {
             min_volume = volume;
-            v62 = i;
+            start_channel = i;
           }
         }
         /*v65 = start_channel;
@@ -1804,12 +1835,7 @@
 //----- (004AB71F) --------------------------------------------------------
 void AudioPlayer::StopChannels(int uStartChannel, int uEndChannel)
 {
-  //AudioPlayer *v3; // esi@1
   int v4; // ecx@1
-  //AudioPlayer_3DSample *v5; // edi@4
-  int v6; // ebx@12
-  MixerChannel *pChannel; // edi@14
-  //_STREAM *v8; // esi@23
   int v9; // [sp+4h] [bp-4h]@3
 
   if ( bPlayerReady )
@@ -1819,41 +1845,36 @@
       v9 = 0;
       if ( uNum3DSamples > 0 )
       {
-        //v5 = p3DSamples;//;(char *)&p3DSamples[0].field_8;
         for ( v4 = 0; v4 < uNum3DSamples; ++v4 )
         {
           if ( (uStartChannel == -1 || v4 < uStartChannel || v4 > uEndChannel)
-			  && p3DSamples[v4].field_8
-			  && pSoundList->pSounds[p3DSamples[v4].field_8].eType != SOUND_DESC_SYSTEM)
+              && p3DSamples[v4].field_8
+              && pSoundList->pSounds[p3DSamples[v4].field_8].eType != SOUND_DESC_SYSTEM)
           {
             AIL_end_3D_sample(p3DSamples[v4].hSample);
             _4ABF23(&p3DSamples[v4]);
             p3DSamples[v4].field_4 = 0;
             v4 = v9;
           }
-          //v5 += 16;
           v9 = v4;
         }
       }
     }
     if ( hDigDriver && uMixerChannels > 0 )
     {
-      pChannel = pMixerChannels;
-      for ( v6 = 0; v6 < uMixerChannels; ++v6 )
+      for ( int i = 0; i < uMixerChannels; ++i )
       {
-        if ( (uStartChannel == -1 || v6 < uStartChannel || v6 > uEndChannel)
-          && pSoundList->pSounds[pChannel->uSourceTrackIdx].eType != SOUND_DESC_SYSTEM)
+        if ( (uStartChannel == -1 || i < uStartChannel || i > uEndChannel)
+          && pSoundList->pSounds[pMixerChannels[i].uSourceTrackIdx].eType != SOUND_DESC_SYSTEM)
         {
-          AIL_end_sample(pChannel->hSample);
-          FreeChannel(pChannel);
-          pChannel->source_pid = 0;
+          AIL_end_sample(pMixerChannels[i].hSample);
+          FreeChannel(&pMixerChannels[i]);
+          pMixerChannels[i].source_pid = 0;
         }
-        ++pChannel;
       }
     }
     if (hSequence)
       AIL_end_sequence(hSequence);
-    //v8 = hStream;
     if (hStream)
       AIL_pause_stream(hStream, 1);
   }
@@ -1886,7 +1907,7 @@
   char v5; // dl@5
   _PROVIDER *v6; // eax@9
   //HWND v7; // ST00_4@9
-  MixerChannel *pChannel; // edi@14
+  //MixerChannel *pChannel; // edi@14
   _SAMPLE *v9; // eax@15
   //_REDBOOK *v10; // eax@19
   //int v11; // ecx@21
@@ -1954,19 +1975,11 @@
       }
     }
   }
-  if ( uMixerChannels > 0 )
+  for ( v3; v3 < uMixerChannels; ++v3 )
   {
-    pChannel = pMixerChannels;
-    do
-    {
-      v9 = AIL_allocate_sample_handle(hDigDriver);
-      pChannel->hSample = v9;
-      if ( !v9 )
-        break;
-      ++v3;
-      ++pChannel;
-    }
-    while ( v3 < uMixerChannels );
+    pMixerChannels[v3].hSample = AIL_allocate_sample_handle(hDigDriver);
+    if ( !pMixerChannels[v3].hSample )
+      break;
   }
   uMixerChannels = v3;
   if ( bPlayerReady )
@@ -2197,19 +2210,11 @@
         {
 LABEL_16:
           pSoundList->UnloadSound(pChannel->uSourceTrackIdx, 1);
-          v10 = 0;
-          if ( num_same_sound_on_channels  > 0 )
+          for ( v10 = 0; v10 < num_same_sound_on_channels; v10++ )
           {
-            do
-            {
-              v11 = v14[v10];
-              v12 = 16 * (v14[v10++] + 47);
-              pMixerChannels[v11].uSourceTrackID = 0;
-              //v13 = __OFSUB__(v10, num_same_sound_on_channels);
-              //v6 = v10 - num_same_sound_on_channels < 0;
-              *(unsigned int *)((char *)&bEAXSupported + v12) = 0;
-            }
-            while (v10 < num_same_sound_on_channels);
+            v12 = 16 * (v14[v10] + 47);
+            pMixerChannels[v14[v10]].uSourceTrackID = 0;
+            *(unsigned int *)((char *)&bEAXSupported + v12) = 0;
           }
         }
       }
--- a/DecalBuilder.cpp	Thu Dec 12 21:42:18 2013 +0600
+++ b/DecalBuilder.cpp	Thu Dec 12 21:44:02 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/Events.cpp	Thu Dec 12 21:42:18 2013 +0600
+++ b/Events.cpp	Thu Dec 12 21:44:02 2013 +0600
@@ -1337,12 +1337,9 @@
         //v7 = "";
         break;
       case EVENT_ChangeDoorState:
-        sub_449A49_door_switch_animation(_evt->v5, _evt->v6);
+        Door_switch_animation(_evt->v5, _evt->v6);
         ++curr_seq_num;
         v4 = v124;
-
-        //v6 = v123;
-        //v7 = "";
         break;
       case EVENT_OpenChest:
         if ( !Chest::Open(_evt->v5) )
--- a/Game.cpp	Thu Dec 12 21:42:18 2013 +0600
+++ b/Game.cpp	Thu Dec 12 21:44:02 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 21:42:18 2013 +0600
+++ b/Indoor.cpp	Thu Dec 12 21:44:02 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;
@@ -937,13 +937,12 @@
   }
 }
 
-
 //----- (004AE5BA) --------------------------------------------------------
 Texture *BLVFace::GetTexture()
 {
   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;
@@ -1827,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)
@@ -1835,7 +1834,7 @@
       else
       {
         pFace->uBitmapID = pBitmaps_LOD->LoadTexture(pTexName);
-        pFace->uAttributes &= ~0x4000;
+        pFace->uAttributes &= ~FACE_TEXTURE_FRAME;
       }
     }
     else
@@ -2580,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) --------------------------------------------------------
@@ -2670,46 +2676,22 @@
     return true;
 }
 
-
-
-
 //----- (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
@@ -2717,381 +2699,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;
@@ -3932,10 +3720,10 @@
   int v38; // edx@62
   //int v44; // [sp+20h] [bp-20h]@10
   bool v47; // [sp+24h] [bp-1Ch]@43
-  bool v48; // [sp+28h] [bp-18h]@10
+  bool current_vertices_Y; // [sp+28h] [bp-18h]@10
   bool v49; // [sp+28h] [bp-18h]@41
-  bool v50; // [sp+2Ch] [bp-14h]@12
-  signed int v53; // [sp+30h] [bp-10h]@10
+  bool next_vertices_Y; // [sp+2Ch] [bp-14h]@12
+  signed int number_hits; // [sp+30h] [bp-10h]@10
   signed int v54; // [sp+30h] [bp-10h]@41
   signed int v55; // [sp+34h] [bp-Ch]@1
 
@@ -3969,19 +3757,19 @@
       blv_floor_face_vert_coord_X[2 * pFloor->uNumVertices] = blv_floor_face_vert_coord_X[0];
       blv_floor_face_vert_coord_Y[2 * pFloor->uNumVertices] = blv_floor_face_vert_coord_Y[0];
 
-      v50 = blv_floor_face_vert_coord_Y[0] >= y;
-      v53 = 0;
+      next_vertices_Y = blv_floor_face_vert_coord_Y[0] >= y;
+      number_hits = 0;
 
       for (uint j = 0; j < 2 * pFloor->uNumVertices; ++j)
       {
-        if (v53 >= 2)
+        if (number_hits >= 2)
           break;
 
-        v48 = v50;
-        v50 = blv_floor_face_vert_coord_Y[j + 1] >= y;
+        current_vertices_Y = next_vertices_Y;
+        next_vertices_Y = blv_floor_face_vert_coord_Y[j + 1] >= y;
 
         v13 = i;
-        if (v48 == v50)
+        if (current_vertices_Y == next_vertices_Y)
           continue;
 
         v14 = blv_floor_face_vert_coord_X[j + 1] >= x ? 0 : 2;
@@ -3990,19 +3778,19 @@
         if (v15 == 3)
           continue;
         else if (!v15)
-          ++v53;
+          ++number_hits;
         else
         {
           long long a_div_b = fixpoint_div(y - blv_floor_face_vert_coord_Y[j], blv_floor_face_vert_coord_Y[j + 1] - blv_floor_face_vert_coord_Y[j]);
           long long res = fixpoint_mul((signed int)blv_floor_face_vert_coord_X[j + 1] - (signed int)blv_floor_face_vert_coord_X[j], a_div_b);
 
             if (res + blv_floor_face_vert_coord_X[j] >= x)
-                ++v53;
+                ++number_hits;
           }
       }
 
 
-        if ( v53 == 1 )
+        if ( number_hits == 1 )
         {
           if ( v55 >= 50 )
             break;
@@ -6873,13 +6661,8 @@
   int v42; // eax@120
   BLVFace *pFace; // esi@126
   int v46; // ecx@133
-  //int v48; // eax@133
-  //int v49; // ST40_4@136
-  //int v50; // ST40_4@140
   int v52; // eax@140
-  //signed int v53; // edi@146
   int v54; // ebx@146
-  //int v55; // ST30_4@146
   int v63; // [sp-8h] [bp-68h]@75
   int v65; // [sp-4h] [bp-64h]@75
   unsigned int uFaceEvent; // [sp+14h] [bp-4Ch]@1
@@ -6889,7 +6672,6 @@
   bool party_walking_flag; // [sp+2Ch] [bp-34h]@1
   unsigned int uFaceID; // [sp+30h] [bp-30h]@1
   int v80; // [sp+34h] [bp-2Ch]@1
-  //int v81; // [sp+38h] [bp-28h]@47
   int v82; // [sp+3Ch] [bp-24h]@47
   int _view_angle; // [sp+40h] [bp-20h]@47
   int bJumping; // [sp+44h] [bp-1Ch]@1
@@ -7161,14 +6943,14 @@
     v1 = 0;
     v2 = 0;
   }
+
   stru_721530.field_84 = -1;
   stru_721530.field_70 = 0;
   stru_721530.prolly_normal_d = pParty->field_14_radius;
   stru_721530.field_8_radius = pParty->field_14_radius / 2;
-  int v83 = 0;
   stru_721530.field_0 = 1;
   stru_721530.height = pParty->uPartyHeight - 32;
-  while ( 1 )
+  for ( uint i = 0; i < 100; i++ )
   {
     new_party_z = party_z;
     stru_721530.position.x = new_party_x;
@@ -7256,7 +7038,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
@@ -7281,7 +7063,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 )
@@ -7294,7 +7076,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
@@ -7309,13 +7091,13 @@
     }
     v2 = (unsigned __int64)(58500i64 * v2) >> 16;
     v1 = (unsigned __int64)(58500i64 * v1) >> 16;
-    ++v83;
+    //++v83;
     pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
-    if ( v83 >= 100 )
-    {
-      new_party_z = v87;
-      break;
-    }
+    //if ( v83 >= 100 )
+    //{
+      //new_party_z = v87;
+      //break;
+    //}
   }
 
   //  //Воспроизведение звуков ходьбы/бега-------------------------
--- a/Indoor.h	Thu Dec 12 21:42:18 2013 +0600
+++ b/Indoor.h	Thu Dec 12 21:44:02 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/Items.h	Thu Dec 12 21:42:18 2013 +0600
+++ b/Items.h	Thu Dec 12 21:44:02 2013 +0600
@@ -30,6 +30,7 @@
   ITEM_AURA_EFFECT_BLUE = 0x20,//32
   ITEM_AURA_EFFECT_GREEN = 0x40,//64
   ITEM_AURA_EFFECT_PURPLE = 0x80,//128
+  ITEM_ENCHANT_ANIMATION = 0xF0,//240
   ITEM_STOLEN = 0x100,
   ITEM_HARDENED = 0x200,
 };
--- a/Mouse.cpp	Thu Dec 12 21:42:18 2013 +0600
+++ b/Mouse.cpp	Thu Dec 12 21:44:02 2013 +0600
@@ -228,81 +228,61 @@
 //----- (00469CCD) --------------------------------------------------------
 void Mouse::DrawCursor()
 {
-  Mouse *v1; // esi@1
-  char v11; // zf@6
-  signed int v3; // eax@6
-  signed int v4; // ecx@6
-  Vec4_int_ *v5; // edx@21
-  int v6; // edi@21
-  int v7; // ebx@21
-  int v8; // eax@29
   unsigned int v9; // eax@31
 
-  v1 = this;
   if ( this->bInitialized )
   {
     if ( !this->field_8 && this->bActive && !this->field_C )
       pMouse->_469AE4();
-    v11 = v1->field_C == 0;
-    v3 = v1->uMouseClickX;
-    v4 = v1->uMouseClickY;
-    v1->field_F4 = 1;
-    if ( !v11 )
-      goto LABEL_12;
+    this->field_F4 = 1;
+    if ( this->field_C )
+    {
+      this->field_F4 = 0;
+      return;
+    }
     if ( pRenderer->bWindowMode )
     {
-      if ( v3 < 0 || v4 < 0 || v3 > 639 || v4 > 479 )
+      if ( this->uMouseClickX < 0 || this->uMouseClickY < 0 || this->uMouseClickX > 639 || this->uMouseClickY > 479 )
       {
-LABEL_12:
-        v1->field_F4 = 0;
+        this->field_F4 = 0;
         return;
       }
     }
     else
     {
-      if ( v3 < 0 )
-        v3 = 0;
-      if ( v4 < 0 )
-        v4 = 0;
-      if ( v3 > 639 )
-        v3 = 639;
-      if ( v4 > 479 )
-        v4 = 479;
+      if ( this->uMouseClickX < 0 )
+        this->uMouseClickX = 0;
+      if ( this->uMouseClickY < 0 )
+        this->uMouseClickY = 0;
+      if ( this->uMouseClickX > 639 )
+        this->uMouseClickX = 639;
+      if ( this->uMouseClickY > 479 )
+        this->uMouseClickY = 479;
     }
-    v5 = &v1->pCursorBitmapRect;
-    v6 = v3 + v1->uCursorBitmapPitch;
-    v7 = v4 + v1->field_5C[0];
-    v1->pCursorBitmapRect.y = v4;
-    v1->pCursorBitmapRect.x = v3;
-    v1->pCursorBitmapRect.z = v6;
-    v1->pCursorBitmapRect.w = v7;
-    if ( v3 < 0 )
-      v5->x = 0;
-    if ( v4 < 0 )
-      v1->pCursorBitmapRect.y = 0;
-    if ( v6 > 640 )
-      v1->pCursorBitmapRect.z = 640;
-    if ( v7 > 480 )
-      v1->pCursorBitmapRect.w = 480;
-    v8 = v1->pCursorBitmapRect.z;
-    v1->bActive = 0;
-    v1->uCursorBitmapWidth = v8 - v5->x;
-    v11 = v1->bRedraw == 0;
-    v1->uCursorBitmapHeight = v1->pCursorBitmapRect.w - v1->pCursorBitmapRect.y;
-    if ( !v11 )
+    this->pCursorBitmapRect.x = this->uMouseClickX;
+    this->pCursorBitmapRect.w = this->uMouseClickY + this->field_5C[0];
+    this->pCursorBitmapRect.y = this->uMouseClickY;
+    this->pCursorBitmapRect.z = this->uMouseClickX + this->uCursorBitmapPitch;
+    if ( this->uMouseClickX < 0 )
+      this->pCursorBitmapRect.x = 0;
+    if ( this->uMouseClickY < 0 )
+      this->pCursorBitmapRect.y = 0;
+    if ( this->pCursorBitmapRect.z > 640 )
+      this->pCursorBitmapRect.z = 640;
+    if ( this->pCursorBitmapRect.w > 480 )
+      this->pCursorBitmapRect.w = 480;
+    this->bActive = 0;
+    this->uCursorBitmapWidth = this->pCursorBitmapRect.z - this->pCursorBitmapRect.x;
+    this->uCursorBitmapHeight = this->pCursorBitmapRect.w - this->pCursorBitmapRect.y;
+    if ( this->bRedraw )
     {
       if ( pMouse->ptr_90 )
         v9 = 2 * pMouse->uCursorBitmapPitch;
       else
         v9 = 0;
-      pRenderer->_4A6DF5(
-        v1->pCursorBitmap_sysmem,
-        v9,
-        &v1->pCursorBitmapPos,
-        pRenderer->pTargetSurface,
-        pRenderer->uTargetSurfacePitch,
-        &v1->pCursorBitmapRect);
-      v1->bRedraw = false;
+      pRenderer->_4A6DF5( this->pCursorBitmap_sysmem, v9, &this->pCursorBitmapPos, pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch,
+        &this->pCursorBitmapRect);//срабатывает когда берём курсором вещь в инвенторе
+      this->bRedraw = false;
     }
   }
 }
--- a/Outdoor.cpp	Thu Dec 12 21:42:18 2013 +0600
+++ b/Outdoor.cpp	Thu Dec 12 21:44:02 2013 +0600
@@ -2049,7 +2049,7 @@
   //v73 = strlen(pContainer);
   strcpy(Str + strlen(Str) - 4, ".ddm");
   //strcpy((char *)v141 + v73, (const char *)v108);
-  v39 = pNew_LOD->FindContainer(Str, 1);//
+  v39 = pNew_LOD->FindContainer(Str, 1);//error
   fread(&header, 0x10u, 1u, v39);
   Str2 = 0;
   if (header.uVersion != 91969 ||
@@ -3645,7 +3645,7 @@
 {
   int v1; // edi@1
   int v2; // ebx@1
-  int v3; // eax@14
+  int floor_level; // eax@14
   int v6; // esi@45
   ODMFace *face; // ecx@45
   signed int v33; // eax@143
@@ -3670,15 +3670,9 @@
   BSPModel *v60; // eax@228
   unsigned __int64 v61; // qax@228
   int v62; // eax@241
-  unsigned int v65; // ebx@263
   unsigned int v66; // esi@263
-  int v67; // eax@263
   signed int v68; // ecx@263
   int v69; // eax@263
-  int v70; // ebx@271
-  int v71; // esi@271
-  int v72; // edi@271
-  int v73; // eax@271
   unsigned int v76; // edi@293
   bool v77; // edx@297
   bool v78; // ecx@303
@@ -3704,7 +3698,7 @@
   bool bFeatherFall; // [sp+28h] [bp-6Ch]@4
   int v105; // [sp+2Ch] [bp-68h]@24
   bool bWaterWalk; // [sp+30h] [bp-64h]@1
-  int v109; // [sp+3Ch] [bp-58h]@28
+  int ceiling_height; // [sp+3Ch] [bp-58h]@28
   int v110; // [sp+40h] [bp-54h]@180
   int v111; // [sp+44h] [bp-50h]@14
   bool hovering; // [sp+48h] [bp-4Ch]@1
@@ -3719,7 +3713,6 @@
   int pZ; // [sp+74h] [bp-20h]@1
   bool party_walking_flag; // [sp+78h] [bp-1Ch]@1
   int _angle_y; // [sp+7Ch] [bp-18h]@48
-  int v126; // [sp+80h] [bp-14h]@48
   int v128; // [sp+88h] [bp-Ch]@1
   int v129; // [sp+8Ch] [bp-8h]@92
 
@@ -3767,15 +3760,16 @@
 
   int bmodel_standing_on_pid;
   int is_on_water = false;
-  v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, bWaterWalk);
+  floor_level = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, bWaterWalk);
   int is_not_on_bmodel = bmodel_standing_on_pid == 0;
 
-  v111 = v3;
+  v111 = floor_level;
   if ( bFeatherFall )
-    pParty->uFallStartY = v3;
+    pParty->uFallStartY = floor_level;
   else
-    v3 = pParty->uFallStartY;
-  if ( v3 - pZ > 512 && !bFeatherFall && pZ <= v111 + 1 )
+    floor_level = pParty->uFallStartY;
+
+  if ( floor_level - pZ > 512 && !bFeatherFall && pZ <= v111 + 1 )//падение на 3D Model
   {
     if (pParty->uFlags & PARTY_FLAGS_1_LANDING)
     {
@@ -3792,14 +3786,15 @@
       }
     }
   }
-  v109 = -1;
+
+  ceiling_height = -1;
   if ( pParty->bFlying )
-    v109 = GetCeilingHeight(pX, pY, pZ + pParty->uPartyHeight, (int)&v102);
+    ceiling_height = GetCeilingHeight(pX, pY, pZ + pParty->uPartyHeight, (int)&v102);//высота потолка
   //v107 = bmodel_standing_on_pid == 0;
   v105 = v111 + 1;
   if ( pZ <= v111 + 1 )
   {
-    v109 = -1;
+    ceiling_height = -1;
     pParty->bFlying = false;
   }
   else
@@ -3844,7 +3839,7 @@
   _walk_speed = pParty->uWalkSpeed;
   _angle_y = pParty->sRotationY;
   _angle_x = pParty->sRotationX;
-  v126 = pEventTimer->dt_in_some_format;
+  //v126 = pEventTimer->dt_in_some_format;
   /*v119 = (Player **)((unsigned __int64)(pEventTimer->dt_in_some_format
                                       * (signed __int64)((signed int)(pParty->field_20_prolly_turn_speed
                                                                     * stru_5C6E00->uIntegerPi)
@@ -3879,16 +3874,16 @@
               v2 = 0;
               pParty->uFallSpeed = 0;
               *(float *)&v128 = 0.0;
-              if ( v102 && pZ < v109 && (signed int)(pParty->uPartyHeight + pZ) >= v109 )//сверить с ида(ошибка)
+              if ( v102 && pZ < ceiling_height && (signed int)(pParty->uPartyHeight + pZ) >= ceiling_height )//столкновение с потолком(ошибка)
               {
                 pParty->field_6E0 = 0;
                 pParty->field_6E4 = 0;
                 pPartyActionQueue->uNumActions = 0;
                 pParty->uFlags |= PARTY_FLAGS_1_LANDING;
-                pParty->vPosition.z = v109 - pParty->uPartyHeight - 31;
+                pParty->vPosition.z = ceiling_height - pParty->uPartyHeight - 31;
                 pParty->field_6F0 = pZ;
                 pParty->bFlying = false;
-                pZ = v109 - pParty->uPartyHeight - 31;
+                pZ = ceiling_height - pParty->uPartyHeight - 31;
                 v113 = pParty->field_6F0;
               }
               pParty->uFallSpeed = 0;
@@ -4121,7 +4116,7 @@
       case PARTY_Jump:
         if ( (!partyAtHighSlope || bmodel_standing_on_pid) && !hovering && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) )
         {
-          v126 = pParty->field_24 << 6;
+          //v126 = pParty->field_24 << 6;
           hovering = true;
           pParty->uFallSpeed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)pParty->uFallSpeed);
         }
@@ -4144,15 +4139,14 @@
     }
   }
 
-//LABEL_123:
   pParty->sRotationY = _angle_y;
   pParty->sRotationX = _angle_x;
   if ( pZ < v111 || pParty->bFlying)
   {
     if ( pParty->bFlying )
     {
-      v126 = stru_5C6E00->Cos(GetTickCount());
-      v129 = (unsigned __int64)(4i64 * v126) >> 16;
+      //v126 = stru_5C6E00->Cos(GetTickCount());
+      v129 = (unsigned __int64)(4i64 * stru_5C6E00->Cos(GetTickCount())) >> 16;
       pZ = v113 + v129;
       if ( pModel )
         pZ = v113;
@@ -4243,20 +4237,23 @@
   stru_721530.field_8_radius = pParty->field_14_radius >> 1;
   stru_721530.field_0 = 1;
   stru_721530.height = pParty->uPartyHeight - 32;
-  for ( v126 = 0; v126 < 100; v126++ )
+  for ( uint i = 0; i < 100; i++ )
   {
     stru_721530.position.x = pX;
+    stru_721530.position.y = pY;
+    stru_721530.position.z = stru_721530.height + pZ + 1;
+
     stru_721530.normal.x = pX;
-    stru_721530.velocity.x = v2;
-    stru_721530.position.y = pY;
     stru_721530.normal.y = pY;
     stru_721530.normal.z = stru_721530.prolly_normal_d + pZ + 1;
-    stru_721530.position.z = stru_721530.height + pZ + 1;
+
+    stru_721530.velocity.x = v2;
     stru_721530.velocity.y = v128;
     stru_721530.velocity.z = pParty->uFallSpeed;
-    v36 = 0;
+
     stru_721530.uSectorID = 0;
-    if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3 )
+    v36 = 0;
+    if ( pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == 3 )
       v36 = 13312;
     if ( stru_721530._47050A(v36) )
       break;
@@ -4264,7 +4261,7 @@
     v37 = WorldPosToGridCellZ(pParty->vPosition.y);
     v38 = WorldPosToGridCellX(pParty->vPosition.x);
     _46E26D_collide_against_sprites(v38, v37);
-    _46ED8A_collide_against_sprite_objects(4u);
+    _46ED8A_collide_against_sprite_objects(4);
     for ( i = 0; i < (signed int)uNumActors; ++i )
       Actor::_46DF1A_collide_against_actor(i, 0);
     if ( stru_721530.field_7C >= stru_721530.field_6C )
@@ -4287,7 +4284,7 @@
     pModel = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, pY);
     v42 = IsTerrainSlopeTooHigh(pX, _angle_y);
     is_not_on_bmodel = false;
-    v118 = v42;
+    //v118 = v42;
     if ( !v97 && !v110 && !bmodel_standing_on_pid )
       is_not_on_bmodel = true;
     v43 = 1;
@@ -4302,7 +4299,7 @@
     {
       if ( pModel && v129 > pZ )
         v44 = 0;
-      if ( v118 && v119 > pZ )
+      if ( v42 && v119 > pZ )
         v43 = 0;
       if ( v44 )
       {
@@ -4349,19 +4346,18 @@
       pModel = (BSPModel *)58500;
       v128 = (unsigned __int64)(58500i64 * v128) >> 16;
       v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
-      ++v126;
       pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
       continue;
     }
     if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
     {
-      v118 = integer_sqrt(v2 * v2 + v128 * v128);
+      //v118 = integer_sqrt(v2 * v2 + v128 * v128);
       v129 = stru_5C6E00->Atan2(_angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x,
                                _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y);
-      v59 = (signed int)stru_5C6E00->Cos(v129) * (signed __int64)v118;
+      v59 = (signed int)stru_5C6E00->Cos(v129) * (signed __int64)integer_sqrt(v2 * v2 + v128 * v128);
       v122 = v59 >> 16;
       v2 = v59 >> 16;
-      v61 = (signed int)stru_5C6E00->Sin(v129) * (signed __int64)v118;
+      v61 = (signed int)stru_5C6E00->Sin(v129) * (signed __int64)integer_sqrt(v2 * v2 + v128 * v128);
       v122 = v61 >> 16;
       v128 = v61 >> 16;
     }
@@ -4371,13 +4367,8 @@
       {
         pParty->bFlying = false;
         pModel = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9];
-        //v127 = v46;
         pODMFace = &pModel->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F];
         v48 = pODMFace->pBoundingBox.z2 - pODMFace->pBoundingBox.z1;
-        //v51 = __OFSUB__(v48, 32);
-        //v49 = v48 == 32;
-        //v50 = v48 - 32 < 0;
-        //v52 = pODMFace->pFacePlane.vNormal.z;
         v129 = v48 <= 32;
         v119 = pODMFace->pFacePlane.vNormal.z < 46378;
         if ( bUnderwater == 1 )
@@ -4392,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; //
@@ -4401,7 +4392,6 @@
           pModel = (BSPModel *)58500;
           v128 = (unsigned __int64)(58500i64 * v128) >> 16;
           v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
-          //++v126;
           pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
           continue;
         }
@@ -4416,14 +4406,7 @@
           v128 += (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.y) >> 16;
           v54 = 0;
           if ( !v119 )
-          {
-            //pModel = (BSPModel *)pODMFace->pFacePlane.vNormal.z;
             pParty->uFallSpeed += (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.z) >> 16;
-            //v54 = pModel;
-          }
-          //pParty->uFallSpeed += (int)v54;
-          //v128 += _walk_speed;
-          //v2 += v129;
           v55 = stru_721530.prolly_normal_d
               - ((signed int)(pODMFace->pFacePlane.dist
                             + v122 * pODMFace->pFacePlane.vNormal.z
@@ -4436,8 +4419,7 @@
             if ( !v119 )
               pZ = v122 + (pODMFace->pFacePlane.vNormal.z * v55 >> 16);
           }
-          //v45 = stru_721530.uFaceID;
-          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; //
@@ -4446,7 +4428,6 @@
           pModel = (BSPModel *)58500;
           v128 = (unsigned __int64)(58500i64 * v128) >> 16;
           v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
-          //++v126;
           pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
           continue;
         }
@@ -4454,19 +4435,12 @@
              + pParty->uFallSpeed * pODMFace->pFacePlane.vNormal.z + v2 * pODMFace->pFacePlane.vNormal.x) >> 16;
         if ((stru_721530.speed >> 3) > v118 )
           v118 = stru_721530.speed >> 3;
-        //v122 = pODMFace->pFacePlane.vNormal.x;
         v2 += (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.x) >> 16;
-        //pModel = (BSPModel *)pODMFace->pFacePlane.vNormal.y;
         v128 += (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.y) >> 16;
-        //v129 = pODMFace->pFacePlane.vNormal.z;
         pParty->uFallSpeed += (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.z) >> 16;
-        //pParty->uFallSpeed += v129;
-        //v2 += v122;
-        //v128 += (int)pModel;
         if ( v2 * v2 + v128 * v128 >= 400 )
         {
-          //v45 = stru_721530.uFaceID;
-          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; //
@@ -4493,14 +4467,14 @@
 
   //Воспроизведение звуков ходьбы/бега------------------------
   v122 = abs(pParty->vPosition.x - pX);
-  v126 = abs(pParty->vPosition.y - pY);
+  uint pY_ = abs(pParty->vPosition.y - pY);
   v62 = abs(pParty->vPosition.z - pZ);
   if ( bWalkSound && pParty->walk_sound_timer <= 0 )
   {
     pAudioPlayer->_4AA258(804);//stop sound
     if ( party_running_flag && (!hovering || high_fall_flag) )
     {
-      if ( integer_sqrt(v122 * v122 + v126 * v126 + v62 * v62) >= 16 )
+      if ( integer_sqrt(v122 * v122 + pY_ * pY_ + v62 * v62) >= 16 )
       {
         if ( !is_not_on_bmodel
            && !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) )
@@ -4515,7 +4489,7 @@
     }
     else if( party_walking_flag && (!hovering || high_fall_flag) )
     {
-      if ( integer_sqrt(v122 * v122 + v126 * v126 + v62 * v62) >= 8 )
+      if ( integer_sqrt(v122 * v122 + pY_ * pY_ + v62 * v62) >= 8 )
       {
         if ( is_not_on_bmodel
           || BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 )
@@ -4529,54 +4503,48 @@
       }
     }
   }
-  if ( integer_sqrt(v122 * v122 + v126 * v126 + v62 * v62) < 8 )//отключить  звук ходьбы при остановке
+  if ( integer_sqrt(v122 * v122 + pY_ * pY_ + v62 * v62) < 8 )//отключить  звук ходьбы при остановке
     pAudioPlayer->_4AA258(804);
 //------------------------------------------------------------------------
   if ( !hovering || !high_fall_flag )
     pParty->uFlags &= ~PARTY_FLAGS_1_FALLING;
   else
     pParty->uFlags |= PARTY_FLAGS_1_FALLING;
-  v126 = WorldPosToGridCellX(pParty->vPosition.x);
-  v65 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
+  int pMap_X = WorldPosToGridCellX(pParty->vPosition.x);
+  int pMap_Y = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
   unsigned int v114_a = WorldPosToGridCellX(pX);
   v66 = WorldPosToGridCellZ(pY) - 1;
-  pModel = (BSPModel *)((~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1);
-  v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114_a, v65) >> 1) & 1;
-  v67 = pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v66);
+  pModel = (BSPModel *)((~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(pMap_X, pMap_Y) >> 1) & 1);
+  v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114_a, pMap_Y) >> 1) & 1;
   v68 = 0;
-  v69 = (~(unsigned int)v67 >> 1) & 1;
-  if ( v114_a == v126 && v66 == v65 && v122 && v69 )
+  v69 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(pMap_X, v66) >> 1) & 1;
+  if ( v114_a == pMap_X && v66 == pMap_Y && v122 && v69 )
     v68 = 1;
   if ( !is_not_on_bmodel )
     v68 = 1;
   if ( v68 )
   {
-    v70 = pZ;
-    v71 = pX;
-    v72 = pY;
-    //pParty->uFallSpeed = v121;
-    v73 = pZ;
     pParty->vPosition.x = pX;
     pParty->vPosition.y = pY;
     pParty->vPosition.z = pZ;
     pParty->field_6F0 = v113;
     if ( pZ > 8160 )
     {
-      v73 = 8160;
+      pZ = 8160;
       pParty->uFallStartY = 8160;
       pParty->vPosition.z = 8160;
     }
-    if ( !v103 //
-      || (EventProcessor(v103, 0, 1), pParty->vPosition.x == v71)
-      && pParty->vPosition.y == v72
-      && (v73 = pParty->vPosition.z, pParty->vPosition.z == v70) )
+    if ( !v103 //падение на землю
+      || (EventProcessor(v103, 0, 1), pParty->vPosition.x == pX)
+      && pParty->vPosition.y == pY
+      && pParty->vPosition.z == pZ )
     {
-      if ( v73 < v111 )
+      if ( pParty->vPosition.z < v111 )
       {
         pParty->uFallSpeed = 0;
-        v73 = v105;
+        //v73 = v105;
         pParty->vPosition.z = v105;
-        if ( pParty->uFallStartY - v70 > 512 && !bFeatherFall && v70 <= v105 && !bUnderwater )//Fall to the ground(падение на землю с высоты)
+        if ( pParty->uFallStartY - pZ > 512 && !bFeatherFall && pZ <= v105 && !bUnderwater )//Fall to the ground(падение на землю с высоты)
         {
           if ( pParty->uFlags & PARTY_FLAGS_1_LANDING )
           {
@@ -4587,22 +4555,22 @@
             for ( uint i = 1; i <= 4; ++i )
             {
               v110 = pPlayers[i]->GetMaxHealth();
-              pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
+              pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - pZ) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
                 DMGT_PHISYCAL);
               v110 = 20 - pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualEndurance());
               pPlayers[i]->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
             }
-            v73 = pParty->vPosition.z;
+            //v73 = pParty->vPosition.z;
           }
         }
-        pParty->uFallStartY = v70;
+        pParty->uFallStartY = pZ;
       }
-      if ( v102 && v73 < v109 )
+      if ( v102 && pParty->vPosition.z < ceiling_height )
       {
-        if ( (signed int)(pParty->uPartyHeight + v73) >= v109 )
+        if ( (signed int)(pParty->uPartyHeight + pParty->vPosition.z) >= ceiling_height )
         {
-          pParty->vPosition.z = v109 - pParty->uPartyHeight - 1;
-          pParty->field_6F0 = v109 - pParty->uPartyHeight - 1;
+          pParty->vPosition.z = ceiling_height - pParty->uPartyHeight - 1;
+          pParty->field_6F0 = ceiling_height - pParty->uPartyHeight - 1;
         }
       }
       pParty->uFlags &= ~0x204;
@@ -4618,26 +4586,20 @@
   if ( !pParty->bFlying && high_fall_flag && !bWaterWalk )
   {
     if ( pModel )
+      v78 = v69 != 0;
+    else
     {
-      v78 = v69 != 0;
+      party_drowning_flag = true;
+      v78 = true;
     }
-	else
-	{
-		party_drowning_flag = true;
-		v78 = 1;
-	}
   }
   else
-	v78 = 1;
+    v78 = true;
 
   if ( v77 )
-  {
     pParty->vPosition.x = pX;
-  }
   if ( v78 )
-  {
     pParty->vPosition.y = pY;
-  }
 
   if ( v78 || v77)
   {
@@ -4684,12 +4646,12 @@
       pParty->uFlags |= PARTY_FLAGS_1_WATER_DAMAGE;
   }
 
-  if ( !v103//
+  if ( !v103//падение на воду
     || (EventProcessor(v103, 0, 1), pParty->vPosition.x == pX)
     && pParty->vPosition.y == pY
     && (v82 = pParty->vPosition.z, pParty->vPosition.z == v81) )
   {
-    if ( v82 < v111 )
+    if ( pParty->vPosition.z < v111 )
     {
       v82 = v105;
       pParty->uFallSpeed = 0;
@@ -4715,10 +4677,10 @@
       }
       pParty->uFallStartY = v81;
     }
-    if ( v102 && v82 < v109 && (signed int)(pParty->uPartyHeight + v82) >= v109 )
+    if ( v102 && v82 < ceiling_height && (signed int)(pParty->uPartyHeight + v82) >= ceiling_height )
     {
-      pParty->vPosition.z = v82 + pParty->uPartyHeight - v109 + 1;
-      pParty->field_6F0 = v82 + pParty->uPartyHeight - v109 + 1;
+      pParty->vPosition.z = v82 + pParty->uPartyHeight - ceiling_height + 1;
+      pParty->field_6F0 = v82 + pParty->uPartyHeight - ceiling_height + 1;
     }
   }
 }
--- a/Outdoor.h	Thu Dec 12 21:42:18 2013 +0600
+++ b/Outdoor.h	Thu Dec 12 21:44:02 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 21:42:18 2013 +0600
+++ b/Render.cpp	Thu Dec 12 21:44:02 2013 +0600
@@ -3563,19 +3563,12 @@
 //----- (004A0BEE) --------------------------------------------------------
 char Render::RasterLine2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor)
 {
-  int v6; // edi@1
-  int v7; // edx@5
   unsigned int v8; // ebx@5
-  int v9; // eax@7
   unsigned int v10; // ecx@9
   unsigned int v11; // esi@13
   int v12; // eax@17
   int v13; // eax@21
-  Render *v14; // edi@21
-  int v15; // eax@25
   int v16; // eax@27
-  signed int v17; // eax@28
-  signed int v18; // edi@30
   signed __int64 v19; // qax@41
   int v20; // edi@41
   unsigned int v21; // edi@46
@@ -3590,8 +3583,6 @@
   int v30; // ebx@60
   int v31; // edx@61
   int v32; // edi@61
-  int v34; // [sp+Ch] [bp-10h]@3
-  Render *v35; // [sp+10h] [bp-Ch]@1
   __int64 v36; // [sp+14h] [bp-8h]@1
   signed int v37; // [sp+18h] [bp-4h]@28
   unsigned int uXa; // [sp+24h] [bp+8h]@49
@@ -3600,29 +3591,24 @@
   int uZa; // [sp+2Ch] [bp+10h]@38
 
   v36 = 0i64;
-  v6 = this->raster_clip_x;
-  v35 = this;
-  if ( (signed int)uX < v6 )
+  if ( (signed int)uX < this->raster_clip_x )
     HIDWORD(v36) = 8;
-  v34 = this->raster_clip_z;
   if ( (signed int)uX > this->raster_clip_z )
-    HIDWORD(v36) |= 4u;
-  v7 = this->raster_clip_y;
+    HIDWORD(v36) |= 4;
   v8 = uY;
-  if ( (signed int)uY < v7 )
-    HIDWORD(v36) |= 2u;
-  v9 = this->raster_clip_w;
-  if ( (signed int)uY > v9 )
-    HIDWORD(v36) |= 1u;
+  if ( (signed int)uY < this->raster_clip_y )
+    HIDWORD(v36) |= 2;
+  if ( (signed int)uY > this->raster_clip_w )
+    HIDWORD(v36) |= 1;
   v10 = uZ;
-  if ( (signed int)uZ < v6 )
+  if ( (signed int)uZ < this->raster_clip_x )
     LODWORD(v36) = 8;
-  if ( (signed int)uZ > v34 )
+  if ( (signed int)uZ > this->raster_clip_z )
     LODWORD(v36) = v36 | 4;
   v11 = uW;
-  if ( (signed int)uW < v7 )
+  if ( (signed int)uW < this->raster_clip_y )
     LODWORD(v36) = v36 | 2;
-  if ( (signed int)uW > v9 )
+  if ( (signed int)uW > this->raster_clip_w )
     LODWORD(v36) = v36 | 1;
   LOBYTE(v12) = v36;
   if ( (unsigned int)v36 & HIDWORD(v36) )
@@ -3655,11 +3641,11 @@
       }
       v25 = 0;
 
-      __debugbreak(); //target sruface will most likely be 32bits/pixel, but this sub awaits 16 bits
-      v26 = (unsigned __int16 *)v35->pTargetSurface;
+      //__debugbreak(); //target sruface will most likely be 32bits/pixel, but this sub awaits 16 bits
+      v26 = (unsigned __int16 *)this->pTargetSurface;
       if ( v26 )
       {
-        if ( (signed int)uXa <= v23 )
+        if ( (signed int)uXa <= v23 )//рисуем вертикальную линию
         {
           v30 = v23 + 1;
           if ( v30 > 0 )
@@ -3667,7 +3653,7 @@
             v31 = 2 * v24;
             v32 = 2 * v21;
             v12 = (int)&v26[v12];
-            do
+            for ( v30; v30; --v30 )
             {
               v25 += uXa;
               *(short *)v12 = uColor;
@@ -3677,12 +3663,10 @@
                 v25 -= uYb;
                 v12 += v31;
               }
-              --v30;
             }
-            while ( v30 );
           }
         }
-        else
+        else//рисуем горизонтальную линию
         {
           v27 = uXa + 1;
           if ( (signed int)(uXa + 1) > 0 )
@@ -3690,7 +3674,7 @@
             v28 = 2 * v21;
             v29 = 2 * v24;
             v12 = (int)&v26[v12];
-            do
+            for ( v27; v27; --v27 )
             {
               v25 += uYb;
               *(short *)v12 = uColor;
@@ -3700,9 +3684,7 @@
                 v25 -= uXa;
                 v12 += v28;
               }
-              --v27;
             }
-            while ( v27 );
           }
         }
       }
@@ -3713,46 +3695,41 @@
   {
     if ( BYTE4(v36) & 8 )
     {
-      v13 = (signed int)((uW - uY) * (v6 - uX)) / (signed int)(uZ - uX);
-      v14 = v35;
+      v13 = (signed int)((uW - uY) * (this->raster_clip_x - uX)) / (signed int)(uZ - uX);
       v8 = v13 + uY;
-      uX = v35->raster_clip_x;
+      uX = this->raster_clip_x;
       goto LABEL_24;
     }
-    v10 = v6;
-    v11 = (signed int)((uY - uW) * (v6 - uZ)) / (signed int)(uX - uZ) + uW;
-  }
-  v14 = v35;
+    v10 = this->raster_clip_x;
+    v11 = (signed int)((uY - uW) * (this->raster_clip_x - uZ)) / (signed int)(uX - uZ) + uW;
+  }
 LABEL_24:
   if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 )
   {
-    v15 = v14->raster_clip_z;
+    //v15 = this->raster_clip_z;
     if ( BYTE4(v36) & 4 )
     {
-      v14 = v35;
-      v8 += (signed int)((v11 - v8) * (v15 - uX)) / (signed int)(v10 - uX);
-      uX = v35->raster_clip_z;
+      v8 += (signed int)((v11 - v8) * (this->raster_clip_z - uX)) / (signed int)(v10 - uX);
+      uX = this->raster_clip_z;
     }
     else
     {
-      v16 = (signed int)((v8 - v11) * (v15 - v10)) / (signed int)(uX - v10);
-      v10 = v14->raster_clip_z;
+      v16 = (signed int)((v8 - v11) * (this->raster_clip_z - v10)) / (signed int)(uX - v10);
+      v10 = this->raster_clip_z;
       v11 += v16;
     }
   }
-  v17 = v14->raster_clip_y;
   v37 = 0;
-  uYa = v14->raster_clip_y;
-  if ( (signed int)v8 < v17 )
+  uYa = this->raster_clip_y;
+  if ( (signed int)v8 < this->raster_clip_y )
     v37 = 2;
-  v18 = v14->raster_clip_w;
-  if ( (signed int)v8 > v18 )
-    v37 |= 1u;
-  if ( (signed int)v11 >= v17 )
+  if ( (signed int)v8 > this->raster_clip_w )
+    v37 |= 1;
+  if ( (signed int)v11 >= this->raster_clip_y )
     v12 = 0;
   else
     v12 = 2;
-  if ( (signed int)v11 > v18 )
+  if ( (signed int)v11 > this->raster_clip_w )
     LOBYTE(v12) = v12 | 1;
   if ( !(v12 & v37) )
   {
@@ -3763,8 +3740,8 @@
       if ( v37 & 2 )
       {
         uX += (signed int)((v10 - uX) * (uYa - v8)) / (signed int)(v11 - v8);
-        LOBYTE(v12) = (char)v35;
-        v8 = v35->raster_clip_y;
+        LOBYTE(v12) = (char)this;
+        v8 = this->raster_clip_y;
       }
       else
       {
@@ -3779,14 +3756,14 @@
     {
       if ( v37 & 1 )
       {
-        uX += (signed int)((v10 - uX) * (v35->raster_clip_w - v8)) / (signed int)(v11 - v8);
-        LOBYTE(v12) = (char)v35;
-        v8 = v35->raster_clip_w;
+        uX += (signed int)((v10 - uX) * (this->raster_clip_w - v8)) / (signed int)(v11 - v8);
+        LOBYTE(v12) = (char)this;
+        v8 = this->raster_clip_w;
       }
       else
       {
-        v12 = (signed int)((uX - v10) * (v35->raster_clip_w - v11)) / (signed int)(v8 - v11);
-        v11 = v35->raster_clip_w;
+        v12 = (signed int)((uX - v10) * (this->raster_clip_w - v11)) / (signed int)(v8 - v11);
+        v11 = this->raster_clip_w;
         v10 += v12;
       }
     }
@@ -7050,47 +7027,25 @@
 //----- (004A6DF5) --------------------------------------------------------
 void Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7)
 {
-  int result; // eax@0
   int v8; // ecx@3
-  unsigned __int16 *v9; // edi@4
   unsigned __int16 *v10; // ebx@4
   int v11; // esi@4
-  unsigned __int16 *pBitmapa; // [sp+14h] [bp+8h]@3
-  unsigned __int16 *pTargeta; // [sp+20h] [bp+14h]@3
 
   if ( !pBitmap || !pTarget)
     return;
 
-      pBitmapa = &pBitmap[pBitmapXY->x + uBitmapPitch * pBitmapXY->y];
-
-      __debugbreak(); // sub expects 16bit target surface, we may have 32bit
-      pTargeta = (unsigned short *)pTarget + a7->x + uTargetPitch * a7->y;
-      v8 = a7->z - a7->x;
-      v11 = a7->w - a7->y;
-      if ( v11 > 0 )
-      {
-        v9 = pBitmapa;
-        v10 = pTargeta;
-        do
-        {
-          if ( v8 > 0 )
-          {
-            result = v8;
-            do
-            {
-              *v9 = *v10;
-              ++v9;
-              ++v10;
-              --result;
-            }
-            while ( result );
-          }
-          v9 += uBitmapPitch - v8;
-          v10 += uTargetPitch - v8;
-          --v11;
-        }
-        while ( v11 );
-      }
+  v8 = a7->z - a7->x;
+  v11 = a7->w - a7->y;
+  v10 = (unsigned short *)pTarget + a7->x + uTargetPitch * a7->y;
+  for ( int y = 0; y < v11; ++y )
+  {
+    for ( int x = 0; x < v8; ++x )
+    {
+      WritePixel16(a7->x + x, a7->y + y, *v10);
+      ++v10;
+    }
+    v10 += uTargetPitch - v8;
+  }
 }
 
 //----- (004A6D87) --------------------------------------------------------
--- a/SpriteObject.cpp	Thu Dec 12 21:42:18 2013 +0600
+++ b/SpriteObject.cpp	Thu Dec 12 21:44:02 2013 +0600
@@ -206,26 +206,14 @@
 //----- (00471C03) --------------------------------------------------------
 void SpriteObject::UpdateObject_fn0_ODM(unsigned int uLayingItemID)
 {
-  //SpriteObject *v1; // esi@1
   ObjectDesc *object; // ebx@1
-  signed int v3; // edx@1
-  int v4; // ecx@1
-  int v5; // ST04_4@1
   int v6; // eax@1
   int v7; // ecx@1
   int v8; // edi@1
   int v9; // eax@4
-  __int16 v10; // ax@7
-  int v11; // edx@11
-  int v12; // ecx@11
-  signed int v13; // edx@14
-  signed int v14; // edx@16
-  int v15; // eax@24
-  int v16; // eax@25
   int v17; // ST10_4@25
-  signed int v18; // eax@25
-  signed int v19; // eax@28
-  Actor *v20; // edi@31
+  //signed int v19; // eax@28
+  //Actor *v20; // edi@31
   int v21; // eax@41
   int v22; // ecx@43
   __int16 v23; // bx@45
@@ -235,16 +223,16 @@
   int v27; // eax@52
   __int16 v28; // cx@55
   int v29; // eax@55
-  signed int v30; // edi@59
-  BSPModel *v31; // ecx@61
-  ODMFace *v32; // edi@61
+  //signed int v30; // edi@59
+  BSPModel *bmodel; // ecx@61
+  ODMFace *face; // edi@61
   int v33; // eax@62
   int v34; // ecx@62
   int v35; // eax@63
   int v36; // ecx@67
   __int16 v37; // ax@67
   int v38; // eax@72
-  int v39; // eax@72
+  //int v39; // eax@72
   unsigned __int64 v40; // qax@72
   int v41; // eax@72
   unsigned __int8 v42; // sf@74
@@ -258,7 +246,6 @@
   int v50; // [sp+10h] [bp-98h]@52
   Vec3_int_ v51; // [sp+14h] [bp-94h]@11
   Particle_sw Dst; // [sp+20h] [bp-88h]@45
-  unsigned int uLayingItemID_; // [sp+88h] [bp-20h]@1
   int v54; // [sp+8Ch] [bp-1Ch]@1
   int v55; // [sp+90h] [bp-18h]@1
   int v56; // [sp+94h] [bp-14h]@11
@@ -267,16 +254,11 @@
   int on_water; // [sp+A0h] [bp-8h]@1
   int v60; // [sp+A4h] [bp-4h]@11
 
-  uLayingItemID_ = uLayingItemID;
-  //v1 = &pSpriteObjects[uLayingItemID];
   v58 = 0;
   object = &pObjectList->pObjects[pSpriteObjects[uLayingItemID].uObjectDescID];
   v57 = IsTerrainSlopeTooHigh(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y);
-  v3 = pSpriteObjects[uLayingItemID].vPosition.y;
-  v4 = pSpriteObjects[uLayingItemID].vPosition.x;
-  v5 = object->uHeight;
   v55 = 0;
-  v6 = ODM_GetFloorLevel(v4, v3, pSpriteObjects[uLayingItemID].vPosition.z, v5, &on_water, &v55, 0);
+  v6 = ODM_GetFloorLevel(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, object->uHeight, &on_water, &v55, 0);
   v7 = v6;
   v54 = v6;
   v8 = v6 + 1;
@@ -286,16 +268,15 @@
     {
       v9 = v6 + 60;
       if ( v55 )
-        v9 = v7 + 30;
+        v9 = v6 + 30;
       sub_42F960_create_object(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, v9);
-      SpriteObject::OnInteraction(uLayingItemID_);
+      SpriteObject::OnInteraction(uLayingItemID);
     }
   }
   else
   {
     v58 = 1;
   }
-  v10 = object->uFlags;
   if ( !(object->uFlags & OBJECT_DESC_NO_GRAVITY) )
   {
     if ( v58 )
@@ -305,10 +286,8 @@
     }
     if ( v57 )
     {
-      v11 = pSpriteObjects[uLayingItemID].vPosition.y;
-      v12 = pSpriteObjects[uLayingItemID].vPosition.x;
       pSpriteObjects[uLayingItemID].vPosition.z = v8;
-      ODM_GetTerrainNormalAt(v12, v11, &v51);
+      ODM_GetTerrainNormalAt(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, &v51);
       pSpriteObjects[uLayingItemID].vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
       v56 = abs(v51.y * pSpriteObjects[uLayingItemID].vVelocity.y + v51.z * pSpriteObjects[uLayingItemID].vVelocity.z + v51.x * pSpriteObjects[uLayingItemID].vVelocity.x) >> 16;
       //v60 = ((unsigned __int64)(v56 * (signed __int64)v51.x) >> 16);
@@ -320,11 +299,11 @@
       v7 = v54;
       goto LABEL_13;
     }
-    if ( v10 & 0x40 )
+    if ( object->uFlags & OBJECT_DESC_INTERACTABLE )
     {
       if ( pSpriteObjects[uLayingItemID].vPosition.z < v7 )
         pSpriteObjects[uLayingItemID].vPosition.z = v8;
-      if ( !_46BFFA_check_object_intercept(uLayingItemID_, 0) )
+      if ( !_46BFFA_check_object_intercept(uLayingItemID, 0) )
         return;
     }
     pSpriteObjects[uLayingItemID].vPosition.z = v8;
@@ -334,31 +313,29 @@
     pSpriteObjects[uLayingItemID].vVelocity.x = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.x);
     pSpriteObjects[uLayingItemID].vVelocity.y = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.y);
     pSpriteObjects[uLayingItemID].vVelocity.z = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.z);
-
-    if ( (pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y + pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x) < 400 )
-        {
-
-    pSpriteObjects[uLayingItemID].vVelocity.y = 0;
-    pSpriteObjects[uLayingItemID].vVelocity.x = 0;
-    memset(&Dst, 0, 0x68u);
-    Dst.x = (double)pSpriteObjects[uLayingItemID].vPosition.x;
-    Dst.y = (double)pSpriteObjects[uLayingItemID].vPosition.y;
-    Dst.z = (double)pSpriteObjects[uLayingItemID].vPosition.z;
-    Dst.r = 0.0;
-    Dst.g = 0.0;
-    Dst.b = 0.0;
-    if (object->uFlags & OBJECT_DESC_TRIAL_FIRE )
+    if ( (pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y
+        + pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x) < 400 )
     {
-      Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
-      Dst.uDiffuse = 0xFF3C1E;
-      Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
-      Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT);
-      Dst.flt_28 = 1.0;
-      pGame->pParticleEngine->AddParticle(&Dst);
-    }
-    else if ( object->uFlags & OBJECT_DESC_TRIAL_LINE)
-    {
-
+      pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+      pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+      memset(&Dst, 0, 0x68u);
+      Dst.x = (double)pSpriteObjects[uLayingItemID].vPosition.x;
+      Dst.y = (double)pSpriteObjects[uLayingItemID].vPosition.y;
+      Dst.z = (double)pSpriteObjects[uLayingItemID].vPosition.z;
+      Dst.r = 0.0;
+      Dst.g = 0.0;
+      Dst.b = 0.0;
+      if (object->uFlags & OBJECT_DESC_TRIAL_FIRE )
+      {
+        Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
+        Dst.uDiffuse = 0xFF3C1E;
+        Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
+        Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT);
+        Dst.flt_28 = 1.0;
+        pGame->pParticleEngine->AddParticle(&Dst);
+      }
+      else if ( object->uFlags & OBJECT_DESC_TRIAL_LINE)
+      {
         Dst.type = ParticleType_Line;
         Dst.uDiffuse = rand();
         Dst.timeToLive = 64;
@@ -366,46 +343,41 @@
         Dst.flt_28 = 1.0;
         pGame->pParticleEngine->AddParticle(&Dst);
       }
-    else if ( object->uFlags & OBJECT_DESC_TRIAL_PARTICLE )
-        {
-      Dst.type = ParticleType_Bitmap | ParticleType_8;
-      Dst.uDiffuse = rand();
-      Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
-      Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT);
-      Dst.flt_28 = 1.0;
-      pGame->pParticleEngine->AddParticle(&Dst);
+      else if ( object->uFlags & OBJECT_DESC_TRIAL_PARTICLE )
+      {
+        Dst.type = ParticleType_Bitmap | ParticleType_8;
+        Dst.uDiffuse = rand();
+        Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
+        Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT);
+        Dst.flt_28 = 1.0;
+        pGame->pParticleEngine->AddParticle(&Dst);
+      }
+      return;
     }
-    return;
-        }
   }
 LABEL_13:
-  if ( pSpriteObjects[uLayingItemID].vPosition.z > v7
-    && (v13 = pSpriteObjects[uLayingItemID].vPosition.x, v13 >= -0x8000)
-    && v13 <= 0x8000
-    && (v14 = pSpriteObjects[uLayingItemID].vPosition.y, v14 >= -0x8000)
-    && v14 <= 0x8000
-    && pSpriteObjects[uLayingItemID].vPosition.z <= 13000
+  if ( pSpriteObjects[uLayingItemID].vPosition.x >= -0x8000 && pSpriteObjects[uLayingItemID].vPosition.x <= 0x8000
+    && pSpriteObjects[uLayingItemID].vPosition.y >= -0x8000 && pSpriteObjects[uLayingItemID].vPosition.y <= 0x8000
+    && pSpriteObjects[uLayingItemID].vPosition.z > v7 && pSpriteObjects[uLayingItemID].vPosition.z <= 13000
     || !(object->uFlags & OBJECT_DESC_INTERACTABLE) )
     goto LABEL_92;
   if ( pSpriteObjects[uLayingItemID].vPosition.z < v7 )
     pSpriteObjects[uLayingItemID].vPosition.z = v8;
-  if ( _46BFFA_check_object_intercept(uLayingItemID_, 0) )
+  if ( _46BFFA_check_object_intercept(uLayingItemID, 0) )
   {
 LABEL_92:
     stru_721530.field_0 = 0;
-    v55 = 0;
     stru_721530.prolly_normal_d = object->uRadius;
     stru_721530.height = object->uHeight;
     stru_721530.field_8_radius = 0;
     stru_721530.field_70 = 0;
-    while ( 1 )
+    for ( v55 = 0; v55 < 100; ++v55 )
     {
       stru_721530.position.x = pSpriteObjects[uLayingItemID].vPosition.x;
       stru_721530.normal.x = stru_721530.position.x;
-      v15 = pSpriteObjects[uLayingItemID].vPosition.y;
       stru_721530.uSectorID = 0;
-      stru_721530.position.y = v15;
-      stru_721530.normal.y = v15;
+      stru_721530.position.y = pSpriteObjects[uLayingItemID].vPosition.y;
+      stru_721530.normal.y = pSpriteObjects[uLayingItemID].vPosition.y;
       stru_721530.position.z = pSpriteObjects[uLayingItemID].vPosition.z + stru_721530.prolly_normal_d + 1;
       stru_721530.normal.z = stru_721530.position.z;
       stru_721530.velocity.x = pSpriteObjects[uLayingItemID].vVelocity.x;
@@ -414,24 +386,19 @@
       if ( stru_721530._47050A(0) )
         return;
       _46E889_collide_against_bmodels(0);
-      v16 = WorldPosToGridCellZ(pSpriteObjects[uLayingItemID].vPosition.y);
-      v18 = WorldPosToGridCellX(pSpriteObjects[uLayingItemID].vPosition.x);
-      _46E26D_collide_against_sprites(v18, v16);
+      _46E26D_collide_against_sprites(WorldPosToGridCellX(pSpriteObjects[uLayingItemID].vPosition.x), WorldPosToGridCellZ(pSpriteObjects[uLayingItemID].vPosition.y));
       if (PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) != OBJECT_Player)
         _46EF01_collision_chech_player(0);
       if (PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) == OBJECT_Actor)
       {
-        v19 = PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid);
-        if (( v19 >= 0 )&&( v19 < (signed int)(uNumActors - 1) ))
+        if (( PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid) >= 0 )
+          &&( PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid) < (signed int)(uNumActors - 1) ))
         {
-         
-            v20 = &pActors[v19];
-           for (v56 =0; v56 < uNumActors; ++v56)            
-              {
-                if ( v20->GetActorsRelation(&pActors[v56]) )
-                  Actor::_46DF1A_collide_against_actor(v56, 0);
-
-              }
+          for (v56 =0; v56 < uNumActors; ++v56)
+          {
+            if ( pActors[PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid)].GetActorsRelation(&pActors[v56]) )
+              Actor::_46DF1A_collide_against_actor(v56, 0);
+          }
         }
       }
       else
@@ -449,7 +416,7 @@
         else
           v44 = v54 + 60;
         sub_42F960_create_object(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, v44);
-        SpriteObject::OnInteraction(uLayingItemID_);
+        SpriteObject::OnInteraction(uLayingItemID);
         return;
       }
       if ( stru_721530.field_7C >= stru_721530.field_6C )
@@ -510,30 +477,28 @@
       {
         if ( v29 < v54 )
           pSpriteObjects[uLayingItemID].vPosition.z = v54 + 1;
-        if ( !_46BFFA_check_object_intercept(uLayingItemID_, stru_721530.uFaceID) )
+        if ( !_46BFFA_check_object_intercept(uLayingItemID, stru_721530.uFaceID) )
           return;
       }
-      v30 = (signed int)PID_ID(stru_721530.uFaceID);
       if (PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
         break;
       if (PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
       {
-        v31 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9];
-        v32 = &v31->pFaces[v30 & 0x3F];
-        if ( v32->uPolygonType != 3 )
+        bmodel = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9];
+        face = &bmodel->pFaces[PID_ID(stru_721530.uFaceID) & 0x3F];
+        if ( face->uPolygonType != POLYGON_Floor )
         {
-          v56 = abs(v32->pFacePlane.vNormal.z * pSpriteObjects[uLayingItemID].vVelocity.z + v32->pFacePlane.vNormal.y * pSpriteObjects[uLayingItemID].vVelocity.y
-                                                                + v32->pFacePlane.vNormal.x * pSpriteObjects[uLayingItemID].vVelocity.x) >> 16;
+          v56 = abs(face->pFacePlane.vNormal.x * pSpriteObjects[uLayingItemID].vVelocity.x
+                  + face->pFacePlane.vNormal.y * pSpriteObjects[uLayingItemID].vVelocity.y
+                  + face->pFacePlane.vNormal.z * pSpriteObjects[uLayingItemID].vVelocity.z) >> 16;
           if ( (stru_721530.speed >> 3) > v56 )
             v56 = stru_721530.speed >> 3;
-          v57 = v32->pFacePlane.vNormal.x;
-          v57 = (unsigned __int64)(v56 * (signed __int64)v57) >> 16;
-          v58 = v32->pFacePlane.vNormal.y;
-          v58 = (unsigned __int64)(v56 * (signed __int64)v58) >> 16;
-          v60 = ((unsigned __int64)(v56 * (signed __int64)v32->pFacePlane.vNormal.z) >> 16);
+          v57 = (unsigned __int64)(v56 * (signed __int64)face->pFacePlane.vNormal.x) >> 16;
+          v58 = (unsigned __int64)(v56 * (signed __int64)face->pFacePlane.vNormal.y) >> 16;
+          v60 = (unsigned __int64)(v56 * (signed __int64)face->pFacePlane.vNormal.z) >> 16;
           pSpriteObjects[uLayingItemID].vVelocity.x += 2 * v57;
           pSpriteObjects[uLayingItemID].vVelocity.y += 2 * v58;
-          if ( v32->pFacePlane.vNormal.z <= 32000 )
+          if ( face->pFacePlane.vNormal.z <= 32000 )
           {
             v37 = 2 * (short)v60;
           }
@@ -545,17 +510,16 @@
             v37 = (unsigned int)(32000 * v36) >> 16;
           }
           pSpriteObjects[uLayingItemID].vVelocity.z += v37;
-          if ( BYTE3(v32->uAttributes) & 0x10 )
-            EventProcessor(v32->sCogTriggeredID, 0, 1);
+          if ( BYTE3(face->uAttributes) & 0x10 )
+            EventProcessor(face->sCogTriggeredID, 0, 1);
           goto LABEL_74;
         }
-        v33 = v31->pVertices.pVertices[v32->pVertexIDs[0]].z;
-        v34 = pSpriteObjects[uLayingItemID].vVelocity.x;
-        pSpriteObjects[uLayingItemID].vPosition.z = v33 + 1;
-        if ( pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y + v34 * v34 >= 400 )
+        pSpriteObjects[uLayingItemID].vPosition.z = bmodel->pVertices.pVertices[face->pVertexIDs[0]].z + 1;
+        if ( pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x
+           + pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y >= 400 )
         {
-          if ( BYTE3(v32->uAttributes) & 0x10 )
-            EventProcessor(v32->sCogTriggeredID, 0, 1);
+          if ( BYTE3(face->uAttributes) & 0x10 )
+            EventProcessor(face->sCogTriggeredID, 0, 1);
           goto LABEL_74;
         }
         LOWORD(v35) = 0;
@@ -564,29 +528,16 @@
         pSpriteObjects[uLayingItemID].vVelocity.y = v35;
       }
 LABEL_74:
-      pSpriteObjects[uLayingItemID].vVelocity.x = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)pSpriteObjects[uLayingItemID].vVelocity.x) >> 16);
-      pSpriteObjects[uLayingItemID].vVelocity.y = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)pSpriteObjects[uLayingItemID].vVelocity.y) >> 16);
-      pSpriteObjects[uLayingItemID].vVelocity.z = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)pSpriteObjects[uLayingItemID].vVelocity.z) >> 16);
-
-      ++v55;
-      //v43 = __OFSUB__(v55, 100);
-   //   v42 = v55 - 100 < 0;
-      if (v55>=100 )//!(v42 ^ v43) 
-        return;
+      pSpriteObjects[uLayingItemID].vVelocity.x = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.x);
+      pSpriteObjects[uLayingItemID].vVelocity.y = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.y);
+      pSpriteObjects[uLayingItemID].vVelocity.z = fixpoint_mul(58500, pSpriteObjects[uLayingItemID].vVelocity.z);
     }
-    v57 = integer_sqrt(pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y + pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x);
-    v38 = stru_5C6E00->Atan2(pSpriteObjects[uLayingItemID].vPosition.x - pLevelDecorations[v30].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y - pLevelDecorations[v30].vPosition.y);
-    v56 = v38;
-    v39 = stru_5C6E00->Cos(v38);
-   // v60 = v39;
-    v40 = v39 * (signed __int64)v57;
-    v58 = v40 >> 16;
-    pSpriteObjects[uLayingItemID].vVelocity.x = WORD1(v40);
-    v41 = stru_5C6E00->Sin(v56 - stru_5C6E00->uIntegerHalfPi);
-   // v60 = v41;
-    v35 = (unsigned __int64)(v41 * (signed __int64)v57) >> 16;
-    v58 = v35;
-    pSpriteObjects[uLayingItemID].vVelocity.y = v35;
+    v57 = integer_sqrt(pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x
+                     + pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y);
+    v38 = stru_5C6E00->Atan2(pSpriteObjects[uLayingItemID].vPosition.x - pLevelDecorations[PID_ID(stru_721530.uFaceID)].vPosition.x,
+                             pSpriteObjects[uLayingItemID].vPosition.y - pLevelDecorations[PID_ID(stru_721530.uFaceID)].vPosition.y);
+    pSpriteObjects[uLayingItemID].vVelocity.x = (unsigned __int64)(stru_5C6E00->Cos(v38) * (signed __int64)v57) >> 16;
+    pSpriteObjects[uLayingItemID].vVelocity.y = (unsigned __int64)(stru_5C6E00->Sin(v38 - stru_5C6E00->uIntegerHalfPi) * (signed __int64)v57) >> 16;
     goto LABEL_74;
   }
 }
@@ -596,53 +547,28 @@
 {
   SpriteObject *pSpriteObject; // esi@1
   ObjectDesc *pObject; // edi@1
-  //int v3; // ST08_4@1
-  //__int16 v4; // ax@5
-  __int16 v5; // ax@7
-  BLVFace *v6; // ecx@11
-  BLVFace *v7; // eax@11
-  signed int v8; // ebx@12
   int v9; // ecx@16
   __int16 v10; // di@18
-  char v11; // al@19
-  //int v12; // eax@25
-  int v13; // eax@31
   int v14; // ebx@34
   signed int v15; // ebx@46
-  BLVFace *v16; // edi@48
   int v17; // eax@50
   int v18; // eax@52
   int v19; // ecx@52
   Vec3_short_ *v20; // ecx@53
-  //int v21; // ecx@57
   __int16 v22; // ax@57
   int v23; // edi@62
-  //int v24; // edi@62
-  //int v25; // eax@62
-  //unsigned __int64 v26; // qax@62
   unsigned __int8 v27; // sf@64
   unsigned __int8 v28; // of@64
   __int16 v29; // di@67
   char v30; // al@68
-  const char *v31; // [sp-8h] [bp-98h]@19
-  const char *v32; // [sp-8h] [bp-98h]@68
-  enum TEXTURE_TYPE v33; // [sp-4h] [bp-94h]@19
-  enum TEXTURE_TYPE v34; // [sp-4h] [bp-94h]@68
   Particle_sw Dst; // [sp+Ch] [bp-84h]@18
-  //unsigned int uLayingItemID_; // [sp+74h] [bp-1Ch]@1
-  //ObjectDesc *v37; // [sp+78h] [bp-18h]@1
   unsigned int uFaceID; // [sp+7Ch] [bp-14h]@4
   int v39; // [sp+80h] [bp-10h]@33
-  Actor *v39b;
   int v40; // [sp+84h] [bp-Ch]@28
-  //int v41; // [sp+88h] [bp-8h]@34
-  int v42; // [sp+8Ch] [bp-4h]@4
+   int v42; // [sp+8Ch] [bp-4h]@4
 
-  //uLayingItemID_ = uLayingItemID;
   pSpriteObject = &pSpriteObjects[uLayingItemID];
   pObject = &pObjectList->pObjects[pSpriteObject->uObjectDescID];
-  //v3 = pSpriteObject->vPosition.x;
-  //v37 = &pObjectList->pObjects[pSpriteObject->uObjectDescID];
   pSpriteObject->uSectorID = pIndoor->GetSector(pSpriteObject->vPosition.x, pSpriteObject->vPosition.y, pSpriteObject->vPosition.z);
   v42 = BLV_GetFloorLevel(pSpriteObject->vPosition.x, pSpriteObject->vPosition.y, pSpriteObject->vPosition.z, pSpriteObject->uSectorID, &uFaceID);
   if ( abs(pSpriteObject->vPosition.x) > 32767
@@ -655,82 +581,56 @@
     SpriteObject::OnInteraction(uLayingItemID);
     return;
   }
-  v5 = pObject->uFlags;
-  if ( v5 & 0x20 )
+  if ( pObject->uFlags & OBJECT_DESC_NO_GRAVITY )//не падающие объекты
   {
-LABEL_24:
-    v8 = 0;
 LABEL_25:
-    stru_721530.field_0 = v8;
-    uFaceID = v8;
+    stru_721530.field_0 = 0;
     stru_721530.prolly_normal_d = pObject->uRadius;
-
     stru_721530.field_84 = -1;
     stru_721530.height = pObject->uHeight;
-    stru_721530.field_8_radius = v8;
-    stru_721530.field_70 = v8;
-    while ( 1 )
+    stru_721530.field_8_radius = 0;
+    stru_721530.field_70 = 0;
+    for ( uFaceID = 0; uFaceID < 100; uFaceID++ )
     {
       stru_721530.position.x = pSpriteObject->vPosition.x;
+      stru_721530.position.y = pSpriteObject->vPosition.y;
+      stru_721530.position.z = stru_721530.prolly_normal_d + pSpriteObject->vPosition.z + 1;
+
       stru_721530.normal.x = stru_721530.position.x;
-      stru_721530.position.y = pSpriteObject->vPosition.y;
       stru_721530.normal.y = stru_721530.position.y;
-      stru_721530.position.z = stru_721530.prolly_normal_d + pSpriteObject->vPosition.z + 1;
       stru_721530.normal.z = stru_721530.position.z;
+
       stru_721530.velocity.x = pSpriteObject->vVelocity.x;
       stru_721530.velocity.y = pSpriteObject->vVelocity.y;
       stru_721530.velocity.z = pSpriteObject->vVelocity.z;
+
       stru_721530.uSectorID = pSpriteObject->uSectorID;
-      if ( stru_721530._47050A(v8) )
+      if ( stru_721530._47050A(0) )
         return;
-      v40 = v8;
-      do
+
+      for ( v40 = 0; v40 < 100; ++v40 )
       {
         _46E44E_collide_against_faces_and_portals(0);
         _46E0B2_collide_against_decorations();
         if (PID_TYPE(pSpriteObject->spell_caster_pid) != OBJECT_Player)
           _46EF01_collision_chech_player(1);
-        v13 = pSpriteObject->spell_caster_pid;
-        v42 = v8;
-        if (PID_TYPE(v13) == OBJECT_Actor)
+        if (PID_TYPE(pSpriteObject->spell_caster_pid) == OBJECT_Actor)
         {
-          if ( (signed int)uNumActors > v8 )
+          for ( v42 = 0; v42 < (signed int)uNumActors; ++v42 )
           {
-            v39b = pActors.data();//[0].word_000086_some_monster_id;
-            do
-            {
-              //v41 = pActors[v1->field_58 >> 3].pMonsterInfo.uID - 1;
-              //v14 = (signed __int64)((double)v41 * 0.3333333333333333);
-              //v41 = *(short *)(v39 - 38) - 1;
-              //if ( v14 != (unsigned int)(signed __int64)((double)v41 * 0.3333333333333333) )
-				if( pActors[pSpriteObject->spell_caster_pid >> 3].pMonsterInfo.uID != v39b->pMonsterInfo.uID )
-					//not sure: pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius
-					Actor::_46DF1A_collide_against_actor(v42, pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius);
-              ++v42;
-              ++v39b;// += 836;
-            }
-            while ( v42 < (signed int)uNumActors );
-            v8 = 0;
+            if( pActors[pSpriteObject->spell_caster_pid >> 3].pMonsterInfo.uID != pActors[v42].pMonsterInfo.uID )
+             //not sure: pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius
+              Actor::_46DF1A_collide_against_actor(v42, pMonsterList->pMonsters[pActors[v42].word_000086_some_monster_id-1].uToHitRadius);
           }
         }
         else
         {
-          if ( (signed int)uNumActors > v8 )
-          {
-            v39b = pActors.data();//[0].word_000086_some_monster_id;
-            do
-            {
-				Actor::_46DF1A_collide_against_actor(v42++, pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius);
-              ++v39b;
-            }
-            while ( v42 < (signed int)uNumActors );
-          }
+          for ( v42 = 0; v42 < (signed int)uNumActors; v42++ )
+            Actor::_46DF1A_collide_against_actor(v42, pMonsterList->pMonsters[pActors[v42].word_000086_some_monster_id-1].uToHitRadius);
         }
         if ( _46F04E_collide_against_portals() )
           break;
-        ++v40;
       }
-      while ( v40 < 100 );
       if ( stru_721530.field_7C >= stru_721530.field_6C )
       {
         pSpriteObject->vPosition.x = stru_721530.normal2.x;
@@ -739,44 +639,42 @@
         pSpriteObject->uSectorID = LOWORD(stru_721530.uSectorID);
         if ( !(HIBYTE(pObject->uFlags) & 1) )
           return;
-        memset(&Dst, v8, 0x68u);
-        v29 = pObject->uFlags;
+        memset(&Dst, 0, 0x68u);
         Dst.x = (double)pSpriteObject->vPosition.x;
         Dst.y = (double)pSpriteObject->vPosition.y;
         Dst.z = (double)pSpriteObject->vPosition.z;
         Dst.r = 0.0;
         Dst.g = 0.0;
         Dst.b = 0.0;
-        if ( v29 & 0x200 )
+        if ( pObject->uFlags & OBJECT_DESC_TRIAL_FIRE )
         {
           Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
           Dst.uDiffuse = 0xFF3C1E;
-          v30 = rand();
-          v34 = (TEXTURE_TYPE)v8;
-          v32 = "effpar01";
+          Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
+          Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT);
+          Dst.flt_28 = 1.0;
+          pGame->pParticleEngine->AddParticle(&Dst);
+          return;
         }
-        else
+        else if ( pObject->uFlags & OBJECT_DESC_TRIAL_LINE )
         {
-          if ( v29 & 0x400 )
-          {
-            Dst.type = ParticleType_Line;
-            Dst.uDiffuse = rand();
-            Dst.timeToLive = 64;
-            Dst.uTextureID = v8;
-            Dst.flt_28 = 1.0;
-            pGame->pParticleEngine->AddParticle(&Dst);
-            return;
-          }
+          Dst.type = ParticleType_Line;
+          Dst.uDiffuse = rand();
+          Dst.timeToLive = 64;
+          Dst.uTextureID = 0;
+          Dst.flt_28 = 1.0;
+          pGame->pParticleEngine->AddParticle(&Dst);
+          return;
+        }
+        else if ( pObject->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
+        {
           Dst.type = ParticleType_Bitmap | ParticleType_8;
           Dst.uDiffuse = rand();
-          v30 = rand();
-          v34 = (TEXTURE_TYPE)v8;
-          v32 = "effpar03";
+          Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
+          Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT);
+          Dst.flt_28 = 1.0;
+          pGame->pParticleEngine->AddParticle(&Dst);
         }
-        Dst.timeToLive = (unsigned __int8)(v30 & 0x80) + 128;
-        Dst.uTextureID = pBitmaps_LOD->LoadTexture(v32, v34);
-        Dst.flt_28 = 1.0;
-        pGame->pParticleEngine->AddParticle(&Dst);
         return;
       }
       //v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16;
@@ -787,7 +685,7 @@
       pSpriteObject->vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
       pSpriteObject->uSectorID = stru_721530.uSectorID;
       stru_721530.field_70 += stru_721530.field_7C;
-      if ( pObject->uFlags & 0x40 && !_46BFFA_check_object_intercept(uLayingItemID, stru_721530.uFaceID) )
+      if ( pObject->uFlags & OBJECT_DESC_INTERACTABLE && !_46BFFA_check_object_intercept(uLayingItemID, stru_721530.uFaceID) )
         return;
       v15 = (signed int)stru_721530.uFaceID >> 3;
       if (PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
@@ -798,145 +696,129 @@
         pSpriteObject->vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v23), v40);
         pSpriteObject->vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v23), v40);
       }
-      else
+      if (PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
       {
-        if (PID_TYPE(stru_721530.uFaceID) != OBJECT_BModel)
-          goto LABEL_64;
         stru_721530.field_84 = (signed int)PID_ID(stru_721530.uFaceID);
-        v16 = &pIndoor->pFaces[v15];
-        if ( v16->uPolygonType != 3 )
+        if ( pIndoor->pFaces[v15].uPolygonType != POLYGON_Floor )
         {
-          v42 = abs(v16->pFacePlane_old.vNormal.x * pSpriteObject->vVelocity.x + v16->pFacePlane_old.vNormal.z * pSpriteObject->vVelocity.z
-                                                                    + v16->pFacePlane_old.vNormal.y * pSpriteObject->vVelocity.y) >> 16;
+          v42 = abs(pIndoor->pFaces[v15].pFacePlane_old.vNormal.x * pSpriteObject->vVelocity.x
+                  + pIndoor->pFaces[v15].pFacePlane_old.vNormal.y * pSpriteObject->vVelocity.y
+                  + pIndoor->pFaces[v15].pFacePlane_old.vNormal.z * pSpriteObject->vVelocity.z) >> 16;
           if ( (stru_721530.speed >> 3) > v42 )
             v42 = stru_721530.speed >> 3;
-          pSpriteObject->vVelocity.x += 2 * fixpoint_mul(v42, v16->pFacePlane_old.vNormal.x);
-          pSpriteObject->vVelocity.y += 2 * fixpoint_mul(v42, v16->pFacePlane_old.vNormal.y);
-          v39 = fixpoint_mul(v42, v16->pFacePlane_old.vNormal.z);
-          if ( v16->pFacePlane_old.vNormal.z <= 32000 )
-          {
+          pSpriteObject->vVelocity.x += 2 * fixpoint_mul(v42, pIndoor->pFaces[v15].pFacePlane_old.vNormal.x);
+          pSpriteObject->vVelocity.y += 2 * fixpoint_mul(v42, pIndoor->pFaces[v15].pFacePlane_old.vNormal.y);
+          v39 = fixpoint_mul(v42, pIndoor->pFaces[v15].pFacePlane_old.vNormal.z);
+          if ( pIndoor->pFaces[v15].pFacePlane_old.vNormal.z <= 32000 )
             v22 = 2 * v39;
-          }
           else
           {
             pSpriteObject->vVelocity.z += v39;
             v22 = fixpoint_mul(32000, v39);
           }
           pSpriteObject->vVelocity.z += v22;
-          if ( BYTE3(v16->uAttributes) & 0x10 )
-            EventProcessor(pIndoor->pFaceExtras[v16->uFaceExtraID].uEventID, 0, 1);
-          goto LABEL_63;
+          if ( BYTE3(pIndoor->pFaces[v15].uAttributes) & 0x10 )
+            EventProcessor(pIndoor->pFaceExtras[pIndoor->pFaces[v15].uFaceExtraID].uEventID, 0, 1);
+          pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x);
+          pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y);
+          pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z);
+          continue;
         }
-        if ( pObject->uFlags & 0x80 )
+        if ( pObject->uFlags & OBJECT_DESC_BOUNCE )
         {
-          v17 = -pSpriteObject->vVelocity.z >> 1;
+          v17 = -pSpriteObject->vVelocity.z / 2;
           pSpriteObject->vVelocity.z = v17;
           if ( (signed __int16)v17 < 10 )
             pSpriteObject->vVelocity.z = 0;
-          if ( BYTE3(v16->uAttributes) & 0x10 )
-            EventProcessor(pIndoor->pFaceExtras[v16->uFaceExtraID].uEventID, 0, 1);
-          goto LABEL_63;
+          if ( BYTE3(pIndoor->pFaces[v15].uAttributes) & 0x10 )
+            EventProcessor(pIndoor->pFaceExtras[pIndoor->pFaces[v15].uFaceExtraID].uEventID, 0, 1);
+          pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x);
+          pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y);
+          pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z);
+          continue;
         }
-        v18 = pSpriteObject->vVelocity.y;
-        v19 = pSpriteObject->vVelocity.x;
         pSpriteObject->vVelocity.z = 0;
-        if ( v19 * v19 + v18 * v18 >= 400 )
+        if ( pSpriteObject->vVelocity.x * pSpriteObject->vVelocity.x + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y >= 400 )
         {
-          if ( BYTE3(v16->uAttributes) & 0x10 )
-            EventProcessor(pIndoor->pFaceExtras[v16->uFaceExtraID].uEventID, 0, 1);
-          goto LABEL_63;
+          if ( BYTE3(pIndoor->pFaces[v15].uAttributes) & 0x10 )
+            EventProcessor(pIndoor->pFaceExtras[pIndoor->pFaces[v15].uFaceExtraID].uEventID, 0, 1);
+          pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x);
+          pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y);
+          pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z);
+          continue;
         }
-        v20 = pIndoor->pVertices;
         pSpriteObject->vVelocity.z = 0;
         pSpriteObject->vVelocity.y = 0;
         pSpriteObject->vVelocity.x = 0;
-        pSpriteObject->vPosition.z = v20[*v16->pVertexIDs].z + 1;
+        pSpriteObject->vPosition.z = pIndoor->pVertices[*pIndoor->pFaces[v15].pVertexIDs].z + 1;
       }
-LABEL_63:
-      //v2 = v37;
-LABEL_64:
       pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x);
       pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y);
       pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z);
-      ++uFaceID;
-      v28 = __OFSUB__(uFaceID, 100);
-      v27 = uFaceID - 100 < 0;
-      if ( !(v27 ^ v28) )
-        return;
-      v8 = 0;
     }
   }
+  //для падающих объектов(для примера выброс вещи из инвентаря)
   if ( v42 <= pSpriteObject->vPosition.z - 3 )
   {
     pSpriteObject->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
-    goto LABEL_24;
+    goto LABEL_25;
   }
-  if ( !(v5 & 0x40) || _46BFFA_check_object_intercept(uLayingItemID, 0) )
+  if ( !(pObject->uFlags & OBJECT_DESC_INTERACTABLE) || _46BFFA_check_object_intercept(uLayingItemID, 0) )
   {
-    v6 = pIndoor->pFaces;
     pSpriteObject->vPosition.z = v42 + 1;
-    v7 = &v6[uFaceID];
-    if ( v7->uPolygonType == 3 )
-    {
-      v8 = 0;
+    if ( pIndoor->pFaces[uFaceID].uPolygonType == POLYGON_Floor )
       pSpriteObject->vVelocity.z = 0;
-    }
     else
     {
-      if ( v7->pFacePlane_old.vNormal.z < 45000 )
+      if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 45000 )
         pSpriteObject->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
-      v8 = 0;
     }
     pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x);
     pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y);
     pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z);
-    v9 = pSpriteObject->vVelocity.x;
-    if ( v9 * v9 + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y < 400 )
+    if ( pSpriteObject->vVelocity.x * pSpriteObject->vVelocity.x + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y < 400 )
     {
-      pSpriteObject->vVelocity.z = v8;
-      pSpriteObject->vVelocity.y = v8;
-      pSpriteObject->vVelocity.x = v8;
-      if ( !(pObject->uFlags & 1) )
+      pSpriteObject->vVelocity.x = 0;
+      pSpriteObject->vVelocity.y = 0;
+      pSpriteObject->vVelocity.z = 0;
+      if ( !(pObject->uFlags & OBJECT_DESC_NO_SPRITE) )
         return;
-      memset(&Dst, v8, 0x68u);
-      v10 = pObject->uFlags;
+      memset(&Dst, 0, 0x68u);
       Dst.x = (double)pSpriteObject->vPosition.x;
       Dst.y = (double)pSpriteObject->vPosition.y;
       Dst.z = (double)pSpriteObject->vPosition.z;
       Dst.r = 0.0;
       Dst.g = 0.0;
       Dst.b = 0.0;
-      if ( v10 & 0x200 )
+      if ( pObject->uFlags & OBJECT_DESC_TRIAL_FIRE )
       {
         Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
         Dst.uDiffuse = 0xFF3C1E;
         Dst.flt_28 = 1.0;
-        v11 = rand();
-        v33 = (TEXTURE_TYPE)v8;
-        v31 = "effpar01";
+        Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
+        Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT);
+        pGame->pParticleEngine->AddParticle(&Dst);
+        return;
       }
-      else
+      else if ( pObject->uFlags & OBJECT_DESC_TRIAL_LINE )
       {
-        if ( v10 & 0x400 )
-        {
-          Dst.type = ParticleType_Line;
-          Dst.uDiffuse = rand();
-          Dst.timeToLive = 64;
-          Dst.uTextureID = v8;
-          Dst.flt_28 = 1.0;
-          pGame->pParticleEngine->AddParticle(&Dst);
-          return;
-        }
+        Dst.type = ParticleType_Line;
+        Dst.uDiffuse = rand();
+        Dst.timeToLive = 64;
+        Dst.uTextureID = 0;
+        Dst.flt_28 = 1.0;
+        pGame->pParticleEngine->AddParticle(&Dst);
+        return;
+      }
+      else if ( pObject->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
+      {
         Dst.type = ParticleType_Bitmap | ParticleType_8;
         Dst.uDiffuse = rand();
         Dst.flt_28 = 1.0;
-        v11 = rand();
-        v33 = (TEXTURE_TYPE)v8;
-        v31 = "effpar03";
+        Dst.timeToLive = (unsigned __int8)(rand() & 0x80) + 128;
+        Dst.uTextureID = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT);
+        pGame->pParticleEngine->AddParticle(&Dst);
       }
-      Dst.timeToLive = (unsigned __int8)(v11 & 0x80) + 128;
-      Dst.uTextureID = pBitmaps_LOD->LoadTexture(v31, v33);
-      pGame->pParticleEngine->AddParticle(&Dst);
       return;
     }
     goto LABEL_25;
@@ -1032,16 +914,16 @@
 
 //----- (0042FA22) --------------------------------------------------------
 void CompactLayingItemsList()
-    {
-    int new_obj_pos=0;
+{
+  int new_obj_pos = 0;
 
-    for (int i=0; i<MAX_SPRITE_OBJECTS; ++i)
-        {
-        if (pSpriteObjects[i].uObjectDescID)
-            memcpy(&pSpriteObjects[new_obj_pos++], &pSpriteObjects[i],sizeof(SpriteObject));
-        }
-    uNumSpriteObjects = new_obj_pos;
-    }
+  for (int i=0; i < MAX_SPRITE_OBJECTS; ++i)
+  {
+    if (pSpriteObjects[i].uObjectDescID)
+      memcpy(&pSpriteObjects[new_obj_pos++], &pSpriteObjects[i],sizeof(SpriteObject));
+  }
+  uNumSpriteObjects = new_obj_pos;
+}
 //----- (00408896) --------------------------------------------------------
 void InitializeSpriteObjects()
 {
@@ -1049,31 +931,27 @@
   {
     SpriteObject* item = &pSpriteObjects[i];
 
-    if (item->uType &&
-        (item->uSoundID & 8 || pObjectList->pObjects[item->uType].uFlags & 0x10))
+    if (item->uType && (item->uSoundID & 8 || pObjectList->pObjects[item->uType].uFlags & OBJECT_DESC_UNPICKABLE))
       SpriteObject::OnInteraction(i);
   }
 }
 //----- (0046BEF1) --------------------------------------------------------
 void SpriteObject::_46BEF1_apply_spells_aoe()
 {
-  SpriteObject *v1; // edi@1
-  Actor *v2; // esi@2
-  __int16 v3; // fps@4
-  unsigned __int8 v4; // c0@4
-  unsigned __int8 v5; // c3@4
-  signed int v6; // [sp+8h] [bp-4h]@1
+  //SpriteObject *v1; // edi@1
+  //Actor *v2; // esi@2
+  //__int16 v3; // fps@4
+  //unsigned __int8 v4; // c0@4
+  //unsigned __int8 v5; // c3@4
+  //signed int v6; // [sp+8h] [bp-4h]@1
 
-  int v7,v8,v9,v10,v11;
-
-  v6 = 0;
-  v1 = this;
+  int v7,v9,v10,v11;
+  __debugbreak();//Ritor1
   if ( (signed int)uNumActors > 0 )
   {
-    v2 = pActors.data();//[0].vPosition.y;
-    do
+    for ( uint i = 0; i < uNumActors; ++i )
     {
-      if ( v2->CanAct() )
+      if ( pActors[i].CanAct() )
       {
         //UNDEF(v3);
 		//.text:0046BF26                 movsx   eax, word ptr [esi-2]
@@ -1081,17 +959,17 @@
 		//.text:0046BF31                 mov     [ebp+var_8], eax
 		//.text:0046BF37                 fild    [ebp+var_8]
 		// v7 pushed to stack
-		v7 = v2->vPosition.x - this->vPosition.x;
+		v7 = pActors[i].vPosition.x - this->vPosition.x;
 
 		//.text:0046BF2D                 movsx   ecx, word ptr [esi+2]
-		v8 = v2->vPosition.z;
+		//v8 = pActors[i].vPosition.z;
 
 		//.text:0046BF34                 movsx   eax, word ptr [esi]
 		//.text:0046BF3A                 sub     eax, [edi+8]
 		//.text:0046BF3D                 mov     [ebp+var_8], eax
 		//.text:0046BF44                 fild    [ebp+var_8]
 		// v9 pushed to stack
-		v9 = v2->vPosition.y - this->vPosition.y;
+		v9 = pActors[i].vPosition.y - this->vPosition.y;
 
 		//.text:0046BF40                 movsx   eax, word ptr [esi-6]
 		//.text:0046BF47                 sar     eax, 1
@@ -1101,12 +979,12 @@
 		//.text:0046BF51                 fild    [ebp+var_8]
 		//.text:0046BF58                 fld     st
 		// v10 pushed to stack, two times
-		v10 = v2->uActorHeight / 2 + v8 - this->vVelocity.y;
+		v10 = pActors[i].uActorHeight / 2 + pActors[i].vPosition.z - this->vVelocity.y;
 
 		//.text:0046BF54                 movsx   eax, word ptr [esi-8]
 		//.text:0046BF5A                 add     eax, 100h
 		//.text:0046BF63                 mov     ecx, eax
-		v11 = this->vVelocity.x;
+		//v11 = this->vVelocity.x;
 
 		//.text:0046BF5F                 fmul    st, st(1)
 		// stack: v10*v10, v10, v9, v7
@@ -1118,7 +996,7 @@
 		// stack: v7*v9, v10*v10, v10, v9, v7
 		
 		//.text:0046BF67                 imul    ecx, eax
-		v11 = v11 * v11;
+		v11 = this->vVelocity.x * this->vVelocity.x;
 
 		//.text:0046BF6A                 faddp   st(1), st
 		// stack: v10*v10+v7*v9, v10, v9, v7
@@ -1148,23 +1026,16 @@
 		//.text:0046BF83                 fstp    st
 		//.text:0046BF85                 jnz     short loc_46BFDD
 
-		if ( v11 >= v10*v10+v7*v9+v7*v7 )
+		if ( v11 >= v7 * v7 + v9 * v9 + v10 * v10 )
         {
-          if ( stru_50C198.GetMagicalResistance(v2, 0xAu) )
+          if ( stru_50C198.GetMagicalResistance(&pActors[i], 0xAu) )
           {
-			  v2->pActorBuffs[v1->spell_id].Apply(
-              pParty->uTimePlayed + (signed int)(signed __int64)((double)(v1->spell_level << 7) * 0.033333335),
-              v1->spell_skill,
-              4u,
-              0,
-              0);
-            HIWORD(v2->uAttributes) |= 8u;
+            pActors[i].pActorBuffs[this->spell_id].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(this->spell_level << 7) * 0.033333335),
+                   this->spell_skill, 4, 0, 0);
+            HIWORD(pActors[i].uAttributes) |= 8;
           }
         }
       }
-      ++v6;
-      ++v2;
     }
-    while ( v6 < (signed int)uNumActors );
   }
 }
\ No newline at end of file
--- a/UI/Books/UIMapBook.cpp	Thu Dec 12 21:42:18 2013 +0600
+++ b/UI/Books/UIMapBook.cpp	Thu Dec 12 21:44:02 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 21:42:18 2013 +0600
+++ b/UI/UICharacter.cpp	Thu Dec 12 21:44:02 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 )
@@ -1387,11 +1387,11 @@
         }
         else
         {
-          if ( item->uAttributes & 2 )
+          if ( item->uAttributes & ITEM_BROKEN )
             pRenderer->DrawTransparentRedShade(item_X, item_Y, pIcons_LOD->GetTexture(v127));
           else
           {
-            if ( item->uAttributes & 1 )
+            if ( item->uAttributes & ITEM_IDENTIFIED )
               pRenderer->DrawTextureTransparent(item_X, item_Y, pIcons_LOD->GetTexture(v127));
             else
               pRenderer->DrawTransparentGreenShade(item_X, item_Y, pIcons_LOD->GetTexture(v127));
@@ -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 21:42:18 2013 +0600
+++ b/UI/UIPopup.cpp	Thu Dec 12 21:44:02 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 )
@@ -485,9 +485,8 @@
     memcpy(&pMonsterInfoUI_Doll, &pActors[uActorID], sizeof(pMonsterInfoUI_Doll));
     pMonsterInfoUI_Doll.uCurrentActionAnimation = ANIM_Bored;
     pMonsterInfoUI_Doll.uCurrentActionTime = 0;
-    v8 = rand();
-    v9 = v8 % 256 + 128;
-    pMonsterInfoUI_Doll.uCurrentActionLength = v8 % 256 + 128;
+    v9 = rand() % 256 + 128;
+    pMonsterInfoUI_Doll.uCurrentActionLength = v9;
   }
 
   if ( (signed int)pMonsterInfoUI_Doll.uCurrentActionTime > (signed __int16)v9 )
@@ -523,11 +522,11 @@
   v106.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v10->uPaletteIndex, 0, 1);
   v106.sZValue = 0;
   v106.uFlags = 0;
-  pRenderer->SetRasterClipRect(0, 0, 0x27Fu, 0x1DFu);
-  pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportY - 1, Color16(0xE1u, 255, 0x9Bu));
-  pRenderer->RasterLine2D( v106.uViewportX + 129,  v106.uViewportY - 1,  v106.uViewportX + 129,    v106.uViewportW + 1, Color16(0xE1u, 255, 0x9Bu));
-  pRenderer->RasterLine2D(v106.uViewportX + 129, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportW + 1, Color16(0xE1u, 255, 0x9Bu));
-  pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportY - 1, Color16(0xE1u, 255, 0x9Bu));
+  pRenderer->SetRasterClipRect(0, 0, 639, 479);
+  pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportY - 1, Color16(0xE1u, 255, 0x9Bu));//горизонтальная верхняя линия
+  pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportY - 1, Color16(0xE1u, 255, 0x9Bu));//горизонтальная нижняя линия
+  pRenderer->RasterLine2D(v106.uViewportX + 129, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportW + 1, Color16(0xE1u, 255, 0x9Bu));//левая вертикальная линия
+  pRenderer->RasterLine2D(v106.uViewportX + 129, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportW + 1, Color16(0xE1u, 255, 0x9Bu));//правая вертикальная линия
   if ( pRenderer->pRenderD3D )
   {
     v106.uScreenSpaceY = v115 + v106.uViewportY + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uBufferHeight;
@@ -634,7 +633,7 @@
                        pDesc.dwWidth  * src_x / pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uAreaWidth;
             uint b = src[idx] & 0x1F;
             //*dst++ = b | 2 * (src[idx] & 0xFFE0);
-            pRenderer->WritePixel16(y, x, b | 2 * (src[idx] & 0xFFE0));
+            pRenderer->WritePixel16(x, y, b | 2 * (src[idx] & 0xFFE0));
           }
         }
         pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface->Unlock(0);
--- a/UI/UIShops.cpp	Thu Dec 12 21:42:18 2013 +0600
+++ b/UI/UIShops.cpp	Thu Dec 12 21:44:02 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 21:42:18 2013 +0600
+++ b/UI/UiGame.cpp	Thu Dec 12 21:44:02 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/Viewport.cpp	Thu Dec 12 21:42:18 2013 +0600
+++ b/Viewport.cpp	Thu Dec 12 21:44:02 2013 +0600
@@ -669,7 +669,7 @@
   {
     if ( !pParty->pPickedItem.uItemID )
       return;
-	__debugbreak();//no checker
+	//__debugbreak();//no checker
     v6 = 0;
     a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
     if ( (signed int)pObjectList->uNumObjects <= 0 )
--- a/mm7_3.cpp	Thu Dec 12 21:42:18 2013 +0600
+++ b/mm7_3.cpp	Thu Dec 12 21:44:02 2013 +0600
@@ -58,18 +58,12 @@
   unsigned __int8 v6; // sf@12
   unsigned __int8 v7; // of@12
   int result; // eax@14
-  //BLVSector *v9; // ebx@15
-  int v10; // ecx@15
+  //int v10; // ecx@15
   int pFloor; // eax@16
-  //BLVFace *v12; // ebp@16
-  int v13; // eax@24
-  int v14; // esi@24
   int v15; // eax@24
   int v16; // edx@25
   int v17; // eax@29
   unsigned int v18; // eax@33
-  int v19; // eax@35
-  int v20; // edx@35
   int v21; // eax@35
   int v22; // ecx@36
   int v23; // eax@40
@@ -79,24 +73,19 @@
   int i; // [sp+18h] [bp-40h]@1
   int a10; // [sp+1Ch] [bp-3Ch]@1
   int v29; // [sp+20h] [bp-38h]@14
-  int v30; // [sp+24h] [bp-34h]@35
-  int v31; // [sp+28h] [bp-30h]@24
   int v32; // [sp+2Ch] [bp-2Ch]@15
   int pSectorsArray[10]; // [sp+30h] [bp-28h]@1
 
   pSector = &pIndoor->pSectors[stru_721530.uSectorID];
-  v2 = 0;
+  i = 1;
   a10 = b1;
   pSectorsArray[0] = stru_721530.uSectorID;
-  for ( i = 1; v2 < pSector->uNumPortals; ++v2 )
+  for ( v2 = 0; v2 < pSector->uNumPortals; ++v2 )
   {
     pFace = &pIndoor->pFaces[pSector->pPortals[v2]];
-    if ( stru_721530.sMaxX <= pFace->pBounding.x2
-      && stru_721530.sMinX >= pFace->pBounding.x1
-      && stru_721530.sMaxY <= pFace->pBounding.y2
-      && stru_721530.sMinY >= pFace->pBounding.y1
-      && stru_721530.sMaxZ <= pFace->pBounding.z2
-      && stru_721530.sMinZ >= pFace->pBounding.z1
+    if ( stru_721530.sMaxX <= pFace->pBounding.x2 && stru_721530.sMinX >= pFace->pBounding.x1
+      && stru_721530.sMaxY <= pFace->pBounding.y2 && stru_721530.sMinY >= pFace->pBounding.y1
+      && stru_721530.sMaxZ <= pFace->pBounding.z2 && stru_721530.sMinZ >= pFace->pBounding.z1
       && abs((pFace->pFacePlane_old.dist
             + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x
             + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y
@@ -112,51 +101,35 @@
     }
   }
   result = 0;
-  v29 = 0;
-  if ( i > 0 )
+  for ( v29 = 0; v29 < i; v29++ )
   {
-    while ( 1 )
+    pSector = &pIndoor->pSectors[pSectorsArray[v29]];
+    v32 = pSector->uNumFloors + pSector->uNumWalls + pSector->uNumCeilings;
+    for ( v26 = 0;  v26 < v32; v26++ )
     {
-      pSector = &pIndoor->pSectors[pSectorsArray[result]];
-      v10 = 0;
-      v32 = pSector->uNumFloors + pSector->uNumWalls + pSector->uNumCeilings;
-      v26 = 0;
-      if ( v32 > 0 )
-        break;
-LABEL_46:
-      result = v29++ + 1;
-      if ( v29 >= i )
-        return result;
-    }
-    while ( 1 )
-    {
-      pFloor = pSector->pFloors[v10];
-      pFace = &pIndoor->pFaces[pFloor];
-      if ( pFace->Portal()
-        || stru_721530.sMaxX > pFace->pBounding.x2
-        || stru_721530.sMinX < pFace->pBounding.x1
-        || stru_721530.sMaxY > pFace->pBounding.y2
-        || stru_721530.sMinY < pFace->pBounding.y1
-        || stru_721530.sMaxZ > pFace->pBounding.z2
-        || stru_721530.sMinZ < pFace->pBounding.z1
-        || pFloor == stru_721530.field_84 )
-        goto LABEL_45;
-      v13 = pFace->pFacePlane_old.vNormal.y;
-      v14 = pFace->pFacePlane_old.dist;
-      v31 = v13;
-      v15 = (stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x + v14 + stru_721530.normal.y * v13
-           + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z) >> 16;
+      pFloor = pSector->pFloors[v26];
+      pFace = &pIndoor->pFaces[pSector->pFloors[v26]];
+      if ( !pFace->Portal()
+        && stru_721530.sMaxX <= pFace->pBounding.x2 && stru_721530.sMinX >= pFace->pBounding.x1
+        && stru_721530.sMaxY <= pFace->pBounding.y2 && stru_721530.sMinY >= pFace->pBounding.y1
+        && stru_721530.sMaxZ <= pFace->pBounding.z2 && stru_721530.sMinZ >= pFace->pBounding.z1
+        && pFloor != stru_721530.field_84 )
+      {
+      v15 = ( pFace->pFacePlane_old.dist + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x
+                                         + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y
+                                         + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z ) >> 16;
       if ( v15 > 0 )
       {
-        v16 = (stru_721530.normal2.y * v31 + pFace->pFacePlane_old.dist + stru_721530.normal2.z * pFace->pFacePlane_old.vNormal.z
-             + stru_721530.normal2.x * pFace->pFacePlane_old.vNormal.x) >> 16;
+        v16 = ( pFace->pFacePlane_old.dist + stru_721530.normal2.x * pFace->pFacePlane_old.vNormal.x
+                                           + stru_721530.normal2.y * pFace->pFacePlane_old.vNormal.y
+                                           + stru_721530.normal2.z * pFace->pFacePlane_old.vNormal.z ) >> 16;
         if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d )
         {
           if ( v16 <= v15 )
           {
             a3 = stru_721530.field_6C;
             if ( sub_47531C(stru_721530.prolly_normal_d, &a3, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
-                   stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10) )
+                 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10) )
             {
               v17 = a3;
             }
@@ -180,18 +153,14 @@
       }
 LABEL_34:
       if ( !(stru_721530.field_0 & 1)
-        || (v19 = pFace->pFacePlane_old.vNormal.x,
-            v20 = pFace->pFacePlane_old.vNormal.y,
-            v30 = v19,
-            v21 = (stru_721530.position.x * v19 + pFace->pFacePlane_old.dist + stru_721530.position.y * v20
-                 + stru_721530.position.z * pFace->pFacePlane_old.vNormal.z) >> 16,
-            v21 <= 0)
-        || (v22 = (stru_721530.field_4C * v30 + pFace->pFacePlane_old.dist + stru_721530.field_50 * v20
-                 + stru_721530.field_54 * pFace->pFacePlane_old.vNormal.z) >> 16,
-            v21 > stru_721530.prolly_normal_d)
-        && v22 > stru_721530.prolly_normal_d
-        || v22 > v21 )
-        goto LABEL_45;
+        || (v21 = ( pFace->pFacePlane_old.dist + stru_721530.position.x * pFace->pFacePlane_old.vNormal.x
+                                               + stru_721530.position.y * pFace->pFacePlane_old.vNormal.y
+                                               + stru_721530.position.z * pFace->pFacePlane_old.vNormal.z) >> 16, v21 <= 0)
+        || (v22 = ( pFace->pFacePlane_old.dist + stru_721530.field_4C * pFace->pFacePlane_old.vNormal.x
+                                               + stru_721530.field_50 * pFace->pFacePlane_old.vNormal.y
+                                               + stru_721530.field_54 * pFace->pFacePlane_old.vNormal.z) >> 16, v21 > stru_721530.prolly_normal_d)
+        && v22 > stru_721530.prolly_normal_d || v22 > v21 )
+        continue;
       a3 = stru_721530.field_6C;
       if ( sub_47531C(stru_721530.field_8_radius, &a3, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
              stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10) )
@@ -213,11 +182,9 @@
           stru_721530.uFaceID = v24;
         }
       }
-LABEL_45:
-      v10 = v26++ + 1;
-      if ( v26 >= v32 )
-        goto LABEL_46;
+      }
     }
+    result = v29 + 1;
   }
   return result;
 }
@@ -227,259 +194,150 @@
 int __fastcall _46E889_collide_against_bmodels(unsigned int ecx0)
 {
   int result; // eax@1
-  BSPModel *v2; // ecx@3
   int v3; // ebx@9
-  ODMFace *v4; // eax@11
-  int v5; // edi@17
-  int v6; // esi@17
-  unsigned int v7; // ecx@17
   int v8; // eax@19
   int v9; // ecx@20
   int v10; // eax@24
-  int v11; // ST18_4@25
-  int v12; // ST1C_4@25
-  int v13; // ST0C_4@25
   unsigned int v14; // eax@28
   int v15; // eax@30
   int v16; // ecx@31
   unsigned int v17; // eax@36
-  int v18; // ST18_4@41
-  int v19; // ST1C_4@41
-  int v20; // ST0C_4@41
   int v21; // eax@42
   unsigned int v22; // eax@43
-  //BLVFace f; // [sp+Ch] [bp-7Ch]@1
-  int v24; // [sp+6Ch] [bp-1Ch]@9
   int a11; // [sp+70h] [bp-18h]@1
-  unsigned int v26; // [sp+74h] [bp-14h]@2
-  unsigned int v27; // [sp+78h] [bp-10h]@10
-  BSPModel *v28; // [sp+7Ch] [bp-Ch]@3
   int a10; // [sp+80h] [bp-8h]@1
   int a2; // [sp+84h] [bp-4h]@23
 
   a11 = ecx0;
 
   BLVFace f; // [sp+Ch] [bp-7Ch]@1
-  //BLVFace::BLVFace(&f);
 
   result = 0;
-  a10 = 0;
-  if ( (signed int)pOutdoor->uNumBModels > 0 )
+  for ( a10 = 0; a10 < (signed int)pOutdoor->uNumBModels; ++a10 )
   {
-    v26 = 0;
-    while ( 1 )
+    if ( stru_721530.sMaxX <= pOutdoor->pBModels[a10].sMaxX && stru_721530.sMinX >= pOutdoor->pBModels[a10].sMinX 
+      && stru_721530.sMaxY <= pOutdoor->pBModels[a10].sMaxY && stru_721530.sMinY >= pOutdoor->pBModels[a10].sMinY
+      && stru_721530.sMaxZ <= pOutdoor->pBModels[a10].sMaxZ && stru_721530.sMinZ >= pOutdoor->pBModels[a10].sMinZ )
     {
-      v2 = &pOutdoor->pBModels[v26 / 0xBC];
-      v28 = &pOutdoor->pBModels[v26 / 0xBC];
-      if ( stru_721530.sMaxX <= pOutdoor->pBModels[v26 / 0xBC].sMaxX )
+      for ( v3 = 0; v3 < pOutdoor->pBModels[a10].uNumFaces; ++v3 )
       {
-        if ( stru_721530.sMinX >= v2->sMinX )
+        if ( stru_721530.sMaxX <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x2 && stru_721530.sMinX >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x1
+          && stru_721530.sMaxY <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y2 && stru_721530.sMinY >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y1
+          && stru_721530.sMaxZ <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z2 && stru_721530.sMinZ >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z1 )
         {
-          if ( stru_721530.sMaxY <= v2->sMaxY )
+          f.pFacePlane_old.vNormal.x = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.x;
+          f.pFacePlane_old.vNormal.y = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.y;
+          f.pFacePlane_old.vNormal.z = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.z;
+          f.pFacePlane_old.dist = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.dist;
+          f.uAttributes = pOutdoor->pBModels[a10].pFaces[v3].uAttributes;
+          f.pBounding.x1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x1;
+          f.pBounding.y1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y1;
+          f.pBounding.z1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z1;
+          f.pBounding.x2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x2;
+          f.pBounding.y2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y2;
+          f.pBounding.z2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z2;
+          f.zCalc1 = pOutdoor->pBModels[a10].pFaces[v3].zCalc1;
+          f.zCalc2 = pOutdoor->pBModels[a10].pFaces[v3].zCalc2;
+          f.zCalc3 = pOutdoor->pBModels[a10].pFaces[v3].zCalc3;
+          f.pXInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pXInterceptDisplacements;
+          f.pYInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pYInterceptDisplacements;
+          f.pZInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pZInterceptDisplacements;
+          f.uPolygonType = (PolygonType)pOutdoor->pBModels[a10].pFaces[v3].uPolygonType;
+          f.uNumVertices = pOutdoor->pBModels[a10].pFaces[v3].uNumVertices;
+          f.uBitmapID = pOutdoor->pBModels[a10].pFaces[v3].uTextureID;
+          f.pVertexIDs = pOutdoor->pBModels[a10].pFaces[v3].pVertexIDs;
+          if ( !f.Ethereal() && !f.Portal() )
           {
-            if ( stru_721530.sMinY >= v2->sMinY )
+            v8 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.normal.x
+                                        + f.pFacePlane_old.vNormal.y * stru_721530.normal.y
+                                        + f.pFacePlane_old.vNormal.z * stru_721530.normal.z ) >> 16;
+            if ( v8 > 0 )
             {
-              if ( stru_721530.sMaxZ <= v2->sMaxZ )
+              v9 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.normal2.x
+                                          + f.pFacePlane_old.vNormal.y * stru_721530.normal2.y
+                                          + f.pFacePlane_old.vNormal.z * stru_721530.normal2.z) >> 16;
+              if ( v8 <= stru_721530.prolly_normal_d || v9 <= stru_721530.prolly_normal_d )
               {
-                if ( stru_721530.sMinZ >= v2->sMinZ )
+                if ( v9 <= v8 )
                 {
-                  v3 = 0;
-                  v24 = v2->uNumFaces;
-                  if ( v24 > 0 )
-                    break;
+                  a2 = stru_721530.field_6C;
+                  if ( sub_4754BF(stru_721530.prolly_normal_d, &a2, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
+                            stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &f, a10, a11) )
+                  {
+                    v10 = a2;
+                  }
+                  else
+                  {
+                    a2 = stru_721530.prolly_normal_d + stru_721530.field_6C;
+                    if ( !sub_475F30( &a2, &f, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
+                             stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, a10) )
+                      goto LABEL_29;
+                    v10 = a2 - stru_721530.prolly_normal_d;
+                    a2 -= stru_721530.prolly_normal_d;
+                  }
+                  if ( v10 < stru_721530.field_7C )
+                  {
+                    stru_721530.field_7C = v10;
+                    v14 = 8 * (v3 | (a10 << 6));
+                    LOBYTE(v14) = v14 | 6;
+                    stru_721530.uFaceID = v14;
+                  }
+                }
+              }
+            }
+LABEL_29:
+            if ( stru_721530.field_0 & 1 )
+            {
+              v15 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.position.x
+                                           + f.pFacePlane_old.vNormal.y * stru_721530.position.y
+                                           + f.pFacePlane_old.vNormal.z * stru_721530.position.z) >> 16;
+              if ( v15 > 0 )
+              {
+                v16 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.field_4C
+                                             + f.pFacePlane_old.vNormal.y * stru_721530.field_50
+                                             + f.pFacePlane_old.vNormal.z * stru_721530.field_54) >> 16;
+                if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d )
+                {
+                  if ( v16 <= v15 )
+                  {
+                    a2 = stru_721530.field_6C;
+                    if ( sub_4754BF(stru_721530.field_8_radius, &a2, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
+                             stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &f, a10, a11) )
+                    {
+                      if ( a2 < stru_721530.field_7C )
+                      {
+                        stru_721530.field_7C = a2;
+                        v17 = 8 * (v3 | (a10 << 6));
+                        LOBYTE(v17) = v17 | 6;
+                        stru_721530.uFaceID = v17;
+                      }
+                    }
+                    else
+                    {
+                      a2 = stru_721530.field_6C + stru_721530.field_8_radius;
+                      if ( sub_475F30(&a2, &f, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
+                                     stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, a10) )
+                      {
+                        v21 = a2 - stru_721530.prolly_normal_d;
+                        a2 -= stru_721530.prolly_normal_d;
+                        if ( a2 < stru_721530.field_7C )
+                        {
+                          stru_721530.field_7C = v21;
+                          v22 = 8 * (v3 | (a10 << 6));
+                          LOBYTE(v22) = v22 | 6;
+                          stru_721530.uFaceID = v22;
+                        }
+                      }
+                    }
+                  }
                 }
               }
             }
           }
         }
       }
-LABEL_39:
-      ++a10;
-      v26 += 188;
-      result = a10;
-      if ( a10 >= (signed int)pOutdoor->uNumBModels )
-        return result;
     }
-    v27 = 0;
-    while ( 1 )
-    {
-      v4 = &v2->pFaces[v27 / 0x134];
-      if ( stru_721530.sMaxX > v4->pBoundingBox.x2
-        || stru_721530.sMinX < v4->pBoundingBox.x1
-        || stru_721530.sMaxY > v4->pBoundingBox.y2
-        || stru_721530.sMinY < v4->pBoundingBox.y1
-        || stru_721530.sMaxZ > v4->pBoundingBox.z2
-        || stru_721530.sMinZ < v4->pBoundingBox.z1 )
-        goto LABEL_38;
-      f.pFacePlane_old.vNormal.x = v4->pFacePlane.vNormal.x;
-      f.pFacePlane_old.vNormal.y = v4->pFacePlane.vNormal.y;
-      v5 = v4->pFacePlane.vNormal.z;
-      f.pFacePlane_old.vNormal.z = v4->pFacePlane.vNormal.z;
-      v6 = v4->pFacePlane.dist;
-      f.pFacePlane_old.dist = v4->pFacePlane.dist;
-      v7 = v4->uAttributes;
-      f.uAttributes = v7;
-      f.pBounding.x1 = v4->pBoundingBox.x1;
-      f.pBounding.y1 = v4->pBoundingBox.y1;
-      f.pBounding.z1 = v4->pBoundingBox.z1;
-      f.pBounding.x2 = v4->pBoundingBox.x2;
-      f.pBounding.y2 = v4->pBoundingBox.y2;
-      f.pBounding.z2 = v4->pBoundingBox.z2;
-      f.zCalc1 = v4->zCalc1;
-      f.zCalc2 = v4->zCalc2;
-      f.zCalc3 = v4->zCalc3;
-      f.pXInterceptDisplacements = v4->pXInterceptDisplacements;
-      f.pYInterceptDisplacements = v4->pYInterceptDisplacements;
-      f.pZInterceptDisplacements = v4->pZInterceptDisplacements;
-      f.uPolygonType = (PolygonType)v4->uPolygonType;
-      f.uNumVertices = v4->uNumVertices;
-      f.uBitmapID = v4->uTextureID;
-      f.pVertexIDs = v4->pVertexIDs;
-      if ( !(v7 & 0x20000000) )
-      {
-        if ( !(v7 & 1) )
-          break;
-      }
-LABEL_37:
-      v2 = v28;
-LABEL_38:
-      v27 += 308;
-      ++v3;
-      if ( v3 >= v24 )
-        goto LABEL_39;
-    }
-    v8 = (v5 * stru_721530.normal.z
-        + v6
-        + f.pFacePlane_old.vNormal.y * stru_721530.normal.y
-        + f.pFacePlane_old.vNormal.x * stru_721530.normal.x) >> 16;
-    if ( v8 > 0 )
-    {
-      v9 = (v5 * stru_721530.normal2.z
-          + v6
-          + f.pFacePlane_old.vNormal.y * stru_721530.normal2.y
-          + f.pFacePlane_old.vNormal.x * stru_721530.normal2.x) >> 16;
-      if ( v8 <= stru_721530.prolly_normal_d || v9 <= stru_721530.prolly_normal_d )
-      {
-        if ( v9 <= v8 )
-        {
-          a2 = stru_721530.field_6C;
-          if ( sub_4754BF(
-                 stru_721530.prolly_normal_d,
-                 &a2,
-                 stru_721530.normal.x,
-                 stru_721530.normal.y,
-                 stru_721530.normal.z,
-                 stru_721530.direction.x,
-                 stru_721530.direction.y,
-                 stru_721530.direction.z,
-                 &f,
-                 a10,
-                 a11) )
-          {
-            v10 = a2;
-          }
-          else
-          {
-            v11 = stru_721530.direction.y;
-            v12 = stru_721530.direction.z;
-            v13 = stru_721530.normal.y;
-            a2 = stru_721530.prolly_normal_d + stru_721530.field_6C;
-            if ( !sub_475F30(
-                    &a2,
-                    &f,
-                    stru_721530.normal.x,
-                    v13,
-                    stru_721530.normal.z,
-                    stru_721530.direction.x,
-                    v11,
-                    v12,
-                    a10) )
-              goto LABEL_29;
-            v10 = a2 - stru_721530.prolly_normal_d;
-            a2 -= stru_721530.prolly_normal_d;
-          }
-          if ( v10 < stru_721530.field_7C )
-          {
-            stru_721530.field_7C = v10;
-            v14 = 8 * (v3 | (a10 << 6));
-            LOBYTE(v14) = v14 | 6;
-            stru_721530.uFaceID = v14;
-          }
-        }
-      }
-    }
-LABEL_29:
-    if ( stru_721530.field_0 & 1 )
-    {
-      v15 = (f.pFacePlane_old.vNormal.z * stru_721530.position.z
-           + f.pFacePlane_old.dist
-           + f.pFacePlane_old.vNormal.y * stru_721530.position.y
-           + f.pFacePlane_old.vNormal.x * stru_721530.position.x) >> 16;
-      if ( v15 > 0 )
-      {
-        v16 = (f.pFacePlane_old.vNormal.z * stru_721530.field_54
-             + f.pFacePlane_old.dist
-             + f.pFacePlane_old.vNormal.y * stru_721530.field_50
-             + f.pFacePlane_old.vNormal.x * stru_721530.field_4C) >> 16;
-        if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d )
-        {
-          if ( v16 <= v15 )
-          {
-            a2 = stru_721530.field_6C;
-            if ( sub_4754BF(stru_721530.field_8_radius,
-                   &a2,
-                   stru_721530.position.x,
-                   stru_721530.position.y,
-                   stru_721530.position.z,
-                   stru_721530.direction.x,
-                   stru_721530.direction.y,
-                   stru_721530.direction.z,
-                   &f,
-                   a10,
-                   a11) )
-            {
-              if ( a2 < stru_721530.field_7C )
-              {
-                stru_721530.field_7C = a2;
-                v17 = 8 * (v3 | (a10 << 6));
-                LOBYTE(v17) = v17 | 6;
-                stru_721530.uFaceID = v17;
-              }
-            }
-            else
-            {
-              v18 = stru_721530.direction.y;
-              v19 = stru_721530.direction.z;
-              v20 = stru_721530.position.y;
-              a2 = stru_721530.field_6C + stru_721530.field_8_radius;
-              if ( sub_475F30(&a2,
-                     &f,
-                     stru_721530.position.x,
-                     v20,
-                     stru_721530.position.z,
-                     stru_721530.direction.x,
-                     v18,
-                     v19,
-                     a10) )
-              {
-                v2 = v28;
-                v21 = a2 - stru_721530.prolly_normal_d;
-                a2 -= stru_721530.prolly_normal_d;
-                if ( a2 < stru_721530.field_7C )
-                {
-                  stru_721530.field_7C = v21;
-                  v22 = 8 * (v3 | (a10 << 6));
-                  LOBYTE(v22) = v22 | 6;
-                  stru_721530.uFaceID = v22;
-                }
-                goto LABEL_38;
-              }
-            }
-          }
-        }
-      }
-    }
-    goto LABEL_37;
+    result = a10;
   }
   return result;
 }
@@ -509,75 +367,41 @@
 //----- (0046ED8A) --------------------------------------------------------
 void __fastcall _46ED8A_collide_against_sprite_objects(unsigned int _this)
 {
-  int v1; // ebx@2
-  ObjectDesc *v2; // edx@4
-  int v3; // esi@5
-  int v4; // ecx@5
-  int v5; // eax@7
-  int v6; // edi@9
-  int v7; // edx@9
-  int v8; // edi@11
-  int v9; // ebx@11
+  ObjectDesc *object; // edx@4
   int v10; // ecx@12
   int v11; // esi@13
-  signed int v12; // [sp+0h] [bp-14h]@1
-  int v13; // [sp+4h] [bp-10h]@9
-  char *v14; // [sp+8h] [bp-Ch]@2
-  unsigned int v15; // [sp+10h] [bp-4h]@1
-
-  v15 = 0;
-  v12 = _this;
+
   if ( (signed int)uNumSpriteObjects > 0 )
   {
-    v1 = (int)&pSpriteObjects[0].uObjectDescID;
-    v14 = (char *)&pSpriteObjects[0].uObjectDescID;
-    do
+    for ( uint i = 0; i < uNumSpriteObjects; ++i )
     {
-      if ( *(short *)v1 )
+      if ( pSpriteObjects[i].uObjectDescID )
       {
-        v2 = &pObjectList->pObjects[*(short *)v1];
-        if ( !(v2->uFlags & 2) )
+        object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID];
+        if ( !(object->uFlags & OBJECT_DESC_NO_COLLISION) )
         {
-          v3 = v2->uRadius;
-          v4 = *(int *)(v1 + 2);
-          if ( stru_721530.sMaxX <= v4 + v3 )
+          if ( stru_721530.sMaxX <= pSpriteObjects[i].vPosition.x + object->uRadius
+            && stru_721530.sMinX >= pSpriteObjects[i].vPosition.x - object->uRadius
+            && stru_721530.sMaxY <= pSpriteObjects[i].vPosition.y + object->uRadius
+            && stru_721530.sMinY >= pSpriteObjects[i].vPosition.y - object->uRadius
+            && stru_721530.sMaxZ <= pSpriteObjects[i].vPosition.z + object->uHeight
+            && stru_721530.sMinZ >= pSpriteObjects[i].vPosition.z )
           {
-            if ( stru_721530.sMinX >= v4 - v3 )
+            if ( abs(((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
+                    - (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16) <= object->uHeight
+                                                                                    + stru_721530.prolly_normal_d )
             {
-              v5 = *(int *)(v1 + 6);
-              if ( stru_721530.sMaxY <= v5 + v3 )
+              v10 = ((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.x
+                   + (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.y) >> 16;
+              if ( v10 > 0 )
               {
-                if ( stru_721530.sMinY >= v5 - v3 )
+                v11 = stru_721530.normal.z + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v10) >> 16);
+                if ( v11 >= pSpriteObjects[i].vPosition.z - stru_721530.prolly_normal_d )
                 {
-                  v6 = v2->uHeight;
-                  v7 = *(int *)(v1 + 10);
-                  v13 = v6;
-                  if ( stru_721530.sMaxZ <= v7 + v6 )
+                  if ( v11 <= object->uHeight + stru_721530.prolly_normal_d + pSpriteObjects[i].vPosition.z )
                   {
-                    if ( stru_721530.sMinZ >= v7 )
-                    {
-                      v8 = v4 - stru_721530.normal.x;
-                      v9 = v5 - stru_721530.normal.y;
-                      if ( abs(((v4 - stru_721530.normal.x) * stru_721530.direction.y
-                              - (v5 - stru_721530.normal.y) * stru_721530.direction.x) >> 16) <= v3
-                                                                                              + stru_721530.prolly_normal_d )
-                      {
-                        v10 = (v8 * stru_721530.direction.x + v9 * stru_721530.direction.y) >> 16;
-                        if ( v10 > 0 )
-                        {
-                          v11 = stru_721530.normal.z
-                              + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v10) >> 16);
-                          if ( v11 >= *(int *)(v14 + 10) - stru_721530.prolly_normal_d )
-                          {
-                            if ( v11 <= v13 + stru_721530.prolly_normal_d + *(int *)(v14 + 10) )
-                            {
-                              if ( v10 < stru_721530.field_7C )
-                                sub_46DEF2(v12, v15);
-                            }
-                          }
-                        }
-                      }
-                    }
+                    if ( v10 < stru_721530.field_7C )
+                      sub_46DEF2(_this, i);
                   }
                 }
               }
@@ -585,11 +409,7 @@
           }
         }
       }
-      ++v15;
-      v1 = (int)(v14 + 112);
-      v14 += 112;
     }
-    while ( (signed int)v15 < (signed int)uNumSpriteObjects );
   }
 }
 
@@ -612,51 +432,39 @@
   v1 = 2 * pParty->field_14_radius;
   result = pParty->vPosition.x;
   v9 = pParty->uPartyHeight;
-  if ( stru_721530.sMaxX <= pParty->vPosition.x + 2 * pParty->field_14_radius )
+  if ( stru_721530.sMaxX <= pParty->vPosition.x + v1 && stru_721530.sMinX >= pParty->vPosition.x - v1
+    && stru_721530.sMaxY <= pParty->vPosition.y + v1 && stru_721530.sMinY >= pParty->vPosition.y - v1
+    && stru_721530.sMaxZ <= (signed int)(pParty->vPosition.z + pParty->uPartyHeight)
+    && stru_721530.sMinZ >= pParty->vPosition.z )
   {
-    if ( stru_721530.sMinX >= pParty->vPosition.x - v1 )
+    v3 = stru_721530.prolly_normal_d + v1;
+    v11 = pParty->vPosition.x - stru_721530.normal.x;
+    v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
+        - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16;
+    v10 = pParty->vPosition.y - stru_721530.normal.y;
+    result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
+                - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16);
+    if ( result <= stru_721530.prolly_normal_d + v1 )
     {
-      if ( stru_721530.sMaxY <= pParty->vPosition.y + v1 )
+      result = v10 * stru_721530.direction.y;
+      v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16;
+      if ( v5 > 0 )
       {
-        if ( stru_721530.sMinY >= pParty->vPosition.y - v1 )
+        v6 = ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v5) >> 16) + stru_721530.normal.z;
+        result = pParty->vPosition.z;
+        if ( v6 >= pParty->vPosition.z )
         {
-          if ( stru_721530.sMaxZ <= (signed int)(pParty->vPosition.z + pParty->uPartyHeight) )
+          result = v9 + pParty->vPosition.z;
+          if ( v6 <= (signed int)(v9 + pParty->vPosition.z) || v8 )
           {
-            if ( stru_721530.sMinZ >= pParty->vPosition.z )
+            result = integer_sqrt(v3 * v3 - v4 * v4);
+            v7 = v5 - integer_sqrt(v3 * v3 - v4 * v4);
+            if ( v7 < 0 )
+              v7 = 0;
+            if ( v7 < stru_721530.field_7C )
             {
-              v3 = stru_721530.prolly_normal_d + v1;
-              v11 = pParty->vPosition.x - stru_721530.normal.x;
-              v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
-                  - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16;
-              v10 = pParty->vPosition.y - stru_721530.normal.y;
-              result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
-                          - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16);
-              if ( result <= v3 )
-              {
-                result = v10 * stru_721530.direction.y;
-                v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16;
-                if ( v5 > 0 )
-                {
-                  v6 = ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v5) >> 16) + stru_721530.normal.z;
-                  result = pParty->vPosition.z;
-                  if ( v6 >= pParty->vPosition.z )
-                  {
-                    result = v9 + pParty->vPosition.z;
-                    if ( v6 <= (signed int)(v9 + pParty->vPosition.z) || v8 )
-                    {
-                      result = integer_sqrt(v3 * v3 - v4 * v4);
-                      v7 = v5 - result;
-                      if ( v7 < 0 )
-                        v7 = 0;
-                      if ( v7 < stru_721530.field_7C )
-                      {
-                        stru_721530.field_7C = v7;
-                        stru_721530.uFaceID = 4;
-                      }
-                    }
-                  }
-                }
-              }
+              stru_721530.field_7C = v7;
+              stru_721530.uFaceID = 4;
             }
           }
         }
@@ -669,76 +477,51 @@
 //----- (0046F04E) --------------------------------------------------------
 int _46F04E_collide_against_portals()
 {
-  BLVSector *v0; // ecx@1
   unsigned int v1; // eax@1
-  int v2; // eax@2
-  BLVFace *v3; // eax@3
+  BLVFace *face; // eax@3
   int v4; // ecx@9
   int v5; // edx@9
   signed int result; // eax@21
-  BLVFace *v7; // eax@22
-  signed int v8; // [sp+0h] [bp-14h]@1
-  BLVSector *v9; // [sp+4h] [bp-10h]@1
   unsigned int v10; // [sp+8h] [bp-Ch]@1
   int a3; // [sp+Ch] [bp-8h]@13
   int v12; // [sp+10h] [bp-4h]@15
 
-  v8 = 0;
-  v0 = &pIndoor->pSectors[stru_721530.uSectorID];
   v1 = 0xFFFFFFu;
   v10 = 0xFFFFFFu;
-  v9 = v0;
-  if ( v0->uNumPortals > 0 )
+  for ( uint i = 0; i < pIndoor->pSectors[stru_721530.uSectorID].uNumPortals; ++i )
   {
-    do
+    if ( pIndoor->pSectors[stru_721530.uSectorID].pPortals[i] != stru_721530.field_80 )
     {
-      v2 = v0->pPortals[v8];
-      if ( v2 != stru_721530.field_80 )
+      face = &pIndoor->pFaces[pIndoor->pSectors[stru_721530.uSectorID].pPortals[i]];
+      if ( stru_721530.sMaxX <= face->pBounding.x2 && stru_721530.sMinX >= face->pBounding.x1
+        && stru_721530.sMaxY <= face->pBounding.y2 && stru_721530.sMinY >= face->pBounding.y1
+        && stru_721530.sMaxZ <= face->pBounding.z2 && stru_721530.sMinZ >= face->pBounding.z1 )
       {
-        v3 = &pIndoor->pFaces[v2];
-        if ( stru_721530.sMaxX <= v3->pBounding.x2 )
+        v4 = (stru_721530.normal.x * face->pFacePlane_old.vNormal.x + face->pFacePlane_old.dist
+            + stru_721530.normal.y * face->pFacePlane_old.vNormal.y
+            + stru_721530.normal.z * face->pFacePlane_old.vNormal.z) >> 16;
+        v5 = (stru_721530.normal2.z * face->pFacePlane_old.vNormal.z + face->pFacePlane_old.dist
+            + stru_721530.normal2.x * face->pFacePlane_old.vNormal.x
+            + stru_721530.normal2.y * face->pFacePlane_old.vNormal.y) >> 16;
+        if ( (v4 < stru_721530.prolly_normal_d || v5 < stru_721530.prolly_normal_d)
+          && (v4 > -stru_721530.prolly_normal_d || v5 > -stru_721530.prolly_normal_d)
+          && (a3 = stru_721530.field_6C, sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, face))
+          && a3 < (signed int)v10 )
         {
-          if ( stru_721530.sMinX >= v3->pBounding.x1
-            && stru_721530.sMaxY <= v3->pBounding.y2
-            && stru_721530.sMinY >= v3->pBounding.y1
-            && stru_721530.sMaxZ <= v3->pBounding.z2
-            && stru_721530.sMinZ >= v3->pBounding.z1 )
-          {
-            v4 = (stru_721530.normal.x * v3->pFacePlane_old.vNormal.x + v3->pFacePlane_old.dist
-                + stru_721530.normal.y * v3->pFacePlane_old.vNormal.y
-                + stru_721530.normal.z * v3->pFacePlane_old.vNormal.z) >> 16;
-            v5 = (stru_721530.normal2.z * v3->pFacePlane_old.vNormal.z + v3->pFacePlane_old.dist
-                + stru_721530.normal2.x * v3->pFacePlane_old.vNormal.x
-                + stru_721530.normal2.y * v3->pFacePlane_old.vNormal.y) >> 16;
-            if ( (v4 < stru_721530.prolly_normal_d || v5 < stru_721530.prolly_normal_d)
-              && (v4 > -stru_721530.prolly_normal_d || v5 > -stru_721530.prolly_normal_d)
-              && (a3 = stru_721530.field_6C, sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, v3))
-              && a3 < (signed int)v10 )
-            {
-              v0 = v9;
-              v10 = a3;
-              v12 = v9->pPortals[v8];
-            }
-            else
-            {
-              v0 = v9;
-            }
-          }
+          v10 = a3;
+          v12 = pIndoor->pSectors[stru_721530.uSectorID].pPortals[i];
         }
       }
-      ++v8;
     }
-    while ( v8 < v0->uNumPortals );
-    v1 = v10;
   }
+  v1 = v10;
   if ( stru_721530.field_7C >= (signed int)v1 && (signed int)v1 <= stru_721530.field_6C )
   {
     stru_721530.field_80 = v12;
-    v7 = &pIndoor->pFaces[v12];
-    if ( v7->uSectorID == stru_721530.uSectorID )
-      stru_721530.uSectorID = v7->uBackSectorID;
+    if ( pIndoor->pFaces[v12].uSectorID == stru_721530.uSectorID )
+      stru_721530.uSectorID = pIndoor->pFaces[v12].uBackSectorID;
     else
-      stru_721530.uSectorID = v7->uSectorID;
+      stru_721530.uSectorID = pIndoor->pFaces[v12].uSectorID;
     stru_721530.field_7C = 268435455;
     result = 0;
   }
@@ -860,61 +643,28 @@
 //----- (004706C6) --------------------------------------------------------
 void UpdateActors_ODM()
 {
-  Actor *v0; // esi@2
-  AIState uAIState; // ax@2
-  //unsigned int v2; // ecx@6
   int v3; // ebx@6
-  //int v4; // eax@8
   int v5; // eax@10
   int v6; // ecx@10
-  //signed int v7; // ebx@10
   signed int v8; // ebx@17
-  //unsigned __int8 v9; // zf@17
   unsigned __int8 v10; // sf@17
   unsigned __int16 v11; // ax@21
-  //int v12; // eax@29
-  //unsigned __int64 v13; // qax@29
-  //int v14; // eax@30
-  //unsigned __int64 v15; // qax@30
-  int v16; // eax@33
-  //int v17; // edi@34
-  //int v18; // edx@42
-  //int v19; // ecx@42
   __int16 v20; // ax@42
-  //int v21; // ebx@42
-  //int v22; // edi@42
-  //int v23; // ecx@42
-  //__int16 v24; // ax@42
   int v25; // eax@45
   signed int v26; // ecx@50
-  //int v27; // eax@52
   int v28; // eax@54
   signed int v29; // ebx@57
   signed int v30; // eax@57
   int v31; // edi@57
   signed int i; // ebx@57
   unsigned int v33; // ecx@58
-  //int v34; // ebx@64
   int v35; // edi@64
   int v36; // eax@64
-  //unsigned __int16 v37; // cx@66
-  signed int v38; // edx@71
   unsigned int v39; // edi@71
-  BSPModel *v40; // eax@75
-  ODMFace *v41; // edi@75
-  int v42; // ebx@76
-  int v43; // ecx@77
-  int v44; // edx@77
-  __int16 v45; // dx@82
+  ODMFace *face; // edi@75
   int v46; // ecx@82
   signed int v47; // ebx@85
   int v48; // edi@85
-  int v49; // edi@85
-  //int v50; // eax@85
-  //unsigned __int64 v51; // qax@85
-  //unsigned __int8 v52; // zf@87
-  //unsigned __int8 v53; // sf@87
- // unsigned __int8 v54; // of@104
   int v55; // eax@107
   unsigned int v56; // edi@107
   int v57; // ST10_4@107
@@ -925,10 +675,7 @@
   Vec3_int_ v62; // [sp+Ch] [bp-44h]@42
   int v63; // [sp+18h] [bp-38h]@64
   int v64; // [sp+1Ch] [bp-34h]@64
-  int v65; // [sp+20h] [bp-30h]@2
-  int v66; // [sp+24h] [bp-2Ch]@2
   bool v67; // [sp+28h] [bp-28h]@10
-  //unsigned int v68; // [sp+2Ch] [bp-24h]@10
   unsigned int v69; // [sp+30h] [bp-20h]@6
   unsigned int v70; // [sp+34h] [bp-1Ch]@10
   int v71; // [sp+38h] [bp-18h]@62
@@ -941,49 +688,38 @@
 
   for (v75 = 0; v75 < uNumActors; ++v75)
   {
-    v0 = &pActors[v75];
-    v66 = v0->vPosition.x;
-    v65 = v0->vPosition.y;
-    uAIState = v0->uAIState;
-    if ( uAIState == Removed || uAIState == Disabled || uAIState == Summoned || !v0->uMovementSpeed )
-	{
-		continue;
-	}
+    if ( pActors[v75].uAIState == Removed || pActors[v75].uAIState == Disabled || pActors[v75].uAIState == Summoned
+     || !pActors[v75].uMovementSpeed )
+      continue;
     v3 = 0;
     v69 = 0;
-    if ( MonsterStats::BelongsToSupertype(v0->pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) )
+    if ( MonsterStats::BelongsToSupertype(pActors[v75].pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) )
       v3 = 1;
-    v0->uSectorID = 0;
-    uIsFlying = v0->pMonsterInfo.uFlying;
-    if ( !v0->CanAct() )
+    pActors[v75].uSectorID = 0;
+    uIsFlying = pActors[v75].pMonsterInfo.uFlying;
+    if ( !pActors[v75].CanAct() )
       uIsFlying = 0;
-    v70 = IsTerrainSlopeTooHigh(v0->vPosition.x, v0->vPosition.y);
-    v5 = ODM_GetFloorLevel(
-           v0->vPosition.x,
-           v0->vPosition.y,
-           v0->vPosition.z,
-           v0->uActorHeight,
-           &uIsOnWater,
-           (int *)&v69,
-           v3);
-    v6 = v0->vPosition.z;
+    v70 = IsTerrainSlopeTooHigh(pActors[v75].vPosition.x, pActors[v75].vPosition.y);
+    v5 = ODM_GetFloorLevel(pActors[v75].vPosition.x, pActors[v75].vPosition.y, pActors[v75].vPosition.z,
+           pActors[v75].uActorHeight, &uIsOnWater, (int *)&v69, v3);
+    v6 = pActors[v75].vPosition.z;
     uIsAboveFloor = 0;
     v67 = v69 == 0;
     if ( v6 > v5 + 1 )
       uIsAboveFloor = 1;
-    if ( uAIState == Dead && uIsOnWater && !uIsAboveFloor )
+    if ( pActors[v75].uAIState == Dead && uIsOnWater && !uIsAboveFloor )
     {
-      v0->uAIState = Removed;
-	  continue;
+      pActors[v75].uAIState = Removed;
+      continue;
     }
-    if ( v0->uCurrentActionAnimation == ANIM_Walking )
+    if ( pActors[v75].uCurrentActionAnimation == ANIM_Walking )
     {
-      v8 = v0->uMovementSpeed;
-      if ( (signed __int64)v0->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0 )
+      v8 = pActors[v75].uMovementSpeed;
+      if ( (signed __int64)pActors[v75].pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0 )
       {
         v8 = (signed __int64)((double)v8 * 0.5);
       }
-      if ( uAIState == Fleeing || uAIState == Pursuing )
+      if ( pActors[v75].uAIState == Fleeing || pActors[v75].uAIState == Pursuing )
       {
         v8 *= 2;
       }
@@ -992,100 +728,97 @@
       if ( v8 > 1000 )
         v8 = 1000;
 
-      v0->vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v0->uYawAngle), v8);
-      v0->vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v0->uYawAngle), v8);
+      pActors[v75].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(pActors[v75].uYawAngle), v8);
+      pActors[v75].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(pActors[v75].uYawAngle), v8);
       if ( uIsFlying )
       {
-        v0->vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(v0->uPitchAngle), v8);
+        pActors[v75].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pActors[v75].uPitchAngle), v8);
       }
       //v7 = v68;
     }
     else
     {
-      v0->vVelocity.x = fixpoint_mul(55000, v0->vVelocity.x);
-      v0->vVelocity.y = fixpoint_mul(55000, v0->vVelocity.y);
+      pActors[v75].vVelocity.x = fixpoint_mul(55000, pActors[v75].vVelocity.x);
+      pActors[v75].vVelocity.y = fixpoint_mul(55000, pActors[v75].vVelocity.y);
       if ( uIsFlying )
-      {
-        v0->vVelocity.z = fixpoint_mul(55000, v0->vVelocity.z);
-      }
+        pActors[v75].vVelocity.z = fixpoint_mul(55000, pActors[v75].vVelocity.z);
     }
-    if ( v0->vPosition.z < v5 )
+    if ( pActors[v75].vPosition.z < v5 )
     {
-      v16 = uIsFlying;
-      v0->vPosition.z = v5;
-      v0->vVelocity.z = v16 != 0 ? 0x14 : 0;
+      pActors[v75].vPosition.z = v5;
+      pActors[v75].vVelocity.z = uIsFlying != 0 ? 0x14 : 0;
     }
     //v17 = 0;
     if ( !uIsAboveFloor || uIsFlying )
     {
       if ( v70 && !uIsAboveFloor && v67 )
       {
-        v0->vPosition.z = v5;
-        ODM_GetTerrainNormalAt(v0->vPosition.x, v0->vPosition.y, &v62);
+        pActors[v75].vPosition.z = v5;
+        ODM_GetTerrainNormalAt(pActors[v75].vPosition.x, pActors[v75].vPosition.y, &v62);
         v20 = GetGravityStrength();
         //v21 = v62.y;
         //v22 = v62.z;
         //v23 = v62.y * v0->vVelocity.y;
-        v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20;
-        int v73 = abs(v62.x * v0->vVelocity.x + v62.z * v0->vVelocity.z + v62.y * v0->vVelocity.y) >> 16;
+        pActors[v75].vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20;
+        int v73 = abs(v62.x * pActors[v75].vVelocity.x + v62.z * pActors[v75].vVelocity.z + v62.y * pActors[v75].vVelocity.y) >> 16;
         //v72b = v21;
-        v0->vVelocity.x += fixpoint_mul(v73, v62.x);
-        v0->vVelocity.y += fixpoint_mul(v73, v62.y);
-        v0->vVelocity.z += fixpoint_mul(v73, v62.z);
+        pActors[v75].vVelocity.x += fixpoint_mul(v73, v62.x);
+        pActors[v75].vVelocity.y += fixpoint_mul(v73, v62.y);
+        pActors[v75].vVelocity.z += fixpoint_mul(v73, v62.z);
         //v17 = 0;
       }
     }
     else
     {
-      v0->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
+      pActors[v75].vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
     }
-    if ( pParty->armageddon_timer != 0 && v0->CanAct() )
+    if ( pParty->armageddon_timer != 0 && pActors[v75].CanAct() )
     {
-      v0->vVelocity.x += rand() % 100 - 50;
-      v0->vVelocity.y += rand() % 100 - 50;
-      v0->vVelocity.z += rand() % 100 - 20;
+      pActors[v75].vVelocity.x += rand() % 100 - 50;
+      pActors[v75].vVelocity.y += rand() % 100 - 50;
+      pActors[v75].vVelocity.z += rand() % 100 - 20;
       v25 = rand();
-      v0->uAIState = Stunned;
-      v0->uYawAngle += v25 % 32 - 16;
-      v0->UpdateAnimation();
+      pActors[v75].uAIState = Stunned;
+      pActors[v75].uYawAngle += v25 % 32 - 16;
+      pActors[v75].UpdateAnimation();
     }
-    if ( v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y < 400 && v70 == 0 )
+    if ( pActors[v75].vVelocity.x * pActors[v75].vVelocity.x + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y < 400 && v70 == 0 )
     {
-      v0->vVelocity.y = 0;
-      v0->vVelocity.x = 0;
+      pActors[v75].vVelocity.y = 0;
+      pActors[v75].vVelocity.x = 0;
     }
     stru_721530.field_0 = 1;
     if ( !uIsFlying )
       v26 = 40;
     else
-      v26 = v0->uActorRadius;
+      v26 = pActors[v75].uActorRadius;
 
     stru_721530.field_84 = -1;
     stru_721530.field_8_radius = v26;
     stru_721530.prolly_normal_d = v26;
-    stru_721530.height = v0->uActorHeight;
+    stru_721530.height = pActors[v75].uActorHeight;
     stru_721530.field_70 = 0;
-    v69 = 0;
-    while ( 1 )
+
+    for ( v69 = 0; v69 < 100; ++v69 )
     {
-      stru_721530.position.x = v0->vPosition.x;
+      stru_721530.position.x = pActors[v75].vPosition.x;
       stru_721530.normal.x = stru_721530.position.x;
-      stru_721530.position.y = v0->vPosition.y;
+      stru_721530.position.y = pActors[v75].vPosition.y;
       stru_721530.normal.y = stru_721530.position.y;
-      v28 = v0->vPosition.z;
+      v28 = pActors[v75].vPosition.z;
       stru_721530.normal.z = v28 + v26 + 1;
       stru_721530.position.z = v28 - v26 + stru_721530.height - 1;
       if ( stru_721530.position.z < stru_721530.normal.z )
         stru_721530.position.z = v28 + v26 + 1;
-      stru_721530.velocity.x = v0->vVelocity.x;
+      stru_721530.velocity.x = pActors[v75].vVelocity.x;
       stru_721530.uSectorID = 0;
-      stru_721530.velocity.y = v0->vVelocity.y;
-      stru_721530.velocity.z = v0->vVelocity.z;
+      stru_721530.velocity.y = pActors[v75].vVelocity.y;
+      stru_721530.velocity.z = pActors[v75].vVelocity.z;
       if ( stru_721530._47050A(0) )
         break;
-      _46E889_collide_against_bmodels(1u);
-      v29 = WorldPosToGridCellZ(v0->vPosition.y);
-      v30 = WorldPosToGridCellX(v0->vPosition.x);
+      _46E889_collide_against_bmodels(1);
+      v29 = WorldPosToGridCellZ(pActors[v75].vPosition.y);
+      v30 = WorldPosToGridCellX(pActors[v75].vPosition.x);
       _46E26D_collide_against_sprites(v30, v29);
       _46EF01_collision_chech_player(0);
       _46ED8A_collide_against_sprite_objects(PID(OBJECT_Actor,v75));
@@ -1101,182 +834,159 @@
         v70 = fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
       //v34 = 0;
       v35 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
-      v36 = ODM_GetFloorLevel(stru_721530.normal2.x,
-              stru_721530.normal2.y,
+      v36 = ODM_GetFloorLevel(stru_721530.normal2.x, stru_721530.normal2.y,
               stru_721530.normal2.z - stru_721530.prolly_normal_d - 1,
-              v0->uActorHeight,
-              (int *)&v63,
-              &v64,
-              0);
+              pActors[v75].uActorHeight, (int *)&v63, &v64, 0);
       if ( uIsOnWater )
       {
         if ( v35 < v36 + 60 )
         {
-          if ( uAIState == Dead || uAIState == Dying || uAIState == Removed || uAIState == Disabled )
+          if ( pActors[v75].uAIState == Dead || pActors[v75].uAIState == Dying || pActors[v75].uAIState == Removed
+            || pActors[v75].uAIState == Disabled )
           {
             if ( v64 )
               v61 = v36 + 30;
             else
               v61 = v5 + 60;
-            sub_42F960_create_object(v0->vPosition.x, v0->vPosition.y, v61);
-            v0->uAIState = Removed;
+            sub_42F960_create_object(pActors[v75].vPosition.x, pActors[v75].vPosition.y, v61);
+            pActors[v75].uAIState = Removed;
             return;
           }
         }
       }
       if ( stru_721530.field_7C >= stru_721530.field_6C )
       {
-        v0->vPosition.x = LOWORD(stru_721530.normal2.x);
-        v0->vPosition.y = LOWORD(stru_721530.normal2.y);
-        v0->vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1;
+        pActors[v75].vPosition.x = LOWORD(stru_721530.normal2.x);
+        pActors[v75].vPosition.y = LOWORD(stru_721530.normal2.y);
+        pActors[v75].vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1;
         break;
       }
       //v72b = fixpoint_mul(stru_721530.field_7C, stru_721530.field_58.x);
-      v0->vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x);
+      pActors[v75].vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x);
       //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
-      v0->vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y);
+      pActors[v75].vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y);
       //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
-      v0->vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
-      v38 = stru_721530.uFaceID;
+      pActors[v75].vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
       stru_721530.field_70 += stru_721530.field_7C;
-	  v39 = PID_ID(v38);
-      switch ( PID_TYPE(v38) )
+      v39 = PID_ID(stru_721530.uFaceID);
+      switch ( PID_TYPE(stru_721530.uFaceID) )
       {
         case OBJECT_Actor:
           if ( pTurnEngine->turn_stage != 2 && pTurnEngine->turn_stage != 3 || pParty->bTurnBasedModeOn != 1 )
           {
 			//if(pParty->bTurnBasedModeOn == 1)
 				//v34 = 0;
-            if ( v0->pMonsterInfo.uHostilityType )
+            if ( pActors[v75].pMonsterInfo.uHostilityType )
             {
               if ( v71 == 0 )
-			  {
-				  Actor::AI_Flee(v75, v38, 0, (AIDirection *)0);
-			  }
-			  else
-			  {
-				  Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0);
-			  }
+                Actor::AI_Flee(v75, stru_721530.uFaceID, 0, (AIDirection *)0);
+              else
+                Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0);
             }
             else if ( v71 )
-			{
               Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0);
-			}
-			else if ( pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly )
-            {
-              Actor::AI_Flee(v75, v38, 0, (AIDirection *)0);
-            }
-			else
-			{
-				Actor::AI_FaceObject(v75, v38, 0, (AIDirection *)0);
-			}
+            else if ( pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly )
+              Actor::AI_Flee(v75, stru_721530.uFaceID, 0, (AIDirection *)0);
+            else
+              Actor::AI_FaceObject(v75, stru_721530.uFaceID, 0, (AIDirection *)0);
           }
           break;
         case OBJECT_Player:
-          if ( !v0->GetActorsRelation(0) )
+          if ( !pActors[v75].GetActorsRelation(0) )
           {
-            v38 = stru_721530.uFaceID;
-            Actor::AI_FaceObject(v75, v38, 0, (AIDirection *)0);
+            Actor::AI_FaceObject(v75, stru_721530.uFaceID, 0, (AIDirection *)0);
             break;
           }
           //v52 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == 0;
           //v53 = SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) < 0;
-          v0->vVelocity.y = 0;
-          v0->vVelocity.x = 0;
+          pActors[v75].vVelocity.y = 0;
+          pActors[v75].vVelocity.x = 0;
           //if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0) )
-		  if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime < 0)
+          if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime < 0)
             pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
           viewparams->bRedrawGameUI = 1;
           break;
         case OBJECT_Decoration:
-          v47 = integer_sqrt(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y);
-          v48 = stru_5C6E00->Atan2(
-                  v0->vPosition.x - pLevelDecorations[v39].vPosition.x,
-                  v0->vPosition.y - pLevelDecorations[v39].vPosition.y);
-          v49 = v48;
-          v0->vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v48), v47);
-          v0->vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v48), v47);
+          v47 = integer_sqrt(pActors[v75].vVelocity.x * pActors[v75].vVelocity.x + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y);
+          v48 = stru_5C6E00->Atan2( pActors[v75].vPosition.x - pLevelDecorations[v39].vPosition.x,
+                  pActors[v75].vPosition.y - pLevelDecorations[v39].vPosition.y);
+          //v49 = v48;
+          pActors[v75].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v48), v47);
+          pActors[v75].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v48), v47);
           break;
         case OBJECT_BModel:
-          v40 = &pOutdoor->pBModels[v38 >> 9];
-          v41 = &v40->pFaces[v39 & 0x3F];
-          if ( !(v41->uAttributes & 0x20000000) )
+          face = &pOutdoor->pBModels[stru_721530.uFaceID >> 9].pFaces[v39 & 0x3F];
+          if ( !face->Ethereal() )
           {
-            v42 = v41->uPolygonType;
-            if ( v42 == 3 )
+            if ( face->uPolygonType == 3 )
             {
-              v43 = v0->vVelocity.y;
-              v44 = v0->vVelocity.x;
-              v0->vVelocity.z = 0;
-              v0->vPosition.z = LOWORD(v40->pVertices.pVertices[v41->pVertexIDs[0]].z) + 1;
-              if ( v44 * v44 + v43 * v43 < 400 )
+              pActors[v75].vVelocity.z = 0;
+              pActors[v75].vPosition.z = LOWORD(pOutdoor->pBModels[stru_721530.uFaceID >> 9].pVertices.pVertices[face->pVertexIDs[0]].z) + 1;
+              if ( pActors[v75].vVelocity.x * pActors[v75].vVelocity.x
+                 + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y < 400 )
               {
-                v0->vVelocity.y = 0;
-                v0->vVelocity.x = 0;
+                pActors[v75].vVelocity.y = 0;
+                pActors[v75].vVelocity.x = 0;
               }
             }
             else
             {
-              v72b = abs(v41->pFacePlane.vNormal.y * v0->vVelocity.y + v41->pFacePlane.vNormal.z * v0->vVelocity.z
-                                                                    + v41->pFacePlane.vNormal.x * v0->vVelocity.x) >> 16;
+              v72b = abs(face->pFacePlane.vNormal.y * pActors[v75].vVelocity.y + face->pFacePlane.vNormal.z * pActors[v75].vVelocity.z
+                                                                    + face->pFacePlane.vNormal.x * pActors[v75].vVelocity.x) >> 16;
               if ( (stru_721530.speed >> 3) > v72b )
                 v72b = stru_721530.speed >> 3;
 
-              v0->vVelocity.x += fixpoint_mul(v72b, v41->pFacePlane.vNormal.x);
-              v0->vVelocity.y += fixpoint_mul(v72b, v41->pFacePlane.vNormal.y);
-              v0->vVelocity.z += fixpoint_mul(v72b, v41->pFacePlane.vNormal.z);
-              if ( v42 != 4 )
+              pActors[v75].vVelocity.x += fixpoint_mul(v72b, face->pFacePlane.vNormal.x);
+              pActors[v75].vVelocity.y += fixpoint_mul(v72b, face->pFacePlane.vNormal.y);
+              pActors[v75].vVelocity.z += fixpoint_mul(v72b, face->pFacePlane.vNormal.z);
+              if ( face->uPolygonType != 4 )
               {
-                v45 = v0->vPosition.z;
                 v46 = stru_721530.prolly_normal_d
-                    - ((v41->pFacePlane.dist
-                      + v41->pFacePlane.vNormal.x * v0->vPosition.x
-                      + v41->pFacePlane.vNormal.y * v0->vPosition.y
-                      + v41->pFacePlane.vNormal.z * v0->vPosition.z) >> 16);
+                    - ((face->pFacePlane.dist
+                      + face->pFacePlane.vNormal.x * pActors[v75].vPosition.x
+                      + face->pFacePlane.vNormal.y * pActors[v75].vPosition.y
+                      + face->pFacePlane.vNormal.z * pActors[v75].vPosition.z) >> 16);
                 if ( v46 > 0 )
                 {
-                  v0->vPosition.x += (unsigned int)(v46 * v41->pFacePlane.vNormal.x) >> 16;
-                  v0->vPosition.y += (unsigned int)(v46 * v41->pFacePlane.vNormal.y) >> 16;
-                  v0->vPosition.z = v45 + ((unsigned int)(v46 * v41->pFacePlane.vNormal.z) >> 16);
+                  pActors[v75].vPosition.x += (unsigned int)(v46 * face->pFacePlane.vNormal.x) >> 16;
+                  pActors[v75].vPosition.y += (unsigned int)(v46 * face->pFacePlane.vNormal.y) >> 16;
+                  pActors[v75].vPosition.z += (unsigned int)(v46 * face->pFacePlane.vNormal.z) >> 16;
                 }
-                v0->uYawAngle = stru_5C6E00->Atan2(v0->vVelocity.x, v0->vVelocity.y);
+                pActors[v75].uYawAngle = stru_5C6E00->Atan2(pActors[v75].vVelocity.x, pActors[v75].vVelocity.y);
               }
             }
           }
           break;
       }
 
-      v0->vVelocity.x = fixpoint_mul(58500, v0->vVelocity.x);
-      v0->vVelocity.y = fixpoint_mul(58500, v0->vVelocity.y);
-      v0->vVelocity.z = fixpoint_mul(58500, v0->vVelocity.z);
-
-      ++v69;
-      if ( v69 >= 100 )
-        break;
+      pActors[v75].vVelocity.x = fixpoint_mul(58500, pActors[v75].vVelocity.x);
+      pActors[v75].vVelocity.y = fixpoint_mul(58500, pActors[v75].vVelocity.y);
+      pActors[v75].vVelocity.z = fixpoint_mul(58500, pActors[v75].vVelocity.z);
+
       v26 = stru_721530.prolly_normal_d;
     }
-    v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(v66), WorldPosToGridCellZ(v65) - 1) >> 1) & 1;
-    v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(v0->vPosition.x), WorldPosToGridCellZ(v0->vPosition.y) - 1) >> 1) & 1;
-    if ( WorldPosToGridCellX(v66) == WorldPosToGridCellX(v0->vPosition.x) 
-		&& WorldPosToGridCellZ(v65) == WorldPosToGridCellZ(v0->vPosition.y)
-		&& v58 
-		|| v67 != 0 )
+
+    v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(pActors[v75].vPosition.x), WorldPosToGridCellZ(pActors[v75].vPosition.y) - 1) >> 1) & 1;
+    v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(pActors[v75].vPosition.x), WorldPosToGridCellZ(pActors[v75].vPosition.y) - 1) >> 1) & 1;
+    if ( WorldPosToGridCellX(pActors[v75].vPosition.x) == WorldPosToGridCellX(pActors[v75].vPosition.x) 
+      && WorldPosToGridCellZ(pActors[v75].vPosition.y) == WorldPosToGridCellZ(pActors[v75].vPosition.y)
+      && v58  || v67 != 0 )
     {
-      if ( MonsterStats::BelongsToSupertype(v0->pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) )
+      if ( MonsterStats::BelongsToSupertype(pActors[v75].pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) )
       {
         v58 = v58 == 0;
         v59 = v59 == 0;
       }
       if ( !uIsFlying && v58 && !v59 )
       {
-        v0->vPosition.x = v66;
-        v0->vPosition.y = v65;
-        if ( v0->CanAct() )
+        pActors[v75].vPosition.x = pActors[v75].vPosition.x;
+        pActors[v75].vPosition.y = pActors[v75].vPosition.y;
+        if ( pActors[v75].CanAct() )
         {
-          v0->uYawAngle -= 32;
-          v0->uCurrentActionTime = 0;
-          v0->uCurrentActionLength = 128;
-          v0->uAIState = Fleeing;
+          pActors[v75].uYawAngle -= 32;
+          pActors[v75].uCurrentActionTime = 0;
+          pActors[v75].uCurrentActionLength = 128;
+          pActors[v75].uAIState = Fleeing;
         }
       }
     }
@@ -1290,13 +1000,11 @@
   //unsigned int v1; // edi@1
   //char *v2; // esi@2
   //__int16 v3; // dx@5
-  ObjectDesc *v4; // eax@5
+  ObjectDesc *object; // eax@5
   int v5; // ecx@6
   __int16 v6; // cx@7
   signed int v7; // eax@9
-  __int16 v8; // cx@14
-  __int16 v9; // dx@14
-  unsigned int v10; // ecx@16
+  //unsigned int v10; // ecx@16
   signed int v11; // eax@17
   int v12; // edi@27
   int v13; // eax@27
@@ -1321,47 +1029,45 @@
       item->uAttributes &= ~OBJECT_40;
     else
     {
-              //v3 = item->uObjectDescID;
-      v4 = &pObjectList->pObjects[item->uObjectDescID];
+      object = &pObjectList->pObjects[item->uObjectDescID];
       if (item->AttachedToActor())
       {
           v5 = PID_ID(item->spell_target_pid);
-		  item->vPosition.x = pActors[v5].vPosition.x;
+          item->vPosition.x = pActors[v5].vPosition.x;
           item->vPosition.y = pActors[v5].vPosition.y;
           item->vPosition.z = pActors[v5].vPosition.z + pActors[v5].uActorHeight;
-		  if ( !item->uObjectDescID || (v6 = LOWORD(pEventTimer->uTimeElapsed) + item->uSpriteFrameID, item->uSpriteFrameID = v6, !(v4->uFlags & 4)) )
+          if ( !item->uObjectDescID )
             continue;
-          if ( v6 >= 0 )
+          item->uSpriteFrameID += pEventTimer->uTimeElapsed;
+          if ( !(object->uFlags & OBJECT_DESC_TEMPORARY))
+            continue;
+          if ( item->uSpriteFrameID >= 0 )
           {
-            v7 = v4->uLifetime;
-            if (item->uAttributes & 2)
+            v7 = object->uLifetime;
+            if (item->uAttributes & ITEM_BROKEN)
               v7 = item->field_20;
-            if ( v6 < v7 )
+            if ( item->uSpriteFrameID < v7 )
               continue;
           }
-            v10 = i;
-            SpriteObject::OnInteraction(v10);
-            continue;
+          SpriteObject::OnInteraction(i);
+          continue;
       }
 
         if ( item->uObjectDescID )
         {
-          v8 = LOWORD(pEventTimer->uTimeElapsed) + item->uSpriteFrameID;
-          item->uSpriteFrameID = v8;
-          v9 = v4->uFlags;
-          if ( v9 & 4 )
-		  {    
-			  if ( v8 < 0 )
-			  {
-				v10 = i;
-				SpriteObject::OnInteraction(v10);
-				continue;
-			  }
-			  v11 = v4->uLifetime;
-			  if (item->uAttributes & 2)
-				v11 = item->field_20;
-		  }
-		  if ( !(v9 & 4) || v8 < v11 )
+          item->uSpriteFrameID += pEventTimer->uTimeElapsed;
+          if ( object->uFlags & OBJECT_DESC_TEMPORARY )
+          {
+            if ( item->uSpriteFrameID < 0 )
+            {
+              SpriteObject::OnInteraction(i);
+              continue;
+            }
+            v11 = object->uLifetime;
+            if (item->uAttributes & ITEM_BROKEN)
+              v11 = item->field_20;
+          }
+          if ( !(object->uFlags & OBJECT_DESC_TEMPORARY) || item->uSpriteFrameID < v11 )
           {
             if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
               SpriteObject::UpdateObject_fn0_BLV(i);
@@ -1395,23 +1101,17 @@
             v0 = (unsigned int)(11 * v14) >> 5;
             if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 )
               continue;
-            v10 = i;
-            SpriteObject::OnInteraction(v10);
+            SpriteObject::OnInteraction(i);
             continue;
           }
-          v10 = i;
-          if ( !(v9 & 0x40) )
-		  {
-            SpriteObject::OnInteraction(v10);
+          if ( !(object->uFlags & OBJECT_DESC_INTERACTABLE) )
+          {
+            SpriteObject::OnInteraction(i);
             continue;
-		  }
+          }
           _46BFFA_check_object_intercept(i, PID(OBJECT_Item,i));
         }
     }
-      //v2 += 112;
-      //v1 = v20++ + 1;
-    //}
-    //while ( v20 < (signed int)uNumSpriteObjects );
   }
 }
 
@@ -1452,17 +1152,14 @@
 }
 
 //----- (0047531C) --------------------------------------------------------
-bool __fastcall sub_47531C(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, BLVFace *a9, int a10)
+bool sub_47531C(int a1, int *a2, int pos_x, int pos_y, int pos_z, int dir_x, int dir_y, int dir_z, BLVFace *face, int a10)
 {
-  BLVFace *v10; // ebx@1
   int v11; // ST1C_4@3
   int v12; // edi@3
   int v13; // esi@3
   int v14; // edi@4
   signed __int64 v15; // qtt@6
   __int16 v16; // si@7
-  int *v18; // [sp+Ch] [bp-Ch]@1
-  int v19; // [sp+10h] [bp-8h]@1
   int a7a; // [sp+30h] [bp+18h]@7
   int a9b; // [sp+38h] [bp+20h]@3
   int a9a; // [sp+38h] [bp+20h]@3
@@ -1470,32 +1167,29 @@
   signed int a10a; // [sp+3Ch] [bp+24h]@4
   int a10c; // [sp+3Ch] [bp+24h]@5
 
-  v10 = a9;
-  v18 = a2;
-  v19 = a1;
-  if ( a10 && BYTE3(a9->uAttributes) & 0x20 )
+  if ( a10 && face->Ethereal() )
     return 0;
-  v11 = (unsigned __int64)(a6 * (signed __int64)a9->pFacePlane_old.vNormal.x) >> 16;
-  a10b = (unsigned __int64)(a7 * (signed __int64)a9->pFacePlane_old.vNormal.y) >> 16;
-  a9b = (unsigned __int64)(a8 * (signed __int64)a9->pFacePlane_old.vNormal.z) >> 16;
+  v11 = (unsigned __int64)(dir_x * (signed __int64)face->pFacePlane_old.vNormal.x) >> 16;
+  a10b = (unsigned __int64)(dir_y * (signed __int64)face->pFacePlane_old.vNormal.y) >> 16;
+  a9b = (unsigned __int64)(dir_z * (signed __int64)face->pFacePlane_old.vNormal.z) >> 16;
   v12 = v11 + a9b + a10b;
   a9a = v11 + a9b + a10b;
   v13 = (a1 << 16)
-      - a3 * v10->pFacePlane_old.vNormal.x
-      - a4 * v10->pFacePlane_old.vNormal.y
-      - a5 * v10->pFacePlane_old.vNormal.z
-      - v10->pFacePlane_old.dist;
+      - pos_x * face->pFacePlane_old.vNormal.x
+      - pos_y * face->pFacePlane_old.vNormal.y
+      - pos_z * face->pFacePlane_old.vNormal.z
+      - face->pFacePlane_old.dist;
   if ( abs((a1 << 16)
-         - a3 * v10->pFacePlane_old.vNormal.x
-         - a4 * v10->pFacePlane_old.vNormal.y
-         - a5 * v10->pFacePlane_old.vNormal.z - v10->pFacePlane_old.dist) >= a1 << 16 )
+         - pos_x * face->pFacePlane_old.vNormal.x
+         - pos_y * face->pFacePlane_old.vNormal.y
+         - pos_z * face->pFacePlane_old.vNormal.z - face->pFacePlane_old.dist) >= a1 << 16 )
   {
     a10c = abs(v13) >> 14;
     if ( a10c > abs(v12) )
       return 0;
     LODWORD(v15) = v13 << 16;
     HIDWORD(v15) = v13 >> 16;
-    v14 = v19;
+    v14 = a1;
     a10a = v15 / a9a;
   }
   else
@@ -1503,36 +1197,29 @@
     a10a = 0;
     v14 = abs(v13) >> 16;
   }
-  v16 = a4 + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a7) >> 16) >> 16);
-  LOWORD(a7a) = (short)a3
-              + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a6) >> 16) >> 16)
-              - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.x) >> 16);
-  HIWORD(a7a) = v16 - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.y) >> 16);
-  if ( !sub_475665(
-          v10,
-          a7a,
-          (short)a5
-        + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)a8) >> 16) >> 16)
-        - ((unsigned int)(v14 * v10->pFacePlane_old.vNormal.z) >> 16)) )
+  v16 = pos_y + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_y) >> 16) >> 16);
+  LOWORD(a7a) = (short)pos_x
+              + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_x) >> 16) >> 16)
+              - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.x) >> 16);
+  HIWORD(a7a) = v16 - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.y) >> 16);
+  if ( !sub_475665(face, a7a, (short)pos_z + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_z) >> 16) >> 16)
+        - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.z) >> 16)) )
     return 0;
-  *v18 = a10a >> 16;
+  *a2 = a10a >> 16;
   if ( a10a >> 16 < 0 )
-    *v18 = 0;
+    *a2 = 0;
   return 1;
 }
 
 //----- (004754BF) --------------------------------------------------------
-bool __fastcall sub_4754BF(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, BLVFace *a9, int a10, int a11)
+bool sub_4754BF(int a1, int *a2, int X, int Y, int Z, int dir_x, int dir_y, int dir_z, BLVFace *face, int a10, int a11)
 {
-  BLVFace *v11; // ebx@1
   int v12; // ST1C_4@3
   int v13; // edi@3
   int v14; // esi@3
   int v15; // edi@4
   signed __int64 v16; // qtt@6
   __int16 v17; // si@7
-  int *v19; // [sp+Ch] [bp-Ch]@1
-  int v20; // [sp+10h] [bp-8h]@1
   int a7a; // [sp+30h] [bp+18h]@7
   int a1b; // [sp+38h] [bp+20h]@3
   int a1a; // [sp+38h] [bp+20h]@3
@@ -1540,32 +1227,29 @@
   signed int a11a; // [sp+40h] [bp+28h]@4
   int a11c; // [sp+40h] [bp+28h]@5
 
-  v11 = a9;
-  v19 = a2;
-  v20 = a1;
-  if ( a11 && BYTE3(a9->uAttributes) & 0x20 )
-    return 0;
-  v12 = (unsigned __int64)(a6 * (signed __int64)a9->pFacePlane_old.vNormal.x) >> 16;
-  a11b = (unsigned __int64)(a7 * (signed __int64)a9->pFacePlane_old.vNormal.y) >> 16;
-  a1b = (unsigned __int64)(a8 * (signed __int64)a9->pFacePlane_old.vNormal.z) >> 16;
+  if ( a11 && face->Ethereal() )
+    return false;
+  v12 = (unsigned __int64)(dir_x * (signed __int64)face->pFacePlane_old.vNormal.x) >> 16;
+  a11b = (unsigned __int64)(dir_y * (signed __int64)face->pFacePlane_old.vNormal.y) >> 16;
+  a1b = (unsigned __int64)(dir_z * (signed __int64)face->pFacePlane_old.vNormal.z) >> 16;
   v13 = v12 + a1b + a11b;
   a1a = v12 + a1b + a11b;
   v14 = (a1 << 16)
-      - a3 * v11->pFacePlane_old.vNormal.x
-      - a4 * v11->pFacePlane_old.vNormal.y
-      - a5 * v11->pFacePlane_old.vNormal.z
-      - v11->pFacePlane_old.dist;
+      - X * face->pFacePlane_old.vNormal.x
+      - Y * face->pFacePlane_old.vNormal.y
+      - Z * face->pFacePlane_old.vNormal.z
+      - face->pFacePlane_old.dist;
   if ( abs((a1 << 16)
-         - a3 * v11->pFacePlane_old.vNormal.x
-         - a4 * v11->pFacePlane_old.vNormal.y
-         - a5 * v11->pFacePlane_old.vNormal.z - v11->pFacePlane_old.dist) >= a1 << 16 )
+         - X * face->pFacePlane_old.vNormal.x
+         - Y * face->pFacePlane_old.vNormal.y
+         - Z * face->pFacePlane_old.vNormal.z - face->pFacePlane_old.dist) >= a1 << 16 )
   {
     a11c = abs(v14) >> 14;
     if ( a11c > abs(v13) )
-      return 0;
+      return false;
     LODWORD(v16) = v14 << 16;
     HIDWORD(v16) = v14 >> 16;
-    v15 = v20;
+    v15 = a1;
     a11a = v16 / a1a;
   }
   else
@@ -1573,23 +1257,18 @@
     a11a = 0;
     v15 = abs(v14) >> 16;
   }
-  v17 = a4 + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a7) >> 16) >> 16);
-  LOWORD(a7a) = (short)a3
-              + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a6) >> 16) >> 16)
-              - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.x) >> 16);
-  HIWORD(a7a) = v17 - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.y) >> 16);
-  if ( !sub_4759C9(
-          v11,
-          a10,
-          a7a,
-          (short)a5
-        + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)a8) >> 16) >> 16)
-        - ((unsigned int)(v15 * v11->pFacePlane_old.vNormal.z) >> 16)) )
-    return 0;
-  *v19 = a11a >> 16;
+  v17 = Y + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_y) >> 16) >> 16);
+  LOWORD(a7a) = (short)X
+              + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_x) >> 16) >> 16)
+              - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.x) >> 16);
+  HIWORD(a7a) = v17 - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.y) >> 16);
+  if ( !sub_4759C9(face, a10, a7a, (short)Z + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_z) >> 16) >> 16)
+        - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.z) >> 16)) )
+    return false;
+  *a2 = a11a >> 16;
   if ( a11a >> 16 < 0 )
-    *v19 = 0;
-  return 1;
+    *a2 = 0;
+  return true;
 }
 
 //----- (00475665) --------------------------------------------------------
@@ -1741,12 +1420,12 @@
 //----- (004759C9) --------------------------------------------------------
 bool __fastcall sub_4759C9(BLVFace *a1, int a2, int a3, __int16 a4)
 {
-  unsigned int v4; // eax@1
-  int v5; // edx@4
+  //unsigned int v4; // eax@1
+  //int v5; // edx@4
   __int16 v6; // si@4
-  int v7; // edx@9
+  //int v7; // edx@9
   __int16 v8; // si@9
-  int v9; // edx@13
+  //int v9; // edx@13
   __int16 v10; // si@13
   int v11; // esi@14
   bool v12; // edi@14
@@ -1767,9 +1446,9 @@
   Vec3_int_ **a4c; // [sp+30h] [bp+Ch]@12
   signed int a4d; // [sp+30h] [bp+Ch]@14
 
-  v4 = a1->uAttributes;
+  //v4 = a1->uAttributes;
   v22 = 0;
-  if ( BYTE1(v4) & 1 )
+  if ( BYTE1(a1->uAttributes) & 1 )
   {
     v23 = (signed __int16)a3;
     v24 = SHIWORD(a3);
@@ -1778,11 +1457,11 @@
       a4a = &pOutdoor->pBModels[a2].pVertices.pVertices;
       do
       {
-        v5 = 2 * v22;
+        //v5 = 2 * v22;
         word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].x);
         word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].y);
         word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].x);
-        word_7209A0_intercepts_ys_plus_ys[v5 + 1] = v6 = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].y);
+        word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v6 = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].y);
         ++v22;
       }
       while ( v22 < a1->uNumVertices );
@@ -1790,7 +1469,7 @@
   }
   else
   {
-    if ( BYTE1(v4) & 2 )
+    if ( BYTE1(a1->uAttributes) & 2 )
     {
       v23 = (signed __int16)a3;
       v24 = a4;
@@ -1799,11 +1478,11 @@
         a4b = &pOutdoor->pBModels[a2].pVertices.pVertices;
         do
         {
-          v7 = 2 * v22;
+          //v7 = 2 * v22;
           word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].x);
           word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].z);
           word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].x);
-          word_7209A0_intercepts_ys_plus_ys[v7 + 1] = v8 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].z);
+          word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v8 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].z);
           ++v22;
         }
         while ( v22 < a1->uNumVertices );
@@ -1818,11 +1497,11 @@
         a4c = &pOutdoor->pBModels[a2].pVertices.pVertices;
         do
         {
-          v9 = 2 * v22;
+          //v9 = 2 * v22;
           word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].y);
           word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].z);
           word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].y);
-          word_7209A0_intercepts_ys_plus_ys[v9 + 1] = v10 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].z);
+          word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v10 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].z);
           ++v22;
         }
         while ( v22 < a1->uNumVertices );
@@ -1938,7 +1617,7 @@
 //----- (00475F30) --------------------------------------------------------
 bool __fastcall sub_475F30(int *a1, BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
 {
-  BLVFace *v9; // ebx@1
+  //BLVFace *v9; // ebx@1
   int v10; // ST20_4@2
   int v11; // ST28_4@2
   int v12; // ST24_4@2
@@ -1949,14 +1628,14 @@
   int v17; // ST20_4@9
   signed __int64 v18; // qtt@10
   int v19; // ST14_4@11
-  int *v21; // [sp+14h] [bp-10h]@1
+  //int *v21; // [sp+14h] [bp-10h]@1
   int v22; // [sp+1Ch] [bp-8h]@2
   int v23; // [sp+1Ch] [bp-8h]@10
   signed int v24; // [sp+20h] [bp-4h]@10
 
-  v9 = a2;
-  v21 = a1;
-  if ( BYTE3(a2->uAttributes) & 0x20
+  //v9 = a2;
+  //v21 = a1;
+  if ( a2->Ethereal()
     || (v10 = (unsigned __int64)(a6 * (signed __int64)a2->pFacePlane_old.vNormal.x) >> 16,
         v11 = (unsigned __int64)(a7 * (signed __int64)a2->pFacePlane_old.vNormal.y) >> 16,
         v12 = (unsigned __int64)(a8 * (signed __int64)a2->pFacePlane_old.vNormal.z) >> 16,
@@ -1980,16 +1659,13 @@
   }
   v17 = abs(-(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z)) >> 14;
   if ( v17 > abs(v14)
-    || (LODWORD(v18) = v16 << 16, HIDWORD(v18) = v16 >> 16, v24 = v18 / v22, v23 = v18 / v22, v23 > *v21 << 16)
+    || (LODWORD(v18) = v16 << 16, HIDWORD(v18) = v16 >> 16, v24 = v18 / v22, v23 = v18 / v22, v23 > *a1 << 16)
     || (LOWORD(v19) = a3 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a6) >> 16) + 32768) >> 16),
         HIWORD(v19) = a4 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a7) >> 16) + 32768) >> 16),
-        !sub_4759C9(
-           v9,
-           a9,
-           v19,
+        !sub_4759C9(a2, a9, v19,
            a5 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a8) >> 16) + 32768) >> 16))) )
     return 0;
-  *v21 = v24 >> 16;
+  *a1 = v24 >> 16;
   return 1;
 }
 
@@ -5120,98 +4796,98 @@
   }
 }
 
-
-
 //----- (00449A49) --------------------------------------------------------
-__int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2)
+void Door_switch_animation(unsigned int uDoorID, int a2)
 {
-  int v2; // eax@1
-  int v3; // ebx@1
-  signed int v4; // esi@2
-  int v5; // edx@2
-  BLVDoor *v6; // ecx@8
-  unsigned int v7; // edx@18
-  signed int v8; // esi@19
-  int v9; // eax@19
-  //char Args; // [sp+Ch] [bp-78h]@6
-
-  LOWORD(v2) = LOWORD(pIndoor->pDoors);
-  v3 = a2;
+  int old_state; // eax@1
+  signed int door_id; // esi@2
+
   if ( !pIndoor->pDoors )
-    return v2;
-  v4 = 0;
-  v5 = (int)&pIndoor->pDoors->uDoorID;
-  do
+    return;
+  for ( door_id = 0; door_id < 200; ++door_id )
   {
-    if ( *(int *)v5 == uDoorID )
+    if ( pIndoor->pDoors[door_id].uDoorID == uDoorID )
       break;
-    ++v4;
-    v5 += 80;
   }
-  while ( v4 < 200 );
-  if ( v4 >= 200 )
+  if ( door_id >= 200 )
   {
     Error("Unable to find Door ID: %i!", uDoorID);
   }
-  v6 = &pIndoor->pDoors[v4];
-  if ( v3 == 2 )
+  old_state = pIndoor->pDoors[door_id].uState;
+  //old_state: 0 - в нижнем положении/закрыто
+  //           2 - в верхнем положении/открыто,
+  //a2: 1 - открыть
+  //    2 - опустить/поднять
+  if ( a2 == 2 )
   {
-    LOWORD(v2) = v6->uState;
-    if ( (short)v2 == 3 || (short)v2 == 1 )
-      return v2;
-    if ( (short)v2 )
-      goto LABEL_14;
+    if ( pIndoor->pDoors[door_id].uState == BLVDoor::Closing || pIndoor->pDoors[door_id].uState == BLVDoor::Opening )
+      return;
+    if ( pIndoor->pDoors[door_id].uState )
+    {
+      if ( pIndoor->pDoors[door_id].uState != BLVDoor::Closed && pIndoor->pDoors[door_id].uState != BLVDoor::Closing )
+      {
+        pIndoor->pDoors[door_id].uState = BLVDoor::Closing;
+        if ( old_state == BLVDoor::Open )
+        {
+          pIndoor->pDoors[door_id].uTimeSinceTriggered = 0;
+          return;
+        }
+        if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 )
+        {
+          pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uOpenSpeed
+             - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uCloseSpeed)
+             / 128 << 7) / pIndoor->pDoors[door_id].uOpenSpeed;
+          return;
+        }
+        pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360;
+      }
+      return;
+    }
   }
   else
   {
-    if ( !v3 )
+    if ( a2 == 0 )
     {
-LABEL_14:
-      LOWORD(v2) = v6->uState;
-      if ( (short)v2 && (short)v2 != 3 )
+      if ( pIndoor->pDoors[door_id].uState != BLVDoor::Closed && pIndoor->pDoors[door_id].uState != BLVDoor::Closing )
       {
-        v6->uState = BLVDoor::Closing;
-        if ( (short)v2 == 2 )
+        pIndoor->pDoors[door_id].uState = BLVDoor::Closing;
+        if ( old_state == BLVDoor::Open )
         {
-LABEL_17:
-          v6->uTimeSinceTriggered = 0;
-          return v2;
+          pIndoor->pDoors[door_id].uTimeSinceTriggered = 0;
+          return;
         }
-        v7 = v6->uTimeSinceTriggered;
-        v2 = 15360;
-        if ( v7 != 15360 )
+        if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 )
         {
-          v8 = v6->uOpenSpeed;
-          v9 = v6->uCloseSpeed;
-LABEL_26:
-          v2 = (v6->uMoveLength << 7) / v8 - ((signed int)(v7 * v9) / 128 << 7) / v8;
-          goto LABEL_27;
+          pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uOpenSpeed
+             - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uCloseSpeed)
+             / 128 << 7) / pIndoor->pDoors[door_id].uOpenSpeed;
+          return;
         }
-        goto LABEL_27;
+        pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360;
       }
-      return v2;
+      return;
     }
-    if ( v3 != 1 )
-      return v2;
+    if ( a2 != 1 )
+      return;
   }
-  LOWORD(v2) = v6->uState;
-  if ( (short)v2 != 2 && (short)v2 != 1 )
+  if ( old_state != BLVDoor::Open && old_state != BLVDoor::Opening )
   {
-    v6->uState = BLVDoor::Opening;
-    if ( !(short)v2 )
-      goto LABEL_17;
-    v7 = v6->uTimeSinceTriggered;
-    v2 = 15360;
-    if ( v7 != 15360 )
+    pIndoor->pDoors[door_id].uState = BLVDoor::Opening;
+    if ( old_state == BLVDoor::Closed )
+    {
+      pIndoor->pDoors[door_id].uTimeSinceTriggered = 0;
+      return;
+    }
+    if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 )
     {
-      v8 = v6->uCloseSpeed;
-      v9 = v6->uOpenSpeed;
-      goto LABEL_26;
+      pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uCloseSpeed
+         - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uOpenSpeed)
+         / 128 << 7) / pIndoor->pDoors[door_id].uCloseSpeed;
+      return;
     }
-LABEL_27:
-    v6->uTimeSinceTriggered = v2;
+    pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360;
   }
-  return v2;
+  return;
 }
 
 //----- (00449B57) --------------------------------------------------------
@@ -5240,9 +4916,8 @@
   strcpy(GameUI_Footer_TimedString.data(), pString);
   GameUI_Footer_TimeLeft = 1000 * uNumSeconds + GetTickCount();
 
-  for (int i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data());
-        i > 450;
-        i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()) )
+  for (int i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); i > 450;
+           i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()) )
     GameUI_Footer_TimedString[strlen(GameUI_Footer_TimedString.data()) - 1] = 0;
 }
 
@@ -5283,19 +4958,15 @@
 void mm7__vector_constructor(void *a1, int objSize, int numObjs, int ( *constructor)(int))
 {
   void *v4; // esi@2
-  int v5; // edi@2
-
-  if ( numObjs - 1 >= 0 )
+
+  if ( numObjs > 0 )
   {
     v4 = a1;
-    v5 = numObjs;
-    do
+    for ( int i = numObjs; i; --i )
     {
       constructor((int)v4);
       v4 = (char *)v4 + objSize;
-      --v5;
     }
-    while ( v5 );
   }
 }
 
--- a/mm7_4.cpp	Thu Dec 12 21:42:18 2013 +0600
+++ b/mm7_4.cpp	Thu Dec 12 21:44:02 2013 +0600
@@ -578,7 +578,7 @@
       //for lich
       if ( pParty->pPlayers[v49].classType == PLAYER_CLASS_LICH )
       {
-        for ( v31 = 0; v31 < 138; ++v31 )
+        for ( v31 = 0; v31 < 126; ++v31 )
         {
           if ( pParty->pPlayers[v49].pInventoryItemList[v31].uItemID == ITEM_LICH_JAR_FULL )
             lich_jar_flag = true;
--- a/mm7_data.h	Thu Dec 12 21:42:18 2013 +0600
+++ b/mm7_data.h	Thu Dec 12 21:44:02 2013 +0600
@@ -1308,8 +1308,8 @@
 int collide_against_floor_approximate(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID); // idb
 void BLV_ProcessPartyActions();
 void ODM_ProcessPartyActions();
-bool __fastcall sub_47531C(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, struct BLVFace *a9, int a10);
-bool __fastcall sub_4754BF(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, struct BLVFace *a9, int a10, int a11);
+bool sub_47531C(int a1, int *a2, int pos_x, int pos_y, int pos_z, int dir_x, int dir_y, int dir_z, struct BLVFace *face, int a10);
+bool sub_4754BF(int a1, int *a2, int X, int Y, int Z, int dir_x, int dir_y, int dir_z, struct BLVFace *face, int a10, int a11);
 int sub_475665(struct BLVFace *_this, int a2, __int16 a3);
 bool __fastcall sub_4759C9(struct BLVFace *a1, int a2, int a3, __int16 a4);
 bool __fastcall sub_475D85(Vec3_int_ *a1, Vec3_int_ *a2, int *a3, struct BLVFace *a4);
@@ -1334,7 +1334,7 @@
 void OnTimer(int);
 void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName);
 void __fastcall EventCastSpell(int uSpellID, int uSkillLevel, int uSkill, int fromx, int fromy, int fromz, int tox, int toy, int toz);//sub_448DF8
-__int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2); // idb
+void Door_switch_animation(unsigned int uDoorID, int a2); // idb: sub_449A49
 bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2);
 void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle); // idb
 void ShowStatusBarString(const char *pString, unsigned int uNumSeconds);
--- a/stru10.cpp	Thu Dec 12 21:42:18 2013 +0600
+++ b/stru10.cpp	Thu Dec 12 21:44:02 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;