changeset 2101:ee2724b9ca05

RasterLine2D fix and etc.
author Ritor1
date Mon, 16 Dec 2013 18:43:42 +0600
parents e460ca22fe8a
children 0db53678ff48
files Actor.cpp Events.cpp Game.cpp Indoor.cpp MapInfo.h Outdoor.cpp Render.cpp Render.h Spells.cpp UI/UiGame.cpp mm7_2.cpp mm7_3.cpp mm7_data.h
diffstat 13 files changed, 1564 insertions(+), 2086 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Fri Dec 13 22:19:56 2013 +0600
+++ b/Actor.cpp	Mon Dec 16 18:43:42 2013 +0600
@@ -4404,4 +4404,45 @@
     this->pActorBuffs[ACTOR_BUFF_FATE].Reset();
   }
   return rand() % (armorSum + 2 * this->pMonsterInfo.uLevel + 10) + a2a + 1 > armorSum + 5;
+}
+
+//----- (00448A98) --------------------------------------------------------
+void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle)
+{
+  if ( uGroupID )
+  {
+    if ( bToggle )
+    {
+      for ( uint i = 0; i < (unsigned int)uNumActors; ++i )
+      {
+        if ( pActors[i].uGroup == uGroupID )
+        {
+          pActors[i].uAttributes |= uFlag;
+          if ( uFlag == 0x10000 )
+          {
+            pActors[i].uAIState = Disabled;
+            pActors[i].UpdateAnimation();
+          }
+        }
+      }
+    }
+    else
+    {
+      for ( uint i = 0; i < (unsigned int)uNumActors; ++i )
+      {
+        if ( pActors[i].uGroup == uGroupID )
+        {
+          if ( uFlag == 0x10000 )
+          {
+            if ( pActors[i].uAIState != Dead )
+            {
+              if ( pActors[i].uAIState != 4 && pActors[i].uAIState != 11 )
+                pActors[i].uAIState = Standing;
+            }
+          }
+          LODWORD(pActors[i].uAttributes) &= ~uFlag;
+        }
+      }
+    }
+  }
 }
\ No newline at end of file
--- a/Events.cpp	Fri Dec 13 22:19:56 2013 +0600
+++ b/Events.cpp	Mon Dec 16 18:43:42 2013 +0600
@@ -1420,7 +1420,7 @@
         else
           {
           pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)((activeLevelDecoration == NULL) + 1);
-          sub_44987B(v99, MapStartPoint_Party);
+          Transition_StopSound_Autosave(v99, MapStartPoint_Party);
           v133 = 1;
           if ( pCurrentScreen == SCREEN_HOUSE )
             {
--- a/Game.cpp	Fri Dec 13 22:19:56 2013 +0600
+++ b/Game.cpp	Mon Dec 16 18:43:42 2013 +0600
@@ -2772,7 +2772,7 @@
               pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)2;
               dword_5B65C0 = _5B65A8_npcdata_uflags_or_other | _5B65AC_npcdata_fame_or_other | _5B65B0_npcdata_rep_or_other | _5B65B4_npcdata_loword_house_or_other | _5B65B8_npcdata_hiword_house_or_other | v38;
               OnMapLeave();
-              sub_44987B(dword_591164_teleport_map_name, MapStartPoint_Party);
+              Transition_StopSound_Autosave(dword_591164_teleport_map_name, MapStartPoint_Party);
             }
           }
           else
--- a/Indoor.cpp	Fri Dec 13 22:19:56 2013 +0600
+++ b/Indoor.cpp	Mon Dec 16 18:43:42 2013 +0600
@@ -7150,4 +7150,98 @@
     pParty->uFlags |= 0x200;
   if (uFaceEvent)
     EventProcessor(uFaceEvent, 0, 1);
+}
+
+//----- (00449A49) --------------------------------------------------------
+void Door_switch_animation(unsigned int uDoorID, int a2)
+{
+  int old_state; // eax@1
+  signed int door_id; // esi@2
+
+  if ( !pIndoor->pDoors )
+    return;
+  for ( door_id = 0; door_id < 200; ++door_id )
+  {
+    if ( pIndoor->pDoors[door_id].uDoorID == uDoorID )
+      break;
+  }
+  if ( door_id >= 200 )
+  {
+    Error("Unable to find Door ID: %i!", uDoorID);
+  }
+  old_state = pIndoor->pDoors[door_id].uState;
+  //old_state: 0 - в нижнем положении/закрыто
+  //           2 - в верхнем положении/открыто,
+  //a2: 1 - открыть
+  //    2 - опустить/поднять
+  if ( a2 == 2 )
+  {
+    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 ( a2 == 0 )
+    {
+      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;
+    }
+    if ( a2 != 1 )
+      return;
+  }
+  if ( old_state != BLVDoor::Open && old_state != BLVDoor::Opening )
+  {
+    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 )
+    {
+      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;
+    }
+    pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360;
+  }
+  return;
 }
\ No newline at end of file
--- a/MapInfo.h	Fri Dec 13 22:19:56 2013 +0600
+++ b/MapInfo.h	Mon Dec 16 18:43:42 2013 +0600
@@ -102,4 +102,4 @@
 
 
 void TeleportToStartingPoint(MapStartPoint point); // idb
-void sub_44987B(const char *pMapName, MapStartPoint point); // idb
\ No newline at end of file
+void Transition_StopSound_Autosave(const char *pMapName, MapStartPoint point); // sub_44987B idb
\ No newline at end of file
--- a/Outdoor.cpp	Fri Dec 13 22:19:56 2013 +0600
+++ b/Outdoor.cpp	Mon Dec 16 18:43:42 2013 +0600
@@ -4209,10 +4209,7 @@
   {
 	  if ( !bUnderwater && v34 <= 0)
 	  {
-		if ( v34 < -500
-		  && !pParty->bFlying
-		  && pParty->vPosition.z - v111 > 1000
-		  && !pParty->FeatherFallActive())
+		if ( v34 < -500 && !pParty->bFlying && pParty->vPosition.z - v111 > 1000 && !pParty->FeatherFallActive())
 		{ // falling scream
 		  for (int i = 0; i < 4; ++i)
 		  {
@@ -4258,9 +4255,9 @@
     if ( stru_721530._47050A(v36) )
       break;
     _46E889_collide_against_bmodels(1);
-    v37 = WorldPosToGridCellZ(pParty->vPosition.y);
-    v38 = WorldPosToGridCellX(pParty->vPosition.x);
-    _46E26D_collide_against_sprites(v38, v37);
+    //v37 = WorldPosToGridCellZ(pParty->vPosition.y);
+    //v38 = WorldPosToGridCellX(pParty->vPosition.x);
+    _46E26D_collide_against_sprites(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y));
     _46ED8A_collide_against_sprite_objects(4);
     for ( i = 0; i < (signed int)uNumActors; ++i )
       Actor::_46DF1A_collide_against_actor(i, 0);
--- a/Render.cpp	Fri Dec 13 22:19:56 2013 +0600
+++ b/Render.cpp	Mon Dec 16 18:43:42 2013 +0600
@@ -3561,15 +3561,15 @@
 }
 
 //----- (004A0BEE) --------------------------------------------------------
-char Render::RasterLine2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor)
-{
-  unsigned int v8; // ebx@5
-  unsigned int v10; // ecx@9
-  unsigned int v11; // esi@13
-  int v12; // eax@17
+char Render::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor)
+{
+  signed int v8; // ebx@5
+  signed int v10; // ecx@9
+  signed int v11; // esi@13
+  signed int v12; // eax@17
   int v13; // eax@21
   int v16; // eax@27
-  signed __int64 v19; // qax@41
+  signed int v19; // qax@41
   int v20; // edi@41
   unsigned int v21; // edi@46
   int v22; // esi@47
@@ -3591,28 +3591,29 @@
   int uZa; // [sp+2Ch] [bp+10h]@38
 
   v36 = 0i64;
-  if ( (signed int)uX < this->raster_clip_x )
+  if ( uX < this->raster_clip_x )// x выходит за рамки левой границы
     HIDWORD(v36) = 8;
-  if ( (signed int)uX > this->raster_clip_z )
+  if ( uX > this->raster_clip_z )// x выходит за рамки правой границы
     HIDWORD(v36) |= 4;
 
+  if ( uZ < this->raster_clip_x )// z выходит за рамки левой границы
+    LODWORD(v36) = 8;
+  if ( uZ > this->raster_clip_z )// z выходит за рамки правой границы
+    LODWORD(v36) |= 4;
+
+  if ( uY < this->raster_clip_y )// y выходит за рамки верхней границы
+    HIDWORD(v36) |= 2;
+  if ( uY > this->raster_clip_w )// y выходит за рамки нижней границы
+    HIDWORD(v36) |= 1;
+
+  if ( uW < this->raster_clip_y )// w выходит за рамки верхней границы
+    LODWORD(v36) |= 2;
+  if ( uW > this->raster_clip_w )// w выходит за рамки нижней границы
+    LODWORD(v36) |= 1;
+
   v8 = uY;
-  if ( (signed int)uY < this->raster_clip_y )
-    HIDWORD(v36) |= 2;
-  if ( (signed int)uY > this->raster_clip_w )
-    HIDWORD(v36) |= 1;
-
+  v11 = uW;
   v10 = uZ;
-  if ( (signed int)uZ < this->raster_clip_x )
-    LODWORD(v36) = 8;
-  if ( (signed int)uZ > this->raster_clip_z )
-    LODWORD(v36) = v36 | 4;
-
-  v11 = uW;
-  if ( (signed int)uW < this->raster_clip_y )
-    LODWORD(v36) = v36 | 2;
-  if ( (signed int)uW > this->raster_clip_w )
-    LODWORD(v36) = v36 | 1;
 
   LOBYTE(v12) = v36;
   if ( (unsigned int)v36 & HIDWORD(v36) )
@@ -3646,8 +3647,6 @@
       v25 = 0;
 
       v26 = (unsigned __int16 *)this->pTargetSurface;
-      int y = 0;
-      int x = 0;
       if ( v26 )
       {
         if ( (signed int)uXa <= v23 )//рисуем вертикальную линию
@@ -3658,6 +3657,8 @@
             v31 = 2 * v24;
             v32 = 2 * v21;
             v12 = (int)&v26[v12];
+            int y = 0;
+            int x = 0;
             for ( v30; v30; --v30 )
             {
               v25 += uXa;
@@ -3683,11 +3684,12 @@
         else//рисуем горизонтальную линию
         {
           v27 = uXa + 1;
-          int x = 0;
           if ( (signed int)(uXa + 1) > 0 )
           {
             v28 = 2 * v21;
             v29 = 2 * v24;
+            int y = 0;
+            int x = 0;
             v12 = (int)&v26[v12];
             for ( v27; v27; --v27 )
             {
@@ -3719,13 +3721,13 @@
   {
     if ( BYTE4(v36) & 8 )
     {
-      v13 = (signed int)((uW - uY) * (this->raster_clip_x - uX)) / (signed int)(uZ - uX);
+      v13 = ((uW - uY) * (this->raster_clip_x - uX)) / (uZ - uX);
       v8 = v13 + uY;
       uX = this->raster_clip_x;
       goto LABEL_24;
     }
     v10 = this->raster_clip_x;
-    v11 = (signed int)((uY - uW) * (this->raster_clip_x - uZ)) / (signed int)(uX - uZ) + uW;
+    v11 = ((uY - uW) * (this->raster_clip_x - uZ)) / (uX - uZ) + uW;
   }
 LABEL_24:
   if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 )
@@ -3733,28 +3735,30 @@
     //v15 = this->raster_clip_z;
     if ( BYTE4(v36) & 4 )
     {
-      v8 += (signed int)((v11 - v8) * (this->raster_clip_z - uX)) / (signed int)(v10 - uX);
+      v8 += ((v11 - v8) * (this->raster_clip_z - uX)) / (v10 - uX);
       uX = this->raster_clip_z;
     }
     else
     {
-      v16 = (signed int)((v8 - v11) * (this->raster_clip_z - v10)) / (signed int)(uX - v10);
+      v16 = ((v8 - v11) * (this->raster_clip_z - v10)) / (uX - v10);
       v10 = this->raster_clip_z;
       v11 += v16;
     }
   }
   v37 = 0;
   uYa = this->raster_clip_y;
-  if ( (signed int)v8 < this->raster_clip_y )
+  if ( v8 < this->raster_clip_y )
     v37 = 2;
-  if ( (signed int)v8 > this->raster_clip_w )
+  if ( v8 > this->raster_clip_w )
     v37 |= 1;
-  if ( (signed int)v11 >= this->raster_clip_y )
+
+  if ( v11 >= this->raster_clip_y )
     v12 = 0;
   else
     v12 = 2;
-  if ( (signed int)v11 > this->raster_clip_w )
+  if ( v11 > this->raster_clip_w )
     LOBYTE(v12) = v12 | 1;
+
   if ( !(v12 & v37) )
   {
     v12 ^= v37;
@@ -3763,13 +3767,13 @@
     {
       if ( v37 & 2 )
       {
-        uX += (signed int)((v10 - uX) * (uYa - v8)) / (signed int)(v11 - v8);
+        uX += ((v10 - uX) * (uYa - v8)) / (v11 - v8);
         LOBYTE(v12) = (char)this;
         v8 = this->raster_clip_y;
       }
       else
       {
-        v19 = (signed int)((uX - v10) * (uYa - v11));
+        v19 = (uX - v10) * (uYa - v11);
         v20 = v8 - v11;
         v11 = uYa;
         v12 = v19 / v20;
@@ -3780,13 +3784,13 @@
     {
       if ( v37 & 1 )
       {
-        uX += (signed int)((v10 - uX) * (this->raster_clip_w - v8)) / (signed int)(v11 - v8);
+        uX += ((v10 - uX) * (this->raster_clip_w - v8)) / (v11 - v8);
         LOBYTE(v12) = (char)this;
         v8 = this->raster_clip_w;
       }
       else
       {
-        v12 = (signed int)((uX - v10) * (this->raster_clip_w - v11)) / (signed int)(v8 - v11);
+        v12 = ((uX - v10) * (this->raster_clip_w - v11)) / (v8 - v11);
         v11 = this->raster_clip_w;
         v10 += v12;
       }
@@ -7838,7 +7842,7 @@
               {
                   if ( *v28 )
                   {
-                    v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[i & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1));
+                    v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1));
                     if ( v20 >= a7 )
                     {
                       if ( v20 <= a8 )
--- a/Render.h	Fri Dec 13 22:19:56 2013 +0600
+++ b/Render.h	Mon Dec 16 18:43:42 2013 +0600
@@ -292,7 +292,7 @@
   void CreateSomeTexture();
   bool InitializeFullscreen();
   bool SwitchToWindow();
-  char RasterLine2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor);
+  char RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor);
   void ClearZBuffer(int a2, int a3);
   void SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW);
   void ParseTargetPixelFormat();
--- a/Spells.cpp	Fri Dec 13 22:19:56 2013 +0600
+++ b/Spells.cpp	Mon Dec 16 18:43:42 2013 +0600
@@ -554,9 +554,9 @@
   a1.uType = stru_4E3ACC[uSpellID].uType;
   if ( uSpellID > 58 )
   {
-    if ( uSpellID == 69 )
+    if ( uSpellID == SPELL_BODY_PROTECTION_FROM_BODY )
       goto LABEL_117;
-    if ( uSpellID != 83 )
+    if ( uSpellID != SPELL_LIGHT_DAY_OF_THE_GODS )
       return;
     v40 = v15 - 2;
     if ( v40 )
@@ -574,7 +574,8 @@
         v37 = &pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS];
         v36 = pParty->uTimePlayed + v39;
         v37->Apply(v36, a7b, v43, 0, 0);
-        goto LABEL_139;
+        pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+        return;
       }
       if ( v41 == 1 )
       {
@@ -588,7 +589,8 @@
        v37 = &pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS];
        v36 = pParty->uTimePlayed + v39;
        v37->Apply(v36, a7b, v43, 0, 0);
-       goto LABEL_139;
+        pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+        return;
       }
     }
     v42 = 10800 * uSkill;
@@ -601,20 +603,21 @@
     v37 = &pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS];
     v36 = pParty->uTimePlayed + v39;
     v37->Apply(v36, a7b, v43, 0, 0);
-    goto LABEL_139;
+    pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+    return;
   }
   if ( uSpellID != 58 )
   {
     switch ( uSpellID )
     {
-      case 2:
-      case 6:
-      case 18:
-      case 26:
-      case 29:
-      case 32:
-      case 39:
-      case 41:
+      case SPELL_FIRE_FIRE_BOLT:
+      case SPELL_FIRE_FIREBALL:
+      case SPELL_AIR_LIGHNING_BOLT:
+      case SPELL_WATER_ICE_BOLT:
+      case SPELL_WATER_ACID_BURST:
+      case SPELL_WATER_ICE_BLAST:
+      case SPELL_EARTH_BLADES:
+      case SPELL_EARTH_ROCK_BLAST:
         a1.stru_24.Reset();
         v16 = 0;
         a1.spell_id = uSpellID;
@@ -622,22 +625,23 @@
         a1.spell_skill = v15;
         if ( (signed int)pObjectList->uNumObjects <= 0 )
         {
-          v18 = 0;
-          a1.uObjectDescID = v18;
+          //v18 = 0;
+          a1.uObjectDescID = 0;
           *(_QWORD *)&a1.vPosition.y = __PAIR__(fromz, fromy);
           a1.vPosition.x = fromx;
           a1.uAttributes = 16;
           a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz);
           a1.field_60_distance_related_prolly_lod = v55;
-          v20 = yaw;
+          //v20 = yaw;
           a1.uSpriteFrameID = 0;
           a1.spell_caster_pid = 8000 | OBJECT_Item;
           a1.spell_target_pid = 0;
           a1.uFacing = yaw;
           a1.uSoundID = 0;
           v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
-          a1.Create(v20, pitch, v49, 0);
-          goto LABEL_139;
+          a1.Create(yaw, pitch, v49, 0);
+          pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+          return;
         }
         v17 = (char *)&pObjectList->pObjects->uObjectID;
         while ( (short)a1.uType != *(short *)v17 )
@@ -646,22 +650,23 @@
           v17 += 56;
           if ( v16 >= (signed int)pObjectList->uNumObjects )
           {
-            v18 = 0;
-            a1.uObjectDescID = v18;
+            //v18 = 0;
+            a1.uObjectDescID = 0;
             *(_QWORD *)&a1.vPosition.y = __PAIR__(fromz, fromy);
             a1.vPosition.x = fromx;
             a1.uAttributes = 16;
             a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz);
             a1.field_60_distance_related_prolly_lod = v55;
-            v20 = yaw;
+            //v20 = yaw;
             a1.uSpriteFrameID = 0;
             a1.spell_caster_pid = 8000 | OBJECT_Item;
             a1.spell_target_pid = 0;
             a1.uFacing = yaw;
             a1.uSoundID = 0;
             v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
-            a1.Create(v20, pitch, v49, 0);
-            goto LABEL_139;
+            a1.Create(yaw, pitch, v49, 0);
+            pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+            return;
           }
         }
         v18 = v16;
@@ -671,16 +676,17 @@
         a1.uAttributes = 16;
         a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz);
         a1.field_60_distance_related_prolly_lod = v55;
-        v20 = yaw;
+        //v20 = yaw;
         a1.uSpriteFrameID = 0;
         a1.spell_caster_pid = 8000 | OBJECT_Item;
         a1.spell_target_pid = 0;
         a1.uFacing = yaw;
         a1.uSoundID = 0;
         v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
-        a1.Create(v20, pitch, v49, 0);
-        goto LABEL_139;
-      case 24:
+        a1.Create(yaw, pitch, v49, 0);
+        pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+        return;
+      case SPELL_WATER_POISON_SPRAY:
         switch ( v15 )
         {
           case 1:
@@ -706,9 +712,7 @@
           a1.spell_level = uSkill;
           a1.spell_skill = v15;
           if ( (signed int)pObjectList->uNumObjects <= 0 )
-          {
             v23 = 0;
-          }
           else
           {
             v22 = (char *)&pObjectList->pObjects->uObjectID;
@@ -734,7 +738,8 @@
                   a1.uFacing = i + yaw;
                   a1.Create((signed __int16)(i + (short)yaw), pitch, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0);
                 }
-                goto LABEL_139;
+                pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+                return;
               }
             }
             v23 = v21;
@@ -754,81 +759,82 @@
             a1.uFacing = i + yaw;
             a1.Create((signed __int16)(i + (short)yaw), pitch, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0);
           }
-          goto LABEL_139;
+          pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+          return;
         }
         a1.stru_24.Reset();
-        v16 = 0;
         a1.spell_id = uSpellID;
         a1.spell_level = uSkill;
         a1.spell_skill = v15;
         if ( (signed int)pObjectList->uNumObjects <= 0 )
-       {
-         v18 = 0;
-         a1.uObjectDescID = v18;
-         *(_QWORD *)&a1.vPosition.y = __PAIR__(fromz, fromy);
-         a1.vPosition.x = fromx;
-         a1.uAttributes = 16;
-         a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz);
-         a1.field_60_distance_related_prolly_lod = v55;
-         v20 = yaw;
-         a1.uSpriteFrameID = 0;
-         a1.spell_caster_pid = 8000 | OBJECT_Item;
-         a1.spell_target_pid = 0;
-         a1.uFacing = yaw;
-         a1.uSoundID = 0;
-         v51 = 0;
-         v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
-         v47 = pitch;
-         a1.Create(v20, v47, v49, v51);
-         goto LABEL_139;
-       }
-        v19 = (char *)&pObjectList->pObjects->uObjectID;
-        do
         {
-          if ( (short)a1.uType == *(short *)v19 )
+          //v18 = 0;
+          a1.uObjectDescID = 0;
+          *(_QWORD *)&a1.vPosition.y = __PAIR__(fromz, fromy);
+          a1.vPosition.x = fromx;
+          a1.uAttributes = 16;
+          a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz);
+          a1.field_60_distance_related_prolly_lod = v55;
+          //v20 = yaw;
+          a1.uSpriteFrameID = 0;
+          a1.spell_caster_pid = 8000 | OBJECT_Item;
+          a1.spell_target_pid = 0;
+          a1.uFacing = yaw;
+          a1.uSoundID = 0;
+          //v51 = 0;
+          v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
+          //v47 = pitch;
+          a1.Create(yaw, pitch, v49, 0);
+          pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+          return;
+        }
+        //v19 = (char *)&pObjectList->pObjects->uObjectID;
+        for ( v16 = 0; v16 < (signed int)pObjectList->uNumObjects; ++v16 )
+        {
+          if ( (short)a1.uType == pObjectList->pObjects[v16].uObjectID )
           {
-            v18 = v16;
-            a1.uObjectDescID = v18;
+            //v18 = v16;
+            a1.uObjectDescID = v16;
             *(_QWORD *)&a1.vPosition.y = __PAIR__(fromz, fromy);
             a1.vPosition.x = fromx;
             a1.uAttributes = 16;
             a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz);
             a1.field_60_distance_related_prolly_lod = v55;
-            v20 = yaw;
+            //v20 = yaw;
             a1.uSpriteFrameID = 0;
             a1.spell_caster_pid = 8000 | OBJECT_Item;
             a1.spell_target_pid = 0;
             a1.uFacing = yaw;
             a1.uSoundID = 0;
-            v51 = 0;
+            //v51 = 0;
             v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
-            v47 = pitch;
-            a1.Create(v20, v47, v49, v51);
-            goto LABEL_139;
+            //v47 = pitch;
+            a1.Create(yaw, pitch, v49, 0);
+            pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+            return;
           }
-          ++v16;
-          v19 += 56;
+          //v19 += 56;
         }
-        while ( v16 < (signed int)pObjectList->uNumObjects );
-        v18 = 0;
-        a1.uObjectDescID = v18;
+        //v18 = 0;
+        a1.uObjectDescID = 0;
         *(_QWORD *)&a1.vPosition.y = __PAIR__(fromz, fromy);
         a1.vPosition.x = fromx;
         a1.uAttributes = 16;
         a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz);
         a1.field_60_distance_related_prolly_lod = v55;
-        v20 = yaw;
+        //v20 = yaw;
         a1.uSpriteFrameID = 0;
         a1.spell_caster_pid = 8000 | OBJECT_Item;
         a1.spell_target_pid = 0;
         a1.uFacing = yaw;
         a1.uSoundID = 0;
-        v51 = 0;
+        //v51 = 0;
         v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
-        v47 = pitch;
-        a1.Create(v20, v47, v49, v51);
-        goto LABEL_139;
-      case 15:
+        //v47 = pitch;
+        a1.Create(yaw, pitch, v49, 0);
+        pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+        return;
+      case SPELL_AIR_SPARKS:
         switch ( v15 )
         {
           case 1:
@@ -853,8 +859,8 @@
         a1.spell_skill = v15;
         if ( (signed int)pObjectList->uNumObjects <= 0 )
         {
-          v27 = 0;
-          a1.uObjectDescID = v27;
+          //v27 = 0;
+          a1.uObjectDescID = 0;
           *(_QWORD *)&a1.vPosition.y = __PAIR__(fromz, fromy);
           a1.vPosition.x = fromx;
           a1.uAttributes = 16;
@@ -869,7 +875,8 @@
             a1.uFacing = j + yaw;
             a1.Create((signed __int16)(j + (short)yaw), pitch, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0);
           }
-          goto LABEL_139;
+          pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+          return;
         }
         v26 = (char *)&pObjectList->pObjects->uObjectID;
         while ( (short)a1.uType != *(short *)v26 )
@@ -894,7 +901,8 @@
               a1.uFacing = j + yaw;
               a1.Create((signed __int16)(j + (short)yaw), pitch, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0);
             }
-            goto LABEL_139;
+            pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+            return;
           }
         }
         v27 = v25;
@@ -911,14 +919,12 @@
         for ( j = a7d / -2; j <= a7d / 2; j += a8c )
         {
           a1.uFacing = j + yaw;
-          a1.Create(
-            (signed __int16)(j + (short)yaw),
-            pitch,
-            pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed,
-            0);
+          a1.Create((signed __int16)(j + (short)yaw), pitch,
+            pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0);
         }
-        goto LABEL_139;
-      case 43:
+        pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+        return;
+      case SPELL_EARTH_DEATH_BLOSSOM:
         if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
           return;
         a1.stru_24.Reset();
@@ -928,8 +934,8 @@
         a1.spell_skill = v15;
         if ( (signed int)pObjectList->uNumObjects <= 0 )
         {
-          v31 = 0;
-          a1.uObjectDescID = v31;
+          //v31 = 0;
+          a1.uObjectDescID = 0;
           *(_QWORD *)&a1.vPosition.y = __PAIR__(fromz, fromy);
           a1.vPosition.x = fromx;
           a1.uAttributes = 16;
@@ -939,12 +945,13 @@
           a1.spell_caster_pid = 8000 | OBJECT_Item;
           a1.spell_target_pid = 4;
           a1.uSoundID = 0;
-          v51 = 0;
+          //v51 = 0;
           v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
-          v20 = yaw;
+          //v20 = yaw;
           v47 = (signed int)stru_5C6E00->uIntegerHalfPi / 2;
-          a1.Create(v20, v47, v49, v51);
-          goto LABEL_139;
+          a1.Create(yaw, v47, v49, 0);
+          pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+          return;
         }
         v30 = (char *)&pObjectList->pObjects->uObjectID;
         break;
@@ -979,19 +986,17 @@
         //if ( !levela )
         //  return;
         pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(v9 * 128) * 0.033333335),
-          v15,
-          0,
-          0,
-          0);
+          v15, 0, 0, 0);
         //v33 = spellnum_;
         pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0);
         pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1);
         pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2);
         pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3);
-        goto LABEL_138;
-      case 17:
-      case 38:
-      case 51:
+        pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+        return;
+      case SPELL_AIR_SHIELD:
+      case SPELL_EARTH_STONESKIN:
+      case SPELL_SPIRIT_HEROISM:
         switch ( v15 )
         {
           case 1:
@@ -1026,15 +1031,16 @@
         pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1);
         pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2);
         pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3);
-        v52 = 0;
-        v50 = 0;
-        v48 = v60;
-        v46 = v15;
+        //v52 = 0;
+        //v50 = 0;
+        //v48 = v60;
+        //v46 = v15;
         v36 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(v9 << 7) * 0.033333335);
-        v37 = &pParty->pPartyBuffs[uSkill];
-        v37->Apply(v36, v46, v48, v50, v52);
-        goto LABEL_139;;
-      case 8:
+        //v37 = &pParty->pPartyBuffs[uSkill];
+        pParty->pPartyBuffs[uSkill].Apply(v36, v15, v60, 0, 0);
+        pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+        return;
+      case SPELL_FIRE_IMMOLATION:
         if ( v15 == 2 || v15 == 3 || v15 != 4 )
           v38 = 60 * uSkill;
         else
@@ -1051,11 +1057,12 @@
         v37 = &pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION];
         v36 = pParty->uTimePlayed + v39;
         v37->Apply(v36, v46, v48, v50, v52);
-        goto LABEL_139;
-      case 3:
-      case 14:
-      case 25:
-      case 36:
+        pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+        return;
+      case SPELL_FIRE_PROTECTION_FROM_FIRE:
+      case SPELL_AIR_PROTECTION_FROM_AIR:
+      case SPELL_WATER_PROTECTION_FROM_WATER:
+      case SPELL_EARTH_PROTECTION_FROM_EARTH:
         goto LABEL_117;
       default:
         return;
@@ -1066,8 +1073,8 @@
       v30 += 56;
       if ( v29 >= (signed int)pObjectList->uNumObjects )
       {
-        v31 = 0;
-        a1.uObjectDescID = v31;
+        //v31 = 0;
+        a1.uObjectDescID = 0;
         *(_QWORD *)&a1.vPosition.y = __PAIR__(fromz, fromy);
         a1.vPosition.x = fromx;
         a1.uAttributes = 16;
@@ -1077,12 +1084,13 @@
         a1.spell_caster_pid = 8000 | OBJECT_Item;
         a1.spell_target_pid = 4;
         a1.uSoundID = 0;
-        v51 = 0;
+        //v51 = 0;
         v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
-        v20 = yaw;
+        //v20 = yaw;
         v47 = (signed int)stru_5C6E00->uIntegerHalfPi / 2;
-        a1.Create(v20, v47, v49, v51);
-        goto LABEL_139;
+        a1.Create(yaw, v47, v49, 0);
+        pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+        return;
       }
     }
     v31 = v29;
@@ -1096,12 +1104,13 @@
     a1.spell_caster_pid = 8000 | OBJECT_Item;
     a1.spell_target_pid = 4;
     a1.uSoundID = 0;
-    v51 = 0;
+    //v51 = 0;
     v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed;
-    v20 = yaw;
+    //v20 = yaw;
     v47 = (signed int)stru_5C6E00->uIntegerHalfPi / 2;
-    a1.Create(v20, v47, v49, v51);
-    goto LABEL_139;
+    a1.Create(yaw, v47, v49, 0);
+    pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
+    return;
   }
 LABEL_117:
   v44 = uSkill;
@@ -1158,9 +1167,9 @@
   pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3);
   pParty->pPartyBuffs[uSkill].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)a6_4 * 4.2666669), v15, v60, 0, 0);
   //levela = 1;
-LABEL_138:
+//LABEL_138:
   //if ( levela )
-LABEL_139:
+//LABEL_139:
     pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);
 }
 //----- (00427769) --------------------------------------------------------
--- a/UI/UiGame.cpp	Fri Dec 13 22:19:56 2013 +0600
+++ b/UI/UiGame.cpp	Mon Dec 16 18:43:42 2013 +0600
@@ -1819,7 +1819,7 @@
 void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int bRedrawOdmMinimap)
 {
   int uHeight; // ebx@6
-  unsigned int pW; // ebx@23
+  signed int pW; // ebx@23
   int v15; // eax@23
   double v20; // st7@30
   signed int v27; // eax@37
@@ -1828,15 +1828,15 @@
   int pPoint_X; // edi@72
   int pPoint_Y; // ebx@72
   unsigned int lPitch; // [sp+20h] [bp-34h]@1
-  unsigned int pY; // [sp+20h] [bp-34h]@23
-  unsigned int pX; // [sp+24h] [bp-30h]@23
+  signed int pY; // [sp+20h] [bp-34h]@23
+  signed int pX; // [sp+24h] [bp-30h]@23
   signed int v70; // [sp+24h] [bp-30h]@37
   signed int uBluea; // [sp+28h] [bp-2Ch]@37
   int v73; // [sp+2Ch] [bp-28h]@30
   signed int uCenterY; // [sp+48h] [bp-Ch]@1
   signed int uCenterX; // [sp+4Ch] [bp-8h]@1
   signed int uWidth; // [sp+5Ch] [bp+8h]@30
-  unsigned int pZ; // [sp+60h] [bp+Ch]@23
+  signed int pZ; // [sp+60h] [bp+Ch]@23
   float uWb; // [sp+60h] [bp+Ch]@30
   unsigned int pColor;
 
@@ -1992,6 +1992,8 @@
         v15 = abs(pOutline->sZ - pParty->vPosition.z) / 8;
         if ( v15 > 100 )
           v15 = 100;
+		//if ( i == 1000 )//pY < 0 && pW > 16 )
+			//__debugbreak();
         pRenderer->RasterLine2D(pX, pY, pZ, pW, viewparams->pPalette[-v15 + 200]);
       }
     }
--- a/mm7_2.cpp	Fri Dec 13 22:19:56 2013 +0600
+++ b/mm7_2.cpp	Mon Dec 16 18:43:42 2013 +0600
@@ -2278,7 +2278,6 @@
   if (val < 1)
     return val;
 
-
     v2 = 0;
     v3 = val;
     result = 0;
@@ -2349,32 +2348,16 @@
 //----- (00452B2E) --------------------------------------------------------
 int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides)
 {
-  signed int v2; // edi@1
   int v3; // esi@1
-  int result; // eax@2
-  unsigned int v5; // ebx@4
-
-  v2 = uDiceSides;
+
   v3 = 0;
   if ( uDiceSides )
   {
-    if ( (signed int)uNumDice > 0 )
-    {
-      v5 = uNumDice;
-      do
-      {
-        --v5;
-        v3 += rand() % v2 + 1;
-      }
-      while ( v5 );
-    }
-    result = v3;
+    for ( uint i = 0; i < uNumDice; ++i)
+      v3 += rand() % uDiceSides + 1;
+    return v3;
   }
-  else
-  {
-    result = 0;
-  }
-  return result;
+  return 0;
 }
 
 //----- (00453F62) --------------------------------------------------------
@@ -2734,37 +2717,36 @@
   pHostileTXT_Raw = NULL;
   pHostileTXT_Raw = (char *)pEvents_LOD->LoadRaw("hostile.txt", 0);
   strtok(pHostileTXT_Raw, "\r");
-  for (i=0; i<89; ++i)
-	  {
-	  test_string = strtok(NULL, "\r") + 1;
-	  break_loop = false;
-	  decode_step=0;
-	  do 
-		  {
-		  c = *(unsigned char*)test_string;
-		  temp_str_len = 0;
-		  while((c!='\t')&&(c>0))
-			  {
-			  ++temp_str_len;
-			  c=test_string[temp_str_len];
-			  }		
-		  tmp_pos=test_string+temp_str_len;
-		  if (*tmp_pos == 0)
-			  break_loop = true;
-		  *tmp_pos = 0;
-		  if (temp_str_len)
-			  {
-			  if ( decode_step >= 1 && decode_step < 90 )
-				  relations[decode_step-1][i] = atoi(test_string);
-			  }
-		  else
-			  { 
-			  break_loop = true;
-			  }
-		  ++decode_step;
-		  test_string=tmp_pos+1;
-		  } while ((decode_step<92)&&!break_loop);
-	  }
+  for ( i=0; i < 89; ++i )
+  {
+     test_string = strtok(NULL, "\r") + 1;
+     break_loop = false;
+     decode_step=0;
+     do 
+     {
+       c = *(unsigned char*)test_string;
+       temp_str_len = 0;
+       while((c!='\t') && (c > 0))
+       {
+         ++temp_str_len;
+         c = test_string[temp_str_len];
+       }
+       tmp_pos=test_string+temp_str_len;
+       if (*tmp_pos == 0)
+         break_loop = true;
+       *tmp_pos = 0;
+       if (temp_str_len)
+       {
+         if ( decode_step >= 1 && decode_step < 90 )
+           relations[decode_step-1][i] = atoi(test_string);
+       }
+       else
+         break_loop = true;
+       ++decode_step;
+       test_string=tmp_pos+1;
+     }
+     while ((decode_step < 92) && !break_loop );
+   }
   if ( pHostileTXT_Raw)
   {
     free(pHostileTXT_Raw);
@@ -2831,7 +2813,7 @@
   //GUIProgressBar *v0; // ebx@1
   //signed int v1; // ebp@1
   //char *v2; // esi@2
-  __int16 v3; // cx@3
+  //__int16 v3; // cx@3
   int v4; // edx@8
   //size_t v5; // edi@14
   signed int v6; // esi@14
@@ -2853,7 +2835,7 @@
 
   GenerateItemsInChest();
   pGameLoadingUI_ProgressBar->Progress();
-  pParty->uFlags |= 2u;
+  pParty->uFlags |= 2;
   pParty->field_7B5_in_arena_quest = 0;
   dword_5C6DF8 = 1;
   pNPCStats->uNewlNPCBufPos = 0;
@@ -2867,13 +2849,13 @@
     //v2 = (char *)&pActors[0].uNPC_ID;
     //do
     //{
-      v3 = pActors[i].pMonsterInfo.uID;
+      //v3 = pActors[i].pMonsterInfo.uID;
       v17 = 0;
       if ( pActors[i].pMonsterInfo.uID >= 115 && pActors[i].pMonsterInfo.uID <= 186
         || pActors[i].pMonsterInfo.uID >= 232 && pActors[i].pMonsterInfo.uID <= 249 )
         v17 = 1;
       //v1 = 0;
-      v4 = (v3 - 1) % 3;
+      v4 = (pActors[i].pMonsterInfo.uID - 1) % 3;
       if ( 2 == v4 )
       {
         if ( pActors[i].sNPC_ID && pActors[i].sNPC_ID < 5000 )
@@ -2884,15 +2866,15 @@
         if ( v4 != 1 )
         {
           if ( v4 == 0 && pActors[i].sNPC_ID == 0 )
-			pActors[i].sNPC_ID = 0;
-		  continue;
+            pActors[i].sNPC_ID = 0;
+          continue;
         }
       }
       if ( pActors[i].sNPC_ID > 0 && pActors[i].sNPC_ID < 5000 )
         continue;
       if ( v17 )
       {
-        pNPCStats->InitializeAdditionalNPCs(&pNPCStats->pAdditionalNPC[pNPCStats->uNewlNPCBufPos], v3, 0, v19);
+        pNPCStats->InitializeAdditionalNPCs(&pNPCStats->pAdditionalNPC[pNPCStats->uNewlNPCBufPos], pActors[i].pMonsterInfo.uID, 0, v19);
         v14 = LOWORD(pNPCStats->uNewlNPCBufPos) + 5000;
         ++pNPCStats->uNewlNPCBufPos;
         pActors[i].sNPC_ID = v14;
@@ -2917,60 +2899,38 @@
     //v7 = (char *)&pActors[0].pMonsterInfo;
     //do
     //{
-      v8 = 0;
-      if ( v6 > 0 )
-      {
-        do
-        {
-          if ( v21[v8] == pActors[i].pMonsterInfo.uID - 1 )
-            break;
-          ++v8;
-        }
-        while ( v8 < v6 );
-      }
-
-      if ( v8 == v6 )
-      {
-        v21[v6++] = pActors[i].pMonsterInfo.uID - 1;
-        v20 = v6;
-        if ( v6 == 16 )
-          break;
-      }
-      //++v16;
-      //v7 += 836;
+    for ( v8 = 0; v8 < v6; ++v8 )
+    {
+      if ( v21[v8] == pActors[i].pMonsterInfo.uID - 1 )
+        break;
+    }
+
+    if ( v8 == v6 )
+    {
+      v21[v6++] = pActors[i].pMonsterInfo.uID - 1;
+      v20 = v6;
+      if ( v6 == 16 )
+        break;
+    }
+    //++v16;
+    //v7 += 836;
     //}
     //while ( v16 < (signed int)v5 );
   }
 
   pGameLoadingUI_ProgressBar->Progress();
 
-  if ( v6 > 0 )
-  {
-    int _v0 = 0;
-    do
+    for ( int _v0 = 0; _v0 < v6; ++_v0 )
     {
-      v9 = v21[_v0];
-      v18 = 4;
-      v10 = &pMonsterStats->pInfos[v9 + 1];
-      //v11 = (int *)pMonsterList->pMonsters[v9].pSoundSampleIDs;
-      MonsterDesc* v11 = &pMonsterList->pMonsters[v9];
-      do
-      {
-        pSoundList->LoadSound(v11->pSoundSampleIDs[4 - v18], 0);
-        //v11 = (int *)((char *)v11 + 2);
-        --v18;
-      }
-      while ( v18 );
+      for ( v18 = 4; v18; --v18 )
+        pSoundList->LoadSound(pMonsterList->pMonsters[v21[_v0]].pSoundSampleIDs[4 - v18], 0);
       v12 = 0;
       do
-        v13 = pSoundList->LoadSound(v12++ + word_4EE088_sound_ids[v10->uSpell1ID], 1);
+        v13 = pSoundList->LoadSound(v12++ + word_4EE088_sound_ids[pMonsterStats->pInfos[v21[_v0] + 1].uSpell1ID], 1);
       while ( v13 );
-      ++_v0;
     }
-    while ( _v0 < v6 );
     //v0 = pGameLoadingUI_ProgressBar;
     //v1 = 0;
-  }
 
   pGameLoadingUI_ProgressBar->Progress();
 
@@ -3467,7 +3427,7 @@
       {
         if ( !RegCreateKeyExA(v7, "1.0", 0, "", 0, 0xF003Fu, 0, &v8, &dwDisposition) )
         {
-          RegSetValueExA(v8, lpValueName, 0, 4u, Data, 4u);
+          RegSetValueExA(v8, lpValueName, 0, 4, Data, 4);
           RegCloseKey(v8);
         }
         RegCloseKey(v7);
@@ -4107,21 +4067,12 @@
     pUIAnims[i]->y = _4E98D0[i][2];
   }
 
-  v5 = 0;
-  if ( (signed int)pObjectList->uNumObjects > 0 )
+  for ( v5 = 0; v5 < (signed int)pObjectList->uNumObjects; ++v5 )
   {
-    v6 = 0;
-    do
-    {
-      BYTE3(v7) = 0;
-      v8 = &pObjectList->pObjects[v6];
-      ++v6;
-      *(short *)((char *)&v7 + 1) = v8->uParticleTrailColorR;
-      LOBYTE(v7) = v8->uParticleTrailColorG;
-      ++v5;
-      v8->uParticleTrailColor = v8->uParticleTrailColorB | (v7 << 8);
-    }
-    while ( v5 < (signed int)pObjectList->uNumObjects );
+    BYTE3(v7) = 0;
+    *(short *)((char *)&v7 + 1) = pObjectList->pObjects[v5].uParticleTrailColorR;
+    LOBYTE(v7) = pObjectList->pObjects[v5].uParticleTrailColorG;
+    pObjectList->pObjects[v5].uParticleTrailColor = pObjectList->pObjects[v5].uParticleTrailColorB | (v7 << 8);
   }
   flt_6BE3A0 = 0.55000001f;
   MainMenuUI_Create();
@@ -4686,7 +4637,7 @@
   {
     LOBYTE(viewparams->field_20) = 0;
   }
-  pParty->uFlags |= 2u;
+  pParty->uFlags |= 2;
   viewparams->uSomeY = viewparams->uScreen_topL_Y;
   viewparams->uSomeX = viewparams->uScreen_topL_X;
   viewparams->uSomeZ = viewparams->uScreen_BttmR_X;
@@ -4736,22 +4687,15 @@
 int __fastcall _46A6AC_spell_render(int a1, int a2, int a3)
 {
   int result; // eax@2
-  unsigned int v4; // edx@3
   int *v5; // esi@6
   unsigned int v6; // ebx@6
   signed int v7; // edi@9
-  unsigned __int16 v8; // ax@9
   int i; // eax@14
   int v10; // ecx@19
-  int v11; // [sp+0h] [bp-18h]@1
-  unsigned int v12; // [sp+4h] [bp-14h]@3
   unsigned int v13; // [sp+8h] [bp-10h]@4
-  int v14; // [sp+Ch] [bp-Ch]@1
   int *v15; // [sp+10h] [bp-8h]@4
   int v16; // [sp+14h] [bp-4h]@3
 
-  v11 = a2;
-  v14 = a1;
   if ( pRenderer->pRenderD3D )
   {
     result = _46A6AC_spell_render_d3d(a1, a2, a3);
@@ -4760,56 +4704,47 @@
   {
     __debugbreak(); // SW render never called
     v16 = 0;
-    v4 = viewparams->uScreen_topL_X;
-    v12 = viewparams->uScreen_BttmR_X;
     if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y )
     {
       v15 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y];
       v13 = ((viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y - 1) >> 1) + 1;
-      do
+      for ( v13; v13; --v13 )
       {
-        if ( (signed int)v4 < (signed int)v12 )
+        if ( (signed int)viewparams->uScreen_topL_X < (signed int)viewparams->uScreen_BttmR_X )
         {
           v5 = v15;
-          v6 = ((v12 - v4 - 1) >> 1) + 1;
-          do
+          v6 = ((viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X - 1) >> 1) + 1;
+          for ( v6; v6; --v6 )
           {
             if ( PID_TYPE(*(char *)v5) == OBJECT_Actor)
             {
               if ( *v5 <= a3 << 16 )
               {
                 v7 = PID_ID((signed int)(unsigned __int16)*v5);
-                v8 = pActors[v7].uAIState;
-                if ( v8 != 5 )
+                if ( pActors[v7].uAIState != Dead && pActors[v7].uAIState != Dying && pActors[v7].uAIState != Removed
+                  && pActors[v7].uAIState != Summoned && pActors[v7].uAIState != Disabled )
                 {
-                  if ( v8 != 4 && v8 != 11 && v8 != 17 && v8 != 19 )
+                  for ( i = 0; i < v16; ++i )
                   {
-                    for ( i = 0; i < v16; ++i )
+                    if ( *(int *)(a1 + 4 * i) == v7 )
+                      break;
+                  }
+                  if ( i == v16 )
+                  {
+                    if ( i < a2 - 1 )
                     {
-                      if ( *(int *)(v14 + 4 * i) == v7 )
-                        break;
-                    }
-                    if ( i == v16 )
-                    {
-                      if ( i < v11 - 1 )
-                      {
-                        v10 = v16++;
-                        *(int *)(v14 + 4 * v10) = v7;
-                      }
+                      v10 = v16++;
+                      *(int *)(a1 + 4 * v10) = v7;
                     }
                   }
                 }
               }
             }
             v5 += 2;
-            --v6;
           }
-          while ( v6 );
         }
         v15 += 1280;
-        --v13;
       }
-      while ( v13 );
     }
     result = v16;
   }
@@ -4820,67 +4755,42 @@
 int __fastcall _46A6AC_spell_render_d3d(int a1, int a2, int a3)
 {
   unsigned int v3; // eax@2
-  int v4; // ecx@2
   unsigned int v5; // eax@2
   unsigned int v6; // eax@4
-  unsigned int v7; // edi@4
-  unsigned __int16 v8; // ax@4
-  float v9; // ST00_4@9
   int v10; // ecx@11
   unsigned int v12; // [sp+10h] [bp-14h]@1
-  int v13; // [sp+14h] [bp-10h]@1
-  int v14; // [sp+18h] [bp-Ch]@1
   int v15; // [sp+1Ch] [bp-8h]@1
   unsigned int a1a; // [sp+20h] [bp-4h]@1
 
-  v13 = a1;
-  v14 = a2;
   v15 = 0;
-  a1a = 0;
   v12 = pRenderer->GetBillboardDrawListSize();
-  if ( (signed int)v12 > 0 )
+  if ( (signed int)pRenderer->GetBillboardDrawListSize() > 0 )
   {
-    do
+    for ( a1a = 0; (signed int)a1a < (signed int)v12; ++a1a )
     {
       v3 = pRenderer->GetParentBillboardID(a1a);
-      v4 = pBillboardRenderList[v3].sZValue;
       v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid;
       if ( PID_TYPE(v5) == OBJECT_Actor)
       {
-        if ( v4 <= (unsigned int)(a3 << 16) )
+        if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(a3 << 16) )
         {
           v6 = PID_ID(v5);
-          v7 = v6;
-          v8 = pActors[v6].uAIState;
-          if ( v8 != Dead )
+          if ( pActors[v6].uAIState != Dead && pActors[v6].uAIState != Dying && pActors[v6].uAIState != Removed
+            && pActors[v6].uAIState != Disabled && pActors[v6].uAIState != Summoned )
           {
-            if ( v8 != Dying )
+            if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)a3, a1a) )
             {
-              if ( v8 != Removed )
+              if ( v15 < a2 - 1 )
               {
-                if ( v8 != Disabled )
-                {
-                  if ( v8 != Summoned )
-                  {
-                    v9 = (double)a3;
-                    if ( pGame->pVisInstance->DoesRayIntersectBillboard(v9, a1a) )
-                    {
-                      if ( v15 < v14 - 1 )
-                      {
-                        v10 = v15++;
-                        *(int *)(v13 + 4 * v10) = v7;
-                      }
-                    }
-                  }
-                }
+                __debugbreak();// *(int *)(a1 + 4 * v10) = v6; что это такое?
+                v10 = v15++;
+                *(int *)(a1 + 4 * v10) = v6;
               }
             }
           }
         }
       }
-      ++a1a;
     }
-    while ( (signed int)a1a < (signed int)v12 );
   }
   return v15;
 }
@@ -4888,8 +4798,6 @@
 //----- (0046A89E) --------------------------------------------------------
 int __fastcall _46A89E_immolation_effect(int a1, int a2, int a3)
 {
-  signed int v3; // edi@1
-  Actor *v4; // esi@2
   int v5; // ebx@3
   int v6; // eax@3
   int v7; // ebx@3
@@ -4897,74 +4805,50 @@
   int v9; // edx@4
   unsigned int v10; // edx@6
   unsigned int v11; // edx@8
-  __int16 v12; // ax@10
   int v13; // ecx@15
-  int v15; // [sp+4h] [bp-18h]@1
-  int v16; // [sp+8h] [bp-14h]@1
   int v17; // [sp+Ch] [bp-10h]@3
   int v18; // [sp+10h] [bp-Ch]@3
   int v19; // [sp+18h] [bp-4h]@1
 
-  v3 = 0;
-  v15 = a2;
-  v16 = a1;
   v19 = 0;
-  if ( (signed int)uNumActors > 0 )
+  for ( uint i = 0; i < (signed int)uNumActors; ++i )
   {
-    v4 = pActors.data();//[0].uAIState;
-    do
+    v5 = abs(pActors[i].vPosition.x - pParty->vPosition.x);
+    v17 = abs(pActors[i].vPosition.y - pParty->vPosition.y);
+    v18 = abs(pActors[i].vPosition.z - pParty->vPosition.z);
+    v6 = v5;
+    v7 = v17;
+    v8 = v18;
+    if ( v6 < v17 )
     {
-	  v5 = abs(v4->vPosition.x - pParty->vPosition.x);
-	  v17 = abs(v4->vPosition.y - pParty->vPosition.y);
-	  v18 = abs(v4->vPosition.z - pParty->vPosition.z);
-      v6 = v5;
-      v7 = v17;
-      v8 = v18;
-      if ( v6 < v17 )
-      {
-        v9 = v6;
-        v6 = v17;
-        v7 = v9;
-      }
-      if ( v6 < v18 )
-      {
-        v10 = v6;
-        v6 = v18;
-        v8 = v10;
-      }
-      if ( v7 < (signed int)v8 )
+      v9 = v6;
+      v6 = v17;
+      v7 = v9;
+    }
+    if ( v6 < v18 )
+    {
+      v10 = v6;
+      v6 = v18;
+      v8 = v10;
+    }
+    if ( v7 < (signed int)v8 )
+    {
+      v11 = v8;
+      v8 = v7;
+      v7 = v11;
+    }
+    if ( (signed int)(((unsigned int)(11 * v7) >> 5) + (v8 >> 2) + v6) <= a3 )
+    {
+      if ( pActors[i].uAIState != Dead && pActors[i].uAIState != Dying && pActors[i].uAIState != Removed
+        && pActors[i].uAIState != Disabled && pActors[i].uAIState != Summoned )
       {
-        v11 = v8;
-        v8 = v7;
-        v7 = v11;
+        __debugbreak();// *(int *)(a1 + 4 * v13) = i; что это такое?
+        v13 = v19++;
+        *(int *)(a1 + 4 * v13) = i;
+        if ( v19 >= a2 - 1 )
+          break;
       }
-      if ( (signed int)(((unsigned int)(11 * v7) >> 5) + (v8 >> 2) + v6) <= a3 )
-      {
-		v12 = v4->uAIState;
-        if ( v4->uAIState != 5 )
-        {
-          if ( v12 != 4 )
-          {
-            if ( v12 != 11 )
-            {
-              if ( v12 != 19 )
-              {
-                if ( v12 != 17 )
-                {
-                  v13 = v19++;
-                  *(int *)(v16 + 4 * v13) = v3;
-                  if ( v19 >= v15 - 1 )
-                    break;
-                }
-              }
-            }
-          }
-        }
-      }
-      ++v3;
-      ++v4;
     }
-    while ( v3 < (signed int)uNumActors );
   }
   return v19;
 }
@@ -4999,19 +4883,13 @@
 //----- (0046BFFA) --------------------------------------------------------
 bool __fastcall _46BFFA_check_object_intercept(unsigned int uLayingItemID, signed int a2)
 {
-  //SpriteObject *v2; // esi@1
-  ObjectDesc *v3; // ebx@1
-  unsigned __int16 v5; // cx@9
-  //unsigned __int16 v6; // cx@14
-  //signed int v7; // edx@14
+  ObjectDesc *object; // ebx@1
   unsigned int v8; // eax@19
-  unsigned int v9; // edi@19
   signed int v10; // ebx@19
   char *v11; // edx@20
   unsigned __int16 v12; // ax@23
   int v13; // eax@27
   unsigned int v14; // ebx@33
-  //unsigned __int16 v15; // ax@35
   int v16; // eax@36
   unsigned int v17; // eax@37
   __int16 v18; // di@37
@@ -5047,7 +4925,6 @@
   int v48; // edx@87
   int v49; // edx@88
   int v50; // edx@89
-  unsigned int v51; // eax@93
   signed int v52; // ebx@93
   char *v53; // edx@94
   unsigned __int16 v54; // ax@98
@@ -5069,11 +4946,6 @@
   char *v70; // edx@125
   unsigned __int16 v71; // ax@128
   unsigned int v72; // ebx@131
-  //int v73; // ST14_4@132
-  //int v74; // ST10_4@132
-  //int v75; // ebx@132
-  //int v76; // ST0C_4@132
-  //unsigned __int16 v77; // ax@132
   int v78; // eax@133
   char v79; // zf@139
   unsigned int v80; // eax@140
@@ -5095,13 +4967,8 @@
   unsigned __int16 v96; // ax@184
   int v97; // eax@185
   unsigned __int16 v98; // ax@191
-  unsigned int v99; // ecx@191
   char v100; // ST18_1@198
-  //int v101; // ST14_4@198
   int v102; // eax@198
-  //int v103; // ST10_4@198
-  //int v104; // ST0C_4@198
-  //unsigned __int16 v105; // ax@200
   signed int v106; // eax@208
   unsigned int v107; // edx@220
   signed int v108; // ebx@225
@@ -5112,7 +4979,6 @@
   unsigned __int16 v113; // si@241
   int v114; // eax@242
   int v115; // eax@245
-  //signed int v116; // eax@245
   unsigned __int16 v117; // ax@251
   unsigned int v118; // ecx@251
   signed int v119; // ebx@251
@@ -5122,14 +4988,7 @@
   char *v123; // edx@261
   int v124; // eax@267
   int v125; // [sp-20h] [bp-4Ch]@28
-  //signed int v126; // [sp-1Ch] [bp-48h]@27
-  //unsigned int v127; // [sp-18h] [bp-44h]@27
-  //signed int v128; // [sp-14h] [bp-40h]@27
-  //signed int v129; // [sp-10h] [bp-3Ch]@27
-  //int v130; // [sp-Ch] [bp-38h]@27
-  //unsigned int v131; // [sp-8h] [bp-34h]@27
   char v132; // [sp-8h] [bp-34h]@131
-  //int v133; // [sp-4h] [bp-30h]@27
   char v134; // [sp-4h] [bp-30h]@131
   signed int v135; // [sp-4h] [bp-30h]@217
   int v136; // [sp+Ch] [bp-20h]@208
@@ -5141,21 +5000,15 @@
   unsigned int v142; // [sp+1Ch] [bp-10h]@158
   signed int v143; // [sp+1Ch] [bp-10h]@172
   char *v144; // [sp+1Ch] [bp-10h]@192
-  signed int v145; // [sp+20h] [bp-Ch]@1
   signed int v146; // [sp+20h] [bp-Ch]@60
   int v147; // [sp+20h] [bp-Ch]@72
   signed int v148; // [sp+20h] [bp-Ch]@158
-  //int v149; // [sp+20h] [bp-Ch]@198
   unsigned __int16 v150; // [sp+20h] [bp-Ch]@208
-  int v151; // [sp+24h] [bp-8h]@1
   signed int v152; // [sp+24h] [bp-8h]@208
-  unsigned int v153; // [sp+28h] [bp-4h]@1
-
-  v153 = uLayingItemID;
-  //v2 = &pSpriteObjects[uLayingItemID];
-  v3 = &pObjectList->pObjects[pSpriteObjects[uLayingItemID].uObjectDescID];
-  v145 = a2;
-  v151 = PID_TYPE(a2);
+
+  //применение: фаерболт в храме луны
+  object = &pObjectList->pObjects[pSpriteObjects[uLayingItemID].uObjectDescID];
+  //v151 = PID_TYPE(a2);
   if ( PID_TYPE(a2) == OBJECT_Actor)
   {
     if ( PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) == OBJECT_Actor 
@@ -5169,14 +5022,13 @@
   }
   if ( pParty->bTurnBasedModeOn == 1 )
   {
-    v5 = pSpriteObjects[uLayingItemID].uAttributes;
-    if ( v5 & 4 )
+    if ( pSpriteObjects[uLayingItemID].uAttributes & 4 )
     {
       --pTurnEngine->pending_actions;
-      pSpriteObjects[uLayingItemID].uAttributes = v5 & 0xFFFB;
+      pSpriteObjects[uLayingItemID].uAttributes &= 0xFFFB;
     }
   }
-  if ( v151 == OBJECT_BModel && PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) != OBJECT_Player)
+  if ( PID_TYPE(a2) == OBJECT_BModel && PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) != OBJECT_Player)
       {
       if (PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid) < 500)  //bugfix  PID_ID(v2->spell_caster_pid)==1000
          BYTE2(pActors[PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid)].uAttributes) |= 4;
@@ -5198,86 +5050,59 @@
           {
             if ( pSpriteObjects[uLayingItemID].uType != 9080 )
               return 0;
-LABEL_191:
-            v98 = pSpriteObjects[uLayingItemID].uType + 1;
-            v99 = pObjectList->uNumObjects;
-            v32 = 0;
-            pSpriteObjects[uLayingItemID].uType = v98;
-            v146 = 0;
-            if ( (signed int)v99 > 0 )
+            v95 = 0;
+            pSpriteObjects[uLayingItemID].uType = pSpriteObjects[uLayingItemID].uType + 1;
+            for ( v146 = 0; v146 < (signed int)pObjectList->uNumObjects; ++v146 )
             {
-              v144 = (char *)&pObjectList->pObjects->uObjectID;
-              while ( v98 != *(short *)v144 )
-              {
-                ++v146;
-                v144 += 56;
-                if ( v146 >= (signed int)v99 )
-                {
-                  pSpriteObjects[uLayingItemID].uObjectDescID = 0;
-                  if ( !v32 )
-                    SpriteObject::OnInteraction(v153);
-                  v100 = pSpriteObjects[uLayingItemID].field_61;
-                  pSpriteObjects[uLayingItemID].uSpriteFrameID = v32;
-                  v102 = 8 * v153;
-                  LOBYTE(v102) = PID(OBJECT_Item,v153);
-                  pSpriteObjects[uLayingItemID].vVelocity.x = v32;
-                  pSpriteObjects[uLayingItemID].vVelocity.y = v32;
-                  pSpriteObjects[uLayingItemID].vVelocity.z = v32;
-                  AttackerInfo.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, v32);
-                  if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
-                    trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v3->uParticleTrailColor);
-                  if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v32 )
-                    v47 = 0;
-                  else
-                    v47 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
-                  v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
-                  pAudioPlayer->PlaySound((SoundID)v125, v102, v32, -1, v32, v47, v32, v32);
-                  return 0;
-                }
-              }
-              pSpriteObjects[uLayingItemID].uObjectDescID = v146;
-              if ( v146 == (short)v32 )
-                SpriteObject::OnInteraction(v153);
-              v100 = pSpriteObjects[uLayingItemID].field_61;
-              pSpriteObjects[uLayingItemID].uSpriteFrameID = v32;
-              v102 = 8 * v153;
-              LOBYTE(v102) = PID(OBJECT_Item,v153);
-              pSpriteObjects[uLayingItemID].vVelocity.x = v32;
-              pSpriteObjects[uLayingItemID].vVelocity.y = v32;
-              pSpriteObjects[uLayingItemID].vVelocity.z = v32;
-              AttackerInfo.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, v32);
-              if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
-                trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v3->uParticleTrailColor);
-              if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v32 )
-                v47 = 0;
-              else
-                v47 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
-              v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
-              pAudioPlayer->PlaySound((SoundID)v125, v102, v32, -1, v32, v47, v32, v32);
-              return 0;
+              if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v146].uObjectID )
+                v95 = v146;
             }
-            pSpriteObjects[uLayingItemID].uObjectDescID = 0;
-            if ( !v32 )
-              SpriteObject::OnInteraction(v153);
+            pSpriteObjects[uLayingItemID].uObjectDescID = v95;
+            if ( !v95 )
+              SpriteObject::OnInteraction(uLayingItemID);
             v100 = pSpriteObjects[uLayingItemID].field_61;
-            pSpriteObjects[uLayingItemID].uSpriteFrameID = v32;
-            v102 = 8 * v153;
-            LOBYTE(v102) = PID(OBJECT_Item,v153);
-            pSpriteObjects[uLayingItemID].vVelocity.x = v32;
-            pSpriteObjects[uLayingItemID].vVelocity.y = v32;
-            pSpriteObjects[uLayingItemID].vVelocity.z = v32;
-            AttackerInfo.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, v32);
-            if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
-              trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v3->uParticleTrailColor);
-            if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v32 )
+            pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
+            v102 = 8 * uLayingItemID;
+            LOBYTE(v102) = PID(OBJECT_Item, uLayingItemID);
+            pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+            pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+            pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+            AttackerInfo.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, 0);
+            if (object->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
+              trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, object->uParticleTrailColor);
+            if ( !pSpriteObjects[uLayingItemID].uSoundID )
               v47 = 0;
             else
               v47 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
             v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
-            pAudioPlayer->PlaySound((SoundID)v125, v102, v32, -1, v32, v47, v32, v32);
+            pAudioPlayer->PlaySound((SoundID)v125, v102, 0, -1, 0, v47, 0, 0);
             return 0;
           }
-          goto LABEL_93;
+          sub_43A97E(uLayingItemID, a2);
+          ++pSpriteObjects[uLayingItemID].uType;
+          v95 = 0;
+          for ( v52 = 0; v52 < (signed int)pObjectList->uNumObjects; ++v52 )
+          {
+            if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v52].uObjectID )
+              v95 = v52;
+          }
+          pSpriteObjects[uLayingItemID].uObjectDescID = v95;
+          if ( !v95 )
+            SpriteObject::OnInteraction(uLayingItemID);
+          v96 = pSpriteObjects[uLayingItemID].uSoundID;
+          pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+          pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+          pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+          pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
+          if ( !v96 )
+            v97 = 0;
+          else
+            v97 = (signed __int16)v96 + 4;
+          v124 = 8 * uLayingItemID;
+          LOBYTE(v124) = v124 | 2;
+          v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
+          pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v97, 0, 0);
+          return 0;
         }
 LABEL_172:
         v143 = 17030;
@@ -5294,40 +5119,27 @@
             break;
         }
         v138 = 1;
-        if ( v151 != OBJECT_Actor)
+        if ( PID_TYPE(a2) != OBJECT_Actor)
         {
           if ( pSpriteObjects[uLayingItemID].uType != 9030 || pSpriteObjects[uLayingItemID].spell_skill != 4 )
-		  {
-			  SpriteObject::OnInteraction(v153);
-			  return 0;
-		  }
-		  pSpriteObjects[uLayingItemID]._46BEF1_apply_spells_aoe();
+          {
+            SpriteObject::OnInteraction(uLayingItemID);
+            return 0;
+          }
+          pSpriteObjects[uLayingItemID]._46BEF1_apply_spells_aoe();
 LABEL_233:
           if ( !v138 )
           {
-            v109 = pObjectList->uNumObjects;
             ++pSpriteObjects[uLayingItemID].uType;
-            v110 = 0;
-            if ( (signed int)v109 <= 0 )
-            {
-LABEL_238:
-              v112 = 0;
-            }
-            else
+            v112 = 0;
+            for ( v110 = 0; v110 < (signed int)pObjectList->uNumObjects; ++v110 )
             {
-              v111 = (char *)&pObjectList->pObjects->uObjectID;
-              while ( pSpriteObjects[uLayingItemID].uType != *(short *)v111 )
-              {
-                ++v110;
-                v111 += 56;
-                if ( v110 >= (signed int)v109 )
-                  goto LABEL_238;
-              }
-              v112 = v110;
+              if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v110].uObjectID )
+                v112 = v110;
             }
             pSpriteObjects[uLayingItemID].uObjectDescID = v112;
             if ( !v112 )
-              SpriteObject::OnInteraction(v153);
+              SpriteObject::OnInteraction(uLayingItemID);
             pSpriteObjects[uLayingItemID].vVelocity.z = 0;
             pSpriteObjects[uLayingItemID].vVelocity.y = 0;
             pSpriteObjects[uLayingItemID].vVelocity.x = 0;
@@ -5337,16 +5149,16 @@
               v114 = (signed __int16)v113 + 4;
             else
               v114 = 0;
-            v115 = 8 * v153;
-            LOBYTE(v115) = PID(OBJECT_Item,v153);
+            v115 = 8 * uLayingItemID;
+            LOBYTE(v115) = PID(OBJECT_Item, uLayingItemID);
             v125 = v143 + 1;
             pAudioPlayer->PlaySound((SoundID)v125, v115, 0, -1, 0, v114, 0, 0);
             return 0;
           }
-          SpriteObject::OnInteraction(v153);
+          SpriteObject::OnInteraction(uLayingItemID);
           return 0;
         }
-        v106 = v145;
+        v106 = a2;
         v150 = 0;
         v139 = PID_ID(v106);
         v137 = pSpriteObjects[uLayingItemID].spell_level;
@@ -5412,55 +5224,100 @@
         v107 = v135;
         goto LABEL_222;
       }
-      if ( pSpriteObjects[uLayingItemID].uType == 8090 || pSpriteObjects[uLayingItemID].uType == 7030 || pSpriteObjects[uLayingItemID].uType == 7090 || pSpriteObjects[uLayingItemID].uType == 8000 )
-        goto LABEL_93;
+      if ( pSpriteObjects[uLayingItemID].uType == 8090
+        || pSpriteObjects[uLayingItemID].uType == 7030
+        || pSpriteObjects[uLayingItemID].uType == 7090 || pSpriteObjects[uLayingItemID].uType == 8000 )
+      {
+        sub_43A97E(uLayingItemID, a2);
+        ++pSpriteObjects[uLayingItemID].uType;
+        v95 = 0;
+        for ( v52 = 0; v52 < (signed int)pObjectList->uNumObjects; ++v52 )
+        {
+          if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v52].uObjectID )
+            v95 = v52;
+        }
+        pSpriteObjects[uLayingItemID].uObjectDescID = v95;
+        if ( !v95 )
+          SpriteObject::OnInteraction(uLayingItemID);
+        v96 = pSpriteObjects[uLayingItemID].uSoundID;
+        pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+        pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+        pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+        pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
+        if ( !v96 )
+          v97 = 0;
+        else
+          v97 = (signed __int16)v96 + 4;
+        v124 = 8 * uLayingItemID;
+        LOBYTE(v124) = v124 | 2;
+        v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
+        pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v97, 0, 0);
+        return 0;
+      }
       if ( pSpriteObjects[uLayingItemID].uType == 8010 )
       {
-        if ( v151 == 3
-          && MonsterStats::BelongsToSupertype(pActors[PID_ID(v145)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
-          sub_43A97E(v153, v145);
-        v93 = pObjectList->uNumObjects;
+        if ( PID_TYPE(a2) == 3
+          && MonsterStats::BelongsToSupertype(pActors[PID_ID(a2)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
+          sub_43A97E(uLayingItemID, a2);
         ++pSpriteObjects[uLayingItemID].uType;
-        v9 = 0;
-        v52 = 0;
-        if ( (signed int)v93 > 0 )
+        //v9 = 0;
+        v95 = 0;
+        for ( v52 = 0; v52 < (signed int)pObjectList->uNumObjects; ++v52 )
         {
-          v94 = (char *)&pObjectList->pObjects->uObjectID;
-          while ( pSpriteObjects[uLayingItemID].uType != *(short *)v94 )
-          {
-            ++v52;
-            v94 += 56;
-            if ( v52 >= (signed int)v93 )
-              goto LABEL_181;
-          }
-          v95 = v52;
-          pSpriteObjects[uLayingItemID].uObjectDescID = v95;
-			if ( v95 == (short)v9 )
-				SpriteObject::OnInteraction(v153);
-			v96 = pSpriteObjects[uLayingItemID].uSoundID;
-			pSpriteObjects[uLayingItemID].vVelocity.z = v9;
-			pSpriteObjects[uLayingItemID].vVelocity.y = v9;
-			pSpriteObjects[uLayingItemID].vVelocity.x = v9;
-			pSpriteObjects[uLayingItemID].uSpriteFrameID = v9;
-			if ( v96 == (short)v9 )
-				v97 = 0;
-			else
-				v97 = (signed __int16)v96 + 4;
-			v92 = v153;
-            v124 = 8 * v92;
-            LOBYTE(v124) = v124 | 2;
-            v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
-            pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v97, v9, v9);
-            return 0;
+          if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v52].uObjectID )
+            v95 = v52;
         }
-        goto LABEL_181;
+        pSpriteObjects[uLayingItemID].uObjectDescID = v95;
+        if ( !v95 )
+          SpriteObject::OnInteraction(uLayingItemID);
+        v96 = pSpriteObjects[uLayingItemID].uSoundID;
+         pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+        pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+        pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+        pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
+        if ( !v96 )
+          v97 = 0;
+        else
+          v97 = (signed __int16)v96 + 4;
+        v92 = uLayingItemID;
+        v124 = 8 * v92;
+        LOBYTE(v124) = v124 | 2;
+        v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
+        pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v97, 0, 0);
+        return 0;
       }
       v79 = pSpriteObjects[uLayingItemID].uType == 8030;
     }
     else
     {
       if ( pSpriteObjects[uLayingItemID].uType == 6090 )
-        goto LABEL_93;
+      {
+        sub_43A97E(uLayingItemID, a2);
+        ++pSpriteObjects[uLayingItemID].uType;
+        v95 = 0;
+        for ( v52 = 0; v52 < (signed int)pObjectList->uNumObjects; ++v52 )
+        {
+          if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v52].uObjectID )
+            v95 = v52;
+        }
+        pSpriteObjects[uLayingItemID].uObjectDescID = v95;
+        if ( !v95 )
+          SpriteObject::OnInteraction(uLayingItemID);
+        v96 = pSpriteObjects[uLayingItemID].uSoundID;
+        pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+        pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+        pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+        pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
+        if ( !v96 )
+          v97 = 0;
+        else
+          v97 = (signed __int16)v96 + 4;
+        v124 = 8 * uLayingItemID;
+        LOBYTE(v124) = v124 | 2;
+        v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
+        pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v97, 0, 0);
+        return 0;
+      }
       if ( pSpriteObjects[uLayingItemID].uType <= 4070 )
       {
         if ( pSpriteObjects[uLayingItemID].uType != 4070 )
@@ -5472,81 +5329,75 @@
             if ( v49 )
             {
               v50 = v49 - 908;
-              if ( !v50 )
-                goto LABEL_93;
+              if ( v49 == 908 )
+              {
+                sub_43A97E(uLayingItemID, a2);
+                ++pSpriteObjects[uLayingItemID].uType;
+                v95 = 0;
+                for ( v52 = 0; v52 < (signed int)pObjectList->uNumObjects; ++v52 )
+                {
+                  if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v52].uObjectID )
+                    v95 = v52;
+                }
+                pSpriteObjects[uLayingItemID].uObjectDescID = v95;
+                if ( !v95 )
+                  SpriteObject::OnInteraction(uLayingItemID);
+                v96 = pSpriteObjects[uLayingItemID].uSoundID;
+                pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+                pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+                pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+                pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
+                if ( !v96 )
+                  v97 = 0;
+                else
+                  v97 = (signed __int16)v96 + 4;
+                v124 = 8 * uLayingItemID;
+                LOBYTE(v124) = v124 | 2;
+                v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
+                pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v97, 0, 0);
+                return 0;
+              }
               v45 = v50 - 30;
               v44 = v45 == 0;
               goto LABEL_91;
             }
-            v54 = pSpriteObjects[uLayingItemID].uType - 1;
-            v55 = pObjectList->uNumObjects;
-            v9 = 0;
-            v56 = 0;
-            v44 = pObjectList->uNumObjects == 0;
-            v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-            pSpriteObjects[uLayingItemID].uType = v54;
-            if ( v20 | v44 )
+            //v9 = 0;
+            pSpriteObjects[uLayingItemID].uType = pSpriteObjects[uLayingItemID].uType - 1;
+            v58 = 0;
+            for ( v56 = 0; v56 < (signed int)pObjectList->uNumObjects; ++v56 )
             {
-LABEL_102:
-              v58 = 0;
-            }
-            else
-            {
-              v57 = (char *)&pObjectList->pObjects->uObjectID;
-              while ( v54 != *(short *)v57 )
-              {
-                ++v56;
-                v57 += 56;
-                if ( v56 >= (signed int)v55 )
-                  goto LABEL_102;
-              }
-              v58 = v56;
+              if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v56].uObjectID )
+                v58 = v56;
             }
             pSpriteObjects[uLayingItemID].uObjectDescID = v58;
             if ( !v58 )
-              SpriteObject::OnInteraction(v153);
+              SpriteObject::OnInteraction(uLayingItemID);
             pSpriteObjects[uLayingItemID].vVelocity.z = 0;
             pSpriteObjects[uLayingItemID].vVelocity.y = 0;
             pSpriteObjects[uLayingItemID].vVelocity.x = 0;
             pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
-            sub_43A97E(v153, v145);
-            if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v9 )
+            sub_43A97E(uLayingItemID, a2);
+            if ( !pSpriteObjects[uLayingItemID].uSoundID )
               v16 = 0;
             else
               v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
-            v124 = 8 * v153;
+            v124 = 8 * uLayingItemID;
             LOBYTE(v124) = v124 | 2;
             v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
-            pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v16, v9, v9);
+            pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v16, 0, 0);
             return 0;
           }
-          v59 = pSpriteObjects[uLayingItemID].uType + 2;
-          v60 = pObjectList->uNumObjects;
-          v9 = 0;
-          v61 = 0;
-          v44 = pObjectList->uNumObjects == 0;
-          v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-          pSpriteObjects[uLayingItemID].uType = v59;
-          if ( v20 | v44 )
+          //v9 = 0;
+          pSpriteObjects[uLayingItemID].uType = pSpriteObjects[uLayingItemID].uType + 2;
+          v63 = 0;
+          for ( v61 = 0; v61 < (signed int)pObjectList->uNumObjects; ++v61 )
           {
-LABEL_111:
-            v63 = 0;
-          }
-          else
-          {
-            v62 = (char *)&pObjectList->pObjects->uObjectID;
-            while ( v59 != *(short *)v62 )
-            {
-              ++v61;
-              v62 += 56;
-              if ( v61 >= (signed int)v60 )
-                goto LABEL_111;
-            }
-            v63 = v61;
+            if ( v59 == pObjectList->pObjects[v61].uObjectID )
+              v63 = v61;
           }
           pSpriteObjects[uLayingItemID].uObjectDescID = v63;
           if ( !v63 )
-            SpriteObject::OnInteraction(v153);
+            SpriteObject::OnInteraction(uLayingItemID);
           v64 = pSpriteObjects[uLayingItemID].uFacing - stru_5C6E00->uIntegerDoublePi;
           v44 = pSpriteObjects[uLayingItemID].spell_skill == 4;
           pSpriteObjects[uLayingItemID].vVelocity.z = 0;
@@ -5560,60 +5411,45 @@
             v141 = v65;
             do
             {
-              v64 += (signed int)stru_5C6E00->uIntegerHalfPi >> 1;
+              v64 += (signed int)stru_5C6E00->uIntegerHalfPi / 2;
               pSpriteObjects[uLayingItemID].Create(v64, 0, 1000, 0);
               --v141;
             }
             while ( v141 );
           }
-          SpriteObject::OnInteraction(v153);
-          if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v9 )
+          SpriteObject::OnInteraction(uLayingItemID);
+          if ( !pSpriteObjects[uLayingItemID].uSoundID )
             v16 = 0;
           else
             v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
-          v124 = 8 * v153;
+          v124 = 8 * uLayingItemID;
           LOBYTE(v124) = v124 | 2;
           v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
-          pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v16, v9, v9);
+          pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v16, 0, 0);
           return 0;
         }
-        if ( v151 == 6 || v151 == 5 || (v66 = 0, !v151) )
+        //v66 = 0;
+        if ( PID_TYPE(a2) == 6 || PID_TYPE(a2) == 5 ||  !PID_TYPE(a2) )
           return 1;
-        v67 = pSpriteObjects[uLayingItemID].uType + 1;
-        v68 = pObjectList->uNumObjects;
-        v69 = 0;
-        v44 = pObjectList->uNumObjects == 0;
-        v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-        pSpriteObjects[uLayingItemID].uType = v67;
-        if ( v20 | v44 )
+        pSpriteObjects[uLayingItemID].uType = pSpriteObjects[uLayingItemID].uType + 1;
+        v71 = 0;
+        for ( v69 = 0; v69 < (signed int)pObjectList->uNumObjects; ++v69 )
         {
-LABEL_128:
-          v71 = 0;
-        }
-        else
-        {
-          v70 = (char *)&pObjectList->pObjects->uObjectID;
-          while ( v67 != *(short *)v70 )
-          {
-            ++v69;
-            v70 += 56;
-            if ( v69 >= (signed int)v68 )
-              goto LABEL_128;
-          }
-          v71 = v69;
+          if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v69].uObjectID )
+            v71 = v69;
         }
         pSpriteObjects[uLayingItemID].uObjectDescID = v71;
         if ( !v71 )
-          SpriteObject::OnInteraction(v153);
+          SpriteObject::OnInteraction(uLayingItemID);
         v134 = 0;
-        v72 = v153;
+        v72 = uLayingItemID;
         v132 = 0;
-        pSpriteObjects[uLayingItemID].vVelocity.z = v66;
-        pSpriteObjects[uLayingItemID].vVelocity.y = v66;
-        pSpriteObjects[uLayingItemID].vVelocity.x = v66;
-        pSpriteObjects[uLayingItemID].uSpriteFrameID = v66;
+        pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+        pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+        pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+        pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
         AttackerInfo.Add(PID(OBJECT_Item,v72), 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v132, v134);
-        if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v66 )
+        if ( !pSpriteObjects[uLayingItemID].uSoundID )
           v78 = 0;
         else
           v78 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
@@ -5623,33 +5459,17 @@
       }
       if ( pSpriteObjects[uLayingItemID].uType == 4090 )
       {
-        v84 = pSpriteObjects[uLayingItemID].uType + 2;
-        v85 = pObjectList->uNumObjects;
-        v9 = 0;
-        v86 = 0;
-        v44 = pObjectList->uNumObjects == 0;
-        v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-        pSpriteObjects[uLayingItemID].uType = v84;
-        if ( v20 | v44 )
+        //v9 = 0;
+        pSpriteObjects[uLayingItemID].uType = pSpriteObjects[uLayingItemID].uType + 2;
+        v88 = 0;
+        for ( v86 = 0; v86 < (signed int)pObjectList->uNumObjects; ++v86 )
         {
-LABEL_155:
-          v88 = 0;
-        }
-        else
-        {
-          v87 = (char *)&pObjectList->pObjects->uObjectID;
-          while ( v84 != *(short *)v87 )
-          {
-            ++v86;
-            v87 += 56;
-            if ( v86 >= (signed int)v85 )
-              goto LABEL_155;
-          }
-          v88 = v86;
+          if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v86].uObjectID )
+            v88 = v86;
         }
         pSpriteObjects[uLayingItemID].uObjectDescID = v88;
         if ( !v88 )
-          SpriteObject::OnInteraction(v153);
+          SpriteObject::OnInteraction(uLayingItemID);
         v89 = pSpriteObjects[uLayingItemID].uFacing - stru_5C6E00->uIntegerDoublePi;
         pSpriteObjects[uLayingItemID].vVelocity.z = 0;
         pSpriteObjects[uLayingItemID].vVelocity.y = 0;
@@ -5667,54 +5487,39 @@
           --v148;
         }
         while ( v148 );
-        SpriteObject::OnInteraction(v153);
-        if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v9 )
+        SpriteObject::OnInteraction(uLayingItemID);
+        if ( !pSpriteObjects[uLayingItemID].uSoundID )
           v16 = 0;
         else
           v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
-        v124 = 8 * v153;
+        v124 = 8 * uLayingItemID;
         LOBYTE(v124) = v124 | 2;
         v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id-1] + 1;
-        pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v16, v9, v9);
+        pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v16, 0, 0);
         return 0;
       }
       if ( pSpriteObjects[uLayingItemID].uType == 4092 )
       {
-        v80 = pObjectList->uNumObjects;
-        v66 = 0;
-        v81 = 0;
-        v44 = pObjectList->uNumObjects == 0;
-        v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
+        //v66 = 0;
         pSpriteObjects[uLayingItemID].uType = 4091;
-        if ( v20 | v44 )
+        v83 = 0;
+        for ( v81 = 0; v81 < (signed int)pObjectList->uNumObjects; ++v81 )
         {
-LABEL_144:
-          v83 = 0;
-        }
-        else
-        {
-          v82 = (char *)&pObjectList->pObjects->uObjectID;
-          while ( *(short *)v82 != 4091 )
-          {
-            ++v81;
-            v82 += 56;
-            if ( v81 >= (signed int)v80 )
-              goto LABEL_144;
-          }
-          v83 = v81;
+          if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v81].uObjectID )
+            v83 = v81;
         }
         pSpriteObjects[uLayingItemID].uObjectDescID = v83;
         if ( !v83 )
-          SpriteObject::OnInteraction(v153);
+          SpriteObject::OnInteraction(uLayingItemID);
         v134 = 0;
-        v72 = v153;
+        v72 = uLayingItemID;
         v132 = pSpriteObjects[uLayingItemID].field_61;
-        pSpriteObjects[uLayingItemID].vVelocity.z = v66;
-        pSpriteObjects[uLayingItemID].vVelocity.y = v66;
-        pSpriteObjects[uLayingItemID].vVelocity.x = v66;
-        pSpriteObjects[uLayingItemID].uSpriteFrameID = v66;
+        pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+        pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+        pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+        pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
         AttackerInfo.Add(PID(OBJECT_Item,v72), 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v132, v134);
-        if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v66 )
+        if ( !pSpriteObjects[uLayingItemID].uSoundID )
           v78 = 0;
         else
           v78 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
@@ -5723,7 +5528,33 @@
         return 0;
       }
       if ( pSpriteObjects[uLayingItemID].uType == 4100 || pSpriteObjects[uLayingItemID].uType == 6010 )
-        goto LABEL_93;
+      {
+        sub_43A97E(uLayingItemID, a2);
+        ++pSpriteObjects[uLayingItemID].uType;
+        v95 = 0;
+        for ( v52 = 0; v52 < (signed int)pObjectList->uNumObjects; ++v52 )
+        {
+          if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v52].uObjectID )
+            v95 = v52;
+        }
+        pSpriteObjects[uLayingItemID].uObjectDescID = v95;
+        if ( !v95 )
+          SpriteObject::OnInteraction(uLayingItemID);
+        v96 = pSpriteObjects[uLayingItemID].uSoundID;
+        pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+        pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+        pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+        pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
+        if ( !v96 )
+          v97 = 0;
+        else
+          v97 = (signed __int16)v96 + 4;
+        v124 = 8 * uLayingItemID;
+        LOBYTE(v124) = v124 | 2;
+        v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
+        pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v97, 0, 0);
+        return 0;
+      }
       v79 = pSpriteObjects[uLayingItemID].uType == 6040;
     }
     if ( !v79 )
@@ -5731,37 +5562,50 @@
     goto LABEL_172;
   }
   if ( pSpriteObjects[uLayingItemID].uType == 3060 )
-    goto LABEL_93;
+  {
+    sub_43A97E(uLayingItemID, a2);
+    ++pSpriteObjects[uLayingItemID].uType;
+    v95 = 0;
+    for ( v52 = 0; v52 < (signed int)pObjectList->uNumObjects; ++v52 )
+    {
+      if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v52].uObjectID )
+        v95 = v52;
+    }
+    pSpriteObjects[uLayingItemID].uObjectDescID = v95;
+    if ( !v95 )
+      SpriteObject::OnInteraction(uLayingItemID);
+    v96 = pSpriteObjects[uLayingItemID].uSoundID;
+    pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+    pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+    pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+    pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
+    if ( !v96 )
+      v97 = 0;
+    else
+      v97 = (signed __int16)v96 + 4;
+    v124 = 8 * uLayingItemID;
+    LOBYTE(v124) = v124 | 2;
+    v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
+    pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v97, 0, 0);
+    return 0;
+  }
   if ( pSpriteObjects[uLayingItemID].uType <= 555 )
   {
     if ( pSpriteObjects[uLayingItemID].uType == 555 )
     {
-      sub_43A97E(v153, v145);
-      v23 = pObjectList->uNumObjects;
+      sub_43A97E(uLayingItemID, a2);
       ++pSpriteObjects[uLayingItemID].uType;
       v18 = 0;
-      v24 = 0;
-      if ( (signed int)v23 <= 0 )
-      {
-LABEL_41:
-        v22 = 0;
-      }
-      else
+      v22 = 0;
+      v25 = (char *)&pObjectList->pObjects->uObjectID;
+      for ( v24 = 0; v24 < (signed int)pObjectList->uNumObjects; ++v24 )
       {
-        v25 = (char *)&pObjectList->pObjects->uObjectID;
-        while ( pSpriteObjects[uLayingItemID].uType != *(short *)v25 )
-        {
-          ++v24;
-          v25 += 56;
-          if ( v24 >= (signed int)v23 )
-            goto LABEL_41;
-        }
-        v22 = v24;
+        if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v24].uObjectID )
+          v22 = v24;
       }
-LABEL_42:
       pSpriteObjects[uLayingItemID].uObjectDescID = v22;
       if ( v22 == v18 )
-        SpriteObject::OnInteraction(v153);
+        SpriteObject::OnInteraction(uLayingItemID);
       pSpriteObjects[uLayingItemID].vVelocity.z = v18;
       pSpriteObjects[uLayingItemID].vVelocity.y = v18;
       pSpriteObjects[uLayingItemID].vVelocity.x = v18;
@@ -5780,18 +5624,29 @@
         case 530:
         case 535:
         case 540:
-          sub_43A97E(v153, v145);
-          v8 = pObjectList->uNumObjects;
+          sub_43A97E(uLayingItemID, a2);
           ++pSpriteObjects[uLayingItemID].uType;
-          v9 = 0;
-          v10 = 0;
-          if ( (signed int)v8 <= 0 )
+          v12 = 0;
+          for ( v10 = 0; v10 < (signed int)pObjectList->uNumObjects; ++v10 )
           {
-            v12 = 0;
-            goto LABEL_24;
+            if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v10].uObjectID )
+              v12 = v10;
           }
-          v11 = (char *)&pObjectList->pObjects->uObjectID;
-          break;
+          pSpriteObjects[uLayingItemID].uObjectDescID = v12;
+          if ( !v12 )
+            SpriteObject::OnInteraction(uLayingItemID);
+          v44 = pSpriteObjects[uLayingItemID].uType == 555;
+          pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+          pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+          pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+          pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
+          if ( !v44 )
+          {
+            v13 = 8 * uLayingItemID;
+            LOBYTE(v13) = PID(OBJECT_Item, uLayingItemID);
+            pAudioPlayer->PlaySound(SOUND_8, v13, 0, -1, 0, 0, 0, 0);
+          }
+          return 0;
         case 545:
         case 550:
           if ( pSpriteObjects[uLayingItemID].stru_24.uItemID != 405 && pSpriteObjects[uLayingItemID].stru_24.uSpecEnchantmentType != 3 )
@@ -5800,54 +5655,46 @@
             pSpriteObjects[uLayingItemID].vVelocity.y = 0;
             pSpriteObjects[uLayingItemID].vVelocity.x = 0;
             pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
-            sub_43A97E(v153, v145);
-            SpriteObject::OnInteraction(v153);
+            sub_43A97E(uLayingItemID, a2);
+            SpriteObject::OnInteraction(uLayingItemID);
             if ( pSpriteObjects[uLayingItemID].uSoundID == 0 )
               v16 = 0;
             else
               v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
-            v124 = 8 * v153;
+            v124 = 8 * uLayingItemID;
             LOBYTE(v124) = v124 | 2;
             v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id] + 1;
             pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v16, 0, 0);
             return 0;
           }
-          v17 = pObjectList->uNumObjects;
           v18 = 0;
-          v19 = 0;
-          v44 = pObjectList->uNumObjects == 0;
-          v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
           pSpriteObjects[uLayingItemID].uType = 600;
-          if ( v20 | v44 )
-            goto LABEL_41;
-          v21 = (char *)&pObjectList->pObjects->uObjectID;
-          while ( *(short *)v21 != 600 )
+          v22 = 0;
+          for ( v19 = 0; v19 < (signed int)pObjectList->uNumObjects; ++v19 )
           {
-            ++v19;
-            v21 += 56;
-            if ( v19 >= (signed int)v17 )
-              goto LABEL_41;
+            if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v19].uObjectID )
+              v22 = v19;
           }
-          v22 = v19;
-          goto LABEL_42;
+          pSpriteObjects[uLayingItemID].uObjectDescID = v22;
+          if ( !v22 )
+            SpriteObject::OnInteraction(uLayingItemID);
+          pSpriteObjects[uLayingItemID].vVelocity.z = v18;
+          pSpriteObjects[uLayingItemID].vVelocity.y = v18;
+          pSpriteObjects[uLayingItemID].vVelocity.x = v18;
+          pSpriteObjects[uLayingItemID].uSpriteFrameID = v18;
         default:
           return 0;
       }
-      while ( pSpriteObjects[uLayingItemID].uType != *(short *)v11 )
+      v12 = 0;
+      for ( v10; v10 < (signed int)v8; ++v10 )
       {
-        ++v10;
         v11 += 56;
-        if ( v10 >= (signed int)v8 )
-        {
-          v12 = 0;
-          goto LABEL_24;
-        }
+        if ( pSpriteObjects[uLayingItemID].uType != *(short *)v11 )
+          v12 = v10;
       }
-      v12 = v10;
-LABEL_24:
       pSpriteObjects[uLayingItemID].uObjectDescID = v12;
       if ( !v12 )
-        SpriteObject::OnInteraction(v153);
+        SpriteObject::OnInteraction(uLayingItemID);
       v44 = pSpriteObjects[uLayingItemID].uType == 555;
       pSpriteObjects[uLayingItemID].vVelocity.z = 0;
       pSpriteObjects[uLayingItemID].vVelocity.y = 0;
@@ -5855,9 +5702,9 @@
       pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
       if ( !v44 )
       {
-        v13 = 8 * v153;
-        LOBYTE(v13) = PID(OBJECT_Item,v153);
-        pAudioPlayer->PlaySound(SOUND_8, v13, v9, -1, v9, v9, v9, v9);
+        v13 = 8 * uLayingItemID;
+        LOBYTE(v13) = PID(OBJECT_Item, uLayingItemID);
+        pAudioPlayer->PlaySound(SOUND_8, v13, 0, -1, 0, 0, 0, 0);
         return 0;
       }
     }
@@ -5872,284 +5719,276 @@
     if ( v42 )
     {
       v43 = v42 - 40;
-      if ( !v43 )
-        goto LABEL_59;
+      if ( v42 == 40 )
+      {
+        if ( PID_TYPE(a2) != 3 )
+        {
+          //v32 = 0;
+          pSpriteObjects[uLayingItemID].uType = pSpriteObjects[uLayingItemID].uType + 1;
+          v46 = 0;
+          for ( v146 = 0; v146 < (signed int)pObjectList->uNumObjects; ++v146 )
+          {
+            if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v146].uObjectID )
+              v46 = v146;
+          }
+          pSpriteObjects[uLayingItemID].uObjectDescID = v46;
+          if ( !v46 )
+            SpriteObject::OnInteraction(uLayingItemID);
+          v100 = pSpriteObjects[uLayingItemID].field_61;
+          pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
+          v102 = 8 * uLayingItemID;
+          LOBYTE(v102) = PID(OBJECT_Item, uLayingItemID);
+          pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+          pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+          pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+          AttackerInfo.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, 0);
+          if (object->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
+            trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, object->uParticleTrailColor);
+          if ( !pSpriteObjects[uLayingItemID].uSoundID )
+            v47 = 0;
+          else
+            v47 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
+          v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
+          pAudioPlayer->PlaySound((SoundID)v125, v102, 0, -1, 0, v47, 0, 0);
+          return 0;
+        }
+        return 1;
+      }
       v45 = v43 - 910;
       v44 = v45 == 0;
 LABEL_91:
       if ( !v44 && v45 != 20 )
         return 0;
     }
-LABEL_93:
-    sub_43A97E(v153, v145);
-    v51 = pObjectList->uNumObjects;
+    sub_43A97E(uLayingItemID, a2);
     ++pSpriteObjects[uLayingItemID].uType;
-    v9 = 0;
-    v52 = 0;
-    if ( (signed int)v51 > 0 )
+    v95 = 0;
+    for ( v52 = 0; v52 < (signed int)pObjectList->uNumObjects; ++v52 )
     {
-      v53 = (char *)&pObjectList->pObjects->uObjectID;
-      while ( pSpriteObjects[uLayingItemID].uType != *(short *)v53 )
-      {
-        ++v52;
-        v53 += 56;
-        if ( v52 >= (signed int)v51 )
-          goto LABEL_181;
-      }
-      v95 = v52;
+      if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v52].uObjectID )
+        v95 = v52;
     }
-	else
-	{
-LABEL_181:
-    v95 = 0;
-	}
     pSpriteObjects[uLayingItemID].uObjectDescID = v95;
-    if ( v95 == (short)v9 )
-      SpriteObject::OnInteraction(v153);
+    if ( !v95 )
+      SpriteObject::OnInteraction(uLayingItemID);
     v96 = pSpriteObjects[uLayingItemID].uSoundID;
-    pSpriteObjects[uLayingItemID].vVelocity.z = v9;
-    pSpriteObjects[uLayingItemID].vVelocity.y = v9;
-    pSpriteObjects[uLayingItemID].vVelocity.x = v9;
-    pSpriteObjects[uLayingItemID].uSpriteFrameID = v9;
-    if ( v96 == (short)v9 )
+    pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+    pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+    pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+    pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
+    if ( !v96 )
       v97 = 0;
     else
       v97 = (signed __int16)v96 + 4;
-    v92 = v153;
+    v124 = 8 * uLayingItemID;
+    LOBYTE(v124) = v124 | 2;
+    v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
+    pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v97, 0, 0);
+    return 0;
+  }
+  if ( pSpriteObjects[uLayingItemID].uType == 1100 )
+  {
+    sub_43A97E(uLayingItemID, a2);
+    ++pSpriteObjects[uLayingItemID].uType;
+    v95 = 0;
+    for ( v52 = 0; v52 < (signed int)pObjectList->uNumObjects; ++v52 )
+    {
+      if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v52].uObjectID )
+        v95 = v52;
+    }
+    pSpriteObjects[uLayingItemID].uObjectDescID = v95;
+    if ( !v95 )
+      SpriteObject::OnInteraction(uLayingItemID);
+    v96 = pSpriteObjects[uLayingItemID].uSoundID;
+    pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+    pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+    pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+    pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
+    if ( !v96 )
+      v97 = 0;
+    else
+      v97 = (signed __int16)v96 + 4;
+    v92 = uLayingItemID;
     v124 = 8 * v92;
     LOBYTE(v124) = v124 | 2;
     v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
-    pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v97, v9, v9);
+    pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v97, 0, 0);
     return 0;
   }
-  if ( pSpriteObjects[uLayingItemID].uType == 1100 )
-    goto LABEL_93;
   v26 = pSpriteObjects[uLayingItemID].uType - 600;
-  if ( !v26 )
+  if ( pSpriteObjects[uLayingItemID].uType == 600 )
   {
-    v33 = pObjectList->uNumObjects;
-    v34 = 0;
-    v44 = pObjectList->uNumObjects == 0;
-    v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
     pSpriteObjects[uLayingItemID].uType = 601;
-    if ( v20 | v44 )
+    v36 = 0;
+    for ( v34 = 0; v34 < (signed int)pObjectList->uNumObjects; ++v34 )
     {
-LABEL_69:
-      v36 = 0;
-    }
-    else
-    {
-      v35 = (char *)&pObjectList->pObjects->uObjectID;
-      while ( *(short *)v35 != 601 )
-      {
-        ++v34;
-        v35 += 56;
-        if ( v34 >= (signed int)v33 )
-          goto LABEL_69;
-      }
-      v36 = v34;
+      if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v34].uObjectID )
+        v36 = v34;
     }
     pSpriteObjects[uLayingItemID].uObjectDescID = v36;
     if ( !v36 )
-      SpriteObject::OnInteraction(v153);
+      SpriteObject::OnInteraction(uLayingItemID);
     v37 = pSpriteObjects[uLayingItemID].vPosition.z;
     pSpriteObjects[uLayingItemID].vVelocity.z = 0;
-    v38 = 8 * v153;
+    v38 = 8 * uLayingItemID;
     v39 = pSpriteObjects[uLayingItemID].vPosition.y;
-    LOBYTE(v38) = PID(OBJECT_Item,v153);
+    LOBYTE(v38) = PID(OBJECT_Item, uLayingItemID);
     pSpriteObjects[uLayingItemID].vVelocity.y = 0;
     pSpriteObjects[uLayingItemID].vVelocity.x = 0;
     v40 = pSpriteObjects[uLayingItemID].vPosition.x;
     pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
     v147 = v38;
     AttackerInfo.Add(v38, 512, v40, v39, v37, 0, 0);
-    if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
-      trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v3->uParticleTrailColor);
+    if (object->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
+      trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, object->uParticleTrailColor);
     pAudioPlayer->PlaySound(SOUND_8, v147, 0, -1, 0, 0, 0, 0);
     return 0;
   }
   v27 = v26 - 410;
-  if ( !v27 )
-    goto LABEL_93;
+  if ( v26 == 410 )
+  {
+    sub_43A97E(uLayingItemID, a2);
+    ++pSpriteObjects[uLayingItemID].uType;
+    v95 = 0;
+    for ( v52 = 0; v52 < (signed int)pObjectList->uNumObjects; ++v52 )
+    {
+      if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v52].uObjectID )
+        v95 = v52;
+    }
+    pSpriteObjects[uLayingItemID].uObjectDescID = v95;
+    if ( !v95 )
+    SpriteObject::OnInteraction(uLayingItemID);
+    v96 = pSpriteObjects[uLayingItemID].uSoundID;
+    pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+    pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+    pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+    pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
+    if ( !v96 )
+      v97 = 0;
+    else
+      v97 = (signed __int16)v96 + 4;
+    v124 = 8 * uLayingItemID;
+    LOBYTE(v124) = v124 | 2;
+    v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
+    pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v97, 0, 0);
+    return 0;
+  }
   v28 = v27 - 40;
   if ( !v28 )
-    goto LABEL_191;
+  {
+    v95 = 0;
+    pSpriteObjects[uLayingItemID].uType = pSpriteObjects[uLayingItemID].uType + 1;
+    for ( v146 = 0; v146 < (signed int)pObjectList->uNumObjects; ++v146 )
+    {
+      if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v146].uObjectID )
+        v95 = v146;
+    }
+    pSpriteObjects[uLayingItemID].uObjectDescID = v95;
+    if ( !v95 )
+      SpriteObject::OnInteraction(uLayingItemID);
+    v100 = pSpriteObjects[uLayingItemID].field_61;
+    pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
+    v102 = 8 * uLayingItemID;
+    LOBYTE(v102) = PID(OBJECT_Item, uLayingItemID);
+    pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+    pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+    pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+    AttackerInfo.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, 0);
+    if (object->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
+      trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, object->uParticleTrailColor);
+    if ( !pSpriteObjects[uLayingItemID].uSoundID )
+      v47 = 0;
+    else
+      v47 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
+    v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
+    pAudioPlayer->PlaySound((SoundID)v125, v102, 0, -1, 0, v47, 0, 0);
+    return 0;
+  }
   v29 = v28 - 10;
   if ( v29 )
   {
     if ( v29 != 20 )
       return 0;
-LABEL_59:
-    if ( v151 != 3 )
+    if ( PID_TYPE(a2) != 3 )
     {
-      v30 = pSpriteObjects[uLayingItemID].uType + 1;
-      v31 = pObjectList->uNumObjects;
-      v32 = 0;
-      pSpriteObjects[uLayingItemID].uType = v30;
-      v146 = 0;
-      if ( (signed int)v31 > 0 )
+      //v32 = 0;
+      pSpriteObjects[uLayingItemID].uType = pSpriteObjects[uLayingItemID].uType + 1;
+      v46 = 0;
+      for ( v146 = 0; v146 < (signed int)pObjectList->uNumObjects; ++v146 )
       {
-        v140 = (char *)&pObjectList->pObjects->uObjectID;
-        while ( v30 != *(short *)v140 )
-        {
-          ++v146;
-          v140 += 56;
-          if ( v146 >= (signed int)v31 )
-          {
-            v46 = 0;
-            pSpriteObjects[uLayingItemID].uObjectDescID = v46;
-            if ( v46 == (short)v32 )
-              SpriteObject::OnInteraction(v153);
-            v100 = pSpriteObjects[uLayingItemID].field_61;
-            pSpriteObjects[uLayingItemID].uSpriteFrameID = v32;
-            v102 = 8 * v153;
-            LOBYTE(v102) = PID(OBJECT_Item,v153);
-            pSpriteObjects[uLayingItemID].vVelocity.x = v32;
-            pSpriteObjects[uLayingItemID].vVelocity.y = v32;
-            pSpriteObjects[uLayingItemID].vVelocity.z = v32;
-            AttackerInfo.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, v32);
-            if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
-              trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v3->uParticleTrailColor);
-            if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v32 )
-              v47 = 0;
-            else
-              v47 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
-            v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
-            pAudioPlayer->PlaySound((SoundID)v125, v102, v32, -1, v32, v47, v32, v32);
-            return 0;
-          }
-        }
-        v46 = v146;
-        pSpriteObjects[uLayingItemID].uObjectDescID = v46;
-        if ( v46 == (short)v32 )
-          SpriteObject::OnInteraction(v153);
-        v100 = pSpriteObjects[uLayingItemID].field_61;
-        pSpriteObjects[uLayingItemID].uSpriteFrameID = v32;
-        v102 = 8 * v153;
-        LOBYTE(v102) = PID(OBJECT_Item,v153);
-        pSpriteObjects[uLayingItemID].vVelocity.x = v32;
-        pSpriteObjects[uLayingItemID].vVelocity.y = v32;
-        pSpriteObjects[uLayingItemID].vVelocity.z = v32;
-        AttackerInfo.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, v32);
-        if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
-          trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v3->uParticleTrailColor);
-        if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v32 )
-          v47 = 0;
-        else
-          v47 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
-        v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
-        pAudioPlayer->PlaySound((SoundID)v125, v102, v32, -1, v32, v47, v32, v32);
-        return 0;
+        if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v146].uObjectID )
+          v46 = v146;
       }
-      v46 = 0;
       pSpriteObjects[uLayingItemID].uObjectDescID = v46;
-      if ( v46 == (short)v32 )
-        SpriteObject::OnInteraction(v153);
+      if ( !v46 )
+        SpriteObject::OnInteraction(uLayingItemID);
       v100 = pSpriteObjects[uLayingItemID].field_61;
-      pSpriteObjects[uLayingItemID].uSpriteFrameID = v32;
-      v102 = 8 * v153;
-      LOBYTE(v102) = PID(OBJECT_Item,v153);
-      pSpriteObjects[uLayingItemID].vVelocity.x = v32;
-      pSpriteObjects[uLayingItemID].vVelocity.y = v32;
-      pSpriteObjects[uLayingItemID].vVelocity.z = v32;
-      AttackerInfo.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, v32);
-      if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
-        trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v3->uParticleTrailColor);
-      if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v32 )
+      pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
+      v102 = 8 * uLayingItemID;
+      LOBYTE(v102) = PID(OBJECT_Item, uLayingItemID);
+      pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+      pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+      pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+      AttackerInfo.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, 0);
+      if (object->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
+        trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, object->uParticleTrailColor);
+      if ( !pSpriteObjects[uLayingItemID].uSoundID )
         v47 = 0;
       else
         v47 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
       v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
-      pAudioPlayer->PlaySound((SoundID)v125, v102, v32, -1, v32, v47, v32, v32);
+      pAudioPlayer->PlaySound((SoundID)v125, v102, 0, -1, 0, v47, 0, 0);
       return 0;
     }
     return 1;
   }
 LABEL_247:
-  if ( v151 == 6 || v151 == 5 || (v9 = 0, !v151) )
+  //v9 = 0;
+  if ( PID_TYPE(a2) == 6 || PID_TYPE(a2) == 5 || !PID_TYPE(a2) )
     return 1;
-  if ( v151 != 2 )
+  if ( PID_TYPE(a2) != 2 )
   {
-    sub_43A97E(v153, v145);
-    v122 = pObjectList->uNumObjects;
+    sub_43A97E(uLayingItemID, a2);
     ++pSpriteObjects[uLayingItemID].uType;
-    v52 = 0;
-    if ( (signed int)v122 > 0 )
+    v95 = 0;
+    for ( v52 = 0; v52 < (signed int)pObjectList->uNumObjects; ++v52 )
     {
-      v123 = (char *)&pObjectList->pObjects->uObjectID;
-      while ( pSpriteObjects[uLayingItemID].uType != *(short *)v123 )
-      {
-        ++v52;
-        v123 += 56;
-        if ( v52 >= (signed int)v122 )
-          goto LABEL_181;
-      }
-      v95 = v52;
-      pSpriteObjects[uLayingItemID].uObjectDescID = v95;
-      if ( v95 == (short)v9 )
-        SpriteObject::OnInteraction(v153);
-      v96 = pSpriteObjects[uLayingItemID].uSoundID;
-      pSpriteObjects[uLayingItemID].vVelocity.z = v9;
-      pSpriteObjects[uLayingItemID].vVelocity.y = v9;
-      pSpriteObjects[uLayingItemID].vVelocity.x = v9;
-      pSpriteObjects[uLayingItemID].uSpriteFrameID = v9;
-      if ( v96 == (short)v9 )
-        v97 = 0;
-      else
-        v97 = (signed __int16)v96 + 4;
-      v92 = v153;
-      v124 = 8 * v92;
-      LOBYTE(v124) = v124 | 2;
-      v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
-      pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v97, v9, v9);
-      return 0;
+      if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v52].uObjectID )
+        v95 = v52;
     }
-    goto LABEL_181;
+    pSpriteObjects[uLayingItemID].uObjectDescID = v95;
+    if ( !v95 )
+      SpriteObject::OnInteraction(uLayingItemID);
+    pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+    pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+    pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+    pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
+    if ( !pSpriteObjects[uLayingItemID].uSoundID )
+      v97 = 0;
+    else
+      v97 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
+    v124 = 8 * uLayingItemID;
+    LOBYTE(v124) = v124 | 2;
+    v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
+    pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v97, 0, 0);
+    return 0;
   }
-  v117 = pSpriteObjects[uLayingItemID].uType + 1;
-  v118 = pObjectList->uNumObjects;
-  v119 = 0;
-  v44 = pObjectList->uNumObjects == 0;
-  v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-  pSpriteObjects[uLayingItemID].uType = v117;
-  if ( v20 | v44 )
-  {
-    v121 = 0;
-  }
-  else
+  pSpriteObjects[uLayingItemID].uType = pSpriteObjects[uLayingItemID].uType + 1;
+  v121 = 0;
+  for ( v119 = 0; v119 < (signed int)pObjectList->uNumObjects; ++v119 )
   {
-    v120 = (char *)&pObjectList->pObjects->uObjectID;
-    while ( v117 != *(short *)v120 )
-    {
-      ++v119;
-      v120 += 56;
-      if ( v119 >= (signed int)v118 )
-      {
-        v121 = 0;
-        pSpriteObjects[uLayingItemID].uObjectDescID = v121;
-        if ( !v121 )
-          SpriteObject::OnInteraction(v153);
-        pSpriteObjects[uLayingItemID].vVelocity.z = 0;
-        pSpriteObjects[uLayingItemID].vVelocity.y = 0;
-        pSpriteObjects[uLayingItemID].vVelocity.x = 0;
-        pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
-        v13 = 8 * v153;
-        LOBYTE(v13) = PID(OBJECT_Item,v153);
-        pAudioPlayer->PlaySound(SOUND_8, v13, v9, -1, v9, v9, v9, v9);
-        return 0;
-      }
-    }
-    v121 = v119;
+    if ( pSpriteObjects[uLayingItemID].uType == pObjectList->pObjects[v119].uObjectID )
+      v121 = v119;
   }
   pSpriteObjects[uLayingItemID].uObjectDescID = v121;
   if ( !v121 )
-    SpriteObject::OnInteraction(v153);
+    SpriteObject::OnInteraction(uLayingItemID);
   pSpriteObjects[uLayingItemID].vVelocity.z = 0;
   pSpriteObjects[uLayingItemID].vVelocity.y = 0;
   pSpriteObjects[uLayingItemID].vVelocity.x = 0;
   pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
-  v13 = 8 * v153;
-  LOBYTE(v13) = PID(OBJECT_Item,v153);
-  pAudioPlayer->PlaySound(SOUND_8, v13, v9, -1, v9, v9, v9, v9);
+  v13 = 8 * uLayingItemID;
+  LOBYTE(v13) = PID(OBJECT_Item,uLayingItemID);
+  pAudioPlayer->PlaySound(SOUND_8, v13, 0, -1, 0, 0, 0, 0);
   return 0;
 }
--- a/mm7_3.cpp	Fri Dec 13 22:19:56 2013 +0600
+++ b/mm7_3.cpp	Mon Dec 16 18:43:42 2013 +0600
@@ -210,7 +210,7 @@
 
   a11 = ecx0;
 
-  BLVFace f; // [sp+Ch] [bp-7Ch]@1
+  BLVFace face; // [sp+Ch] [bp-7Ch]@1
 
   result = 0;
   for ( a10 = 0; a10 < (signed int)pOutdoor->uNumBModels; ++a10 )
@@ -225,51 +225,51 @@
           && 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 )
         {
-          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() )
+          face.pFacePlane_old.vNormal.x = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.x;
+          face.pFacePlane_old.vNormal.y = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.y;
+          face.pFacePlane_old.vNormal.z = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.z;
+          face.pFacePlane_old.dist = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.dist;
+          face.uAttributes = pOutdoor->pBModels[a10].pFaces[v3].uAttributes;
+          face.pBounding.x1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x1;
+          face.pBounding.y1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y1;
+          face.pBounding.z1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z1;
+          face.pBounding.x2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x2;
+          face.pBounding.y2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y2;
+          face.pBounding.z2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z2;
+          face.zCalc1 = pOutdoor->pBModels[a10].pFaces[v3].zCalc1;
+          face.zCalc2 = pOutdoor->pBModels[a10].pFaces[v3].zCalc2;
+          face.zCalc3 = pOutdoor->pBModels[a10].pFaces[v3].zCalc3;
+          face.pXInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pXInterceptDisplacements;
+          face.pYInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pYInterceptDisplacements;
+          face.pZInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pZInterceptDisplacements;
+          face.uPolygonType = (PolygonType)pOutdoor->pBModels[a10].pFaces[v3].uPolygonType;
+          face.uNumVertices = pOutdoor->pBModels[a10].pFaces[v3].uNumVertices;
+          face.uBitmapID = pOutdoor->pBModels[a10].pFaces[v3].uTextureID;
+          face.pVertexIDs = pOutdoor->pBModels[a10].pFaces[v3].pVertexIDs;
+          if ( !face.Ethereal() && !face.Portal() )
           {
-            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;
+            v8 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.normal.x
+                                        + face.pFacePlane_old.vNormal.y * stru_721530.normal.y
+                                        + face.pFacePlane_old.vNormal.z * stru_721530.normal.z ) >> 16;
             if ( v8 > 0 )
             {
-              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;
+              v9 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.normal2.x
+                                          + face.pFacePlane_old.vNormal.y * stru_721530.normal2.y
+                                          + face.pFacePlane_old.vNormal.z * stru_721530.normal2.z) >> 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) )
+                            stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &face, 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,
+                    if ( !sub_475F30( &a2, &face, 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;
@@ -288,21 +288,21 @@
 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;
+              v15 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.position.x
+                                           + face.pFacePlane_old.vNormal.y * stru_721530.position.y
+                                           + face.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;
+                v16 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.field_4C
+                                             + face.pFacePlane_old.vNormal.y * stru_721530.field_50
+                                             + face.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) )
+                             stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &face, a10, a11) )
                     {
                       if ( a2 < stru_721530.field_7C )
                       {
@@ -315,7 +315,7 @@
                     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,
+                      if ( sub_475F30(&a2, &face, 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;
@@ -371,38 +371,32 @@
   int v10; // ecx@12
   int v11; // esi@13
 
-  if ( (signed int)uNumSpriteObjects > 0 )
+  for ( uint i = 0; i < uNumSpriteObjects; ++i )
   {
-    for ( uint i = 0; i < uNumSpriteObjects; ++i )
+    if ( pSpriteObjects[i].uObjectDescID )
     {
-      if ( pSpriteObjects[i].uObjectDescID )
+      object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID];
+      if ( !(object->uFlags & OBJECT_DESC_NO_COLLISION) )
       {
-        object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID];
-        if ( !(object->uFlags & OBJECT_DESC_NO_COLLISION) )
+        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.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 ( 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 )
           {
-            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 )
+            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 )
             {
-              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 )
+              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 )
               {
-                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 )
+                if ( v11 <= object->uHeight + stru_721530.prolly_normal_d + pSpriteObjects[i].vPosition.z )
                 {
-                  if ( v11 <= object->uHeight + stru_721530.prolly_normal_d + pSpriteObjects[i].vPosition.z )
-                  {
-                    if ( v10 < stru_721530.field_7C )
-                      sub_46DEF2(_this, i);
-                  }
+                  if ( v10 < stru_721530.field_7C )
+                    sub_46DEF2(_this, i);
                 }
               }
             }
@@ -416,35 +410,29 @@
 //----- (0046EF01) --------------------------------------------------------
 int _46EF01_collision_chech_player(int a1)
 {
-  int v1; // edx@1
   int result; // eax@1
   int v3; // ebx@7
   int v4; // esi@7
   int v5; // edi@8
   int v6; // ecx@9
   int v7; // edi@12
-  int v8; // [sp+Ch] [bp-10h]@1
-  unsigned int v9; // [sp+10h] [bp-Ch]@1
   int v10; // [sp+14h] [bp-8h]@7
   int v11; // [sp+18h] [bp-4h]@7
 
-  v8 = a1;
-  v1 = 2 * pParty->field_14_radius;
   result = pParty->vPosition.x;
-  v9 = pParty->uPartyHeight;
-  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 )
+  //v9 = pParty->uPartyHeight;
+  if ( stru_721530.sMaxX <= pParty->vPosition.x + (2 * pParty->field_14_radius) && stru_721530.sMinX >= pParty->vPosition.x - (2 * pParty->field_14_radius)
+    && stru_721530.sMaxY <= pParty->vPosition.y + (2 * pParty->field_14_radius) && stru_721530.sMinY >= pParty->vPosition.y - (2 * pParty->field_14_radius)
+    && stru_721530.sMaxZ <= pParty->vPosition.z + pParty->uPartyHeight && stru_721530.sMinZ >= pParty->vPosition.z )
   {
-    v3 = stru_721530.prolly_normal_d + v1;
+    v3 = stru_721530.prolly_normal_d + (2 * pParty->field_14_radius);
     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 ( result <= stru_721530.prolly_normal_d + (2 * pParty->field_14_radius) )
     {
       result = v10 * stru_721530.direction.y;
       v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16;
@@ -454,8 +442,8 @@
         result = pParty->vPosition.z;
         if ( v6 >= pParty->vPosition.z )
         {
-          result = v9 + pParty->vPosition.z;
-          if ( v6 <= (signed int)(v9 + pParty->vPosition.z) || v8 )
+          result = pParty->uPartyHeight + pParty->vPosition.z;
+          if ( v6 <= (signed int)(pParty->uPartyHeight + pParty->vPosition.z) || a1 )
           {
             result = integer_sqrt(v3 * v3 - v4 * v4);
             v7 = v5 - integer_sqrt(v3 * v3 - v4 * v4);
@@ -535,35 +523,13 @@
 //----- (0047050A) --------------------------------------------------------
 int stru141_actor_collision_object::_47050A(int dt)
 {
-  //stru141_actor_collision_object *v2; // esi@1
-  //signed int v3; // eax@1
-  //int v4; // ecx@1
-  //int v5; // edx@1
-  //int v6; // edx@1
   int v7; // eax@1
-  //int v8; // eax@3
   signed int result; // eax@4
-  //int v10; // eax@5
-  //int v11; // eax@5
-  //int v12; // ebx@5
-  //int v13; // edx@5
-  //int v14; // edi@5
-  //int v15; // ecx@5
-  //int v16; // eax@5
   int v17; // eax@5
   int v18; // eax@7
-  //int v19; // edx@9
-  //int v20; // edi@9
   int v21; // eax@9
   int v22; // eax@11
-  //int v23; // edx@13
-  //int v24; // eax@13
-  //int v25; // eax@14
-  //int v26; // eax@16
-  //int v27; // eax@17
-  //int v28; // [sp+14h] [bp+8h]@5
-
-  //v2 = this;
+
   int speed = 1 | integer_sqrt(this->velocity.z * this->velocity.z + this->velocity.y * this->velocity.y + this->velocity.x * this->velocity.x);
 
   this->direction.x = 65536 / speed * this->velocity.x;
@@ -681,7 +647,6 @@
   int v71; // [sp+38h] [bp-18h]@62
   int uIsAboveFloor; // [sp+3Ch] [bp-14h]@10
   int v72b;
-  //int v73; // [sp+40h] [bp-10h]@17
   int uIsFlying; // [sp+44h] [bp-Ch]@8
   unsigned int v75; // [sp+48h] [bp-8h]@1
   int uIsOnWater; // [sp+4Ch] [bp-4h]@10
@@ -997,14 +962,10 @@
 void UpdateObjects()
 {
   unsigned int v0; // ebx@0
-  //unsigned int v1; // edi@1
-  //char *v2; // esi@2
-  //__int16 v3; // dx@5
   ObjectDesc *object; // eax@5
   int v5; // ecx@6
   __int16 v6; // cx@7
   signed int v7; // eax@9
-  //unsigned int v10; // ecx@16
   signed int v11; // eax@17
   int v12; // edi@27
   int v13; // eax@27
@@ -1014,103 +975,94 @@
   unsigned int v17; // edx@32
   int v18; // [sp+4h] [bp-10h]@27
   int v19; // [sp+8h] [bp-Ch]@27
-  //signed int v20; // [sp+10h] [bp-4h]@1
-
-  //v1 = 0;
-  //v20 = 0;
+
   for (uint i = 0; i < uNumSpriteObjects; ++i)
   {
-    SpriteObject* item = &pSpriteObjects[i];
-    //v2 = (char *)&item->uSpriteFrameID;
-    //do
-    //{
-      //LOWORD(v0) = item->uAttributes;
-    if (item->uAttributes & OBJECT_40)
-      item->uAttributes &= ~OBJECT_40;
+    if (pSpriteObjects[i].uAttributes & OBJECT_40)
+      pSpriteObjects[i].uAttributes &= ~OBJECT_40;
     else
     {
-      object = &pObjectList->pObjects[item->uObjectDescID];
-      if (item->AttachedToActor())
+      object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID];
+      if (pSpriteObjects[i].AttachedToActor())
       {
-          v5 = PID_ID(item->spell_target_pid);
-          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 )
-            continue;
-          item->uSpriteFrameID += pEventTimer->uTimeElapsed;
-          if ( !(object->uFlags & OBJECT_DESC_TEMPORARY))
-            continue;
-          if ( item->uSpriteFrameID >= 0 )
-          {
-            v7 = object->uLifetime;
-            if (item->uAttributes & ITEM_BROKEN)
-              v7 = item->field_20;
-            if ( item->uSpriteFrameID < v7 )
-              continue;
-          }
-          SpriteObject::OnInteraction(i);
+        v5 = PID_ID(pSpriteObjects[i].spell_target_pid);
+        pSpriteObjects[i].vPosition.x = pActors[v5].vPosition.x;
+        pSpriteObjects[i].vPosition.y = pActors[v5].vPosition.y;
+        pSpriteObjects[i].vPosition.z = pActors[v5].vPosition.z + pActors[v5].uActorHeight;
+        if ( !pSpriteObjects[i].uObjectDescID )
           continue;
-      }
-
-        if ( item->uObjectDescID )
+        pSpriteObjects[i].uSpriteFrameID += pEventTimer->uTimeElapsed;
+        if ( !(object->uFlags & OBJECT_DESC_TEMPORARY))
+          continue;
+        if ( pSpriteObjects[i].uSpriteFrameID >= 0 )
         {
-          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);
-            else
-              SpriteObject::UpdateObject_fn0_ODM(i);
-			if ( pParty->bTurnBasedModeOn != 1 || !(item->uSectorID & 4) )
-              continue;
-			v12 = abs(pParty->vPosition.x - item->vPosition.x);
-			v18 = abs(pParty->vPosition.y - item->vPosition.y);
-			v19 = abs(pParty->vPosition.z - item->vPosition.z);
-            v13 = v12;
-            v14 = v18;
-            v15 = v19;
-            if ( v12 < v18 )
-            {
-              v13 = v18;
-              v14 = v12;
-            }
-            if ( v13 < v19 )
-            {
-              v16 = v13;
-              v13 = v19;
-              v15 = v16;
-            }
-            if ( v14 < (signed int)v15 )
-            {
-              v17 = v15;
-              v15 = v14;
-              v14 = v17;
-            }
-            v0 = (unsigned int)(11 * v14) >> 5;
-            if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 )
-              continue;
-            SpriteObject::OnInteraction(i);
-            continue;
-          }
-          if ( !(object->uFlags & OBJECT_DESC_INTERACTABLE) )
+          v7 = object->uLifetime;
+          if (pSpriteObjects[i].uAttributes & ITEM_BROKEN)
+             v7 = pSpriteObjects[i].field_20;
+          if ( pSpriteObjects[i].uSpriteFrameID < v7 )
+             continue;
+        }
+        SpriteObject::OnInteraction(i);
+        continue;
+      }
+      if ( pSpriteObjects[i].uObjectDescID )
+      {
+        pSpriteObjects[i].uSpriteFrameID += pEventTimer->uTimeElapsed;
+        if ( object->uFlags & OBJECT_DESC_TEMPORARY )
+        {
+          if ( pSpriteObjects[i].uSpriteFrameID < 0 )
           {
             SpriteObject::OnInteraction(i);
             continue;
           }
-          _46BFFA_check_object_intercept(i, PID(OBJECT_Item,i));
+          v11 = object->uLifetime;
+          if (pSpriteObjects[i].uAttributes & ITEM_BROKEN)
+            v11 = pSpriteObjects[i].field_20;
         }
+        if ( !(object->uFlags & OBJECT_DESC_TEMPORARY) || pSpriteObjects[i].uSpriteFrameID < v11 )
+        {
+          if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+            SpriteObject::UpdateObject_fn0_BLV(i);
+          else
+            SpriteObject::UpdateObject_fn0_ODM(i);
+          if ( pParty->bTurnBasedModeOn != 1 || !(pSpriteObjects[i].uSectorID & 4) )
+            continue;
+          v12 = abs(pParty->vPosition.x - pSpriteObjects[i].vPosition.x);
+          v18 = abs(pParty->vPosition.y - pSpriteObjects[i].vPosition.y);
+          v19 = abs(pParty->vPosition.z - pSpriteObjects[i].vPosition.z);
+          v13 = v12;
+          v14 = v18;
+          v15 = v19;
+          if ( v12 < v18 )
+          {
+            v13 = v18;
+            v14 = v12;
+          }
+          if ( v13 < v19 )
+          {
+            v16 = v13;
+            v13 = v19;
+            v15 = v16;
+          }
+          if ( v14 < (signed int)v15 )
+          {
+            v17 = v15;
+            v15 = v14;
+            v14 = v17;
+          }
+          v0 = (unsigned int)(11 * v14) >> 5;
+          if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 )
+            continue;
+          SpriteObject::OnInteraction(i);
+          continue;
+        }
+        if ( !(object->uFlags & OBJECT_DESC_INTERACTABLE) )
+        {
+          SpriteObject::OnInteraction(i);
+          continue;
+        }
+        _46BFFA_check_object_intercept(i, PID(OBJECT_Item,i));
+      }
     }
   }
 }
@@ -1118,32 +1070,26 @@
 //----- (0047272C) --------------------------------------------------------
 int collide_against_floor_approximate(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID)
 {
-  signed int v5; // ebx@1
   int result; // eax@1
-  int v7; // [sp+10h] [bp-8h]@1
-  signed int v8; // [sp+14h] [bp-4h]@1
-
-  v5 = x - 2;
-  v7 = x;
-  v8 = y;
+
   *pSectorID = pIndoor->GetSector(x - 2, y, z + 40);
-  result = collide_against_floor(v5, v8, z + 40, pSectorID, pFaceID);
+  result = collide_against_floor(x - 2, y, z + 40, pSectorID, pFaceID);
   if ( result == -30000 || !*pSectorID )
   {
-    *pSectorID = pIndoor->GetSector(v7 + 2, v8, z + 40);
-    result = collide_against_floor(v7 + 2, v8, z + 40, pSectorID, pFaceID);
+    *pSectorID = pIndoor->GetSector(x + 2, y, z + 40);
+    result = collide_against_floor(x + 2, y, z + 40, pSectorID, pFaceID);
     if ( result == -30000 || !*pSectorID )
     {
-      *pSectorID = pIndoor->GetSector(v7, v8 - 2, z + 40);
-      result = collide_against_floor(v7, v8 - 2, z + 40, pSectorID, pFaceID);
+      *pSectorID = pIndoor->GetSector(x, y - 2, z + 40);
+      result = collide_against_floor(x, y - 2, z + 40, pSectorID, pFaceID);
       if ( result == -30000 || !*pSectorID )
       {
-        *pSectorID = pIndoor->GetSector(v7, v8 + 2, z + 40);
-        result = collide_against_floor(v7, v8 + 2, z + 40, pSectorID, pFaceID);
+        *pSectorID = pIndoor->GetSector(x, y + 2, z + 40);
+        result = collide_against_floor(x, y + 2, z + 40, pSectorID, pFaceID);
         if ( result == -30000 || !*pSectorID )
         {
-          *pSectorID = pIndoor->GetSector(v7, v8, z + 140);
-          result = collide_against_floor(v7, v8, z + 140, pSectorID, pFaceID);
+          *pSectorID = pIndoor->GetSector(x, y, z + 140);
+          result = collide_against_floor(x, y, z + 140, pSectorID, pFaceID);
         }
       }
     }
@@ -1272,25 +1218,9 @@
 }
 
 //----- (00475665) --------------------------------------------------------
-int sub_475665(BLVFace *_this, int a2, __int16 a3)
+int sub_475665(BLVFace *face, int a2, __int16 a3)
 {
-  unsigned int v3; // eax@1
-  Vec3_short_ *v4; // edx@3
-  signed int v5; // eax@4
-  int v6; // esi@4
-  signed int v7; // eax@7
-  Vec3_short_ *v8; // edx@8
-  signed int v9; // eax@9
-  int v10; // esi@9
-  signed int v11; // eax@11
-  Vec3_short_ *v12; // edx@12
-  signed int v13; // eax@13
-  int v14; // esi@13
-  int v15; // esi@14
   bool v16; // edi@14
-  int v17; // ecx@16
-  signed int v18; // edx@16
-  int v19; // eax@17
   signed int v20; // ebx@18
   int v21; // edi@20
   signed int v22; // ST14_4@22
@@ -1304,113 +1234,86 @@
   signed int v30; // [sp+30h] [bp+Ch]@11
   signed int v31; // [sp+30h] [bp+Ch]@14
 
-  v3 = _this->uAttributes;
-  if ( BYTE1(v3) & 1 )
+  if ( face->uAttributes & FACE_XY_PLANE )
   {
-    v28 = 0;
     v26 = (signed __int16)a2;
     v27 = SHIWORD(a2);
-    if ( _this->uNumVertices )
+    if ( face->uNumVertices )
     {
-      v4 = pIndoor->pVertices;
-      do
+      for ( v28 = 0; v28 < face->uNumVertices; v28++ )
       {
-        v5 = v28;
-        v6 = 2 * v28;
-        word_720C10_intercepts_xs[2 * v28] = _this->pXInterceptDisplacements[v28] + v4[_this->pVertexIDs[v28]].x;
-        word_720B40_intercepts_zs[2 * v28] = _this->pYInterceptDisplacements[v5] + v4[_this->pVertexIDs[v5]].y;
-        word_720C10_intercepts_xs[2 * v28++ + 1] = _this->pXInterceptDisplacements[v5 + 1]
-                                                 + v4[_this->pVertexIDs[v5 + 1]].x;
-        word_720B40_intercepts_zs[v6 + 1] = _this->pYInterceptDisplacements[v5 + 1] + v4[_this->pVertexIDs[v5 + 1]].y;
+        word_720C10_intercepts_xs[2 * v28] = face->pXInterceptDisplacements[v28] + pIndoor->pVertices[face->pVertexIDs[v28]].x;
+        word_720B40_intercepts_zs[2 * v28] = face->pYInterceptDisplacements[v28] + pIndoor->pVertices[face->pVertexIDs[v28]].y;
+        word_720C10_intercepts_xs[2 * v28 + 1] = face->pXInterceptDisplacements[v28 + 1] + pIndoor->pVertices[face->pVertexIDs[v28 + 1]].x;
+        word_720B40_intercepts_zs[2 * v28 + 1] = face->pYInterceptDisplacements[v28 + 1] + pIndoor->pVertices[face->pVertexIDs[v28 + 1]].y;
       }
-      while ( v28 < _this->uNumVertices );
     }
   }
   else
   {
-    if ( BYTE1(v3) & 2 )
+    if ( face->uAttributes & FACE_XZ_PLANE )
     {
       v26 = (signed __int16)a2;
-      v7 = a3;
-      v29 = 0;
-      v27 = v7;
-      if ( _this->uNumVertices )
+      v27 = a3;
+      if ( face->uNumVertices )
       {
-        v8 = pIndoor->pVertices;
-        do
+        for ( v29 = 0; v29 < face->uNumVertices; v29++ )
         {
-          v9 = v29;
-          v10 = 2 * v29;
-          word_720C10_intercepts_xs[2 * v29] = _this->pXInterceptDisplacements[v29] + v8[_this->pVertexIDs[v29]].x;
-          word_720B40_intercepts_zs[2 * v29] = _this->pZInterceptDisplacements[v9] + v8[_this->pVertexIDs[v9]].z;
-          word_720C10_intercepts_xs[2 * v29++ + 1] = _this->pXInterceptDisplacements[v9 + 1] + v8[_this->pVertexIDs[v9 + 1]].x;
-          word_720B40_intercepts_zs[v10 + 1] = _this->pZInterceptDisplacements[v9 + 1] + v8[_this->pVertexIDs[v9 + 1]].z;
+          word_720C10_intercepts_xs[2 * v29] = face->pXInterceptDisplacements[v29] + pIndoor->pVertices[face->pVertexIDs[v29]].x;
+          word_720B40_intercepts_zs[2 * v29] = face->pZInterceptDisplacements[v29] + pIndoor->pVertices[face->pVertexIDs[v29]].z;
+          word_720C10_intercepts_xs[2 * v29 + 1] = face->pXInterceptDisplacements[v29 + 1] + pIndoor->pVertices[face->pVertexIDs[v29 + 1]].x;
+          word_720B40_intercepts_zs[2 * v29 + 1] = face->pZInterceptDisplacements[v29 + 1] + pIndoor->pVertices[face->pVertexIDs[v29 + 1]].z;
         }
-        while ( v29 < _this->uNumVertices );
       }
     }
     else
     {
       v26 = SHIWORD(a2);
-      v11 = a3;
-      v30 = 0;
-      v27 = v11;
-      if ( _this->uNumVertices )
+      v27 = a3;
+      if ( face->uNumVertices )
       {
-        v12 = pIndoor->pVertices;
-        do
+        for ( v30 = 0; v30 < face->uNumVertices; v30++ )
         {
-          v13 = v30;
-          v14 = 2 * v30;
-          word_720C10_intercepts_xs[2 * v30] = _this->pYInterceptDisplacements[v30] + v12[_this->pVertexIDs[v30]].y;
-          word_720B40_intercepts_zs[2 * v30] = _this->pZInterceptDisplacements[v13] + v12[_this->pVertexIDs[v13]].z;
-          word_720C10_intercepts_xs[2 * v30++ + 1] = _this->pYInterceptDisplacements[v13 + 1] + v12[_this->pVertexIDs[v13 + 1]].y;
-          word_720B40_intercepts_zs[v14 + 1] = _this->pZInterceptDisplacements[v13 + 1] + v12[_this->pVertexIDs[v13 + 1]].z;
+          word_720C10_intercepts_xs[2 * v30] = face->pYInterceptDisplacements[v30] + pIndoor->pVertices[face->pVertexIDs[v30]].y;
+          word_720B40_intercepts_zs[2 * v30] = face->pZInterceptDisplacements[v30] + pIndoor->pVertices[face->pVertexIDs[v30]].z;
+          word_720C10_intercepts_xs[2 * v30 + 1] = face->pYInterceptDisplacements[v30 + 1] + pIndoor->pVertices[face->pVertexIDs[v30 + 1]].y;
+          word_720B40_intercepts_zs[2 * v30 + 1] = face->pZInterceptDisplacements[v30 + 1] + pIndoor->pVertices[face->pVertexIDs[v30 + 1]].z;
         }
-        while ( v30 < _this->uNumVertices );
       }
     }
   }
-  v15 = 2 * _this->uNumVertices;
   v31 = 0;
-  word_720C10_intercepts_xs[2 * _this->uNumVertices] = word_720C10_intercepts_xs[0];
-  word_720B40_intercepts_zs[v15] = word_720B40_intercepts_zs[0];
-  v25 = 0;
+  word_720C10_intercepts_xs[2 * face->uNumVertices] = word_720C10_intercepts_xs[0];
+  word_720B40_intercepts_zs[2 * face->uNumVertices] = word_720B40_intercepts_zs[0];
   v16 = word_720B40_intercepts_zs[0] >= v27;
-  if ( v15 <= 0 )
+  if ( 2 * face->uNumVertices <= 0 )
     return 0;
-  do
+  for ( v25 = 0; v25 < 2 * face->uNumVertices; ++v25 )
   {
     if ( v31 >= 2 )
       break;
-    v17 = v25;
-    v18 = word_720B40_intercepts_zs[v25 + 1];
-    if ( v16 ^ (v18 >= v27) )
+    if ( v16 ^ (word_720B40_intercepts_zs[v25 + 1] >= v27) )
     {
-      v19 = word_720C10_intercepts_xs[v17 + 1];
-      if ( v19 >= v26 )
+      if ( word_720C10_intercepts_xs[v25 + 1] >= v26 )
         v20 = 0;
       else
         v20 = 2;
-      v21 = v20 | (word_720C10_intercepts_xs[v17] < v26);
+      v21 = v20 | (word_720C10_intercepts_xs[v25] < v26);
       if ( v21 != 3 )
       {
+        v22 = word_720C10_intercepts_xs[v25 + 1] - word_720C10_intercepts_xs[v25];
+        LODWORD(v23) = v22 << 16;
+        HIDWORD(v23) = v22 >> 16;
         if ( !v21
-          || (v22 = v19 - word_720C10_intercepts_xs[v17],
-              LODWORD(v23) = v22 << 16,
-              HIDWORD(v23) = v22 >> 16,
-              word_720C10_intercepts_xs[v17]
-            + ((signed int)(((unsigned __int64)(v23
-                                              / (v18 - word_720B40_intercepts_zs[v17])
-                                              * ((v27 - (signed int)word_720B40_intercepts_zs[v17]) << 16)) >> 16)
-                          + 32768) >> 16) >= v26) )
+          || (word_720C10_intercepts_xs[v25] + ((signed int)(((unsigned __int64)(v23
+           / (word_720B40_intercepts_zs[v25 + 1] - word_720B40_intercepts_zs[v25])
+           * ((v27 - (signed int)word_720B40_intercepts_zs[v25]) << 16)) >> 16)
+               + 32768) >> 16) >= v26) )
           ++v31;
       }
     }
-    ++v25;
-    v16 = v18 >= v27;
+    v16 = word_720B40_intercepts_zs[v25 + 1] >= v27;
   }
-  while ( v25 < v15 );
   result = 1;
   if ( v31 != 1 )
     result = 0;
@@ -1418,20 +1321,9 @@
 }
 
 //----- (004759C9) --------------------------------------------------------
-bool __fastcall sub_4759C9(BLVFace *a1, int a2, int a3, __int16 a4)
+bool __fastcall sub_4759C9(BLVFace *face, int a2, int a3, __int16 a4)
 {
-  //unsigned int v4; // eax@1
-  //int v5; // edx@4
-  __int16 v6; // si@4
-  //int v7; // edx@9
-  __int16 v8; // si@9
-  //int v9; // edx@13
-  __int16 v10; // si@13
-  int v11; // esi@14
   bool v12; // edi@14
-  int v13; // ecx@16
-  signed int v14; // edx@16
-  int v15; // eax@17
   signed int v16; // ebx@18
   int v17; // edi@20
   signed int v18; // ST14_4@22
@@ -1441,113 +1333,88 @@
   signed int v22; // [sp+18h] [bp-Ch]@1
   int v23; // [sp+1Ch] [bp-8h]@2
   signed int v24; // [sp+20h] [bp-4h]@2
-  Vec3_int_ **a4a; // [sp+30h] [bp+Ch]@3
-  Vec3_int_ **a4b; // [sp+30h] [bp+Ch]@8
-  Vec3_int_ **a4c; // [sp+30h] [bp+Ch]@12
   signed int a4d; // [sp+30h] [bp+Ch]@14
 
-  //v4 = a1->uAttributes;
-  v22 = 0;
-  if ( BYTE1(a1->uAttributes) & 1 )
+  if ( face->uAttributes & FACE_XY_PLANE )
   {
     v23 = (signed __int16)a3;
     v24 = SHIWORD(a3);
-    if ( a1->uNumVertices )
+    if ( face->uNumVertices )
     {
-      a4a = &pOutdoor->pBModels[a2].pVertices.pVertices;
-      do
+      for ( v22 = 0; v22 < face->uNumVertices; ++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[2 * v22 + 1] = v6 = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].y);
-        ++v22;
+        word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pXInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].x);
+        word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pYInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].y);
+        word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pXInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].x);
+        word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pYInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].y);
       }
-      while ( v22 < a1->uNumVertices );
     }
   }
   else
   {
-    if ( BYTE1(a1->uAttributes) & 2 )
+    if ( face->uAttributes & FACE_XZ_PLANE )
     {
       v23 = (signed __int16)a3;
       v24 = a4;
-      if ( a1->uNumVertices )
+      if ( face->uNumVertices )
       {
-        a4b = &pOutdoor->pBModels[a2].pVertices.pVertices;
-        do
+        for ( v22 = 0; v22 < face->uNumVertices; ++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[2 * v22 + 1] = v8 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].z);
-          ++v22;
+          word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pXInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].x);
+          word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pZInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].z);
+          word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pXInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].x);
+          word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pZInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].z);
         }
-        while ( v22 < a1->uNumVertices );
       }
     }
     else
     {
       v23 = SHIWORD(a3);
       v24 = a4;
-      if ( a1->uNumVertices )
+      if ( face->uNumVertices )
       {
-        a4c = &pOutdoor->pBModels[a2].pVertices.pVertices;
-        do
+        for ( v22 = 0; v22 < face->uNumVertices; ++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[2 * v22 + 1] = v10 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].z);
-          ++v22;
+          word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pYInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].y);
+          word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pZInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].z);
+          word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pYInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].y);
+          word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pZInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].z);
         }
-        while ( v22 < a1->uNumVertices );
       }
     }
   }
-  v11 = 2 * a1->uNumVertices;
   a4d = 0;
-  word_720A70_intercepts_xs_plus_xs[2 * a1->uNumVertices] = word_720A70_intercepts_xs_plus_xs[0];
-  word_7209A0_intercepts_ys_plus_ys[v11] = word_7209A0_intercepts_ys_plus_ys[0];
-  v21 = 0;
+  word_720A70_intercepts_xs_plus_xs[2 * face->uNumVertices] = word_720A70_intercepts_xs_plus_xs[0];
+  word_7209A0_intercepts_ys_plus_ys[2 * face->uNumVertices] = word_7209A0_intercepts_ys_plus_ys[0];
   v12 = word_7209A0_intercepts_ys_plus_ys[0] >= v24;
-  if ( v11 <= 0 )
+  if ( 2 * face->uNumVertices <= 0 )
     return 0;
-  do
+  for ( v21 = 0; v21 < 2 * face->uNumVertices; ++v21 )
   {
     if ( a4d >= 2 )
       break;
-    v13 = v21;
-    v14 = word_7209A0_intercepts_ys_plus_ys[v21 + 1];
-    if ( v12 ^ (v14 >= v24) )
+    if ( v12 ^ (word_7209A0_intercepts_ys_plus_ys[v21 + 1] >= v24) )
     {
-      v15 = word_720A70_intercepts_xs_plus_xs[v13 + 1];
-      if ( v15 >= v23 )
+      if ( word_720A70_intercepts_xs_plus_xs[v21 + 1] >= v23 )
         v16 = 0;
       else
         v16 = 2;
-      v17 = v16 | (word_720A70_intercepts_xs_plus_xs[v13] < v23);
+      v17 = v16 | (word_720A70_intercepts_xs_plus_xs[v21] < v23);
       if ( v17 != 3 )
       {
+        v18 = word_720A70_intercepts_xs_plus_xs[v21 + 1] - word_720A70_intercepts_xs_plus_xs[v21];
+        LODWORD(v19) = v18 << 16;
+        HIDWORD(v19) = v18 >> 16;
         if ( !v17
-          || (v18 = v15 - word_720A70_intercepts_xs_plus_xs[v13],
-              LODWORD(v19) = v18 << 16,
-              HIDWORD(v19) = v18 >> 16,
-              word_720A70_intercepts_xs_plus_xs[v13]
-            + ((signed int)(((unsigned __int64)(v19
-                                              / (v14 - word_7209A0_intercepts_ys_plus_ys[v13])
-                                              * ((v24 - (signed int)word_7209A0_intercepts_ys_plus_ys[v13]) << 16)) >> 16)
-                          + 32768) >> 16) >= v23) )
+          || (word_720A70_intercepts_xs_plus_xs[v21] + ((signed int)(((unsigned __int64)(v19
+              / (word_7209A0_intercepts_ys_plus_ys[v21 + 1] - word_7209A0_intercepts_ys_plus_ys[v21])
+              * ((v24 - (signed int)word_7209A0_intercepts_ys_plus_ys[v21]) << 16)) >> 16)
+              + 32768) >> 16) >= v23) )
           ++a4d;
       }
     }
-    ++v21;
-    v12 = v14 >= v24;
+    v12 = word_7209A0_intercepts_ys_plus_ys[v21 + 1] >= v24;
   }
-  while ( v21 < v11 );
   result = 1;
   if ( a4d != 1 )
     result = 0;
@@ -1617,24 +1484,19 @@
 //----- (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
   int v10; // ST20_4@2
   int v11; // ST28_4@2
   int v12; // ST24_4@2
   char v13; // zf@2
   int v14; // edi@2
-  int v15; // eax@5
   signed int v16; // esi@5
   int v17; // ST20_4@9
   signed __int64 v18; // qtt@10
   int v19; // ST14_4@11
-  //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 ( 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,
@@ -1645,11 +1507,10 @@
         v13)
     || v14 > 0 && !a2->Portal())
     return 0;
-  v15 = a4 * a2->pFacePlane_old.vNormal.y;
-  v16 = -(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z);
+  v16 = -(a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z);
   if ( v14 <= 0 )
   {
-    if ( a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z < 0 )
+    if ( a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z < 0 )
       return 0;
   }
   else
@@ -1657,7 +1518,7 @@
     if ( v16 < 0 )
       return 0;
   }
-  v17 = abs(-(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z)) >> 14;
+  v17 = abs(-(a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + 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 > *a1 << 16)
     || (LOWORD(v19) = a3 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a6) >> 16) + 32768) >> 16),
@@ -1726,6 +1587,7 @@
   float v39; // [sp+D0h] [bp-8h]@6
   int *v40; // [sp+D4h] [bp-4h]@2
 
+  __debugbreak();//нужно почистить
   v2 = (char *)&this->field_64[4 * this->uNumVertices];
   v38 = 0;
   *(int *)v2 = this->field_64[0];
@@ -1873,6 +1735,7 @@
   float v39; // [sp+D0h] [bp-8h]@6
   int *v40; // [sp+D4h] [bp-4h]@2
 
+  __debugbreak();//нужно почистить
   v2 = (char *)&this->field_64[4 * this->uNumVertices];
   v38 = 0;
   *(int *)v2 = this->field_64[0];
@@ -2022,7 +1885,7 @@
   float v41; // [sp+2Ch] [bp-4h]@6
   float v42; // [sp+2Ch] [bp-4h]@9
 
-  //v1 = this;
+  __debugbreak();//нужно почистить
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
   {
     v2 = 0;
@@ -2133,7 +1996,6 @@
 bool stru6_stru1_indoor_sw_billboard::sub_477F63()
 {
   signed int v1; // ebx@1
-  stru6_stru1_indoor_sw_billboard *v2; // esi@1
   double v3; // st7@2
   int v4; // edx@4
   char *v5; // ecx@5
@@ -2142,10 +2004,8 @@
   signed int v9; // [sp+Ch] [bp-8h]@1
   float v10; // [sp+10h] [bp-4h]@2
 
-  stru6_stru1_indoor_sw_billboard* a1 = this;
-
+  __debugbreak();//где используется ф-ция sw или hw?
   v1 = 0;
-  v2 = a1;
   v9 = 0;
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
   {
@@ -2157,15 +2017,14 @@
     v10 = (double)pODMRenderParams->shading_dist_mist;
     v3 = 8.0;
   }
-  v4 = a1->uNumVertices;
+  v4 = this->uNumVertices;
   if ( v4 <= 0 )
   {
-    memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4);
-    return v2->uNumVertices != 0;
+    memcpy(&this->field_14[40], &this->field_14[20], 16 * v4);
+    return this->uNumVertices != 0;
   }
-  v5 = (char *)&a1->field_14[20];
-  v6 = v4;
-  do
+  v5 = (char *)&this->field_14[20];
+  for ( v6 = v4; v6; --v6 )
   {
     if ( v3 >= *(float *)v5 || *(float *)v5 >= (double)v10 )
     {
@@ -2175,81 +2034,68 @@
         v1 = 1;
     }
     v5 += 16;
-    --v6;
   }
-  while ( v6 );
   if ( !v1 )
   {
     if ( v9 )
     {
-      v2->_477927(v10);
-      return v2->uNumVertices != 0;
+      this->_477927(v10);
+      return this->uNumVertices != 0;
     }
-    memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4);
-    return v2->uNumVertices != 0;
+    memcpy(&this->field_14[40], &this->field_14[20], 16 * v4);
+    return this->uNumVertices != 0;
   }
   v7 = v3;
   _4775ED(v7);
-  return v2->uNumVertices != 0;
+  return this->uNumVertices != 0;
 }
 
 //----- (0047802A) --------------------------------------------------------
 int stru6_stru1_indoor_sw_billboard::sub_47802A()
 {
   double v6; // st7@4
-  double v12; // st7@16
   signed int v16; // [sp+38h] [bp-Ch]@1
   int a6; // [sp+3Ch] [bp-8h]@5
   int a5; // [sp+40h] [bp-4h]@5
 
-  stru6_stru1_indoor_sw_billboard* a1 = this;
-
+  __debugbreak(); //необходимо проверить this->field_B4[i*4+16]
   v16 = 0;
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
   {
-	for(int i = 0; i < a1->uNumVertices; i++)
+    for(int i = 0; i < this->uNumVertices; i++)
     {
-		v6 = (double)pBLVRenderParams->fov_rad_fixpoint * 0.000015258789 / a1->field_B4[i*4];
-		if ( pRenderer->pRenderD3D )
-		{
-			pGame->pIndoorCameraD3D->Project(
-				round(a1->field_B4[i*4]),
-				round(a1->field_B4[i*4+1]),
-				round(a1->field_B4[i*4+2]),
-				&a5,
-				&a6);
-			a1->field_B4[i*4+16] = (double)a5;
-			a1->field_B4[i*4+17] = (double)a6;
-			a1->field_B4[i*4+18] = round(a1->field_B4[i*4]);
-		}
-		else
-		{
-			a1->field_B4[i*4+16] = (double)pBLVRenderParams->uViewportCenterX - v6 * a1->field_B4[i*4+1];
-			a1->field_B4[i*4+17] = (double)pBLVRenderParams->uViewportCenterY - v6 * a1->field_B4[i*4+2];
-			a1->field_B4[i*4+18] = a1->field_B4[i*4];
-		}
-		a1->field_B4[i*4+19] = a1->field_B4[i*4+3];
-		if ( (double)(signed int)pViewport->uViewportTL_X <= a1->field_B4[i*4+16]
-			&& (double)(signed int)pViewport->uViewportBR_X > a1->field_B4[i*4+16]
-			&& (double)(signed int)pViewport->uViewportTL_Y <= a1->field_B4[i*4+17]
-			&& (double)(signed int)pViewport->uViewportBR_Y > a1->field_B4[i*4+17] )
-			v16 = 1;
+      v6 = (double)pBLVRenderParams->fov_rad_fixpoint * 0.000015258789 / this->field_B4[i*4];
+      if ( pRenderer->pRenderD3D )
+      {
+        pGame->pIndoorCameraD3D->Project(round(this->field_B4[i*4]), round(this->field_B4[i*4+1]), round(this->field_B4[i*4+2]),
+           &a5, &a6);
+        this->field_B4[i*4+16] = (double)a5;
+        this->field_B4[i*4+17] = (double)a6;
+        this->field_B4[i*4+18] = round(this->field_B4[i*4]);
+      }
+      else
+      {
+        this->field_B4[i*4+16] = (double)pBLVRenderParams->uViewportCenterX - v6 * this->field_B4[i*4+1];
+        this->field_B4[i*4+17] = (double)pBLVRenderParams->uViewportCenterY - v6 * this->field_B4[i*4+2];
+        this->field_B4[i*4+18] = this->field_B4[i*4];
+      }
+      this->field_B4[i*4+19] = this->field_B4[i*4+3];
+      if ( (double)(signed int)pViewport->uViewportTL_X <= this->field_B4[i*4+16] && (double)(signed int)pViewport->uViewportBR_X > this->field_B4[i*4+16]
+        && (double)(signed int)pViewport->uViewportTL_Y <= this->field_B4[i*4+17] && (double)(signed int)pViewport->uViewportBR_Y > this->field_B4[i*4+17] )
+        v16 = 1;
     }
   }
   else
   {
-	for(int i = 0; i < a1->uNumVertices; i++)
+    for(int i = 0; i < this->uNumVertices; i++)
     {
-		v12 = (double)pODMRenderParams->int_fov_rad / a1->field_B4[i*4];
-		a1->field_B4[i*4+20] = (double)pViewport->uScreenCenterX - v12 * a1->field_B4[i*4+1];
-		a1->field_B4[i*4+21] = (double)pViewport->uScreenCenterY - v12 * a1->field_B4[i*4+2];
-		*((int *)&a1->field_B4[i*4+22]) = (int)a1->field_B4[i*4];
-		*((int *)&a1->field_B4[i*4+23]) = a1->field_B4[i*4+3];
-		if ( (double)(signed int)pViewport->uViewportTL_X <= a1->field_B4[i*4+20]
-			&& (double)(signed int)pViewport->uViewportBR_X > a1->field_B4[i*4+20]
-			&& (double)(signed int)pViewport->uViewportTL_Y <= a1->field_B4[i*4+21]
-			&& (double)(signed int)pViewport->uViewportBR_Y > a1->field_B4[i*4+21] )
-			v16 = 1;
+       this->field_B4[i*4+20] = (double)pViewport->uScreenCenterX - (double)pODMRenderParams->int_fov_rad / this->field_B4[i*4] * this->field_B4[i*4+1];
+       this->field_B4[i*4+21] = (double)pViewport->uScreenCenterY - (double)pODMRenderParams->int_fov_rad / this->field_B4[i*4] * this->field_B4[i*4+2];
+       *((int *)&this->field_B4[i*4+22]) = (int)this->field_B4[i*4];
+       *((int *)&this->field_B4[i*4+23]) = this->field_B4[i*4+3];
+       if ( (double)(signed int)pViewport->uViewportTL_X <= this->field_B4[i*4+20] && (double)(signed int)pViewport->uViewportBR_X > this->field_B4[i*4+20]
+         && (double)(signed int)pViewport->uViewportTL_Y <= this->field_B4[i*4+21] && (double)(signed int)pViewport->uViewportBR_Y > this->field_B4[i*4+21] )
+         v16 = 1;
     }
   }
   return v16;
@@ -2260,56 +2106,34 @@
 //----- (00479089) --------------------------------------------------------
 bool __fastcall IsBModelVisible(unsigned int uModelID, int *reachable)
 {
-  BSPModel *v2; // eax@1
   int v3; // edi@1
   int v4; // ebx@1
-  int v5; // ST28_4@1
-  int v6; // ecx@1
-  int v7; // ebx@3
-  int v8; // eax@3
   int v9; // eax@3
-  //int v10; // ebx@3
   signed int v11; // esi@6
   int v12; // esi@8
   bool result; // eax@9
-  //unsigned int v14; // [sp+Ch] [bp-20h]@1
-  int v15; // [sp+Ch] [bp-20h]@5
-  //int *v16; // [sp+10h] [bp-1Ch]@1
   int v17; // [sp+1Ch] [bp-10h]@1
-  int v18; // [sp+20h] [bp-Ch]@1
   int v19; // [sp+20h] [bp-Ch]@3
   int angle; // [sp+24h] [bp-8h]@1
-  int v21; // [sp+28h] [bp-4h]@1
-  //int v22; // [sp+28h] [bp-4h]@3
-
-  //v16 = unused;
-  angle = (signed int)(pODMRenderParams->uCameraFovInDegrees << 11) / 360 >> 1;
-  //v14 = uModelID;
-  v2 = &pOutdoor->pBModels[uModelID];
-  v3 = v2->vBoundingCenter.x - pGame->pIndoorCameraD3D->vPartyPos.x;
-  v4 = v2->vBoundingCenter.y - pGame->pIndoorCameraD3D->vPartyPos.y;
-  v5 = stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY);
-  v21 = stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
-  v18 = stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX);
+
+  angle = (signed int)(pODMRenderParams->uCameraFovInDegrees << 11) / 360 / 2;
+  v3 = pOutdoor->pBModels[uModelID].vBoundingCenter.x - pGame->pIndoorCameraD3D->vPartyPos.x;
+  v4 = pOutdoor->pBModels[uModelID].vBoundingCenter.y - pGame->pIndoorCameraD3D->vPartyPos.y;
   stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX);
-  v6 = v5;
-  v17 = v3 * v5 + v4 * v21;
+  v17 = v3 * stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY) + v4 * stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
   if (pGame->pIndoorCameraD3D->sRotationX)
-    v17 = (unsigned __int64)(v17 * (signed __int64)v18) >> 16;
-  v19 = v4 * v6 - v3 * v21;
-  v7 = abs(v4);
-  v8 = abs(v3);
-  v9 = int_get_vector_length(v8, v7, 0);
+    v17 = (unsigned __int64)(v17 * (signed __int64)stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX)) >> 16;
+  v19 = v4 * stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY) - v3 * stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
+  v9 = int_get_vector_length(abs(v3), abs(v4), 0);
   //v10 = v14 * 188;
   //v22 = v9;
   *reachable = false;
   if ( v9 < pOutdoor->pBModels[uModelID].sBoundingRadius + 256 )
     *reachable = true;
-  v15 = stru_5C6E00->Sin(angle);
   if ( v19 >= 0 )
-    v11 = ((unsigned __int64)(v15 * (signed __int64)v17) >> 16) - ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16);
+    v11 = ((unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)v17) >> 16) - ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16);
   else
-    v11 = ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16) + ((unsigned __int64)(v15 * (signed __int64)v17) >> 16);
+    v11 = ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16) + ((unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)v17) >> 16);
   v12 = v11 >> 16;
   if ( v9 <= pODMRenderParams->shading_dist_mist + 2048 )
   {
@@ -2329,28 +2153,25 @@
 //----- (00479295) --------------------------------------------------------
 int Polygon::_479295()
 {
-  ODMFace *v2; // esi@1
   int v3; // ecx@4
   int v4; // eax@4
   int v5; // edx@4
   int v6; // ST14_4@5
-  int v7; // ST04_4@5
-  stru149 *v8; // ecx@5
   Vec3_int_ thisa; // [sp+Ch] [bp-10h]@8
   int v11; // [sp+18h] [bp-4h]@4
 
-  v2 = this->pODMFace;
-  if ( !v2->pFacePlane.vNormal.z )
+  if ( !this->pODMFace->pFacePlane.vNormal.z )
   {
-    v3 = v2->pFacePlane.vNormal.x;
-    v4 = -v2->pFacePlane.vNormal.y;
+    v3 = this->pODMFace->pFacePlane.vNormal.x;
+    v4 = -this->pODMFace->pFacePlane.vNormal.y;
     v5 = 0;
     v11 = 65536;
   }
-  else if ( (v2->pFacePlane.vNormal.x || v2->pFacePlane.vNormal.y) && abs(v2->pFacePlane.vNormal.z) < 59082 )
+  else if ( (this->pODMFace->pFacePlane.vNormal.x || this->pODMFace->pFacePlane.vNormal.y)
+      && abs(this->pODMFace->pFacePlane.vNormal.z) < 59082 )
   {
-    thisa.x = -v2->pFacePlane.vNormal.y;
-    thisa.y = v2->pFacePlane.vNormal.x;
+    thisa.x = -this->pODMFace->pFacePlane.vNormal.y;
+    thisa.y = this->pODMFace->pFacePlane.vNormal.x;
     thisa.z = 0;
     thisa.Normalize_float();
     v4 = thisa.x;
@@ -2365,12 +2186,9 @@
 	  v11 = 0;
 	  v5 = -65536;
   }
-  v6 = v11;
-  sTextureDeltaU = v2->sTextureDeltaU;
-  v7 = v3;
-  v8 = ptr_38;
-  sTextureDeltaV = v2->sTextureDeltaV;
-  v8->_48616B_frustum_odm(v4, v7, 0, 0, v5, v6);
+  sTextureDeltaU = this->pODMFace->sTextureDeltaU;
+  sTextureDeltaV = this->pODMFace->sTextureDeltaV;
+  ptr_38->_48616B_frustum_odm(v4, v3, 0, 0, v5, v11);
   return 1;
 }
 
@@ -3377,21 +3195,14 @@
 //----- (0048257A) --------------------------------------------------------
 int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *pIsOnWater, int bFloatAboveWater)
 {
-  //unsigned int v4; // ebx@1
-  //unsigned int v5; // edi@1
   int result; // eax@9
-  //int v7; // ebx@10
   int v8; // ebx@11
   int v9; // eax@11
   int v10; // ecx@11
-  //int v11; // [sp+Ch] [bp-Ch]@1
-  //int v12; // [sp+10h] [bp-8h]@1
   int v13; // [sp+10h] [bp-8h]@11
   signed int v14; // [sp+14h] [bp-4h]@3
   int v15; // [sp+24h] [bp+Ch]@11
 
-  //v11 = a1;
-  //v12 = a2;
   unsigned int grid_x = WorldPosToGridCellX(a1);
   unsigned int grid_z = WorldPosToGridCellZ(a2) - 1;
 
@@ -3450,10 +3261,6 @@
     return y_x1z1;
 }
 
-
-
-
-
 //----- (00485F53) --------------------------------------------------------
 void  sr_485F53(Vec2_int_ *v)
 {
@@ -3472,15 +3279,14 @@
 //----- (00486089) --------------------------------------------------------
 void Polygon::_normalize_v_18()
 {
-  double v2; // st7@1
-  double v3; // st6@1
-  double v5; // st5@1
-
-  //v1 = this;
-  v2 = (double)this->v_18.x;
-  v3 = (double)this->v_18.y;
-  v5 = (double)this->v_18.z;
-  float len = sqrt(v5 * v5 + v3 * v3 + v2 * v2);
+  //double v2; // st7@1
+  //double v3; // st6@1
+  //double v5; // st5@1
+
+ // v2 = (double)this->v_18.x;
+  //v3 = (double)this->v_18.y;
+ // v5 = (double)this->v_18.z;
+  float len = sqrt((double)this->v_18.z * (double)this->v_18.z + (double)this->v_18.y * (double)this->v_18.y + (double)this->v_18.x * (double)this->v_18.x);
   if (fabsf(len) < 1e-6f)
   {
     v_18.x = 0;
@@ -3489,9 +3295,9 @@
   }
   else
   {
-    v_18.x = round(v2 / len * 65536.0);
-    v_18.y = round(v3 / len * 65536.0);
-    v_18.y = round(v5 / len * 65536.0);
+    v_18.x = round((double)this->v_18.x / len * 65536.0);
+    v_18.y = round((double)this->v_18.y / len * 65536.0);
+    v_18.y = round((double)this->v_18.z / len * 65536.0);
   }
 }
 
@@ -3499,28 +3305,13 @@
 void stru149::_48616B_frustum_odm(int a2, int a3, int a4, int a5, int a6, int a7)
 {
   int v7; // ebx@1
-  //int v8; // esi@1
   int v9; // edi@1
-  //int v10; // eax@1
   int v11; // edx@1
-  //int v12; // esi@2
-  //int v13; // eax@2
-  //int v14; // ST10_4@3
-  //int v15; // esi@3
-  //int v16; // eax@5
   int v17; // ST0C_4@6
-  //int v18; // eax@8
   int v19; // ST0C_4@9
-  //int v20; // eax@10
-  //int v21; // edx@10
-  //int v22; // eax@10
-  //int result; // eax@10
   int v24; // [sp+14h] [bp-14h]@1
   int v25; // [sp+18h] [bp-10h]@1
-  //int v26; // [sp+1Ch] [bp-Ch]@1
   int v27; // [sp+24h] [bp-4h]@1
-  //int v28; // [sp+30h] [bp+8h]@10
-  //int v29; // [sp+3Ch] [bp+14h]@10
 
   v25 = pGame->pIndoorCameraD3D->int_cosine_x;
   v7 = pGame->pIndoorCameraD3D->int_sine_y;
@@ -3939,7 +3730,7 @@
       if ( !pLevelStr[i] )
       {
         pLevelStrOffsets[string_num] = i + 1;
-		++string_num;
+        ++string_num;
         if ( i - prev_string_offset > max_string_length )
           max_string_length = i - prev_string_offset;
         prev_string_offset = i;
@@ -3968,7 +3759,7 @@
   {
     for (uint i = 0; i < uLevelEVT_NumEvents; ++i)
     {
-		test_event=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[i].uEventOffsetInEVT];
+      test_event=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[i].uEventOffsetInEVT];
       if ( test_event->_e_type == EVENT_OnMapLeave )
       {
         EventProcessor(pLevelEVT_Index[i].uEventID, 0, 1, pLevelEVT_Index[i].event_sequence_num);
@@ -3980,161 +3771,150 @@
 //----- (00443FDC) --------------------------------------------------------
 void OnMapLoad()
 {
-	stru176 *v3; // esi@7
-	__int16 v4; // cx@9
-	__int16 v5; // di@9
-	int v6; // eax@9
-	signed __int64 v8; // qax@26
-	unsigned int v9; // ecx@26
-	signed __int64 v10; // qax@26
-	signed __int64 v11; // qax@26
-	int v12; // ST50_4@26
-	signed __int64 v13; // qax@26
-	signed __int64 v14; // qax@26
-	int v15; // ST58_4@26
-	signed __int64 v16; // qax@26
-	int hours; // ebx@26
-	unsigned __int64 v18; // [sp+Ch] [bp-44h]@12
-	signed __int64 seconds; // [sp+14h] [bp-3Ch]@26
-	unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7
-	int minutes; // [sp+2Ch] [bp-24h]@26
-	int years; // [sp+34h] [bp-1Ch]@26
-	int weeks; // [sp+38h] [bp-18h]@26
-	int v26; // [sp+3Ch] [bp-14h]@15
-	int days; // [sp+3Ch] [bp-14h]@26
-	int months; // [sp+40h] [bp-10h]@26
-	__int16 v29; // [sp+46h] [bp-Ah]@9
-	__int16 v30; // [sp+48h] [bp-8h]@9
-	__int16 v31; // [sp+4Ah] [bp-6h]@9
-	__int16 v32; // [sp+4Ch] [bp-4h]@9
-	__int16 v33; // [sp+4Eh] [bp-2h]@9
-
-	for (uint i = 0; i < uLevelEVT_NumEvents; ++i)
-	{
-		EventIndex pEvent = pLevelEVT_Index[i];
-
-		_evt_raw* _evt = (_evt_raw *)(&pLevelEVT[pEvent.uEventOffsetInEVT]);
-
-		if (_evt->_e_type == EVENT_PlaySound)
-		{
-			pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0);
-		}
-		else if (_evt->_e_type == EVENT_OnMapReload)
-		{
-			EventProcessor(pEvent.uEventID, 0, 0, pEvent.event_sequence_num);
-		}
-		else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_Initialize)
-		{
-			v3 = &array_5B5928_timers[dword_5B65C8_timers_count];
-			v20 = pOutdoor->loc_time.uLastVisitDay;
-			if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
-				v20 = pIndoor->stru1.uLastVisitDay;
-
-			v3->timer_evt_type = _evt->_e_type;
-			v3->timer_evt_ID = pEvent.uEventID;
-			v3->timer_evt_seq_num = pEvent.event_sequence_num;
-
-			v3->field_10 = _evt->v5;
-			v3->field_12 = _evt->v6;
-			v3->field_14 = _evt->v7;
-			v3->field_16 = _evt->v8;
-			v3->field_18 = _evt->v9;
-			v3->field_1A = _evt->v10;
-
-
-			v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11;
-
-			v3->time_left_to_fire = ((unsigned short)_evt->v12 << 8) + _evt->v11;
-            v3->fire_interval = ((unsigned short)_evt->v12 << 8) + _evt->v11;
-			if (v3->timer_evt_type  == EVENT_Initialize && !(short)v6 )
-			{
-				if ( v20 )
-					v18 = pParty->uTimePlayed - v20;
-				else
-					v18 = 0i64;
-				v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24;
-
-				if ( v26 / 7 / 4 / 12 )
-				{
-					if ( v3->field_10 )
-					{
-						++dword_5B65C8_timers_count;
-                        v3->next_fire_time = 0;
-						continue;
-					}
-				}
-				if (v26 / 7 / 4 != 0 && v3->field_12 != 0 ||
-					v26 / 7 != 0 && v3->field_14 != 0 ||
-					v26 != 0 || !v20)
-				{
-					++dword_5B65C8_timers_count;
-					v3->next_fire_time = 0;
-					continue;
-				}
-			}
-			else
-			{
-				v8 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375);
-				v9 = v8;
-				v10 = (signed int)v8 / 60;
-				minutes = v10 % 60;
-				v11 = (signed int)(v10 / 60);
-				v12 = v11 % 24;
-				v13 = (signed int)(v11 / 24);
-				days = v13 % 7;
-				v14 = (signed int)(v13 / 7);
-				v15 = v14 % 4;
-				v16 = (signed int)(v14 / 4);
-				years = v16 / 12;
-
-				unsigned __int64 _1 = (unsigned __int64)((double)pParty->uTimePlayed * 0.234375) >> 32;
-				__int64 _2 = ((__int64)v9 << 32) | _1;
-
-				seconds = _2 % 60;
-				//v19 = (signed __int64)__PAIR__((unsigned __int64)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) >> 32,
-				//                        v9)
-				//    % 60;
-
-				hours = v12;
-				weeks = v15;
-				months = v16 % 12;
-				if ( v3->field_10 )
-				{
-					++years;
-				}
-				else
-				{
-					if ( v3->field_12 )
-					{
-						++months;
-					}
-					else
-					{
-						if ( v3->field_14 )
-						{
-							++weeks;
-						}
-						else
-						{
-							++days;
-							minutes = v3->field_18;
-							hours = v3->field_16;
-							seconds = v3->field_1A;
-						}
-					}
-				}
-                v3->next_fire_time = (signed __int64)((double)((seconds
-					+ 60 * minutes
-					+ 3600 * hours
-					+ 0x93A80 * weeks
-					+ 0x15180 * days
-					+ 0x24EA00 * (months + 12i64 * years)) << 7)
-					* 0.033333335);
-
-				++dword_5B65C8_timers_count;
-			}
-		}
-	}
+  __int16 v4; // cx@9
+  __int16 v5; // di@9
+  int v6; // eax@9
+  signed __int64 v8; // qax@26
+  unsigned int v9; // ecx@26
+  signed __int64 v10; // qax@26
+  signed __int64 v11; // qax@26
+  int v12; // ST50_4@26
+  signed __int64 v13; // qax@26
+  signed __int64 v14; // qax@26
+  int v15; // ST58_4@26
+  signed __int64 v16; // qax@26
+  int hours; // ebx@26
+  unsigned __int64 v18; // [sp+Ch] [bp-44h]@12
+  signed __int64 seconds; // [sp+14h] [bp-3Ch]@26
+  unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7
+  int minutes; // [sp+2Ch] [bp-24h]@26
+  int years; // [sp+34h] [bp-1Ch]@26
+  int weeks; // [sp+38h] [bp-18h]@26
+  int v26; // [sp+3Ch] [bp-14h]@15
+  int days; // [sp+3Ch] [bp-14h]@26
+  int months; // [sp+40h] [bp-10h]@26
+  __int16 v29; // [sp+46h] [bp-Ah]@9
+  __int16 v30; // [sp+48h] [bp-8h]@9
+  __int16 v31; // [sp+4Ah] [bp-6h]@9
+  __int16 v32; // [sp+4Ch] [bp-4h]@9
+  __int16 v33; // [sp+4Eh] [bp-2h]@9
+
+  for (uint i = 0; i < uLevelEVT_NumEvents; ++i)
+  {
+    EventIndex pEvent = pLevelEVT_Index[i];
+
+    _evt_raw* _evt = (_evt_raw *)(&pLevelEVT[pEvent.uEventOffsetInEVT]);
+
+    if (_evt->_e_type == EVENT_PlaySound)
+      pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0);
+    else if (_evt->_e_type == EVENT_OnMapReload)
+      EventProcessor(pEvent.uEventID, 0, 0, pEvent.event_sequence_num);
+    else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_Initialize)
+    {
+      //v3 = &array_5B5928_timers[dword_5B65C8_timers_count];
+      v20 = pOutdoor->loc_time.uLastVisitDay;
+      if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
+        v20 = pIndoor->stru1.uLastVisitDay;
+
+      array_5B5928_timers[dword_5B65C8_timers_count].timer_evt_type = _evt->_e_type;
+      array_5B5928_timers[dword_5B65C8_timers_count].timer_evt_ID = pEvent.uEventID;
+      array_5B5928_timers[dword_5B65C8_timers_count].timer_evt_seq_num = pEvent.event_sequence_num;
+
+      array_5B5928_timers[dword_5B65C8_timers_count].field_10 = _evt->v5;
+      array_5B5928_timers[dword_5B65C8_timers_count].field_12 = _evt->v6;
+      array_5B5928_timers[dword_5B65C8_timers_count].field_14 = _evt->v7;
+      array_5B5928_timers[dword_5B65C8_timers_count].field_16 = _evt->v8;
+      array_5B5928_timers[dword_5B65C8_timers_count].field_18 = _evt->v9;
+      array_5B5928_timers[dword_5B65C8_timers_count].field_1A = _evt->v10;
+
+
+      v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11;
+
+      array_5B5928_timers[dword_5B65C8_timers_count].time_left_to_fire = ((unsigned short)_evt->v12 << 8) + _evt->v11;
+      array_5B5928_timers[dword_5B65C8_timers_count].fire_interval = ((unsigned short)_evt->v12 << 8) + _evt->v11;
+      if (array_5B5928_timers[dword_5B65C8_timers_count].timer_evt_type  == EVENT_Initialize && !(short)v6 )
+      {
+        if ( v20 )
+          v18 = pParty->uTimePlayed - v20;
+        else
+          v18 = 0i64;
+        v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24;
+
+        if ( v26 / 7 / 4 / 12 )
+        {
+          if ( array_5B5928_timers[dword_5B65C8_timers_count].field_10 )
+          {
+            ++dword_5B65C8_timers_count;
+            array_5B5928_timers[dword_5B65C8_timers_count].next_fire_time = 0;
+            continue;
+          }
+        }
+        if (v26 / 7 / 4 != 0 && array_5B5928_timers[dword_5B65C8_timers_count].field_12 != 0 ||
+          v26 / 7 != 0 && array_5B5928_timers[dword_5B65C8_timers_count].field_14 != 0 ||
+          v26 != 0 || !v20)
+        {
+          ++dword_5B65C8_timers_count;
+          array_5B5928_timers[dword_5B65C8_timers_count].next_fire_time = 0;
+          continue;
+        }
+      }
+      else
+      {
+        v8 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375);
+        v9 = v8;
+        v10 = (signed int)v8 / 60;
+        minutes = v10 % 60;
+        v11 = (signed int)(v10 / 60);
+        v12 = v11 % 24;
+        v13 = (signed int)(v11 / 24);
+        days = v13 % 7;
+        v14 = (signed int)(v13 / 7);
+        v15 = v14 % 4;
+        v16 = (signed int)(v14 / 4);
+        years = v16 / 12;
+
+        unsigned __int64 _1 = (unsigned __int64)((double)pParty->uTimePlayed * 0.234375) >> 32;
+        __int64 _2 = ((__int64)v9 << 32) | _1;
+
+        seconds = _2 % 60;
+        //v19 = (signed __int64)__PAIR__((unsigned __int64)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) >> 32,
+        //                        v9)
+        //    % 60;
+
+        hours = v12;
+        weeks = v15;
+        months = v16 % 12;
+        if ( array_5B5928_timers[dword_5B65C8_timers_count].field_10 )
+          ++years;
+        else
+        {
+          if ( array_5B5928_timers[dword_5B65C8_timers_count].field_12 )
+            ++months;
+          else
+          {
+            if ( array_5B5928_timers[dword_5B65C8_timers_count].field_14 )
+              ++weeks;
+            else
+            {
+              ++days;
+              minutes = array_5B5928_timers[dword_5B65C8_timers_count].field_18;
+              hours = array_5B5928_timers[dword_5B65C8_timers_count].field_16;
+              seconds = array_5B5928_timers[dword_5B65C8_timers_count].field_1A;
+            }
+          }
+        }
+        array_5B5928_timers[dword_5B65C8_timers_count].next_fire_time = (signed __int64)((double)((seconds
+                    + 60 * minutes
+                    + 3600 * hours
+                    + 0x93A80 * weeks
+                    + 0x15180 * days
+                    + 0x24EA00 * (months + 12i64 * years)) << 7)
+                    * 0.033333335);
+
+        ++dword_5B65C8_timers_count;
+      }
+    }
+  }
 }
 
 //----- (00444360) --------------------------------------------------------
@@ -4154,31 +3934,26 @@
 //----- (00444D80) --------------------------------------------------------
 int GetTravelTime()
 {
-  signed int v0; // esi@1
-
-  v0 = uDefaultTravelTime_ByFoot;
+  signed int new_travel_time; // esi@1
+
+  new_travel_time = uDefaultTravelTime_ByFoot;
   if ( CheckHiredNPCSpeciality(Guide) )
-    --v0;
+    --new_travel_time;
   if ( CheckHiredNPCSpeciality(Tracker) )
-    v0 -= 2;
+    new_travel_time -= 2;
   if ( CheckHiredNPCSpeciality(Pathfinder) )
-    v0 -= 3;
+    new_travel_time -= 3;
   if ( CheckHiredNPCSpeciality(Explorer) )
-    --v0;
-  if ( v0 < 1 )
-    v0 = 1;
-  return v0;
+    --new_travel_time;
+  if ( new_travel_time < 1 )
+    new_travel_time = 1;
+  return new_travel_time;
 }
 // 6BD07C: using guessed type int uDefaultTravelTime_ByFoot;
 
 //----- (004451A8) --------------------------------------------------------
 void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4)
 {
-  int v3; // esi@1
-  int v4; // edi@1
-
-  v3 = a2;
-  v4 = a1;
   if ( !pGUIWindow2 )
   {
     if ( pParty->uFlags & 2 )
@@ -4186,8 +3961,8 @@
     pAudioPlayer->StopChannels(-1, -1);
     pMiscTimer->Pause();
     pEventTimer->Pause();
-    dword_5C3418 = v4;
-    dword_5C341C = v3;
+    dword_5C3418 = a1;
+    dword_5C341C = a2;
     _591094_decoration = activeLevelDecoration;
     pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_GreetingNPC, a4, 0);
     pGUIWindow2->CreateButton( 61, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);
@@ -4209,7 +3984,7 @@
 }
 
 //----- (004465DF) --------------------------------------------------------
-int sub_4465DF_check_season(int a1)
+bool sub_4465DF_check_season(int a1)
 {
   unsigned int v1; // eax@1
   unsigned int v2; // edx@1
@@ -4222,22 +3997,21 @@
   if ( a1 )
   {
     v3 = a1 - 1;
-    if ( v3 )
+    if ( a1 - 1 )
     {
       v4 = v3 - 1;
-      if ( v4 )
+      if ( v3 - 1 )
       {
         if ( v4 != 1 )
-          return 0;
+          return false;
         if ( v1 != 12 )
         {
           if ( (signed int)v1 >= 1 && (signed int)v1 <= 2 )
-            return 1;
+            return true;
           v6 = v1 == 3;
-LABEL_24:
           if ( !v6 || (signed int)v2 >= 21 )
-            return 0;
-          return 1;
+            return false;
+          return true;
         }
       }
       else
@@ -4245,9 +4019,11 @@
         if ( v1 != 9 )
         {
           if ( (signed int)v1 >= 10 && (signed int)v1 <= 11 )
-            return 1;
+            return true;
           v6 = v1 == 12;
-          goto LABEL_24;
+          if ( !v6 || (signed int)v2 >= 21 )
+            return false;
+          return true;
         }
       }
     }
@@ -4256,9 +4032,11 @@
       if ( v1 != 6 )
       {
         if ( (signed int)v1 >= 7 && (signed int)v1 <= 8 )
-          return 1;
+          return true;
         v6 = v1 == 9;
-        goto LABEL_24;
+        if ( !v6 || (signed int)v2 >= 21 )
+          return false;
+        return true;
       }
     }
   }
@@ -4267,137 +4045,86 @@
     if ( v1 != 3 )
     {
       if ( (signed int)v1 >= 4 && (signed int)v1 <= 5 )
-        return 1;
+        return true;
       v6 = v1 == 6;
-      goto LABEL_24;
+      if ( !v6 || (signed int)v2 >= 21 )
+        return false;
+      return true;
     }
   }
   if ( (signed int)v2 >= 21 )
-    return 1;
-  return 0;
+    return true;
+  return false;
 }
 
 //----- (0044861E) --------------------------------------------------------
 void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename)
 {
-  unsigned int v2; // eax@2
-  unsigned __int16 v3; // di@2
-  signed int v4; // esi@5
-  BLVFace *v5; // eax@7
-  unsigned int *v6; // eax@8
-  char *v7; // eax@9
-  int v8; // edi@16
-  char *v9; // esi@16
-  ODMFace *v10; // eax@17
-  unsigned int *v11; // eax@19
-  unsigned __int16 v12; // [sp+Ch] [bp-18h]@2
-  const char *Str2; // [sp+10h] [bp-14h]@1
-  unsigned int v14; // [sp+14h] [bp-10h]@1
-  signed int v15; // [sp+18h] [bp-Ch]@14
-  int v16; // [sp+1Ch] [bp-8h]@15
-  signed int v17; // [sp+20h] [bp-4h]@4
-  signed int v18; // [sp+20h] [bp-4h]@16
-
-  Str2 = pFilename;
-  v14 = uFaceCog;
+  unsigned int texture; // eax@2
+
   if ( uFaceCog )
   {
-    v2 = pBitmaps_LOD->LoadTexture(pFilename);
-    v3 = v2;
-    v12 = v2;
-    if ( v2 != -1 ? (int)&pBitmaps_LOD->pTextures[v2] : 0 )
+    texture = pBitmaps_LOD->LoadTexture(pFilename);
+    if ( texture != -1 ? (int)&pBitmaps_LOD->pTextures[texture] : 0 )
     {
-      pBitmaps_LOD->pTextures[v2].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v2].palette_id1);
+      pBitmaps_LOD->pTextures[texture].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[texture].palette_id1);
 
       if ( uCurrentlyLoadedLevelType == 1 )
       {
-        v17 = 1;
         if ( (signed int)pIndoor->uNumFaceExtras > 1 )
         {
-          v4 = 1;
-          do
+          for ( uint i = 1; i < (signed int)pIndoor->uNumFaceExtras; ++i )
           {
-            if ( pIndoor->pFaceExtras[v4].sCogNumber == v14 )
+            if ( pIndoor->pFaceExtras[i].sCogNumber == uFaceCog )
             {
-              v5 = &pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C];
-              if ( BYTE1(v5->uAttributes) & 0x40 )
+              if ( BYTE1(pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes) & 0x40 )
               {
-                pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uBitmapID = pTextureFrameTable->FindTextureByName(
-                                                                              Str2);
-                v6 = (unsigned int *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uBitmapID;
-                if ( *(_WORD *)v6 )
+                pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = pTextureFrameTable->FindTextureByName(pFilename);
+                if ( pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID)
                 {
-                  pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(_WORD *)v6);
+                  pTextureFrameTable->LoadAnimationSequenceAndPalettes(pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID);
                 }
                 else
                 {
-                  *(_WORD *)v6 = v3;
-                  v7 = (char *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uAttributes;
-                  v7[1] &= 0xBFu;
+                  pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture;
+                  BYTE1(pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes) &= 0xBFu;
                 }
               }
               else
               {
-                v5->uBitmapID = v3;
+                pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture;
               }
             }
-            ++v17;
-            ++v4;
           }
-          while ( v17 < (signed int)pIndoor->uNumFaceExtras );
         }
-        pParty->uFlags |= 2u;
+        pParty->uFlags |= 2;
       }
       else
       {
-        v15 = 0;
-        if ( (signed int)pOutdoor->uNumBModels > 0 )
+        for ( uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j )
         {
-          v16 = 0;
-          do
+          for ( uint i = 0; i < pOutdoor->pBModels[j].uNumFaces; ++i )
           {
-            v8 = 0;
-            v9 = (char *)&pOutdoor->pBModels[v16].pVertices;
-            v18 = 0;
-            if ( (signed int)pOutdoor->pBModels[v16].uNumFaces > 0 )
+            if ( pOutdoor->pBModels[j].pFaces[i].sCogNumber == uFaceCog )
             {
-              do
+              if ( BYTE1(pOutdoor->pBModels[j].pFaces[i].uAttributes) & 0x40 )
               {
-                v10 = (ODMFace *)(v8 + *((_DWORD *)v9 + 4));
-                if ( v10->sCogNumber == v14 )
+                pOutdoor->pBModels[j].pFaces[i].uTextureID = pTextureFrameTable->FindTextureByName(pFilename);
+                if ( pOutdoor->pBModels[j].pFaces[i].uTextureID )
+                  pTextureFrameTable->LoadAnimationSequenceAndPalettes(pOutdoor->pBModels[j].pFaces[i].uTextureID);
+                else
                 {
-                  if ( BYTE1(v10->uAttributes) & 0x40 )
-                  {
-                    *(_WORD *)(*((_DWORD *)v9 + 4) + v8 + 272) = pTextureFrameTable->FindTextureByName(
-                                                                   Str2);
-                    v11 = (unsigned int *)(*((_DWORD *)v9 + 4) + v8 + 272);
-                    if ( *(_WORD *)v11 )
-                    {
-                      pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(_WORD *)v11);
-                    }
-                    else
-                    {
-                      *(_WORD *)v11 = v12;
-                      *(_BYTE *)(*((_DWORD *)v9 + 4) + v8 + 29) &= 0xBFu;
-                    }
-                  }
-                  else
-                  {
-                    v10->uTextureID = v12;
-                  }
+                  pOutdoor->pBModels[j].pFaces[i].uTextureID = texture;
+                  BYTE1(pOutdoor->pBModels[j].pFaces[i].uAttributes) &= 0xBFu;
                 }
-                ++v18;
-                v8 += 308;
               }
-              while ( v18 < *((_DWORD *)v9 + 2) );
+              else
+                pOutdoor->pBModels[j].pFaces[i].uTextureID = texture;
             }
-            ++v15;
-            ++v16;
           }
-          while ( v15 < (signed int)pOutdoor->uNumBModels );
         }
       }
-      pParty->uFlags |= 2u;
+      pParty->uFlags |= 2;
     }
   }
 }
@@ -4420,7 +4147,7 @@
       else
         pLevelDecorations[i].uFlags |= LEVEL_DECORATION_INVISIBLE;
 
-      pParty->uFlags |= 2u;
+      pParty->uFlags |= 2;
     }
   }
 }
@@ -4428,148 +4155,42 @@
 //----- (0044892E) --------------------------------------------------------
 void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on)
 {
-  signed int v3; // esi@2
-  signed int v4; // ecx@4
-  char *v5; // eax@6
-  int v6; // edi@13
-  char *v7; // esi@13
-  signed int v8; // ecx@13
-  ODMFace *v9; // eax@14
-  int v10; // [sp+0h] [bp-Ch]@1
-  signed int v11; // [sp+4h] [bp-8h]@11
-  int v12; // [sp+8h] [bp-4h]@12
-
-  v10 = sCogNumber;
   if ( sCogNumber )
   {
-    v3 = 1;
     if ( uCurrentlyLoadedLevelType == 1 )
     {
-      if ( (signed int)pIndoor->uNumFaceExtras > 1 )
+      for ( uint i = 1; i < (unsigned int)pIndoor->uNumFaceExtras; ++i )
       {
-        v4 = 1;
-        do
+        if ( pIndoor->pFaceExtras[i].sCogNumber == sCogNumber )
         {
-          if ( pIndoor->pFaceExtras[v4].sCogNumber == v10 )
-          {
-            v5 = (char *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uAttributes;
-            if ( on )
-              *(_DWORD *)v5 |= bit;
-            else
-              *(_DWORD *)v5 &= ~bit;
-          }
-          ++v3;
-          ++v4;
+          if ( on )
+            pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes |= bit;
+          else
+            pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes &= ~bit;
         }
-        while ( v3 < (signed int)pIndoor->uNumFaceExtras );
       }
-      pParty->uFlags |= 2u;
+      pParty->uFlags |= 2;
     }
     else
     {
-      v11 = 0;
-      if ( (signed int)pOutdoor->uNumBModels > 0 )
+      for ( uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j )
       {
-        v12 = 0;
-        do
+        for ( uint i = 0; i < (unsigned int)pOutdoor->pBModels[j].uNumFaces; ++i )
         {
-          v6 = 0;
-          v7 = (char *)&pOutdoor->pBModels[v12].pVertices;
-          v8 = 0;
-          if ( (signed int)pOutdoor->pBModels[v12].uNumFaces > 0 )
+          if ( pOutdoor->pBModels[j].pFaces[i].sCogNumber == sCogNumber )
           {
-            do
-            {
-              v9 = (ODMFace *)(v6 + *((_DWORD *)v7 + 4));
-              if ( v9->sCogNumber == v10 )
-              {
-                if ( on )
-                  v9->uAttributes |= bit;
-                else
-                  v9->uAttributes &= ~bit;
-              }
-              ++v8;
-              v6 += 308;
-            }
-            while ( v8 < *((_DWORD *)v7 + 2) );
+            if ( on )
+              pOutdoor->pBModels[j].pFaces[i].uAttributes |= bit;
+            else
+              pOutdoor->pBModels[j].pFaces[i].uAttributes &= ~bit;
           }
-          ++v11;
-          ++v12;
         }
-        while ( v11 < (signed int)pOutdoor->uNumBModels );
       }
     }
-    pParty->uFlags |= 2u;
+    pParty->uFlags |= 2;
   }
 }
 
-//----- (00448A98) --------------------------------------------------------
-void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle)
-{
-  unsigned int v3; // ebx@1
-  unsigned int v4; // ebp@1
-  signed int v5; // edi@1
-  Actor *v6; // esi@4
-  size_t v7; // ecx@10
-  Actor *v8; // eax@11
-  unsigned __int16 v9; // dx@14
-
-  v4 = uGroupID;
-  v5 = Standing;
-  v3 = uFlag;
-  if ( uGroupID )
-  {
-    if ( bToggle )
-    {
-      if ( (signed int)uNumActors > Standing )
-      {
-        v6 = pActors.data();//[0].uAttributes;
-        do
-        {
-          if ( v6->uGroup == v4 )
-          {
-            v6->uAttributes |= v3;
-            if ( v3 == 0x10000 )
-            {
-              v6->uAIState = Disabled;
-              v6->UpdateAnimation();
-            }
-          }
-          ++v5;
-          ++v6;
-        }
-        while ( v5 < (signed int)uNumActors );
-      }
-    }
-    else
-    {
-      v7 = uNumActors;
-      if ( (signed int)uNumActors > Standing )
-      {
-        v8 = pActors.data();//[0].uAIState;
-        do
-        {
-          if ( v8->uGroup == v4 )
-          {
-            if ( v3 == 0x10000 )
-            {
-              v9 = v8->uAIState;
-              if ( v8->uAIState != Dead )
-              {
-                if ( v9 != 4 && v9 != 11 )
-                  v8->uAIState = Standing;
-              }
-            }
-			LODWORD(v8->uAttributes) &= ~v3;
-          }
-          ++v8;
-          --v7;
-        }
-        while ( v7 );
-      }
-    }
-  }
-}
 
 //----- (00448B45) --------------------------------------------------------
 void  GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide)
@@ -4652,63 +4273,44 @@
 //----- (00448CF4) --------------------------------------------------------
 void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName)
 {
-  __int16 v8; // di@1
-  __int16 v9; // si@1
-  unsigned int v10; // eax@1
-  size_t v11; // ebx@2
-  signed int v12; // esi@2
-  Actor *pActor;//Actor_uYawAngle_cr *v13; // ebx@3
-  AIDirection a3; // [sp+Ch] [bp-50h]@2
+  unsigned int map_id; // eax@1
+  size_t old_num_actors; // ebx@2
   AIDirection v15; // [sp+28h] [bp-34h]@2
-  //SpawnPointMM7 v16; // [sp+44h] [bp-18h]@1
-
-  v8 = typeindex;
-  v9 = level;
-
-  SpawnPointMM7 v16; // [sp+44h] [bp-18h]@1
-  //SpawnPointMM7::SpawnPointMM7(&v16);
-
-  v16.vPosition.x = x;
-  v16.vPosition.y = y;
-  v16.vPosition.z = z;
-  v16.uGroup = group;
-  v16.uRadius = 32;
-  v16.uKind = 3;
-  v16.uIndex = v8 + 2 * v9 + v9;
-  v10 = pMapStats->GetMapInfo(pCurrentMapName);
-  if ( v10 )
+  SpawnPointMM7 pSpawnPoint; // [sp+44h] [bp-18h]@1
+
+  pSpawnPoint.vPosition.x = x;
+  pSpawnPoint.vPosition.y = y;
+  pSpawnPoint.vPosition.z = z;
+  pSpawnPoint.uGroup = group;
+  pSpawnPoint.uRadius = 32;
+  pSpawnPoint.uKind = 3;
+  pSpawnPoint.uIndex = typeindex + 2 * level + level;
+  map_id = pMapStats->GetMapInfo(pCurrentMapName);
+  if ( map_id )
   {
-    v11 = uNumActors;
-    SpawnEncounter(&pMapStats->pInfos[v10], &v16, 0, count, 0);
-    Actor::GetDirectionInfo(PID(OBJECT_Actor, v11), 4u, &v15, 1);
-    v12 = v11;
-    if ( (signed int)v11 < (signed int)uNumActors )
+    old_num_actors = uNumActors;
+    SpawnEncounter(&pMapStats->pInfos[map_id], &pSpawnPoint, 0, count, 0);
+    Actor::GetDirectionInfo(PID(OBJECT_Actor, old_num_actors), 4, &v15, 1);
+    for ( uint i = (unsigned int)old_num_actors; i < (unsigned int)uNumActors; ++i )
     {
-      for ( pActor = &pActors[v11]; v12 < (signed int)uNumActors; ++pActor )
-      {
-        pActor->PrepareSprites(0);
-        ++v12;
-        pActor->uYawAngle = v15.uYawAngle;
-        pActor->dword_000334_unique_name = uUniqueName;
-      }
+      pActors[i].PrepareSprites(0);
+      pActors[i].uYawAngle = v15.uYawAngle;
+      pActors[i].dword_000334_unique_name = uUniqueName;
     }
   }
 }
 
 
 //----- (0044987B) --------------------------------------------------------
-void sub_44987B(const char *pMapName, MapStartPoint start_point)
+void Transition_StopSound_Autosave(const char *pMapName, MapStartPoint start_point)
 {
-  const char *v2; // edi@1
-
-  v2 = pMapName;
   pAudioPlayer->StopChannels(-1, -1);
   pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_None);
-  if ( _stricmp(pCurrentMapName, v2) )
+  if ( _stricmp(pCurrentMapName, pMapName) )
     SaveGame(1, 0);
 
   uGameState = GAME_STATE_2;
-  strcpy(pCurrentMapName, v2);
+  strcpy(pCurrentMapName, pMapName);
   uLevel_StartingPointType = start_point;
 }
 // 6BE35C: using guessed type int uLevel_StartingPointType;
@@ -4716,58 +4318,42 @@
 //----- (004498D5) --------------------------------------------------------
 void TeleportToStartingPoint(MapStartPoint point)
 {
-  //unsigned int v1; // ecx@2
-  //int v2; // ecx@3
-  //int v3; // ecx@4
-  unsigned __int16 v4; // ax@11
-  signed int v5; // ecx@12
-  LevelDecoration *v6; // edx@13
-  signed int v7; // ecx@17
-  int v8; // eax@17
-  int v9; // ecx@17
-  const char *v10; // [sp-4h] [bp-84h]@6
+  const char *model_name; // [sp-4h] [bp-84h]@6
   char pName[128]; // [sp+8h] [bp-78h]@11
 
   switch (point)
   {
-    case MapStartPoint_Party: v10 = "Party Start"; break;
-    case MapStartPoint_North: v10 = "North Start"; break;
-    case MapStartPoint_South: v10 = "South Start"; break;
-    case MapStartPoint_East: v10 = "East Start";  break;
-    case MapStartPoint_West: v10 = "West Start";  break;
+    case MapStartPoint_Party: model_name = "Party Start"; break;
+    case MapStartPoint_North: model_name = "North Start"; break;
+    case MapStartPoint_South: model_name = "South Start"; break;
+    case MapStartPoint_East: model_name = "East Start";  break;
+    case MapStartPoint_West: model_name = "West Start";  break;
     default:
       Error("Invalid enum value: %u", point);
   }
 
-  strcpy(pName, v10);
-  v4 = pDecorationList->GetDecorIdByName(pName);
-  if ( v4 )
+  strcpy(pName, model_name);
+  if ( pDecorationList->GetDecorIdByName(pName) )
   {
-    v5 = 0;
+    
     if ( (signed int)uNumLevelDecorations > 0 )
     {
-      v6 = pLevelDecorations.data();
-      while ( v6->uDecorationDescID != (signed __int16)v4 )
+      for ( uint i = 0; i < (signed int)uNumLevelDecorations; ++i )
       {
-        ++v5;
-        ++v6;
-        if ( v5 >= (signed int)uNumLevelDecorations )
-          goto LABEL_20;
+        if ( pLevelDecorations[i].uDecorationDescID == (signed __int16)pDecorationList->GetDecorIdByName(pName) )
+        {
+          pParty->vPosition.x = pLevelDecorations[i].vPosition.x;
+          pParty->vPosition.y = pLevelDecorations[i].vPosition.y;
+          pParty->vPosition.z = pLevelDecorations[i].vPosition.z;
+          pParty->uFallStartY = pParty->vPosition.z;
+          pParty->sRotationY = (signed int)(stru_5C6E00->uIntegerHalfPi * pLevelDecorations[i].field_1A) / 90;
+          if ( pLevelDecorations[i].field_10_y_rot )
+            pParty->sRotationY = pLevelDecorations[i].field_10_y_rot;
+          pParty->sRotationX = 0;
+          pParty->uFallSpeed = 0;
+        }
       }
-      v7 = v5;
-      pParty->vPosition.x = pLevelDecorations[v7].vPosition.x;
-      pParty->vPosition.y = pLevelDecorations[v7].vPosition.y;
-      pParty->vPosition.z = pLevelDecorations[v7].vPosition.z;
-      pParty->uFallStartY = pParty->vPosition.z;
-      v8 = (signed int)(stru_5C6E00->uIntegerHalfPi * pLevelDecorations[v7].field_1A) / 90;
-      v9 = pLevelDecorations[v7].field_10_y_rot;
-      pParty->sRotationY = v8;
-      if ( v9 )
-        pParty->sRotationY = v9;
-      pParty->sRotationX = 0;
-      pParty->uFallSpeed = 0;
     }
-LABEL_20:
     if ( dword_5B65C0 )
     {
       if ( _5B65A8_npcdata_uflags_or_other )
@@ -4796,100 +4382,6 @@
   }
 }
 
-//----- (00449A49) --------------------------------------------------------
-void Door_switch_animation(unsigned int uDoorID, int a2)
-{
-  int old_state; // eax@1
-  signed int door_id; // esi@2
-
-  if ( !pIndoor->pDoors )
-    return;
-  for ( door_id = 0; door_id < 200; ++door_id )
-  {
-    if ( pIndoor->pDoors[door_id].uDoorID == uDoorID )
-      break;
-  }
-  if ( door_id >= 200 )
-  {
-    Error("Unable to find Door ID: %i!", uDoorID);
-  }
-  old_state = pIndoor->pDoors[door_id].uState;
-  //old_state: 0 - в нижнем положении/закрыто
-  //           2 - в верхнем положении/открыто,
-  //a2: 1 - открыть
-  //    2 - опустить/поднять
-  if ( a2 == 2 )
-  {
-    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 ( a2 == 0 )
-    {
-      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;
-    }
-    if ( a2 != 1 )
-      return;
-  }
-  if ( old_state != BLVDoor::Open && old_state != BLVDoor::Opening )
-  {
-    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 )
-    {
-      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;
-    }
-    pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360;
-  }
-  return;
-}
-
 //----- (00449B57) --------------------------------------------------------
 bool _449B57_test_bit( unsigned __int8 *a1, __int16 a2 )
 {
@@ -4949,7 +4441,7 @@
   dword_5B65C0 = 0;
 
   pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen;
-  sub_44987B("nwc.blv", MapStartPoint_Party);
+  Transition_StopSound_Autosave("nwc.blv", MapStartPoint_Party);
   pCurrentScreen = SCREEN_GAME;
   return true;
 }
--- a/mm7_data.h	Fri Dec 13 22:19:56 2013 +0600
+++ b/mm7_data.h	Mon Dec 16 18:43:42 2013 +0600
@@ -1310,8 +1310,8 @@
 void ODM_ProcessPartyActions();
 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);
+int sub_475665(struct BLVFace *face, int a2, __int16 a3);
+bool __fastcall sub_4759C9(struct BLVFace *face, int a2, int a3, __int16 a4);
 bool __fastcall sub_475D85(Vec3_int_ *a1, Vec3_int_ *a2, int *a3, struct BLVFace *a4);
 bool __fastcall sub_475F30(int *a1, struct BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9);
 void sub_4452BB();
@@ -1322,7 +1322,7 @@
 void  DialogueEnding();
 void PrepareHouse(enum HOUSE_ID house); // idb
 bool EnterHouse(enum HOUSE_ID uHouseID);
-int sub_4465DF_check_season(int a1);
+bool sub_4465DF_check_season(int a1);
 int __fastcall IsActorAlive(unsigned int uType, unsigned int uParam, unsigned int uNumAlive); // idb
 int NPC_EventProcessor(int npc_event_id, int entry_line = 0);
 void __fastcall sub_448518_npc_set_item(int npc, unsigned int item, int a3);