changeset 1445:6de9c1316852

Слияние
author Ritor1
date Sat, 03 Aug 2013 00:00:31 +0600
parents 7b1a94270756 (current diff) a6d966e85611 (diff)
children 8b4f4c723edd
files Chest.cpp Outdoor_stuff.h Render.cpp UI/Books/UIMapBook.cpp UI/UIHouses.cpp mm7_2.cpp mm7_3.cpp
diffstat 31 files changed, 2223 insertions(+), 2385 deletions(-) [+]
line wrap: on
line diff
--- a/AudioPlayer.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/AudioPlayer.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -535,57 +535,39 @@
 //----- (004AA258) --------------------------------------------------------
 void AudioPlayer::_4AA258(int a2)
 {
-  AudioPlayer *v2; // esi@1
-  int v3; // edi@4
-  AudioPlayer_3DSample *v4; // ebx@5
-  int v5; // ebx@11
-  MixerChannel *v6; // edi@12
+  if (!bPlayerReady)
+    return;
 
-  v2 = this;
-  if ( this->bPlayerReady )
-  {
-    if ( this->b3DSoundInitialized && a2 && (v3 = 0, this->uNum3DSamples > 0) )
+    if ( this->b3DSoundInitialized && a2 && this->uNum3DSamples > 0 )
     {
-      v4 = this->p3DSamples;
-      while ( v4->field_4 != a2 || AIL_3D_sample_status(v4->hSample) != 4 )
+      for ( uint i = 0; i < this->uNum3DSamples; ++i )
       {
-        ++v3;
-        ++v4;
-        if ( v3 >= v2->uNum3DSamples )
-          goto LABEL_9;
+        if ( this->p3DSamples[i].field_4 == a2 && AIL_3D_sample_status(this->p3DSamples[i].hSample) == 4 )
+          AIL_end_3D_sample(this->p3DSamples[i].hSample);
       }
-      AIL_end_3D_sample(v2->p3DSamples[v3].hSample);
+      goto LABEL_9;
     }
     else
     {
 LABEL_9:
-      if ( v2->hDigDriver )
+      if ( this->hDigDriver )
       {
-        if ( a2 )
+        if ( a2 && this->uMixerChannels > 0 )
         {
-          v5 = 0;
-          if ( v2->uMixerChannels > 0 )
+          for ( uint i = 0; i < this->uMixerChannels; ++i )
           {
-            v6 = v2->pMixerChannels;
-            do
+            if ( this->pMixerChannels[i].source_pid == a2 )
             {
-              if ( v6->source_pid == a2 )
+              if ( AIL_sample_status(this->pMixerChannels[i].hSample) == AIL::Sample::Playing)
               {
-                if ( AIL_sample_status(v6->hSample) == AIL::Sample::Playing)
-                {
-                  AIL_end_sample(v6->hSample);
-                  FreeChannel(v6);
-                }
+                AIL_end_sample(this->pMixerChannels[i].hSample);
+                FreeChannel(&this->pMixerChannels[i]);
               }
-              ++v5;
-              ++v6;
             }
-            while ( v5 < v2->uMixerChannels );
           }
         }
       }
     }
-  }
 }
 
 //----- (004AA306) --------------------------------------------------------
--- a/AudioPlayer.h	Sat Aug 03 00:00:10 2013 +0600
+++ b/AudioPlayer.h	Sat Aug 03 00:00:31 2013 +0600
@@ -78,6 +78,7 @@
   SOUND_7 = 7,
   SOUND_8 = 0x8,
   SOUND_27 = 0x1B,
+  SOUND_64 = 64,
   SOUND_Button = 66,
   SOUND_67 = 67,
   SOUND_71 = 71,
@@ -88,6 +89,7 @@
   SOUND_83 = 83,
   SOUND_84 = 84,
   SOUND_85 = 85,
+  SOUND_103 = 103,
   SOUND_Arcomage_LoseResources = 0x78,
   SOUND_Arcomage_AddResources = 0x79,
   SOUND_Arcomage_TowerWallDamage = 0x7A,
--- a/CastSpellInfo.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/CastSpellInfo.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -4069,36 +4069,26 @@
 //----- (00427DA0) --------------------------------------------------------
 unsigned int CastSpellInfo::PushCastSpellInfo(__int16 a2, __int16 uPlayerID, __int16 skill_level, __int16 a5, int spell_sound_id)
 {
-  unsigned int result; // eax@1
-  CastSpellInfo *v7; // edx@1
-  CastSpellInfo *v8; // ecx@5
-
-  result = 0;
-  v7 = this;
-  while ( v7->spellnum )
+  for ( uint i = 0; i < 10; i++ )
   {
-    ++result;
-    ++v7;
-    if ( (signed int)result >= 10 )
-      goto LABEL_8;
+    if ( !this[i].spellnum )
+    {
+      this[i].spellnum = a2;
+      this[i].uPlayerID = uPlayerID;
+      if ( a5 & 0x10 )
+        this[i].uPlayerID_2 = uPlayerID;
+      this[i].field_6 = 0;
+      this[i].spell_target_pid = 0;
+      this[i].field_8 = a5;
+      this[i].forced_spell_skill_level = skill_level;
+      this[i].sound_id = spell_sound_id;
+      return i;
+    }
   }
-  v8 = &this[result];
-  v8->spellnum = a2;
-  v8->uPlayerID = uPlayerID;
-  if ( a5 & 0x10 )
-    v8->uPlayerID_2 = uPlayerID;
-  v8->field_6 = 0;
-  v8->spell_target_pid = 0;
-  v8->field_8 = a5;
-  v8->forced_spell_skill_level = skill_level;
-  v8->sound_id = spell_sound_id;
-LABEL_8:
-  if ( result == 10 )
-    result = -1;
-  return result;
+  return -1;
 }
 //----- (00427D48) --------------------------------------------------------
-void CastSpellInfo::_427D48(unsigned int uPlayerID)
+void CastSpellInfo::_427D48(unsigned int uPlayerID)//Press S
 {
   CastSpellInfo *v2; // esi@1
   signed int v3; // ebx@1
--- a/Chest.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/Chest.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -419,18 +419,13 @@
     item_in_chest_count = CountChestItems(uChestID);
     if ( item_in_chest_count == -1 )
       return 0;
-    v22 = 0;
-    if ( v5 > 0 )
-    {
-      while ( !Chest::CanPlaceItemAt(v22, v4->uItemID, pChestWindow->par1C) )
+    for( int i = 0; i < v5; i++)
+	{
+      if ( Chest::CanPlaceItemAt(i, v4->uItemID, pChestWindow->par1C) )
       {
-        ++v22;
-        if ( v22 >= v5 )
-          goto LABEL_8;
+        v21 = i;
       }
-      v21 = v22;
     }
-LABEL_8:
     if ( v22 == v5 )
     {
       if ( uActiveCharacter )
--- a/DecorationList.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/DecorationList.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -264,13 +264,12 @@
       ++uID;
       ++v4;
       if ( uID >= (signed int)v2->uNumDecorations )
-        goto LABEL_6;
+        return 0;
     }
     result = uID;
   }
   else
   {
-LABEL_6:
     result = 0;
   }
   return result;
--- a/GUIProgressBar.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/GUIProgressBar.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -203,15 +203,19 @@
         floorf(v4 + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15),
         16,
         pRenderer->uTargetRMask);
-      goto LABEL_11;
+        pRenderer->EndScene();
+		pRenderer->Present();
+		return;
     }
-LABEL_6:
     pRenderer->EndScene();
     return;
   }
 
   if (!pLoadingBg.pPixels)
-    goto LABEL_6;
+  {
+	pRenderer->EndScene();
+    return;
+  }
 
   pRenderer->DrawTextureRGB(0, 0, &pLoadingBg);
   pRenderer->SetRasterClipRect(0, 0, 0x27Fu, 0x1DFu);
@@ -220,7 +224,6 @@
     0x1D7u);
   pRenderer->DrawTextureTransparent(0xACu, 0x1CBu, &pLoadingProgress);
   pRenderer->ResetTextureClipRect();
-LABEL_11:
   pRenderer->EndScene();
   pRenderer->Present();
 }
\ No newline at end of file
--- a/GUIWindow.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/GUIWindow.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -393,19 +393,10 @@
 GUIButton *GUIWindow::GetControl(unsigned int uID)
 {
   GUIButton *result; // eax@1
-  unsigned int v3; // ecx@1
 
   result = this->pControlsHead;
-  v3 = uID;
-  if ( (signed int)uID > 0 )
-  {
-    do
-    {
-      result = result->pNext;
-      --v3;
-    }
-    while ( v3 );
-  }
+  for ( uID; uID; --uID )
+    result = result->pNext;
   return result;
 }
 
@@ -469,9 +460,9 @@
           max_beacons = 3;
 
       
-      __debugbreak(); // warning C4700: uninitialized local variable 'v19' used
+      //__debugbreak(); // warning C4700: uninitialized local variable 'v19' used
       for (int i =0; i< max_beacons; ++i)
-            CreateButton(pLloydsBeaconsPreviewXs[v19], pLloydsBeaconsPreviewYs[v19],
+            CreateButton(pLloydsBeaconsPreviewXs[i], pLloydsBeaconsPreviewYs[i],
                            92, 68, 1, 180, UIMSG_InstallBeacon, i, 0, "", 0);
 
       for (int i =0; i< 5; ++i)
@@ -1106,7 +1097,7 @@
           JailDialog();
           break;
         default:
-          __debugbreak();//New BuildingType
+          //__debugbreak();//New BuildingType (if enter Boat)
           break;
       }
   }
--- a/Game.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/Game.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -89,10 +89,12 @@
 
   if ( pVideoPlayer->AnyMovieLoaded() )
   {
-    if ( pRenderer->pRenderD3D )
-      goto LABEL_22;
-    pRenderer->BeginSceneD3D();
-    pMouse->DrawCursorToTarget();
+    if ( !pRenderer->pRenderD3D )
+    {
+		pRenderer->BeginSceneD3D();
+		pMouse->DrawCursorToTarget();
+		pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
+	}
   }
   else
   {
@@ -133,9 +135,8 @@
         pGame->pLightmapBuilder->DrawLightmapsType(2);
       }
     }
+    pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
   }
-  pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
-LABEL_22:
 
   //DEBUG: force redraw gui
   viewparams->bRedrawGameUI = true;
@@ -1025,10 +1026,13 @@
     || SHIDWORD(v2) < ((unsigned int)v2 < LODWORD(uSomeGammaStartTime)) + HIDWORD(uSomeGammaStartTime) | v4 == 0
     && v3 <= 0x80 )
   {
-    if ( v4 > 0 || v4 >= 0 )
-      goto LABEL_12;
-    v3 = 0;
-    v4 = 0;
+    if ( v4 < 0 )
+	{
+		v3 = 0;
+		v4 = 0;
+		uSomeGammaStartTime = v2;
+		v8 = __PAIR__(v4, v3);
+	}
   }
   else
   {
@@ -1045,10 +1049,9 @@
     v5 = __CFADD__(v3, -128);
     v3 -= 128;
     v4 = v5 + v4 - 1;
+    uSomeGammaStartTime = v2;
+    v8 = __PAIR__(v4, v3);
   }
-  uSomeGammaStartTime = v2;
-  v8 = __PAIR__(v4, v3);
-LABEL_12:
   if ( uSomeGammaDeltaTime )
     v6 = (double)(signed __int64)(uSomeGammaDeltaTime - __PAIR__(v4, v3));
   else
--- a/GammaControl.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/GammaControl.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -72,16 +72,18 @@
   {
     v3 = (double)v6 * 0.0039215689 * this->fGamma;
     if ( v3 >= 1.0 || (v4 = (signed __int64)(v3 * 65535.0), (signed int)v4 > 65535) )
-      goto LABEL_12;
-    if ( (signed int)v4 < 0 )
+	{
+		LODWORD(v4) = 65535;	
+	}
+    else if ( (signed int)v4 < 0 )
     {
       LODWORD(v4) = 0;
-      goto LABEL_8;
     }
+	else
+	{
     if ( (signed int)v4 > 65535 )
-LABEL_12:
       LODWORD(v4) = 65535;
-LABEL_8:
+	}
     ++v6;
     v2[256] = v4;
     *v2 = v4;
--- a/Mouse.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/Mouse.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -57,36 +57,25 @@
 //----- (00469903) --------------------------------------------------------
 void Mouse::SetCursorBitmap(const char *pName)
 {
-  Mouse *v2; // esi@1
-  HCURSOR v3; // eax@10
-  //int v4; // ecx@10
-  double v5; // st7@11
-  float v6; // ST04_4@12
-  LONG v7; // eax@14
-  LONG v8; // eax@17
-  unsigned int v9; // eax@21
-  float v10; // [sp+4h] [bp-18h]@11
   struct tagPOINT Point; // [sp+14h] [bp-8h]@20
 
-  v2 = this;
   if ( !this->bInitialized || !pName )
     return;
   if ( _stricmp("MICON2", pName) )
     pGame->uFlags2 &= 0xFFFFFFEFu;
   else
     pGame->uFlags2 |= 0x10u;
-  if ( _stricmp(v2->pCurrentCursorName, pName) )
-    strcpy(v2->pCurrentCursorName, pName);
+  if ( _stricmp(this->pCurrentCursorName, pName) )
+    strcpy(this->pCurrentCursorName, pName);
   ClearCursor();
-  if ( _strnicmp(pName, "MICON1", 5u) )
+  if ( _strnicmp(pName, "MICON1", 5) )
   {
-    v9 = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE);
-    v2->uCursorTextureID = v9;
-    v2->uCursorTextureID_2 = v9;
-    v2->AllocCursorSystemMem();
-    v2->field_C = 0;
-    v2->bRedraw = 1;
-    v2->bActive = 1;
+    this->uCursorTextureID = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE);
+    this->uCursorTextureID_2 = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE);
+    this->AllocCursorSystemMem();
+    this->field_C = 0;
+    this->bRedraw = 1;
+    this->bActive = 1;
     if ( !areWeLoadingTexture )
     {
       if (uCursorTextureID != -1)
@@ -95,28 +84,17 @@
     }
     return;
   }
-  v2->bActive = 0;
-  v2->field_C = 1;
+  this->bActive = 0;
+  this->field_C = 1;
   if ( !strcmp(pName, "MICON1") )
-  {
-    v3 = LoadCursorA(GetModuleHandleW(nullptr), "Arrow");
-    SetClassLongA(hWnd, GCL_HCURSOR, (LONG)v3);
-  }
+    SetClassLongA(hWnd, GCL_HCURSOR, (LONG)LoadCursorA(GetModuleHandleW(nullptr), "Arrow"));
   else if ( !strcmp(pName, "MICON2") )
-  {
-    v7 = (LONG)LoadCursorA(GetModuleHandleW(nullptr), "Target");
-    SetClassLongA(hWnd, -12, v7);
-  }
+    SetClassLongA(hWnd, -12, (LONG)LoadCursorA(GetModuleHandleW(nullptr), "Target"));
   else if ( !strcmp(pName, "MICON3") )
-  {
-    v8 = (LONG)LoadCursorA(0, (LPCSTR)IDC_WAIT);
-    SetClassLongA(hWnd, -12, v8);
-  }
-//LABEL_18:
-
-    GetCursorPos(&Point);
-	ClientToScreen(hWnd,&Point);
-    SetCursorPos(Point.x, Point.y);
+    SetClassLongA(hWnd, -12, (LONG)LoadCursorA(0, (LPCSTR)IDC_WAIT));
+  GetCursorPos(&Point);
+  ClientToScreen(hWnd,&Point);
+  SetCursorPos(Point.x, Point.y);
 }
 // 506128: using guessed type int areWeLoadingTexture;
 
--- a/Outdoor_stuff.h	Sat Aug 03 00:00:10 2013 +0600
+++ b/Outdoor_stuff.h	Sat Aug 03 00:00:31 2013 +0600
@@ -19,7 +19,7 @@
   void DrawBorderTiles();
   //void _48276F_sr();
   void _normalize_v_18();
-  void _48607B(struct stru149 *a2);
+  void Create_48607B(struct stru149 *a2);
 
   float field_0;
   float field_4;
@@ -70,7 +70,7 @@
 {
   int _48616B(int a2, int a3, int a4, int a5, int a6, int a7);
   int _48653D(int a2, int a3, int a4, int a5, int a6, int a7);
-  int sky_48694B();
+  void Inverse_sky_48694B();
 
   int field_0_party_dir_x;
   int field_4_party_dir_y;
--- a/Party.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/Party.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -84,12 +84,16 @@
     uDefaultPartyHeight = 120;
     field_14 = 37;
     y_rotation_granularity = 25;
+    y_rotation_speed = 90;
+
     uWalkSpeed = 384;
-    y_rotation_speed = 90;
+    walk_sound_timer = 0;
+
     field_24 = 5;
     field_6FC = 0;
     field_708 = 15;
     field_0 = 25;
+
 }
 
 //inlined
--- a/Party.h	Sat Aug 03 00:00:10 2013 +0600
+++ b/Party.h	Sat Aug 03 00:00:31 2013 +0600
@@ -34,6 +34,7 @@
 /*  355 */
 enum PARTY_FLAGS_1: __int32
 {
+  PARTY_FLAGS_1_WATER_DAMAGE = 0x0004,
   PARTY_FLAGS_1_FALLING = 0x0008,
   PARTY_FLAGS_1_ALERT_RED = 0x0010,
   PARTY_FLAGS_1_ALERT_YELLOW = 0x0020,
--- a/Player.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/Player.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -7997,14 +7997,6 @@
       v27->uReputation = 10000;
   }
 }
-// 506568: using guessed type int dword_506568;
-// 507948: using guessed type char bFlashHistoryBook;
-// 507949: using guessed type char bFlashAutonotesBook;
-// 50794A: using guessed type char bFlashQuestBook;
-// 72371C: using guessed type int dword_72371C[];
-// 723E80: using guessed type int dword_723E80_award_related[];
-
-
 
 
 //----- (0044B9C4) --------------------------------------------------------
@@ -8636,7 +8628,7 @@
     }
   }
 
-  assert(false);
+  //assert(false);
   return false;
 }
 // 5B65C4: using guessed type int dword_5B65C4;
@@ -8737,49 +8729,36 @@
   Player *v2; // edx@3
   int v3; // ecx@3
   Player **pPlayers; // esi@8
-  unsigned int v5; // ecx@8
+  //bool item_flag;
   Player *v6; // edx@9
 
-  if ( a1 < 1 || a1 > 4 )
-  {
-    if ( !a1 )
-    {
-      pPlayers = &::pPlayers[1];
-      v5 = 604;
-      while ( 1 )
-      {
-        result = Player_has_item(v5, *pPlayers, 0);
-        if ( !result )
-          break;
-        __debugbreak(); // player.cpp(8748): warning C4700: uninitialized local variable 'v6' used
-        result = v6->pEquipment.uArmor;
-        if ( !result )
-          break;
-        result *= 9;
-        if ( *(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v5 )
-          break;
-        ++pPlayers;
-        if ( (signed int)pPlayers >= (signed int)&qword_A750D8 )
-          goto LABEL_13;
-      }
-    }
-    goto LABEL_6;
-  }
-  result = Player_has_item(604u, ::pPlayers[a1], 0);
-  __debugbreak(); // player.cpp(8764): warning C4700: uninitialized local variable 'v2' used
-  __debugbreak(); // player.cpp(8764): warning C4700: uninitialized local variable 'v3' used
-  if ( !result
-    || (result = v2->pEquipment.uArmor) == 0
-    || (result *= 9, *(int *)&v2->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v3) )
-  {
-LABEL_6:
-    LOBYTE(result) = 0;
-    return result;
-  }
-LABEL_13:
-  LOBYTE(result) = 1;
-  return result;
-}
+  //if ( a1 < 1 || a1 > 4 )
+  //{
+    //if ( !a1 )
+    //{
+      //pPlayers = &::pPlayers[1];
+      //v5 = 604;
+      //while ( 1 )
+  assert ( a1 > 0 && a1 < 5 );
+      for ( uint i = 1; i < 5; ++i )
+      {
+        //item_flag = Player_has_item(604, *pPlayers, 0);
+        if ( !Player_has_item(604, ::pPlayers[i], 0) )
+          return false;
+        //__debugbreak(); // player.cpp(8748): warning C4700: uninitialized local variable 'v6' used
+        //result = ::pPlayers[i]->pEquipment.uArmor;
+        if ( !::pPlayers[i]->pEquipment.uArmor )
+          return false;
+        //result *= 9;
+        if (::pPlayers[i]->pEquippedItems[::pPlayers[i]->pEquipment.uArmor].uItemID != 604 )
+          return false;
+        //++pPlayers;
+        //if ( (signed int)pPlayers >= (signed int)&qword_A750D8 )
+          //return true;
+      }
+      return true;
+    }
+
 //----- (0043EE15) --------------------------------------------------------
 bool __fastcall Player_has_item(unsigned int uItemID, Player *pPlayer, char a3)
 {
--- a/Player.h	Sat Aug 03 00:00:10 2013 +0600
+++ b/Player.h	Sat Aug 03 00:00:31 2013 +0600
@@ -294,11 +294,12 @@
 struct LloydBeacon
 {
   unsigned __int64 uBeaconTime;
-  int field_8;
-  int field_C;
-  int field_10;
-  int field_14;
-  int field_18;
+  int PartyPos_X;
+  int PartyPos_Y;
+  int PartyPos_Z;
+  __int16 PartyRot_X;
+  __int16 PartyRot_Y;
+  int SaveFileID;
 };
 #pragma pack(pop)
 
--- a/Render.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/Render.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -209,27 +209,10 @@
   return result;
 }
 
-
 void Render::RenderTerrainD3D() // New function
 {
-  char result; // al@3
   int v6; // ecx@8
- struct Polygon *pTile; // ebx@8
- struct Polygon *v16;
-  unsigned int v18; // edi@22
-  int v35; // edi@63
-  int v37; // eax@73
-  int v39; // eax@80
-  char v40; // [sp-18h] [bp-70h]@2
-  int v41; // [sp-14h] [bp-6Ch]@2
-  int v42; // [sp-10h] [bp-68h]@2
-  int v43; // [sp-Ch] [bp-64h]@2
-  const char *v44; // [sp-8h] [bp-60h]@2
-  int v45; // [sp-4h] [bp-5Ch]@2
-  int v56;
-  int v57; // [sp+38h] [bp-20h]@36
-  int v64; // [sp+57h] [bp-1h]@2
-  int v62;
+  struct Polygon *pTilePolygon; // ebx@8
 
   //warning: the game uses CW culling by default, ccw is incosistent
   pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW);
@@ -271,20 +254,20 @@
   {
     for (unsigned int x = 0; x < 127; ++x)
     {
-      pTile = &array_77EC08[pOutdoorCamera->uNumPolygons];
-      pTile->flags = 0;
-      pTile->field_32 = 0;
-      pTile->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z);
-      pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTile->uTileBitmapID];
-      if (pTile->uTileBitmapID == 0xFFFF)
+      pTilePolygon = &array_77EC08[pOutdoorCamera->uNumPolygons];
+      pTilePolygon->flags = 0;
+      pTilePolygon->field_32 = 0;
+      pTilePolygon->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z);
+      pTilePolygon->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTilePolygon->uTileBitmapID];
+      if (pTilePolygon->uTileBitmapID == 0xFFFF)
         continue;
 
       //pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z);
-      pTile->flags = pOutdoor->GetSomeOtherTileInfo(x, z);
-      pTile->field_32 = 0;
-      pTile->field_59 = 1;
-      pTile->sTextureDeltaU = 0;
-      pTile->sTextureDeltaV = 0;
+      pTilePolygon->flags = pOutdoor->GetSomeOtherTileInfo(x, z);
+      pTilePolygon->field_32 = 0;
+      pTilePolygon->field_59 = 1;
+      pTilePolygon->sTextureDeltaU = 0;
+      pTilePolygon->sTextureDeltaV = 0;
 //  x,z         x+1,z
 //  .____________.
 //  |            |
@@ -309,30 +292,30 @@
       //v58 = 0;
       //if (v58 == 4) // if all y == first y;  primitive in xz plane 
         //pTile->field_32 |= 0x0001;
-      pTile->pODMFace = nullptr;
-      pTile->uNumVertices = 4;
-      pTile->field_59 = 5;
+      pTilePolygon->pODMFace = nullptr;
+      pTilePolygon->uNumVertices = 4;
+      pTilePolygon->field_59 = 5;
 
 //shading ()----------------------------------------------------------------------------
       //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1];
-      uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 1];//   1 ,     1
+      uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 2];
       assert(norm_idx < uNumTerrainNormals);
 
       auto norm = pTerrainNormals + norm_idx;
       float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) -
                   (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) -
                   (norm->z * (float)pOutdoor->vSunlight.z / 65536.0));
-      pTile->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f);
+      pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f);
 //-----------------------------------------------------------------------------------------------
 
       ++pOutdoorCamera->uNumPolygons;
       ++pOutdoorCamera->field_44;
       assert(pOutdoorCamera->uNumPolygons < 20000);
 
-      pTile->uBModelID = 0;
-      pTile->uBModelFaceID = 0;
-      pTile->field_50 = (8 * (0 | (0 << 6))) | 6;
-      for (unsigned int k = 0; k < pTile->uNumVertices; ++k)
+      pTilePolygon->uBModelID = 0;
+      pTilePolygon->uBModelFaceID = 0;
+      pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6;
+      for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k)
       {
         memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft));
         array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097);
@@ -340,27 +323,27 @@
 
 // check the transparency and texture (tiles) mapping (     ())----------------------
       bool transparent = false;
-      if ( !( pTile->flags & 1 ) ) //   TextureFrameTable
-      {
-        if ( pTile->flags & 2 && pTile->uTileBitmapID == pRenderer->hd_water_tile_id)
+      if ( !( pTilePolygon->flags & 1 ) ) //   TextureFrameTable
+      {
+        if ( /*pTile->flags & 2 && */pTilePolygon->uTileBitmapID == pRenderer->hd_water_tile_id)
         {
           //transparent = false;
           v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame];
         }
         else
         {
-          v6 = pTile->uTileBitmapID;
-          if ( !_strnicmp(pBitmaps_LOD->pTextures[pTile->uTileBitmapID].pName, "wtrdr", 5) )
+          v6 = pTilePolygon->uTileBitmapID;
+          if ( !_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5) )
             transparent = true;
         }
 
       assert(v6 < 1000); // many random crashes here
 
       // for all shore tiles - draw a tile water under them since they're half-empty
-      if (!_strnicmp(pBitmaps_LOD->pTextures[pTile->uTileBitmapID].pName, "wtrdr", 5))  // all shore tile filenames are wtrdrXXX
-        pTile->DrawBorderTiles();
-
-      pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v6], transparent, true);
+      if (!_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5))  // all shore tile filenames are wtrdrXXX
+        pTilePolygon->DrawBorderTiles();
+
+      pRenderer->DrawTerrainPolygon(pTilePolygon->uNumVertices, pTilePolygon, pBitmaps_LOD->pHardwareTextures[v6], transparent, true);
       }
       //else //    
         //pTile->DrawBorderTiles();
@@ -2770,7 +2753,7 @@
 //----- (0049F8B5) --------------------------------------------------------
 FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5)
 {
-  Render *v5; // esi@1
+  //Render *v5; // esi@1
   FILE *result; // eax@1
   FILE *v7; // edi@4
   int v8; // ecx@5
@@ -2792,7 +2775,6 @@
   int v24; // [sp+9Ch] [bp-8h]@2
   char *i; // [sp+A0h] [bp-4h]@8
 
-  v5 = this;
   result = fopen(Filename, "wb");
   Filename = (const char *)result;
   if ( result )
@@ -2853,16 +2835,16 @@
           i = (char *)ptr + 2 * v24;
           do
           {
-            *((char *)ptr + v10) = (signed int)(v5->uTargetRMask & *(short *)a5) >> (LOBYTE(v5->uTargetGBits)
-                                                                                    + LOBYTE(v5->uTargetBBits)
-                                                                                    + v5->uTargetRBits
+            *((char *)ptr + v10) = (signed int)(this->uTargetRMask & *(short *)a5) >> (LOBYTE(this->uTargetGBits)
+                                                                                    + LOBYTE(this->uTargetBBits)
+                                                                                    + this->uTargetRBits
                                                                                     - 8);
-            a3[v10] = (signed int)(v5->uTargetGMask & *(short *)a5) >> (LOBYTE(v5->uTargetBBits)
-                                                                      + LOBYTE(v5->uTargetGBits)
+            a3[v10] = (signed int)(this->uTargetGMask & *(short *)a5) >> (LOBYTE(this->uTargetBBits)
+                                                                      + LOBYTE(this->uTargetGBits)
                                                                       - 8);
             v11 = a5;
             a5 += 2;
-            i[v10++] = (v5->uTargetBMask & *(char *)v11) << (8 - LOBYTE(v5->uTargetBBits));
+            i[v10++] = (this->uTargetBMask & *(char *)v11) << (8 - LOBYTE(this->uTargetBBits));
           }
           while ( v10 < a4 );
         }
@@ -4947,11 +4929,9 @@
 // 4D864C: using guessed type char byte_4D864C;
 
 //----- (004A2DA3) --------------------------------------------------------
-void Render::DrawSkyPolygon(unsigned int uNumVertices, struct Polygon *a3, IDirect3DTexture2 *pTexture)
+void Render::DrawSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture)
 {
   int v7; // eax@7
-  float v13; // ST3C_4@8
-  int i;
 
   if ( !this->uNumD3DSceneBegins )
     return;
@@ -4964,7 +4944,7 @@
       this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
       this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
     }
-    for ( i = 0; i < uNumVertices; ++i )
+    for ( uint i = 0; i < uNumVertices; ++i )
     {
       pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX;
       pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY;
@@ -4974,10 +4954,7 @@
       pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0);
       v7 = 0;
       if (this->bUsingSpecular)
-      {
-        v13 = array_50AC10[i].vWorldViewPosition.x;
-        v7 = sub_47C3D7_get_fog_related_stuff(0, 1, v13);
-      }
+        v7 = sub_47C3D7_get_fog_related_stuff(0, 1, array_50AC10[i].vWorldViewPosition.x);
       pVertices[i].specular = v7;
       pVertices[i].texcoord.x = array_50AC10[i].u;
       pVertices[i].texcoord.y = array_50AC10[i].v;
@@ -5169,7 +5146,7 @@
   if ( v7 == 4 || v7 == 3 )
     v70 = v6;
   stru_8019C8._48653D(65536, 0, 0, 0, 65536, 0);
-  v62._48607B(&stru_8019C8);
+  v62.Create_48607B(&stru_8019C8);
   v62.uTileBitmapID = pFace->uBitmapID;
   v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0);
   if ( !v62.pTexture )
--- a/Render.h	Sat Aug 03 00:00:10 2013 +0600
+++ b/Render.h	Sat Aug 03 00:00:31 2013 +0600
@@ -320,7 +320,7 @@
   unsigned int GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6);
   void DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture);
   void DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders);
-  void DrawSkyPolygon(unsigned int uNumVertices, struct Polygon *a3, IDirect3DTexture2 *pTexture);
+  void DrawSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture);
   void _4A2ED5(signed int a2, struct Polygon *a3, IDirect3DTexture2 *pHwTex);
   void DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, struct Texture *pTex, int uPackedID, unsigned int uColor, int a8);
   void DrawIndoorPolygonNoLight(unsigned int uNumVertices, unsigned int uFaceID);
--- a/SaveLoad.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/SaveLoad.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -795,34 +795,27 @@
     v26 = pRenderer->uTargetSurfacePitch;
     if ( pRenderer->pTargetSurface )
     {
-      v29 = 0;
       if ( height > 0 )
       {
-        do
+        for ( v29 = 0; v29 < height; ++v29 )
         {
-          v28 = 0;
           if ( width > 0 )
           {
             v15 = v26 * (unsigned __int64)(signed __int64)((double)v29 * v25 + 8.0);
-            do
+            for ( v28 = 0; v28 < width; v28++ )
             {
-              v16 = (signed __int64)((double)v28++ * v23 + 8.0);
-              *v3 = _this[v15 + (int)v16];
+              *v3 = _this[v15 + (int)(signed __int64)((double)v28 * v23 + 8.0)];
               ++v3;
             }
-            while ( v28 < width );
           }
-          ++v29;
         }
-        while ( v29 < height );
       }
     }
     else
     {
       if ( height > 0 )
       {
-        v17 = height;
-        do
+        for ( v17 = height; v17; --v17 )
         {
           if ( width > 0 )
           {
@@ -835,9 +828,7 @@
             }
             v3 += width;
           }
-          --v17;
         }
-        while ( v17 );
       }
     }
     pRenderer->EndScene();
@@ -847,11 +838,9 @@
 //----- (0045E26C) --------------------------------------------------------
 void __thiscall SaveScreenshot(const char *pFilename)
 {
-  const char *v1; // edi@1
   unsigned __int16 *v2; // esi@1
 
-  v1 = pFilename;
   v2 = MakeScreenshot(92, 68);
-  pRenderer->SavePCXImage(v1, (char *)v2, 92, 68);
+  pRenderer->SavePCXImage(pFilename, (char *)v2, 92, 68);
   free(v2);
 }
\ No newline at end of file
--- a/UI/Books/UIMapBook.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/UI/Books/UIMapBook.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -86,34 +86,34 @@
 unsigned int __cdecl DrawLloydBeaconsScreen()
 {
   Player *pPlayer; // esi@1
-  char *v1; // eax@1
-  unsigned __int16 v2; // ax@6
-  unsigned int result; // eax@11
-  unsigned int v4; // esi@13
-  unsigned int v5; // ecx@13
-  char v6; // zf@13
-  LloydBeacon *v7; // esi@14
-  int v8; // eax@14
-  unsigned __int64 v9; // kr08_8@14
-  unsigned int v10; // esi@14
-  unsigned int v11; // eax@14
-  char *v12; // eax@19
-  char *v13; // ecx@22
-  int v14; // eax@27
+  char *pText; // eax@1
+  //unsigned __int16 v2; // ax@6
+  //unsigned int result; // eax@11
+  //unsigned int v4; // esi@13
+  //unsigned int v5; // ecx@13
+  //char v6; // zf@13
+  //LloydBeacon *v7; // esi@14
+  int pTextHeight; // eax@14
+  int RemainingTime; // kr08_8@14
+  unsigned int pHours; // esi@14
+  unsigned int pDays; // eax@14
+  char *pSelectionText; // eax@19
+  //char *v13; // ecx@22
+  //int v14; // eax@27
   Texture *v19; // [sp-4h] [bp-8Ch]@4
   GUIWindow pWindow; // [sp+Ch] [bp-7Ch]@1
-  unsigned int v23; // [sp+64h] [bp-24h]@14
-  __int64 v24; // [sp+68h] [bp-20h]@14
-  unsigned int v25; // [sp+70h] [bp-18h]@13
+  //unsigned int v23; // [sp+64h] [bp-24h]@14
+  //__int64 v24; // [sp+68h] [bp-20h]@14
+  //unsigned int v25; // [sp+70h] [bp-18h]@13
   char *Str; // [sp+74h] [bp-14h]@14
-  int v27; // [sp+78h] [bp-10h]@11
-  LloydBeacon *v28; // [sp+7Ch] [bp-Ch]@12
-  RGBTexture *v29; // [sp+80h] [bp-8h]@12
+  int BeaconID; // [sp+78h] [bp-10h]@11
+  //LloydBeacon *v28; // [sp+7Ch] [bp-Ch]@12
+  //RGBTexture *v29; // [sp+80h] [bp-8h]@12
   int uNumMaxBeacons; // [sp+84h] [bp-4h]@6
 
   pPlayer = &pParty->pPlayers[_506348_current_lloyd_playerid];
-  pRenderer->DrawTextureIndexed(8u, 8u, pTexture_LloydBeacons[(unsigned __int8)bRecallingBeacon]);
-  v1 = pGlobalTXT_LocalizationStrings[523];     // Recall Beacon
+  pRenderer->DrawTextureIndexed(8, 8, pTexture_LloydBeacons[(unsigned __int8)bRecallingBeacon]);
+  pText = pGlobalTXT_LocalizationStrings[523];     // Recall Beacon
   pWindow.uFrameX = game_viewport_x;
   pWindow.uFrameY = game_viewport_y;
   pWindow.uFrameWidth = 428;
@@ -121,9 +121,9 @@
   pWindow.uFrameZ = 435;
   pWindow.uFrameW = game_viewport_w;
   if ( !bRecallingBeacon )
-    v1 = pGlobalTXT_LocalizationStrings[375];   // Set Beacon
-  sprintf(pTmpBuf.data(), "%s", v1);
-  pWindow.DrawTitleText(pBook2Font, 0, 22u, 0, pTmpBuf.data(), 3u);
+    pText = pGlobalTXT_LocalizationStrings[375];   // Set Beacon
+  sprintf(pTmpBuf.data(), "%s", pText);
+  pWindow.DrawTitleText(pBook2Font, 0, 22u, 0, pTmpBuf.data(), 3);
   if ( bRecallingBeacon )
   {
     pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6b__zoom_on);
@@ -135,649 +135,531 @@
     v19 = pTex_tab_an_6b__zoom_on;
   }
   pRenderer->DrawTextureTransparent(pBtn_Book_2->uX, pBtn_Book_2->uY, v19);
-  v2 = pPlayer->pActiveSkills[14];
   uNumMaxBeacons = 1;
-  if ( HIBYTE(v2) & 1 || (v2 & 0x80u) != 0 )
+  if ( HIBYTE(pPlayer->pActiveSkills[14]) & 1 || (pPlayer->pActiveSkills[14] & 0x80u) != 0 )
   {
     uNumMaxBeacons = 5;
   }
   else
   {
-    if ( v2 & 0x40 )
+    if ( pPlayer->pActiveSkills[14] & 0x40 )
       uNumMaxBeacons = 3;
   }
-  result = 0;
-  v27 = 0;
   if ( uNumMaxBeacons > 0 )
   {
-    v29 = pSavegameThumbnails.data();
-    v28 = pPlayer->pInstalledBeacons;
-    while ( 1 )
+    for ( BeaconID = 0; BeaconID < uNumMaxBeacons; BeaconID++ )
     {
       pWindow.uFrameWidth = 92;
-      v4 = result;
       pWindow.uFrameHeight = 68;
-      v5 = pLloydsBeaconsPreviewXs[result];
-      pWindow.uFrameY = pLloydsBeaconsPreviewYs[result];
-      v25 = pWindow.uFrameY;
-      pWindow.uFrameX = v5;
+      pWindow.uFrameY = pLloydsBeaconsPreviewYs[BeaconID];
+      pWindow.uFrameX = pLloydsBeaconsPreviewXs[BeaconID];
       pWindow.uFrameW = pWindow.uFrameY + 67;
-      v6 = v29->pPixels == 0;
-      pWindow.uFrameZ = v5 + 91;
-      if ( !v6 )
-        break;
+      pWindow.uFrameZ = pLloydsBeaconsPreviewXs[BeaconID] + 91;
+      //if ( pSavegameThumbnails[BeaconID].pPixels != 0 )
+      if ( pPlayer->pInstalledBeacons[BeaconID].SaveFileID != 0 )
+      {
+        pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook);
+        pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[BeaconID], pLloydsBeaconsPreviewYs[BeaconID], &pSavegameThumbnails[BeaconID]);
+        Str = pMapStats->pInfos[sub_410D99_get_map_index(pPlayer->pInstalledBeacons[BeaconID].SaveFileID)].pName;
+        pTextHeight = pSpellFont->CalcTextHeight(Str, &pWindow, 0, 0);
+        pWindow.uFrameY += -6 - pTextHeight;
+        pWindow.DrawTitleText(pSpellFont, 0, 0, 1, Str, 3);
+        RemainingTime = pPlayer->pInstalledBeacons[BeaconID].uBeaconTime - pParty->uTimePlayed;
+        pHours = (signed __int64)((double)RemainingTime * 0.234375) / 60 / 60;
+        pDays = pHours / 24;
+        if ( pDays )
+        {
+          sprintf(pTmpBuf.data(), "%lu %s", pDays + 1, pGlobalTXT_LocalizationStrings[57]);//days
+          pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4;
+          pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
+          continue;
+        }
+        else
+        {
+          if ( pHours + 1 <= 23 )
+          {
+            if ( pHours < 1 )
+              pSelectionText = pGlobalTXT_LocalizationStrings[109];// Hour
+            else
+              pSelectionText = pGlobalTXT_LocalizationStrings[110];// Hours
+            sprintf(pTmpBuf.data(), "%lu %s", pHours + 1, pSelectionText);
+            pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4;
+            pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
+            continue;
+          }
+        }
+        sprintf(pTmpBuf.data(), "%lu %s", pDays + 1, pGlobalTXT_LocalizationStrings[56]);//Day
+        pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4;
+        pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
+        continue;
+      }
       if ( !bRecallingBeacon )
       {
-        pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[v4], pLloydsBeacons_SomeYs[v4], pTexture_CurrentBook);
-        v14 = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &pWindow, 0, 0);
-        pWindow.DrawTitleText(pSpellFont, 0, (signed int)pWindow.uFrameHeight / 2 - v14 / 2, 1, pGlobalTXT_LocalizationStrings[19], 3);
-      }
-LABEL_29:
-      ++v29;
-      ++v28;
-      result = v27++ + 1;
-      if ( v27 >= uNumMaxBeacons )
-        goto LABEL_30;
-    }
-    pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[v4], pLloydsBeacons_SomeYs[v4], pTexture_CurrentBook);
-    pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[v4], pLloydsBeaconsPreviewYs[v4], v29);
-    v7 = v28;
-    Str = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(v28->field_18))].pName;
-    v8 = pSpellFont->CalcTextHeight(Str, &pWindow, 0, 0);
-    pWindow.uFrameY += -6 - v8;
-    pWindow.DrawTitleText(pSpellFont, 0, 0, 1u, Str, 3u);
-    v9 = v7->uBeaconTime - pParty->uTimePlayed;
-    LODWORD(v24) = LODWORD(v7->uBeaconTime) - LODWORD(pParty->uTimePlayed);
-    HIDWORD(v24) = HIDWORD(v9);
-    v23 = (unsigned __int64)((signed __int64)((double)v24 * 0.234375) / 60 / 60) >> 32;
-    v10 = (signed __int64)((double)v24 * 0.234375) / 60 / 60;
-    v11 = v10 / 0x18;
-    if ( (unsigned int)((signed __int64)((double)v24 * 0.234375) / 60 / 60) / 0x18 )
-    {
-      v13 = pGlobalTXT_LocalizationStrings[57]; // Days
-      if ( v11 > 1 )
-      {
-        sprintf(pTmpBuf.data(), "%lu %s", v11 + 1, v13);
-        pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4;
-        pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
-        goto LABEL_29;
+        pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook);
+        pTextHeight = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &pWindow, 0, 0);
+        pWindow.DrawTitleText(pSpellFont, 0, (signed int)pWindow.uFrameHeight / 2 - pTextHeight / 2, 1, pGlobalTXT_LocalizationStrings[19], 3);//
       }
     }
-    else
-    {
-      if ( (signed __int64)(__PAIR__(v23, v10) + 1) <= 23 )
-      {
-        if ( (v23 & 0x80000000u) != 0 || (signed int)v23 <= 0 && v10 <= 1 )
-          v12 = pGlobalTXT_LocalizationStrings[109];// Hour
-        else
-          v12 = pGlobalTXT_LocalizationStrings[110];// Hours
-        sprintf(pTmpBuf.data(), "%lu %s", v10 + 1, v12);
-        pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4;
-        pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
-        goto LABEL_29;
-      }
-    }
-    v13 = pGlobalTXT_LocalizationStrings[56];   // Day
-    sprintf(pTmpBuf.data(), "%lu %s", v11 + 1, v13);
-    pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4;
-    pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
-    goto LABEL_29;
   }
-LABEL_30:
   if ( byte_506360 )
-  {
-    /*result = pMessageQueue_50CBD0->uNumMessages;
-    if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-    {
-      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CloseAfterInstallBeacon;
-      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
-      result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
-      *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
-      ++pMessageQueue_50CBD0->uNumMessages;
-    }*/
     pMessageQueue_50CBD0->AddMessage(UIMSG_CloseAfterInstallBeacon, 0, 0);
-  }
-  return result;
+  return BeaconID;
 }
 
-
 //----- (00413980) --------------------------------------------------------
 void BookUI_Map_Draw()
-    { 
-    int v6; // eax@31
-    unsigned int map_id; // eax@35
-    Texture *buttnTxtr; // [sp-4h] [bp-DCh]@3
-    char party_coord[120]; // [sp+Ch] [bp-CCh]@37
-    GUIWindow map_window; // [sp+84h] [bp-54h]@35
-    unsigned int textrX, textrY;
+{
+  unsigned int map_id; // eax@35
+  Texture *buttnTxtr; // [sp-4h] [bp-DCh]@3
+  char party_coord[120]; // [sp+Ch] [bp-CCh]@37
+  GUIWindow map_window; // [sp+84h] [bp-54h]@35
+  unsigned int textrX, textrY;
 
-    pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_12);
-    if ( BtnUp_flag || viewparams->field_2C / 128 >= 12 )
-        {
-        buttnTxtr = pTex_tab_an_6a__zoom_off;
-        textrY = pViewport->uViewportTL_Y + 2;
-        textrX = pViewport->uViewportTL_X + 408;
-        }
-    else
-        {
-        buttnTxtr = pTex_tab_an_6b__zoom_on;
-        textrY = pViewport->uViewportTL_Y + 1;
-        textrX = pViewport->uViewportTL_X + 398;
-        }
-    pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
-    if ( BtnDown_flag || viewparams->field_2C / 128 <= 3 )
-        {
-        buttnTxtr = pTex_tab_an_7a__zoot_off;
-        textrY = pViewport->uViewportTL_Y + 38;
-        textrX = pViewport->uViewportTL_X + 408;
-        }
-    else
-        {
-        buttnTxtr = pTex_tab_an_7b__zoot_on;
-        textrY = pViewport->uViewportTL_Y + 38;
-        textrX = pViewport->uViewportTL_X + 398;
-        }
-    pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
-    if ( Book_PageBtn3_flag )
-        {
-        buttnTxtr = pTexture_506390;
-        textrY = pViewport->uViewportTL_Y + 113;
-        textrX = pViewport->uViewportTL_X + 408;
-        }
-    else
-        {
-        buttnTxtr = pTexture_506394;
-        textrY = pViewport->uViewportTL_Y + 113;
-        textrX = pViewport->uViewportTL_X + 398;
-        }
-    pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
-    if ( Book_PageBtn4_flag )
-        {
-        buttnTxtr = pTexture_506388;
-        textrY = pViewport->uViewportTL_X + 150;
-        textrX = pViewport->uViewportTL_Y + 408;
-        }
-    else
-        {
-        buttnTxtr = pTexture_50638C;
-        textrY = pViewport->uViewportTL_X + 150;
-        textrX = pViewport->uViewportTL_Y + 399;
-        }
-    pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
-    if ( Book_PageBtn5_flag )
-        {
-        buttnTxtr = pTexture_506380;
-        textrY = pViewport->uViewportTL_Y + 188;
-        textrX = pViewport->uViewportTL_X + 408;
-        }
-    else
-        {
-        buttnTxtr = pTexture_506384;
-        textrY = pViewport->uViewportTL_Y + 188;
-        textrX = pViewport->uViewportTL_X + 397;
-        }
-    pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
-    if ( Book_PageBtn6_flag )
-        {
-        buttnTxtr = pTexture_506378;
-        textrY = pViewport->uViewportTL_Y + 226;
-        textrX = pViewport->uViewportTL_X + 408;
-        }
-    else
-        {
-        buttnTxtr = pTexture_50637C;
-        textrY = pViewport->uViewportTL_Y + 226;
-        textrX = pViewport->uViewportTL_X + 397;
-        }
-    pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
-    if ( BtnDown_flag )
-        viewparams->CenterOnParty2();
-    if ( BtnUp_flag )
-        viewparams->CenterOnParty();
-    if ( Book_PageBtn3_flag )
-        viewparams->_443219();
-    if ( Book_PageBtn4_flag )
-        viewparams->_443231();
-    if ( Book_PageBtn5_flag )
-        viewparams->_44323D();
-    if ( Book_PageBtn6_flag )
-        viewparams->_443225();
+  pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_12);
+  if ( BtnUp_flag || viewparams->field_2C / 128 >= 12 )
+  {
+    buttnTxtr = pTex_tab_an_6a__zoom_off;
+    textrY = pViewport->uViewportTL_Y + 2;
+    textrX = pViewport->uViewportTL_X + 408;
+  }
+  else
+  {
+    buttnTxtr = pTex_tab_an_6b__zoom_on;
+    textrY = pViewport->uViewportTL_Y + 1;
+    textrX = pViewport->uViewportTL_X + 398;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
+  if ( BtnDown_flag || viewparams->field_2C / 128 <= 3 )
+  {
+    buttnTxtr = pTex_tab_an_7a__zoot_off;
+    textrY = pViewport->uViewportTL_Y + 38;
+    textrX = pViewport->uViewportTL_X + 408;
+  }
+  else
+  {
+    buttnTxtr = pTex_tab_an_7b__zoot_on;
+    textrY = pViewport->uViewportTL_Y + 38;
+    textrX = pViewport->uViewportTL_X + 398;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
+  if ( Book_PageBtn3_flag )
+  {
+    buttnTxtr = pTexture_506390;
+    textrY = pViewport->uViewportTL_Y + 113;
+    textrX = pViewport->uViewportTL_X + 408;
+  }
+  else
+  {
+    buttnTxtr = pTexture_506394;
+    textrY = pViewport->uViewportTL_Y + 113;
+    textrX = pViewport->uViewportTL_X + 398;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
+  if ( Book_PageBtn4_flag )
+  {
+    buttnTxtr = pTexture_506388;
+    textrY = pViewport->uViewportTL_X + 150;
+    textrX = pViewport->uViewportTL_Y + 408;
+  }
+  else
+  {
+    buttnTxtr = pTexture_50638C;
+    textrY = pViewport->uViewportTL_X + 150;
+    textrX = pViewport->uViewportTL_Y + 399;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
+  if ( Book_PageBtn5_flag )
+  {
+    buttnTxtr = pTexture_506380;
+    textrY = pViewport->uViewportTL_Y + 188;
+    textrX = pViewport->uViewportTL_X + 408;
+  }
+  else
+  {
+    buttnTxtr = pTexture_506384;
+    textrY = pViewport->uViewportTL_Y + 188;
+    textrX = pViewport->uViewportTL_X + 397;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
+  if ( Book_PageBtn6_flag )
+  {
+    buttnTxtr = pTexture_506378;
+    textrY = pViewport->uViewportTL_Y + 226;
+    textrX = pViewport->uViewportTL_X + 408;
+  }
+  else
+  {
+    buttnTxtr = pTexture_50637C;
+    textrY = pViewport->uViewportTL_Y + 226;
+    textrX = pViewport->uViewportTL_X + 397;
+  }
+  pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
+  if ( BtnDown_flag )
+    viewparams->CenterOnParty2();
+  if ( BtnUp_flag )
+    viewparams->CenterOnParty();
+  if ( Book_PageBtn3_flag )
+    viewparams->_443219();
+  if ( Book_PageBtn4_flag )
+    viewparams->_443231();
+  if ( Book_PageBtn5_flag )
+    viewparams->_44323D();
+  if ( Book_PageBtn6_flag )
+    viewparams->_443225();
 
-    if ( BtnUp_flag | BtnDown_flag | Book_PageBtn3_flag | Book_PageBtn4_flag | Book_PageBtn5_flag | Book_PageBtn6_flag )
-        pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
-    BtnUp_flag = 0;
-    BtnDown_flag = 0;
-    Book_PageBtn6_flag = 0;
-    Book_PageBtn5_flag = 0;
-    Book_PageBtn4_flag = 0;
-    Book_PageBtn3_flag = 0;
-    DrawBook_Map_sub(97, 49, 361, 313, 0);
-    pRenderer->DrawTextureTransparent(75, 22, pTexture_mapbordr);
-    map_window.uFrameWidth = game_viewport_width;
-    map_window.uFrameHeight = game_viewport_height;
-    map_window.uFrameX = game_viewport_x;
-    map_window.uFrameY = game_viewport_y;
-    map_window.uFrameZ = game_viewport_z;
-    map_window.uFrameW = game_viewport_w;
-    map_id = pMapStats->GetMapInfo(pCurrentMapName.data());
-    if ( map_id )
-        map_window.DrawTitleText(pBook2Font, -14, 12, ui_book_map_title_color, pMapStats->pInfos[map_id].pName, 3);
+  if ( BtnUp_flag | BtnDown_flag | Book_PageBtn3_flag | Book_PageBtn4_flag | Book_PageBtn5_flag | Book_PageBtn6_flag )
+    pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
+  BtnUp_flag = 0;
+  BtnDown_flag = 0;
+  Book_PageBtn6_flag = 0;
+  Book_PageBtn5_flag = 0;
+  Book_PageBtn4_flag = 0;
+  Book_PageBtn3_flag = 0;
+  DrawBook_Map_sub(97, 49, 361, 313, 0);
+  pRenderer->DrawTextureTransparent(75, 22, pTexture_mapbordr);
+  map_window.uFrameWidth = game_viewport_width;
+  map_window.uFrameHeight = game_viewport_height;
+  map_window.uFrameX = game_viewport_x;
+  map_window.uFrameY = game_viewport_y;
+  map_window.uFrameZ = game_viewport_z;
+  map_window.uFrameW = game_viewport_w;
+  map_id = pMapStats->GetMapInfo(pCurrentMapName.data());
+  if ( map_id )
+    map_window.DrawTitleText(pBook2Font, -14, 12, ui_book_map_title_color, pMapStats->pInfos[map_id].pName, 3);
 
-    map_window.uFrameX = 0;
-    sprintf(party_coord, pGlobalTXT_LocalizationStrings[659], pParty->vPosition.x, pParty->vPosition.y); //"x: %d  y: %d"
-    map_window.DrawTitleText(pFontComic, 0, 320, ui_book_map_coordinates_color, party_coord, 0);
-    }
+  map_window.uFrameX = 0;
+  sprintf(party_coord, pGlobalTXT_LocalizationStrings[659], pParty->vPosition.x, pParty->vPosition.y); //"x: %d  y: %d"
+  map_window.DrawTitleText(pFontComic, 0, 320, ui_book_map_coordinates_color, party_coord, 0);
+}
 
 //----- (00442955) --------------------------------------------------------
 void DrawBook_Map_sub( unsigned int tl_x, unsigned int tl_y, unsigned int br_x, int br_y, int _48074 )
+{
+  //unsigned int v11; // edx@11
+  //__int16 v12; // cx@12
+  //signed int v13; // eax@15
+  //int v14; // eax@16
+  int v20; // eax@16
+  signed int v21; // esi@18
+  int v22; // ecx@21
+  BLVMapOutline *v23; // ecx@21
+  Vec3_short_ *v24; // edx@21
+  Vec3_short_ *v25; // eax@21
+  int v26; // ecx@21
+  unsigned __int16 *v27; // edi@21
+  int v28; // edx@21
+  int v29; // eax@21
+  double v30; // st7@23
+  signed __int64 v31; // qax@23
+  unsigned short *v32; // edx@23
+  int textr_width; // esi@23
+  signed int v34; // eax@23
+  signed int v35; // ecx@23
+  int v36; // esi@27
+  int v37; // ecx@27
+  int v38; // edx@31
+  unsigned int v39; // eax@33
+  short *v40; // esi@33
+  short *v41; // edi@33
+  unsigned __int8 v42; // cf@33
+  unsigned int v43; // ecx@33
+  short *v44; // edi@33
+  short *v45; // esi@33
+  int v46; // ecx@33
+  signed int v47; // esi@38
+  signed int v48; // ecx@38
+  int v49; // eax@38
+  signed int v50; // edx@55
+  unsigned int v51; // ecx@55
+  int result; // eax@72
+  int v53; // eax@75
+  int v54; // esi@75
+  int v55; // eax@75
+  __int16 v56; // si@85
+  double v57; // st7@85
+  int v58; // ebx@85
+  signed __int64 v59; // qax@85
+  signed int v60; // edi@85
+  signed __int64 v61; // qax@85
+  signed int v62; // ebx@85
+  signed int v63; // esi@85
+  int v64; // eax@87
+  unsigned int v65; // ebx@95
+  unsigned short *v66; // edx@95
+  unsigned __int16 *v67; // esi@96
+  int v68; // edi@98
+  unsigned __int16 v69; // cx@99
+  unsigned int v70; // [sp-10h] [bp-48074h]@80
+  unsigned int v71; // [sp-Ch] [bp-48070h]@80
+  unsigned int v72; // [sp-8h] [bp-4806Ch]@80
+  signed int v73; // [sp-4h] [bp-48068h]@59
+  unsigned __int16 v74; // [sp-4h] [bp-48068h]@79
+  unsigned short map_texture_16[147456]; // [sp+Ch] [bp-48058h]@23
+  int v76; // [sp+4800Ch] [bp-58h]@23
+  unsigned __int16 *v77; // [sp+48010h] [bp-54h]@27
+  unsigned __int16 *pPalette_16; // [sp+48014h] [bp-50h]@23
+  int v81; // [sp+48020h] [bp-44h]@23
+  unsigned __int16* render16_data;
+  unsigned char* texture8_data;
+  unsigned char* curr_line;
+  int scale_increment;
+  int scaled_posX;
+  int scaled_posY;
+  int stepX_r;
+  int stepY_r;
+  unsigned int teal; // [sp+48028h] [bp-3Ch]@8
+  int pCenterY; // [sp+4802Ch] [bp-38h]@1
+  int screenCenter_X; // [sp+48030h] [bp-34h]@1
+  int pCenterX; // [sp+48034h] [bp-30h]@1
+  int v87; // [sp+48038h] [bp-2Ch]@16
+  unsigned int v88; // [sp+4803Ch] [bp-28h]@16
+  int black; // [sp+48040h] [bp-24h]@8
+  int screenCenterY; // [sp+48044h] [bp-20h]@1
+  unsigned int i; // [sp+48048h] [bp-1Ch]@9
+  unsigned int screenHeight; // [sp+4804Ch] [bp-18h]@16
+  unsigned __int16 *v93; // [sp+48050h] [bp-14h]@16
+  signed int screenWidth; // [sp+48054h] [bp-10h]@8
+  unsigned int v95; // [sp+48058h] [bp-Ch]@16
+  int v96; // [sp+4805Ch] [bp-8h]@10
+  const void *v97; // [sp+48060h] [bp-4h]@16
+  unsigned short *a4a; // [sp+4806Ch] [bp+8h]@85
+  int a5a; // [sp+48070h] [bp+Ch]@86
+
+  screenCenter_X = (signed int)(tl_x + br_x) / 2;
+  screenCenterY = (signed int)(tl_y + br_y) / 2;
+  pRenderer->SetRasterClipRect(tl_x, tl_y, br_x, br_y);
+  pCenterX = viewparams->sViewCenterX;
+  pCenterY = viewparams->sViewCenterY;
+  if ( viewparams->field_2C != 384 )
+  {
+    if ( viewparams->field_2C == 768 )
     {
-    int v5; // ebx@1
-    int v6; // edi@1
-    BLVMapOutlines *v7; // eax@8
-    unsigned __int8 v8; // zf@8
-    unsigned __int8 v9; // sf@8
-    int v10; // esi@10
-    unsigned int v11; // edx@11
-    __int16 v12; // cx@12
-    signed int v13; // eax@15
-    int v14; // eax@16
-    Vec3_short_ *v15; // ecx@16
-    int v16; // edx@16
-    int v17; // ecx@16
-    Vec3_short_ *v18; // eax@16
-    int v19; // ecx@16
-    int v20; // eax@16
-    signed int v21; // esi@18
-    int v22; // ecx@21
-    BLVMapOutline *v23; // ecx@21
-    Vec3_short_ *v24; // edx@21
-    Vec3_short_ *v25; // eax@21
-    int v26; // ecx@21
-    unsigned __int16 *v27; // edi@21
-    int v28; // edx@21
-    int v29; // eax@21
-    double v30; // st7@23
-    signed __int64 v31; // qax@23
-    unsigned short *v32; // edx@23
-    int textr_width; // esi@23
-    signed int v34; // eax@23
-    signed int v35; // ecx@23
-    int v36; // esi@27
-    int v37; // ecx@27
-    int v38; // edx@31
-    unsigned int v39; // eax@33
-    short *v40; // esi@33
-    short *v41; // edi@33
-    unsigned __int8 v42; // cf@33
-    unsigned int v43; // ecx@33
-    short *v44; // edi@33
-    short *v45; // esi@33
-    int v46; // ecx@33
-    signed int v47; // esi@38
-    signed int v48; // ecx@38
-    int v49; // eax@38
-    signed int v50; // edx@55
-    unsigned int v51; // ecx@55
-    int result; // eax@72
-    int v53; // eax@75
-    int v54; // esi@75
-    int v55; // eax@75
-    __int16 v56; // si@85
-    double v57; // st7@85
-    int v58; // ebx@85
-    signed __int64 v59; // qax@85
-    signed int v60; // edi@85
-    signed __int64 v61; // qax@85
-    signed int v62; // ebx@85
-    signed int v63; // esi@85
-    int v64; // eax@87
-    unsigned int v65; // ebx@95
-    unsigned short *v66; // edx@95
-    unsigned __int16 *v67; // esi@96
-    int v68; // edi@98
-    unsigned __int16 v69; // cx@99
-    unsigned int v70; // [sp-10h] [bp-48074h]@80
-    unsigned int v71; // [sp-Ch] [bp-48070h]@80
-    unsigned int v72; // [sp-8h] [bp-4806Ch]@80
-    signed int v73; // [sp-4h] [bp-48068h]@59
-    unsigned __int16 v74; // [sp-4h] [bp-48068h]@79
-    unsigned short map_texture_16[147456]; // [sp+Ch] [bp-48058h]@23
-    int v76; // [sp+4800Ch] [bp-58h]@23
-    unsigned __int16 *v77; // [sp+48010h] [bp-54h]@27
-    unsigned __int16 *pPalette_16; // [sp+48014h] [bp-50h]@23
-    unsigned int surfPitch; // [sp+48018h] [bp-4Ch]@1
+      if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
+        viewparams->field_2C = 680;
+    }
+  }
+  else
+  {
+    viewparams->sViewCenterX = viewparams->indoor_center_x;
+    pCenterX = viewparams->indoor_center_x;
+    pCenterY = viewparams->indoor_center_y;
+    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
+      viewparams->field_2C = viewparams->field_2C - 34;
+  }
+  if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
+  {
+    screenWidth = br_x - tl_x + 1;
+    screenHeight = br_y - tl_y + 1;
+    render16_data = &pRenderer->pTargetSurface[tl_x + tl_y * pRenderer->uTargetSurfacePitch];
+    texture8_data = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0_prolly_alpha_mask;
+    pPalette_16 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
+    scale_increment = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / viewparams->field_2C;
 
-    int v81; // [sp+48020h] [bp-44h]@23
-    unsigned __int16* render16_data;
-    unsigned char* texture8_data;
-    unsigned char* curr_line;
-    int scale_increment;
-    int scaled_posX;
-    int scaled_posY;
-    int stepX_r;
-    int stepY_r;
+    v30 = (double)(1 << (16 - pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2));
+
+    teal = (unsigned int)(signed __int64)((double)(viewparams->sViewCenterX - 22528 / (viewparams->field_2C / 384) + 32768) / v30) << 16;
+    //  v97 = (const void *)((unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16);
 
+    //   v32 = map_texture_16;
+    textr_width = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
+    stepY_r =            (int)(signed __int64)((double)(- pCenterY - 22528 / (viewparams->field_2C / 384)+ 32768) / v30) << 16;
+    //   v81 =   (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
+    black = (signed __int16)(signed __int64)((double)(viewparams->sViewCenterX - 22528 / (viewparams->field_2C / 384) + 32768) / v30);
 
-    unsigned int teal; // [sp+48028h] [bp-3Ch]@8
-    int v84; // [sp+4802Ch] [bp-38h]@1
-    int screenCenter_X; // [sp+48030h] [bp-34h]@1
-    int v86; // [sp+48034h] [bp-30h]@1
-    int v87; // [sp+48038h] [bp-2Ch]@16
-    unsigned int v88; // [sp+4803Ch] [bp-28h]@16
-    int black; // [sp+48040h] [bp-24h]@8
-    int screenCenterY; // [sp+48044h] [bp-20h]@1
-    unsigned int i; // [sp+48048h] [bp-1Ch]@9
-    unsigned int screenHeight; // [sp+4804Ch] [bp-18h]@16
-    unsigned __int16 *v93; // [sp+48050h] [bp-14h]@16
-    signed int screenWidth; // [sp+48054h] [bp-10h]@8
-    unsigned int v95; // [sp+48058h] [bp-Ch]@16
-    int v96; // [sp+4805Ch] [bp-8h]@10
-    const void *v97; // [sp+48060h] [bp-4h]@16
-    unsigned short *a4a; // [sp+4806Ch] [bp+8h]@85
-    int a5a; // [sp+48070h] [bp+Ch]@86
-
-    tl_x = tl_x;
-    tl_y = tl_y;
-    screenCenter_X = (signed int)(tl_x + br_x) >> 1;
-    screenCenterY = (signed int)(tl_y + br_y) >> 1;
-    surfPitch = pRenderer->uTargetSurfacePitch;
-    pRenderer->SetRasterClipRect(tl_x, tl_y, br_x, br_y);
-    v5 = viewparams->field_2C;
-    v6 = viewparams->sViewCenterX;
-    v86 = viewparams->sViewCenterX;
-    v84 = viewparams->sViewCenterY;
-    if ( viewparams->field_2C != 384 )
+    //  v76 = textr_width;
+    scaled_posY = stepY_r >> 16;
+    //nearest neiborhood scaling
+    if ( texture8_data)  
+    {
+      for( uint i = 0; i < screenHeight; ++i )
+      {
+        curr_line=&texture8_data[scaled_posY*textr_width];
+        stepX_r=teal;
+        for( uint j = 0; j < screenWidth; ++j )
         {
-        if ( viewparams->field_2C == 768 )
-            {
-            if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
-                v5 = 680;
-            }
+          scaled_posX=stepX_r>>16;
+          map_texture_16[i*screenWidth+j]=pPalette_16[*(curr_line+scaled_posX)];
+          stepX_r+=scale_increment;      
         }
-    else
-        {
-        v6 = viewparams->indoor_center_x;
-        v86 = viewparams->indoor_center_x;
-        v84 = viewparams->indoor_center_y;
-        if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
-            v5 = viewparams->field_2C - 34;
-        }
-    if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
+        stepY_r+=scale_increment;
+        scaled_posY=stepY_r>>16;
+      }
+    }
+    //move visible square to render
+    for( uint i = 0; i < screenHeight; ++i )
+    {
+      if ( screenWidth > 0 )
+        memcpy((void*)&render16_data[pRenderer->uTargetSurfacePitch * i],(void*)&map_texture_16[i*screenWidth], screenWidth*2);
+    }
+  }
+  else
+  {
+    black = TargetColor(0, 0, 0);
+    teal = TargetColor(0, 0xFFu, 0xFFu);
+    uNumBlueFacesInBLVMinimap = 0;
+    if ( pIndoor->pMapOutlines->uNumOutlines )
+    {
+     for ( uint i = 0; i < pIndoor->pMapOutlines->uNumOutlines; ++i )
+      {
+        if ( !(BYTE1(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace1ID].uAttributes) & 0x20 
+           || (BYTE1(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].uAttributes) & 0x20) ))
         {
-        screenWidth = br_x - tl_x + 1;
-        screenHeight = br_y - tl_y + 1;
-        render16_data = &pRenderer->pTargetSurface[tl_x + tl_y * surfPitch];
-        texture8_data = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0_prolly_alpha_mask;
-        pPalette_16 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
-        scale_increment = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / v5;
-
-        v30 = (double)(1 << (16 - pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2));
-
-
-        teal =               (unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16;
-        //  v97 = (const void *)((unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16);
-
-        //   v32 = map_texture_16;
-        textr_width = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
-        stepY_r =            (int)(signed __int64)((double)(- v84 - 22528 / (v5 / 384)+ 32768) / v30) << 16;
-        //   v81 =   (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
-        black = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
-
-        //  v76 = textr_width;
-        scaled_posY = stepY_r >> 16;
-        //nearest neiborhood scaling
-        if ( texture8_data)  
+          if ( !(pIndoor->pMapOutlines->pOutlines[i].uFlags & 1) )
+          {
+            if ( !(!(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace1ID].uAttributes & 0x80)
+                && !(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].uAttributes & 0x80u) ))
             {
-            for(uint i=0; i<screenHeight;++i)
-                {
-                curr_line=&texture8_data[scaled_posY*textr_width];
-                stepX_r=teal;
-                for(uint j=0; j<screenWidth;++j)
-                    {
-                    scaled_posX=stepX_r>>16;
-                    map_texture_16[i*screenWidth+j]=pPalette_16[*(curr_line+scaled_posX)];
-                    stepX_r+=scale_increment;      
-                    }
-                stepY_r+=scale_increment;
-                scaled_posY=stepY_r>>16;
-                }
+              pIndoor->pMapOutlines->pOutlines[i].uFlags = pIndoor->pMapOutlines->pOutlines[i].uFlags | 1;
+              pIndoor->_visible_outlines[i >> 3] |= 1 << (7 - i % 8);
             }
-        //move visible square to render
-        for(uint i=0; i<screenHeight;++i)
-            {
-            if ( screenWidth > 0 )
-                {
-                memcpy((void*)&render16_data[surfPitch*i],(void*)&map_texture_16[i*screenWidth], screenWidth*2);
-                }
-            }
+          }
+          if ( (!(pIndoor->pMapOutlines->pOutlines[i].uFlags & 1) 
+            && !(!(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace1ID].uAttributes & 0x80)
+            && !(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].uAttributes & 0x80u) ))
+            || pIndoor->pMapOutlines->pOutlines[i].uFlags & 1)
+          {
+            v93 = (unsigned __int16 *)(pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex1ID].x - viewparams->sViewCenterX);
+            screenHeight = pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex1ID].y - pCenterY;
+            v20 = pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].y - pCenterY;
+            v95 = pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].x - viewparams->sViewCenterX;
+            v97 = (const void *)v20;
+            v88 = (unsigned __int64)((pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex1ID].x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16;
+            v87 = (unsigned __int64)((signed int)screenHeight * (signed __int64)viewparams->field_2C) >> 16;
+            v93 = (unsigned __int16 *)((unsigned __int64)((pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16);
+            screenHeight = (unsigned __int64)(v20 * (signed __int64)viewparams->field_2C) >> 16;
+            pRenderer->RasterLine2D(screenCenter_X + v88, screenCenterY - v87,
+            screenCenter_X + ((unsigned __int64)((pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16), screenCenterY - screenHeight, black);
+          }
         }
-    else
-        {
-        black = TargetColor(0, 0, 0);
-        teal = TargetColor(0, 0xFFu, 0xFFu);
-        v7 = pIndoor->pMapOutlines;
-        uNumBlueFacesInBLVMinimap = 0;
-        v8 = pIndoor->pMapOutlines->uNumOutlines == 0;
-        v9 = pIndoor->pMapOutlines->uNumOutlines < 0;
-        screenWidth = 0;
-        if ( !(v9 | v8) )
-            {
-            i = 0;
-            do
+      }
+    }
+    v21 = 0;
+    if ( (signed int)uNumBlueFacesInBLVMinimap > 0 )
+    {
+      while ( 1 )
+      {
+        v22 = pBlueFacesInBLVMinimapIDs[v21];
+        v87 = viewparams->field_2C;
+        v23 = &pIndoor->pMapOutlines->pOutlines[v22];
+        v24 = &pIndoor->pVertices[v23->uVertex1ID];
+        v25 = &pIndoor->pVertices[v23->uVertex2ID];
+        v26 = v25->x;
+        v27 = (unsigned __int16 *)(v24->x - pCenterX);
+        v28 = v24->y - pCenterY;
+        v29 = v25->y - pCenterY;
+        v93 = v27;
+        screenHeight = v28;
+        v97 = (const void *)v29;
+        v87 = (unsigned __int64)((signed int)v27 * (signed __int64)viewparams->field_2C) >> 16;
+        v88 = (unsigned __int64)(v28 * (signed __int64)viewparams->field_2C) >> 16;
+        uint i = (unsigned __int64)((v26 - pCenterX) * (signed __int64)viewparams->field_2C) >> 16;
+        v95 = (unsigned __int64)(v29 * (signed __int64)viewparams->field_2C) >> 16;
+        pRenderer->RasterLine2D(screenCenter_X + ((unsigned __int64)((signed int)v27 * (signed __int64)viewparams->field_2C) >> 16),
+        screenCenterY - v88, screenCenter_X + ((unsigned __int64)((v26 - pCenterX) * (signed __int64)viewparams->field_2C) >> 16), screenCenterY - v95, teal);
+        ++v21;
+        if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap )
+          break;
+      }
+      viewparams->sViewCenterX = pCenterX;
+    }
+  }
+  v47 = ((unsigned __int64)((pParty->vPosition.x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X - 3;
+  v81 = pParty->vPosition.y - pCenterY;
+  v97 = (const void *)((unsigned __int64)((pParty->vPosition.y - pCenterY) * (signed __int64)viewparams->field_2C) >> 16);
+  v48 = 1;
+  v49 = screenCenterY - (int)v97 - 3;
+  if ( v47 >= (signed int)tl_x )
+  {
+    if ( v47 > (signed int)br_x )
+    {
+      if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X - 6) > (signed int)br_x )
+        v48 = 0;
+      v47 = br_x;
+    }
+  }
+  else
+  {
+    if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X) < (signed int)tl_x )
+      v48 = 0;
+    v47 = tl_x;
+  }
+  if ( v49 >= (signed int)tl_y )
+  {
+    if ( v49 > br_y )
+    {
+      if ( screenCenterY - (signed int)v97 - 6 > br_y )
+        v48 = 0;
+      v49 = br_y;
+    }
+  }
+  else
+  {
+    if ( screenCenterY - (signed int)v97 < (signed int)tl_y )
+      v48 = 0;
+    v49 = tl_y;
+  }
+  if ( v48 == 1 )
+  {
+    v51 = pParty->sRotationY & stru_5C6E00->uDoublePiMask;
+    if ( (signed int)v51 <= 1920 )
+      v50 = 7;
+    if ( (signed int)v51 < 1664 )
+      v50 = 6;
+    if ( (signed int)v51 <= 1408 )
+      v50 = 5;
+    if ( (signed int)v51 < 1152 )
+      v50 = 4;
+    if ( (signed int)v51 <= 896 )
+      v50 = 3;
+    if ( (signed int)v51 < 640 )
+      v50 = 2;
+    if ( (signed int)v51 <= 384 )
+      v50 = 1;
+    if ( (signed int)v51 < 128 )
+      v50 = 0;
+    pRenderer->DrawTransparentRedShade(v47, v49, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[v50]));
+  }
+  result = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  v95 = 0;
+  pCenterX = result;
+  if ( (signed int)uNumLevelDecorations > 0 )
+  {
+    screenWidth = (unsigned int)&pLevelDecorations[0].vPosition;
+    do
+    {
+      if ( *(char *)(screenWidth - 2) & 8 )
+      {
+        v53 = *(int *)(screenWidth + 4) - pCenterY;
+        v93 = (unsigned __int16 *)(*(int *)screenWidth - viewparams->sViewCenterX);
+              screenHeight = v53;
+              v54 = ((unsigned __int64)((signed int)v93 * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X;
+              v97 = (const void *)((unsigned __int64)(v53 * (signed __int64)viewparams->field_2C) >> 16);
+              v55 = screenCenterY - (int)v97;
+              if ( v54 >= pRenderer->raster_clip_x )
+              {
+                if ( v54 <= pRenderer->raster_clip_z && v55 >= pRenderer->raster_clip_y && v55 <= pRenderer->raster_clip_w )
                 {
-                v10 = (int)((char *)v7 + i + 4);
-                v96 = pIndoor->pFaces[*(short *)((char *)v7 + i + 8)].uAttributes;
-                if ( !(BYTE1(v96) & 0x20 || (v11 = pIndoor->pFaces[*(short *)((char *)v7 + i + 10)].uAttributes, BYTE1(v11) & 0x20) ))
-                    {
-                    v12 = *(short *)((char *)v7 + i + 14);
-                    if ( !(v12 & 1) )
-                        {
-                        if ( !(!(v96 & 0x80) && (v11 & 0x80u) == 0 ))
-                            {
-                            v96 = (signed int)screenWidth >> 3;
-                            v13 = screenWidth;
-                            *(short *)(v10 + 10) = v12 | 1;
-                            pIndoor->_visible_outlines[v96] |= 1 << (7 - v13 % 8);
-                            }
-                        }
-                    if ( (!(v12 & 1) && !(!(v96 & 0x80) && (v11 & 0x80u) == 0 )) || v12 & 1)
-                        {
-                        v14 = *(short *)v10;
-                        v88 = v5;
-                        v15 = &pIndoor->pVertices[v14];
-                        v16 = v15->x;
-                        v17 = v15->y - v84;
-                        v93 = (unsigned __int16 *)(v16 - v6);
-                        screenHeight = v17;
-                        v18 = &pIndoor->pVertices[*(short *)(v10 + 2)];
-                        v19 = v18->x;
-                        v20 = v18->y - v84;
-                        v95 = v19 - v6;
-                        v97 = (const void *)v20;
-                        v88 = (unsigned __int64)((v16 - v6) * (signed __int64)v5) >> 16;
-                        v87 = (unsigned __int64)((signed int)screenHeight * (signed __int64)v5) >> 16;
-                        v93 = (unsigned __int16 *)((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16);
-                        screenHeight = (unsigned __int64)(v20 * (signed __int64)v5) >> 16;
-                        pRenderer->RasterLine2D(
-                            screenCenter_X + v88,
-                            screenCenterY - v87,
-                            screenCenter_X + ((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16),
-                            screenCenterY - screenHeight,
-                            black);
-                        v7 = pIndoor->pMapOutlines;
-                        }
-                    }
-                ++screenWidth;
-                i += 12;
+                  if ( viewparams->field_2C > 512 )
+                  {
+                    v96 = v55 + 1;
+                    black = v55 - 1;
+                    pRenderer->RasterLine2D(v54 - 1, v55 - 1, v54 - 1, v55 + 1, pCenterX);
+                    pRenderer->RasterLine2D(v54, black, v54, v96, pCenterX);
+                    ++v54;
+                    v72 = v96;
+                    v71 = v54;
+                    v70 = black;
+                  }
+                  else
+                  {
+                    v72 = screenCenterY - (int)v97;
+                    v71 = ((unsigned __int64)((signed int)v93 * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X;
+                    v70 = screenCenterY - (int)v97;
+                  }
+                  pRenderer->RasterLine2D(v54, v70, v71, v72, pCenterX);
                 }
-                while ( screenWidth < (signed int)v7->uNumOutlines );
-            }
-        v21 = 0;
-        if ( (signed int)uNumBlueFacesInBLVMinimap > 0 )
-            {
-            while ( 1 )
-                {
-                v22 = pBlueFacesInBLVMinimapIDs[v21];
-                v87 = v5;
-                v23 = &v7->pOutlines[v22];
-                v24 = &pIndoor->pVertices[v23->uVertex1ID];
-                v25 = &pIndoor->pVertices[v23->uVertex2ID];
-                v26 = v25->x;
-                v27 = (unsigned __int16 *)(v24->x - v86);
-                v28 = v24->y - v84;
-                v29 = v25->y - v84;
-                v93 = v27;
-                screenHeight = v28;
-                v97 = (const void *)v29;
-                v87 = (unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16;
-                v88 = (unsigned __int64)(v28 * (signed __int64)v5) >> 16;
-                i = (unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16;
-                v95 = (unsigned __int64)(v29 * (signed __int64)v5) >> 16;
-                pRenderer->RasterLine2D(
-                    screenCenter_X + ((unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16),
-                    screenCenterY - v88,
-                    screenCenter_X + ((unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16),
-                    screenCenterY - v95,
-                    teal);
-                ++v21;
-                if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap )
-                    break;
-                v7 = pIndoor->pMapOutlines;
-                }
-            v6 = v86;
-            }
-        }
-    v47 = ((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X - 3;
-    v81 = pParty->vPosition.y - v84;
-    v97 = (const void *)((unsigned __int64)((pParty->vPosition.y - v84) * (signed __int64)v5) >> 16);
-    v48 = 1;
-    v49 = screenCenterY - (int)v97 - 3;
-    if ( v47 >= (signed int)tl_x )
-        {
-        if ( v47 > (signed int)br_x )
-            {
-            if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X - 6) > (signed int)br_x )
-                v48 = 0;
-            v47 = br_x;
+              }
             }
-        }
-    else
-        {
-        if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X) < (signed int)tl_x )
-            v48 = 0;
-        v47 = tl_x;
-        }
-    if ( v49 >= (signed int)tl_y )
-        {
-        if ( v49 > br_y )
-            {
-            if ( screenCenterY - (signed int)v97 - 6 > br_y )
-                v48 = 0;
-            v49 = br_y;
-            }
-        }
-    else
-        {
-        if ( screenCenterY - (signed int)v97 < (signed int)tl_y )
-            v48 = 0;
-        v49 = tl_y;
-        }
-    if ( v48 == 1 )
-        {
-        v50 = 0;
-        v51 = pParty->sRotationY & stru_5C6E00->uDoublePiMask;
-        if ( (signed int)(pParty->sRotationY & stru_5C6E00->uDoublePiMask) >= 128 )
-            {
-            if ( (signed int)v51 > 384 )
-                {
-                if ( (signed int)v51 >= 640 )
-                    {
-                    if ( (signed int)v51 > 896 )
-                        {
-                        if ( (signed int)v51 >= 1152 )
-                            {
-                            if ( (signed int)v51 > 1408 )
-                                {
-                                if ( (signed int)v51 >= 1664 )
-                                    {
-                                    if ( (signed int)v51 <= 1920 )
-                                        v73 = 7;
-                                    }
-                                else
-                                    {
-                                    v73 = 6;
-                                    }
-                                }
-                            else
-                                {
-                                v73 = 5;
-                                }
-                            }
-                        else
-                            {
-                            v73 = 4;
-                            }
-                        }
-                    else
-                        {
-                        v73 = 3;
-                        }
-                    }
-                else
-                    {
-                    v73 = 2;
-                    }
-                if( (signed int)v51 <=1920)
-                    v50 = v73;
-                }
-            else
-                v50 = 1;
-            }
-        pRenderer->DrawTransparentRedShade(v47, v49, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[v50]));
-        }
-    result = TargetColor(0xFFu, 0xFFu, 0xFFu);
-    v95 = 0;
-    v86 = result;
-    if ( (signed int)uNumLevelDecorations > 0 )
-        {
-        screenWidth = (unsigned int)&pLevelDecorations[0].vPosition;
-        do
-            {
-            if ( *(char *)(screenWidth - 2) & 8 )
-                {
-                v53 = *(int *)(screenWidth + 4) - v84;
-                v93 = (unsigned __int16 *)(*(int *)screenWidth - v6);
-                screenHeight = v53;
-                v54 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + screenCenter_X;
-                v97 = (const void *)((unsigned __int64)(v53 * (signed __int64)v5) >> 16);
-                v55 = screenCenterY - (int)v97;
-                if ( v54 >= pRenderer->raster_clip_x )
-                    {
-                    if ( v54 <= pRenderer->raster_clip_z && v55 >= pRenderer->raster_clip_y && v55 <= pRenderer->raster_clip_w )
-                        {
-                        v74 = v86;
-                        if ( v5 > 512 )
-                            {
-                            v96 = v55 + 1;
-                            black = v55 - 1;
-                            pRenderer->RasterLine2D(v54 - 1, v55 - 1, v54 - 1, v55 + 1, v86);
-                            pRenderer->RasterLine2D(v54, black, v54, v96, v86);
-                            ++v54;
-                            v74 = v86;
-                            v72 = v96;
-                            v71 = v54;
-                            v70 = black;
-                            }
-                        else
-                            {
-                            v72 = screenCenterY - (int)v97;
-                            v71 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + screenCenter_X;
-                            v70 = screenCenterY - (int)v97;
-                            }
-                        pRenderer->RasterLine2D(v54, v70, v71, v72, v74);
-                        }
-                    }
-                }
             ++v95;
             result = v95;
             screenWidth += 32;
@@ -788,15 +670,15 @@
         {
         screenCenterY = br_x - tl_x + 1;
         v95 = br_y - tl_y + 1;
-        v77 = &pRenderer->pTargetSurface[tl_x + tl_y * surfPitch];
+        v77 = &pRenderer->pTargetSurface[tl_x + tl_y * pRenderer->uTargetSurfacePitch];
         v56 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2;
-        black = (1 << (v56 + 16)) / v5;
+        black = (1 << (v56 + 16)) / viewparams->field_2C;
         v57 = (double)(1 << (16 - v56));
-        v58 = 22528 / (v5 / 384);
-        v59 = (signed __int64)((double)(v6 - v58 + 32768) / v57);
+        v58 = 22528 / (viewparams->field_2C / 384);
+        v59 = (signed __int64)((double)(viewparams->sViewCenterX - v58 + 32768) / v57);
         v60 = (int)v59 << 16;
         v97 = (const void *)((int)v59 << 16);
-        v61 = (signed __int64)((double)(32768 - v58 - v84) / v57);
+        v61 = (signed __int64)((double)(32768 - v58 - pCenterY) / v57);
         pPalette_16 = (unsigned __int16 *)(v60 >> 16);
         v62 = (int)v61 << 16;
         teal = v60 >> 16;
@@ -845,7 +727,7 @@
         if ( (signed int)v95 > 0 )
             {
             v67 = v77;
-            result = 2 * (surfPitch - screenCenterY);
+            result = 2 * (pRenderer->uTargetSurfacePitch - screenCenterY);
             do
                 {
                 if ( screenCenterY > 0 )
@@ -869,5 +751,3 @@
             }
         }
     }
-
-
--- a/UI/Books/UINotesBooks.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/UI/Books/UINotesBooks.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -637,13 +637,7 @@
   num_achieved_awards = 0;
   //v7 = *pStorylineText->StoreLine[v6].pText;//*(&pStorylineText->field_0 + 3 * v6);
   v7 = (int)pStorylineText->StoreLine[v6].pText;//*(&pStorylineText->field_0 + 3 * v6);
-  v8 = BuildDialogueString(
-         pStorylineText->StoreLine[v6].pText,
-         uActiveCharacter - 1,
-         0,
-         0,
-         0,
-         (__int64 *)&pParty->field_3C._s_times[ v6 + 21]);
+  v8 = BuildDialogueString(pStorylineText->StoreLine[v6].pText, uActiveCharacter - 1, 0, 0, 0, (__int64 *)&pParty->field_3C._s_times[ v6 + 21]);
   if ( v7 )
   {
     v9 = pAutonoteFont->_44C6C2(v8, &a1, 1u, (unsigned __int8)byte_5C6D50[dword_506528]);
--- a/UI/UIHouses.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/UI/UIHouses.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -553,7 +553,22 @@
       pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2);
     }
     break;
-    
+
+    case BuildingType_Tavern:
+    {
+      CreateButtonInColumn(0, 0xFu);
+      CreateButtonInColumn(1, 0x10u);
+      CreateButtonInColumn(2, 0x60u);
+      if ( (signed int)window_SpeakInHouse->ptr_1C < 108 || (signed int)window_SpeakInHouse->ptr_1C > 120 )
+      {
+        pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
+        break;
+      }
+      CreateButtonInColumn(3, 101);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 2);
+    }
+    break;
+
     case BuildingType_18:
     case BuildingType_19:
     case BuildingType_Throne_Room:
--- a/UI/UIShops.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/UI/UIShops.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -566,7 +566,7 @@
   int v29; // edx@26
   signed int v31; // esi@31
   unsigned int v32; // eax@33
-  int v33; // eax@34
+  //int v33; // eax@34
   int v35; // eax@35
   char *v36; // edx@36
   signed int v38; // esi@42
@@ -615,7 +615,7 @@
   __int32 v95; // ecx@120
   void *v96; // ST14_4@122
   unsigned __int8 v97; // bl@122
-  ItemGen *v98; // ST10_4@122
+  //ItemGen *v98; // ST10_4@122
   int v99; // eax@122
   char *v100; // eax@122
   const char *v101; // ST18_4@122
@@ -668,8 +668,8 @@
   short text_color;
   int pActiveButton;
 
-  __debugbreak(); // uishops.cpp(952): warning C4700: uninitialized local variable 'v33' used
-  __debugbreak(); // uishops.cpp(981): warning C4700: uninitialized local variable 'v98' used
+  //__debugbreak(); // uishops.cpp(952): warning C4700: uninitialized local variable 'v33' used
+  //__debugbreak(); // uishops.cpp(981): warning C4700: uninitialized local variable 'v98' used
   memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window));
   dialog_window.uFrameX = 483;
   dialog_window.uFrameWidth = 148;
@@ -951,8 +951,8 @@
             || (v32 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount), v11 = 0, !v32)
             || (!(pPlayers[uActiveCharacter]->pOwnItems[v32-1].uAttributes& 2)) )
         return;
-      __debugbreak(); // warning C4700: uninitialized local variable 'v33' used
-      v116 = &pPlayers[uActiveCharacter]->pInventoryItemList[v33 - 1];
+      //__debugbreak(); // warning C4700: uninitialized local variable 'v33' used
+      v116 = &pPlayers[uActiveCharacter]->pInventoryItemList[v32 - 1];
       v35 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[v32 - 1], BuildingType_ArmorShop, window_SpeakInHouse->par1C, 5);
       v15 = (char *)pMerchantsRepairPhrases[v35];
       v36 = BuildDialogueString(v15, uActiveCharacter - 1, v116, (char *)window_SpeakInHouse->ptr_1C, 5, 0);
@@ -980,9 +980,9 @@
         {
           --pItemCount;
           v97 = uActiveCharacter - 1;
-      __debugbreak(); // warning C4700: uninitialized local variable 'v98' used
+      //__debugbreak(); // warning C4700: uninitialized local variable 'v98' used
           v99 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v95-1], BuildingType_ArmorShop,	window_SpeakInHouse->par1C,	2);
-          v100 = BuildDialogueString((char *)pMerchantsBuyPhrases[v99], uActiveCharacter - 1, v98, (char *)window_SpeakInHouse->par1C, 2, 0);
+          v100 = BuildDialogueString((char *)pMerchantsBuyPhrases[v99], uActiveCharacter - 1, &pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v95-1], (char *)window_SpeakInHouse->par1C, 2, 0);
           v103 = pFontArrus->CalcTextHeight(v100, &dialog_window, 0, 0);
           dialog_window.DrawTitleText(pFontArrus, 0, (174 - v103) / 2 + 138, pWhiteColor, v100, 3);
         }
--- a/VideoPlayer.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/VideoPlayer.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -900,39 +900,27 @@
 //----- (004BF1E6) --------------------------------------------------------
 _SMACK *VideoPlayer::OpenSmack(const char *pFilename)
 {
-  VideoPlayer *pVideoPlayer; // esi@1
-  signed int v3; // edi@1
-  int v4; // ebx@2
-  signed int v5; // edi@5
-  //int v6; // ebx@6
-  //HANDLE v8; // [sp-Ch] [bp-1Ch]@10
-  //unsigned int v9; // [sp-8h] [bp-18h]@10
-  //signed int v10; // [sp-4h] [bp-14h]@10
-
-  pVideoPlayer = this;
-  if ( (signed int)this->uNumMightVideoHeaders > 0 )
+  if ( this->uNumMightVideoHeaders )
   {
-	for ( v3 = 0; v3 < (signed int)pVideoPlayer->uNumMightVideoHeaders; ++v3)
+    for ( uint i = 0; i < (signed int)this->uNumMightVideoHeaders; ++i)
     {
-      v4 = _stricmp(pVideoPlayer->pMightVideoHeaders[v3].pVideoName, pFilename);
-	  if ( !v4 )
-	  {
-	    SetFilePointer(pVideoPlayer->hMightVid, pVideoPlayer->pMightVideoHeaders[v3].uFileOffset, 0, 0);
-        return SmackOpen(pVideoPlayer->hMightVid, 0x7140, -1);//problem training house video in WinXP
-	  }
+      if ( !_stricmp(this->pMightVideoHeaders[i].pVideoName, pFilename) )
+      {
+        SetFilePointer(this->hMightVid, this->pMightVideoHeaders[i].uFileOffset, 0, 0);
+        return SmackOpen(this->hMightVid, 0x7140, -1);
+      }
     }
   }
-  v5 = 0;
-  if ( (signed int)pVideoPlayer->uNumMagicVideoHeaders > 0 )
+  if ( this->uNumMagicVideoHeaders )
   {
-    while ( _stricmp(pVideoPlayer->pMagicVideoHeaders[v5].pVideoName, pFilename) )
+    for ( uint i = 0; i < (signed int)this->uNumMagicVideoHeaders; ++i )
     {
-      ++v5;
-      if ( v5 >= (signed int)pVideoPlayer->uNumMagicVideoHeaders )
-        return 0;
+      if ( !_stricmp(this->pMagicVideoHeaders[i].pVideoName, pFilename) )
+      {
+        SetFilePointer(this->hMagicVid, this->pMagicVideoHeaders[i].uFileOffset, 0, 0);
+        return SmackOpen(this->hMagicVid, 0x7140, -1);
+      }
     }
-    SetFilePointer(pVideoPlayer->hMagicVid, pVideoPlayer->pMagicVideoHeaders[v5].uFileOffset, 0, 0);
-    return SmackOpen(pVideoPlayer->hMagicVid, 0x7140, -1);
   }
   return 0;
 }
@@ -940,67 +928,35 @@
 //----- (004BF28F) --------------------------------------------------------
 void VideoPlayer::OpenHouseMovie(const char *pMovieName, unsigned int a3_1)
 {
-  VideoPlayer *v3; // esi@1
-  std::string *v4; // ecx@3
-  _SMACK *v5; // eax@4
-  _SMACK *v6; // eax@7
-  int v7; // eax@7
-  int v8; // ecx@7
-  unsigned int v9; // ebx@8
-  unsigned int v10; // eax@8
-  signed __int64 v11; // qax@9
-  char *v12; // [sp-20h] [bp-54h]@3
-  int v13; // [sp-1Ch] [bp-50h]@3
-  std::string v14; // [sp-18h] [bp-4Ch]@3
-  const char *v15; // [sp-8h] [bp-3Ch]@3
-  int v16; // [sp-4h] [bp-38h]@3
-  char Str2[0x30]; // [sp+Ch] [bp-28h]@4
-  std::string *v18; // [sp+3Ch] [bp+8h]@3
-  std::string *v19; // [sp+3Ch] [bp+8h]@5
-  unsigned __int16 *v20; // [sp+3Ch] [bp+8h]@8
-
-  v3 = this;
   if ( !this->field_54 )
   {
     Prepare();
-    v3->bLoopPlaying = a3_1;
-    if ( LOBYTE(v3->field_104) == 1 )
+    this->bLoopPlaying = a3_1;
+    if ( LOBYTE(this->field_104) == 1 )
     {
-      v15 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925";
-      v12 = "Unsupported Bink playback!";
-      MessageBoxA(nullptr, v12, v15, 0);
+      MessageBoxA(nullptr, "Unsupported Bink playback!", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925", 0);
       return;
     }
     sprintfex(Str2, "%s.smk", pMovieName);
-    v5 = OpenSmack(Str2);
-    v3->pSmackerMovie = v5;
-    if ( !v5 )
+    this->pSmackerMovie = OpenSmack(Str2);
+    if ( !this->pSmackerMovie )
     {
-      v3->Unload();
+      this->Unload();
       sprintf(pTmpBuf.data(), "Can't load %s", &Str2);
-      v15 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:937";
-      MessageBoxA(nullptr, pTmpBuf.data(), v15, 0);
+      MessageBoxA(nullptr, pTmpBuf.data(), "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:937", 0);
       return;
     }
-    v16 = (int)pMovieName;
-    v3->uMovieFormat = 1;
-    strcpy(v3->pCurrentMovieName, (const char *)v16);
-    v6 = v3->pSmackerMovie;
-    v3->dword_0000A0 = 1;
-    v7 = SmackBufferOpen(v3->hWindow, 4, LOWORD(v6->Width), LOWORD(v6->Height), LOWORD(v6->Width), LOWORD(v6->Height));
-    v3->pSmackerBuffer = (_SMACKBUF *)v7;
-    if ( v7 )
+    this->uMovieFormat = 1;
+    strcpy(this->pCurrentMovieName, (const char *)pMovieName);
+    this->dword_0000A0 = 1;
+    this->pSmackerBuffer = (_SMACKBUF *)SmackBufferOpen(this->hWindow, 4, LOWORD(this->pSmackerMovie->Width), LOWORD(this->pSmackerMovie->Height), LOWORD(this->pSmackerMovie->Width), LOWORD(this->pSmackerMovie->Height));
+    if ( this->pSmackerBuffer )
     {
       pRenderer->BeginScene();
-      v9 = pRenderer->uTargetSurfacePitch;
-      v20 = pRenderer->pTargetSurface;
-      v10 = SmackCheckSurfaceFromat();
-      SmackToBuffer(v3->pSmackerMovie, 8, 8, 2 * v9, pRenderer->field_14, v20, v10);
+      SmackToBuffer(this->pSmackerMovie, 8, 8, 2 * pRenderer->uTargetSurfacePitch, pRenderer->field_14, pRenderer->pTargetSurface, SmackCheckSurfaceFromat());
       pRenderer->EndScene();
     }
-    v16 = 32767;
-    v11 = (signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 32767.0);
-    SmackVolumePan(v3->pSmackerMovie, 1040384, v11, 32767);
+    SmackVolumePan(this->pSmackerMovie, 1040384, (signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 32767.0), 32767);
   }
 }
 
@@ -1013,62 +969,48 @@
 //----- (004BF411) --------------------------------------------------------
 void VideoPlayer::OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4)
 {
-  VideoPlayer *pVideoPlayer; // esi@1
-  _BINK *pVideoOpen; // eax@2
-  _SMACK *v6; // eax@3
-  _BINK *pBinkMovie; // eax@5
-  _SMACK *v8; // eax@7
-  char *v9; // eax@7
   unsigned int v10; // eax@11
-  _SMACKBLIT *v11; // eax@14
-  const char *v12; // [sp-4h] [bp-38h]@8
   char pVideoName[120]; // [sp+Ch] [bp-28h]@2
 
-  pVideoPlayer = this;
   if ( !this->field_54 )
   {
     Prepare();
-    pVideoPlayer->bLoopPlaying = bLoop;
+    this->bLoopPlaying = bLoop;
     sprintf(pVideoName, "%s.bik", pFilename);
-    pVideoOpen = OpenBink(pVideoName);
-    pVideoPlayer->pBinkMovie = pVideoOpen;
-    if ( pVideoOpen )
+    this->pBinkMovie = OpenBink(pVideoName);
+    if ( this->pBinkMovie )
     {
-      pVideoPlayer->uMovieFormat = 2;
-      strcpy(pVideoPlayer->pCurrentMovieName, pFilename);
-      pBinkMovie = pVideoPlayer->pBinkMovie;
-      pVideoPlayer->dword_0000A0 = 1;
+      this->uMovieFormat = 2;
+      strcpy(this->pCurrentMovieName, pFilename);
+      pBinkMovie = this->pBinkMovie;
+      this->dword_0000A0 = 1;
       if ( pBinkMovie )
-        pVideoPlayer->pBinkBuffer = CreateBinkBuffer(pVideoPlayer->hWindow, pBinkMovie->uWidth, pBinkMovie->uHeight, 0);
+        this->pBinkBuffer = CreateBinkBuffer(this->hWindow, pBinkMovie->uWidth, pBinkMovie->uHeight, 0);
     }
     else
     {
       Unload();
       sprintfex(pVideoName, "%s.smk", pFilename);
-      v6 = OpenSmack(pVideoName);
-      pVideoPlayer->pSmackerMovie = v6;
-      if ( !v6 )
+      this->pSmackerMovie = OpenSmack(pVideoName);
+      if ( !this->pSmackerMovie )
       {
         Unload();
         sprintf(pVideoName, "Can't load file - anims\\%s.smk", pFilename);
         MessageBoxA(0, pVideoName, "Smacker Error", 0);
         return;
       }
-      pVideoPlayer->uMovieFormat = 1;
-      strcpy(pVideoPlayer->pCurrentMovieName, pFilename);
-      v8 = pVideoPlayer->pSmackerMovie;
-      pVideoPlayer->dword_0000A0 = 2;
-      v9 = (char *)malloc(v8->Width * v8->Height);
-      pVideoPlayer->pSomeSmackerBuffer = v9;
-      if ( !v9 )
+      this->uMovieFormat = 1;
+      strcpy(this->pCurrentMovieName, pFilename);
+      this->dword_0000A0 = 2;
+      this->pSomeSmackerBuffer = (char *)malloc(this->pSmackerMovie->Width * this->pSmackerMovie->Height);
+      if ( !this->pSomeSmackerBuffer )
       {
         Unload();
-        v12 = "Can't allocate memory for buffer";
-        sprintf(pVideoName, v12);
-		MessageBoxA(0, pVideoName, "Smacker Error", 0);
+        sprintf(pVideoName, "Can't allocate memory for buffer");
+        MessageBoxA(0, pVideoName, "Smacker Error", 0);
         return;
       }
-      SmackToBuffer(pVideoPlayer->pSmackerMovie, 0, 0, pVideoPlayer->pSmackerMovie->Width, pVideoPlayer->pSmackerMovie->Height, v9, 0);
+      SmackToBuffer(this->pSmackerMovie, 0, 0, this->pSmackerMovie->Width, this->pSmackerMovie->Height, this->pSomeSmackerBuffer, 0);
 
       v10 = SmackCheckSurfaceFromat();
       if ( a4 )
@@ -1081,13 +1023,11 @@
           Log::Warning(L"Smacker seems to use lower resolution because it thinks CPU is slow");
       }
 
-      v11 = SmackBlitOpen(v10);
-      pVideoPlayer->pSmackMovieBlit = v11;
-      if ( !v11 )
+      this->pSmackMovieBlit = SmackBlitOpen(v10);
+      if ( !this->pSmackMovieBlit )
       {
         Unload();
-        v12 = "Failed to open Blit API";
-		sprintf(pVideoName, v12);
+        sprintf(pVideoName, "Failed to open Blit API");
         MessageBoxA(0, pVideoName, "Smacker Error", 0);
         return;
       }
@@ -1099,22 +1039,15 @@
 //----- (004BF5B2) --------------------------------------------------------
 void VideoPlayer::_4BF5B2()
 {
-  VideoPlayer *v1; // esi@1
-  unsigned int v2; // eax@1
-  _BINK **v3; // edi@2
-
-  v1 = this;
-  v2 = this->uMovieFormat;
-  if ( v2 == 2 )
+  if ( this->uMovieFormat == 2 )
   {
-    v3 = &this->pBinkMovie;
     BinkGoto(pBinkMovie, 1, 0);
     BinkDoFrame(pBinkMovie);
     BinkNextFrame(pBinkMovie);
   }
   else
   {
-    if ( v2 != 1 )
+    if ( this->uMovieFormat != 1 )
       return;
     SmackGoto(pSmackerMovie, 1);
     if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 )
@@ -1124,7 +1057,7 @@
     }
   }
   pMouse->_469E24();
-  if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !v1->pSmackerMovie )
+  if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !this->pSmackerMovie )
   {
     bGameoverLoop = 1;
     sub_4BD8B5();
@@ -1146,27 +1079,16 @@
 //----- (004BF73A) --------------------------------------------------------
 void VideoPlayer::SelectMovieType()
 {
-  VideoPlayer *v1; // esi@1
-  int v2; // edi@1
-  unsigned __int8 v3; // bl@1
-  int v4; // edi@1
   char Source[32]; // [sp+Ch] [bp-40h]@1
 
-  v1 = this;
-  v2 = this->dword_0000A0;
-  v3 = LOBYTE(this->bLoopPlaying);
   strcpy(Source, this->pCurrentMovieName);
   Unload();
-  v4 = v2 - 1;
-  if ( v4 )
-  {
-    if ( v4 == 1 )
-      OpenGlobalMovie(Source, v3, 1);
-  }
+  if ( this->dword_0000A0 == 1 )
+    OpenHouseMovie(Source, LOBYTE(this->bLoopPlaying));
+  else if ( this->dword_0000A0 == 2 )
+    OpenGlobalMovie(Source, LOBYTE(this->bLoopPlaying), 1);
   else
-  {
-    OpenHouseMovie(Source, v3);
-  }
+    __debugbreak();
 }
 
 //----- (004BF8F6) --------------------------------------------------------
--- a/_deleted.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/_deleted.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -2119,8 +2119,8 @@
   if (pOutdoorCamera->uNumPolygons >= 1999)
     return;
 
-  array_77EC08[1999]._48607B(&stru_8019C8);
-  array_77EC08[1999].ptr_38->sky_48694B();
+  array_77EC08[1999].Create_48607B(&stru_8019C8);
+  array_77EC08[1999].ptr_38->Inverse_sky_48694B();
 
   if (pOutdoor->uMainTile_BitmapID == -1)
   {
@@ -2142,8 +2142,8 @@
                        + (double)pViewport->uScreenCenterY);
   cos((double)pIndoorCamera->sRotationX * 0.0030664064);
   sin((double)pIndoorCamera->sRotationX * 0.0030664064);
-  array_77EC08[1999]._48607B(&stru_8019C8);
-  array_77EC08[1999].ptr_38->sky_48694B();
+  array_77EC08[1999].Create_48607B(&stru_8019C8);
+  array_77EC08[1999].ptr_38->Inverse_sky_48694B();
 
   if (pOutdoor->uSky_TextureID == -1)
   {
--- a/mm7_1.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/mm7_1.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -488,8 +488,9 @@
         {
           v10 = 0;
           v11 = *(float *)v3 == *((float *)v6 - 5);
-          goto LABEL_19;
-        }
+          if ( v11 | v10 )
+            goto LABEL_21;
+		}
       }
       else
       {
@@ -497,13 +498,10 @@
         {
           v10 = 0;
           v11 = *(float *)v3 == *((float *)v6 + 7);
-LABEL_19:
           if ( v11 | v10 )
             goto LABEL_21;
-          goto LABEL_20;
         }
       }
-LABEL_20:
       ++v21;
       v22 += 48;
       v24 += 48;
--- a/mm7_2.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/mm7_2.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -481,28 +481,28 @@
   if ( uDialogueType == 85 )
   {
     num_monsters = v4;
-    goto LABEL_22;
-  }
-  if ( uDialogueType == 86 )
+    v4 /= 2;
+  }
+  else if ( uDialogueType == 86 )
   {
     v5 = (signed __int64)((double)v26 * 1.5);
-    goto LABEL_20;
-  }
-  if ( uDialogueType == 87 )
+    num_monsters = v5;
+    v4 /= 2;
+  }
+  else if ( uDialogueType == 87 )
   {
     LODWORD(v5) = 2 * v4;
-LABEL_20:
     num_monsters = v5;
-LABEL_22:
     v4 /= 2;
-    goto LABEL_24;
-  }
-  __debugbreak(); // warning C4700: uninitialized local variable 'v27' used
-  if ( uDialogueType == 88 )
-    num_monsters = 2 * v4;
+  }
   else
-    v4 = v27;
-LABEL_24:
+  {
+    __debugbreak(); // warning C4700: uninitialized local variable 'v27' used
+    if ( uDialogueType == 88 )
+      num_monsters = 2 * v4;
+    else
+      v4 = v27;
+  }
   if ( v4 < 1 )
     v4 = 1;
   if ( v4 > 100 )
@@ -555,20 +555,20 @@
     v16 = rand();
     v17 = 3;
     v22 = 50;
-    goto LABEL_53;
-  }
-  if ( uDialogueType == 86 )
+    v18 = v16 % v17;
+    v13 = v22;
+    v14 = v18 + 6;
+  }
+  else if ( uDialogueType == 86 )
   {
     v16 = rand();
     v17 = 7;
     v22 = 100;
-LABEL_53:
     v18 = v16 % v17;
     v13 = v22;
     v14 = v18 + 6;
-    goto LABEL_55;
-  }
-  if ( uDialogueType == 87 )
+  }
+  else if ( uDialogueType == 87 )
   {
     v15 = rand() % 11;
     v13 = 200;
@@ -587,7 +587,6 @@
       v13 = gold_transaction_amount;
     }
   }
-LABEL_55:
   i = 0;
   for ( gold_transaction_amount = v26 * v13; i < v14; ++i )
   {
@@ -631,7 +630,6 @@
       if ( v0 == -1 )
       {
         _4B4224_UpdateNPCTopics((int)((char *)pDialogueNPCCount - 1));
-//LABEL_33:
         pVideoPlayer->_4BF5B2();
         return 1;
       }
@@ -648,7 +646,6 @@
           if ( v0 != 102 && v0 != 103 && v0 != 104 )
           {
             pVideoPlayer->_4BF5B2();
-//LABEL_28:
             dialog_menu_id = HOUSE_DIALOGUE_MAIN;
             InitializaDialogueOptions(in_current_building_type);
             return 1;
@@ -870,27 +867,21 @@
     /*if ( (signed int)result < 40 )
     {
       pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_Quit;
-      goto LABEL_42;
     }*/
     pMessageQueue_50CBD0->AddMessage(UIMSG_Quit, 1, 0);
-    goto LABEL_43;
   }
   else
   {
     pMessageQueue_50CBD0->AddMessage(UIMSG_ShowFinalWindow, 1, 0);
-    goto LABEL_43;
     /*if ( (signed int)result < 40 )
     {
       pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_C5;
-LABEL_42:
       pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
       result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
       *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
       ++pMessageQueue_50CBD0->uNumMessages;
-      goto LABEL_43;
     }*/
   }
-LABEL_43:
   bGameoverLoop = 0;
   return result;
 }
@@ -1105,19 +1096,25 @@
         pTexture = pMapInfo->pEncounterMonster1Texture;
         v12 = v10 % (v11 - v9 + 1);
         v13 = pMapInfo->Dif_M1;
-        goto LABEL_20;
+        v57 = v13;
+        v56 = v9 + v12;
+        strcpy(Source, pTexture);
+        break;
     case 3u:
         pTexture = pMapInfo->pEncounterMonster1Texture;
         v44 = "%s A";
-        goto LABEL_25;
+        sprintf(Source, v44, pTexture);
+        break;
     case 4u:
         pTexture = pMapInfo->pEncounterMonster2Texture;
         v44 = "%s A";
-        goto LABEL_25;
+        sprintf(Source, v44, pTexture);
+        break;
     case 5u:
         pTexture = pMapInfo->pEncounterMonster3Texture;
         v44 = "%s A";
-        goto LABEL_25;
+        sprintf(Source, v44, pTexture);
+        break;
     case 1u:
         v9 = pMapInfo->uEncounterMonster2AtLeast;
         v14 = rand();
@@ -1125,19 +1122,25 @@
         pTexture = pMapInfo->pEncounterMonster2Texture;
         v12 = v14 % (v15 - v9 + 1);
         v13 = pMapInfo->Dif_M2;
-        goto LABEL_20;
+        v57 = v13;
+        v56 = v9 + v12;
+        strcpy(Source, pTexture);
+        break;
     case 6u:
         pTexture = pMapInfo->pEncounterMonster1Texture;
         v44 = "%s B";
-        goto LABEL_25;
+        sprintf(Source, v44, pTexture);
+        break;
     case 7u:
         pTexture = pMapInfo->pEncounterMonster2Texture;
         v44 = "%s B";
-        goto LABEL_25;
+        sprintf(Source, v44, pTexture);
+        break;
     case 8u:
         pTexture = pMapInfo->pEncounterMonster3Texture;
         v44 = "%s B";
-        goto LABEL_25;
+        sprintf(Source, v44, pTexture);
+        break;
     case 2u:
         v9 = pMapInfo->uEncounterMonster3AtLeast;
         v16 = rand();
@@ -1145,50 +1148,49 @@
         pTexture = pMapInfo->pEncounterMonster3Texture;
         v12 = v16 % (v17 - v9 + 1);
         v13 = pMapInfo->Dif_M3;
-LABEL_20:
         v57 = v13;
         v56 = v9 + v12;
         strcpy(Source, pTexture);
-        goto LABEL_26;
+        break;
     case 9u:
         pTexture = pMapInfo->pEncounterMonster1Texture;
         v44 = "%s C";
-        goto LABEL_25;
+        sprintf(Source, v44, pTexture);
+        break;
     case 0xAu:
         pTexture = pMapInfo->pEncounterMonster2Texture;
         v44 = "%s C";
-        goto LABEL_25;
+        sprintf(Source, v44, pTexture);
+        break;
     case 0xBu:
         pTexture = pMapInfo->pEncounterMonster3Texture;
         v44 = "%s C";
-LABEL_25:
         sprintf(Source, v44, pTexture);
-LABEL_26:
-        if (Source[0] == '0')
-          return;
-        v57 += a3;
-        if ( v57 > 4 )
-          v57 = 4;
-        strcpy(Str2, Source);
-        if ( a4 )
-          v56 = a4;
-        v18 = v56;
-        if ( (signed int)(v56 + uNumActors) >= 500 )
-          return;
-        pSector = 0;
-        pPosX = spawn->vPosition.x;
-        a4 = spawn->vPosition.y;
-        a3 = spawn->vPosition.z;
-        if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-          pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z);
-        v53 = 0;
-        v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64;
-        if ( v18 <= 0 )
-          return;
         break;
       default:
         return;
   }
+    if (Source[0] == '0')
+        return;
+    v57 += a3;
+    if ( v57 > 4 )
+        v57 = 4;
+    strcpy(Str2, Source);
+    if ( a4 )
+        v56 = a4;
+    v18 = v56;
+    if ( (signed int)(v56 + uNumActors) >= 500 )
+        return;
+    pSector = 0;
+    pPosX = spawn->vPosition.x;
+    a4 = spawn->vPosition.y;
+    a3 = spawn->vPosition.z;
+    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+        pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z);
+    v53 = 0;
+    v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64;
+    if ( v18 <= 0 )
+        return;
   for (uint i = v53; i < v56; ++i)
   {
       pMonster = &pActors[uNumActors];
@@ -1222,7 +1224,7 @@
           else
           {
             if ( v24 != 3 )
-              goto LABEL_58;
+              continue;
             pTexture = Source;
             v44 = "%s C";
           }
@@ -1275,7 +1277,12 @@
       v36 = spawn->vPosition.z;
       a3 = spawn->vPosition.z;
       if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
-        goto LABEL_55;
+	  {
+        if ( a5 )
+            pMonster->uAttributes |= 0x080000;
+        ++uNumActors;
+        continue;
+	  }
       v37 = pIndoor->GetSector(pPosX, a4, v36);
       if ( v37 == pSector )
       {
@@ -1286,15 +1293,13 @@
           if ( abs(v38 - a3) <= 1024 )
           {
             a3 = v39;
-LABEL_55:
             if ( a5 )
               pMonster->uAttributes |= 0x080000;
             ++uNumActors;
-            goto LABEL_58;
+            continue;
           }
         }
       }
-LABEL_58:
       ;
       //v53 = (char *)v53 + 1;
       //result = v53;
@@ -1437,7 +1442,7 @@
   int v14; // edx@10
   signed int v15; // ebx@20
   unsigned __int16 v16; // dx@20
-  char *v17; // ecx@21
+  ObjectDesc *v17; // ecx@21
   unsigned __int16 v18; // ax@24
   int v19; // ST0C_4@27
   int v20; // ST08_4@27
@@ -1445,7 +1450,7 @@
   int v22; // eax@27
   signed int v23; // ebx@29
   unsigned __int16 v24; // dx@29
-  char *v25; // ecx@30
+  ObjectDesc *v25; // ecx@30
   unsigned __int16 v26; // ax@33
   //int v27; // ecx@35
   //int v28; // eax@35
@@ -1487,97 +1492,75 @@
     if ( a2->uIndex == 1 )
     {
       v14 = rand() % 51 + 50;
-    }
-    else
+	  a1a.stru_24.uItemID = 197;
+	  v34 = v14;
+	}
+    else if ( a2->uIndex == 2 )
     {
-      if ( a2->uIndex != 2 )
-      {
-        if ( a2->uIndex == 3 )
+		v14 = rand() % 101 + 100;
+		a1a.stru_24.uItemID = 197;
+		v34 = v14;
+	}
+        else if ( a2->uIndex == 3 )
         {
           v14 = rand() % 301 + 200;
+          a1a.stru_24.uItemID = 198;
+		  v34 = v14;
         }
-        else
+        else if ( a2->uIndex == 4 )
+        {
+			  v14 = rand() % 501 + 500;
+			  a1a.stru_24.uItemID = 198;
+			  v34 = v14;
+		}
+		else if ( a2->uIndex == 5 )
         {
-          if ( a2->uIndex != 4 )
-          {
-            if ( a2->uIndex == 5 )
-            {
-              v14 = rand() % 1001 + 1000;
-            }
-            else
+			v14 = rand() % 1001 + 1000;
+            a1a.stru_24.uItemID = 199;
+            v34 = v14;
+        }
+        else if ( a2->uIndex == 6 )
+        {
+				  v14 = rand() % 3001 + 2000;
+				  a1a.stru_24.uItemID = 199;
+				  v34 = v14;
+		}	 
+            v15 = 0;
+            v16 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
+            a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
+            v18 = 0;
+			for( int i = 0; i < pObjectList->uNumObjects; i++ )
             {
-              if ( a2->uIndex != 6 )
-              {
-LABEL_20:
-                v15 = 0;
-                v16 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
-                a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
-                if ( (signed int)pObjectList->uNumObjects <= 0 )
-                {
-LABEL_24:
-                  v18 = 0;
-                }
-                else
-                {
-                  v17 = (char *)&pObjectList->pObjects->uObjectID;
-                  while ( v16 != *(short *)v17 )
-                  {
-                    ++v15;
-                    v17 += 56;
-                    if ( v15 >= (signed int)pObjectList->uNumObjects )
-                      goto LABEL_24;
-                  }
-                  v18 = v15;
-                }
-                a1a.stru_24.SetIdentified();
-                a1a.uObjectDescID = v18;
-                a1a.stru_24.uSpecEnchantmentType = v34;
-                goto LABEL_35;
-              }
-              v14 = rand() % 3001 + 2000;
+				if ( pObjectList->pObjects[i].uObjectID == v16 )
+				{
+					v18 = i;
+					break;
+				}
             }
-            a1a.stru_24.uItemID = 199;
-LABEL_19:
-            v34 = v14;
-            goto LABEL_20;
-          }
-          v14 = rand() % 501 + 500;
-        }
-        a1a.stru_24.uItemID = 198;
-        goto LABEL_19;
-      }
-      v14 = rand() % 101 + 100;
-    }
-    a1a.stru_24.uItemID = 197;
-    goto LABEL_19;
-  }
-  result = a1a.stru_24.GenerateArtifact();
-  if ( !result )
-    return result;
-  v23 = 0;
-  v24 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
-  a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
-  if ( (signed int)pObjectList->uNumObjects <= 0 )
-  {
-LABEL_33:
-    v26 = 0;
+            a1a.stru_24.SetIdentified();
+            a1a.uObjectDescID = v18;
+            a1a.stru_24.uSpecEnchantmentType = v34;
   }
   else
   {
-    v25 = (char *)&pObjectList->pObjects->uObjectID;
-    while ( v24 != *(short *)v25 )
-    {
-      ++v23;
-      v25 += 56;
-      if ( v23 >= (signed int)pObjectList->uNumObjects )
-        goto LABEL_33;
-    }
-    v26 = v23;
-  }
-  a1a.uObjectDescID = v26;
-  a1a.stru_24.Reset();
-
-LABEL_35:
+	  result = a1a.stru_24.GenerateArtifact();
+	  if ( !result )
+		return result;
+	  v23 = 0;
+	  v24 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
+	  a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID;
+	  v26 = 0;
+		for( int i = 0; i < pObjectList->uNumObjects; i++ )
+		{
+			if( v24 == pObjectList->pObjects[i].uObjectID )
+			{
+				v26 = i;
+				break;
+			}
+		}
+	  a1a.uObjectDescID = v26;
+	  a1a.stru_24.Reset();
+  }
   a1a.vPosition.y = a2->vPosition.y;
   a1a.uAttributes = 0;
   a1a.uSoundID = 0;
@@ -1611,23 +1594,15 @@
   v8 = 0;
   v9 = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID;
   a1.uType = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID;
-  if ( (signed int)pObjectList->uNumObjects <= 0 )
-  {
-LABEL_5:
-    v11 = 0;
-  }
-  else
-  {
-    v10 = (char *)&pObjectList->pObjects->uObjectID;
-    while ( v9 != *(short *)v10 )
-    {
-      ++v8;
-      v10 += 56;
-      if ( v8 >= (signed int)pObjectList->uNumObjects )
-        goto LABEL_5;
-    }
-    v11 = v8;
-  }
+  v11 = 0;
+	for( int i = 0; i < pObjectList->uNumObjects; i++ )
+	{
+		if( v9 == pObjectList->pObjects[i].uObjectID )
+		{
+			v11 = i;
+			break;
+		}
+	}
   a1.uObjectDescID = v11;
   a1.vPosition.y = a4;
   a1.vPosition.x = a3;
@@ -1734,22 +1709,16 @@
                           &v27,
                           0);
       v23 = 0;
-      if ( (signed int)pOutdoor->uNumBModels > 0 )
-      {
-        while ( 1 )
-        {
-          v9 = abs(v19.vPosition.y - pOutdoor->pBModels[v8].vBoundingCenter.y);
-          v10 = abs(v19.vPosition.x - pOutdoor->pBModels[v8].vBoundingCenter.x);
-          if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[v8].sBoundingRadius + 256 )
-            break;
-          ++v23;
-          ++v8;
-          if ( v23 >= (signed int)pOutdoor->uNumBModels )
-            goto LABEL_16;
-        }
-        v22 = 1;
-      }
-LABEL_16:
+	  for( int i = 0; i < pOutdoor->uNumBModels; i++ )
+	  {
+		v9 = abs(v19.vPosition.y - pOutdoor->pBModels[i].vBoundingCenter.y);
+		v10 = abs(v19.vPosition.x - pOutdoor->pBModels[i].vBoundingCenter.x);
+		if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[i].sBoundingRadius + 256 )
+		{
+		  v22 = 1;
+		  break;
+		}
+	  }
       v11 = uFaceID == 100;
       if ( uFaceID >= 100 )
         break;
@@ -1797,7 +1766,6 @@
   }
   if ( v11 )
   {
-LABEL_8:
     result = 0;
   }
   else
@@ -2947,34 +2915,43 @@
                 if ( a1 < 78 )
                 {
                   if ( a1 < 89 )
-                    goto LABEL_31;
-                  goto LABEL_28;
+				  {
+					v4 = 0;
+					v1 = 0;
+					v2 = 0;
+					return TargetColor(v2, v1, v4);
+				  }
                 }
+				else
+				{
 LABEL_25:
-                if ( a1 < 89 )
-                {
-                  v4 = 155;
-                  v2 = 255;
-                  goto LABEL_30;
-                }
-LABEL_28:
+					if ( a1 < 89 )
+					{
+					  v4 = 155;
+					  v2 = 255;
+					  v1 = v2;
+					  return TargetColor(v2, v1, v4);
+					}
+				}
                 if ( a1 < 100 )
                 {
                   v4 = 240;
                   v2 = 192;
-                  goto LABEL_30;
+				  v1 = v2;
+				  return TargetColor(v2, v1, v4);
                 }
-LABEL_31:
                 v4 = 0;
                 v1 = 0;
-                goto LABEL_32;
+				v2 = 0;
+				return TargetColor(v2, v1, v4);
               }
 LABEL_21:
               if ( a1 < 78 )
               {
                 v4 = 0;
                 v1 = 128;
-                goto LABEL_23;
+			    v2 = 255;
+			    return TargetColor(v2, v1, v4);
               }
               goto LABEL_25;
             }
@@ -2992,7 +2969,9 @@
           if ( a1 < 56 )
           {
             v2 = 225;
-            goto LABEL_13;
+            v4 = v2;
+            v1 = v2;
+            return TargetColor(v2, v1, v4);
           }
           goto LABEL_18;
         }
@@ -3000,9 +2979,7 @@
         if ( a1 < 45 )
         {
           v2 = 128;
-LABEL_13:
           v4 = v2;
-LABEL_30:
           v1 = v2;
           return TargetColor(v2, v1, v4);
         }
@@ -3013,7 +2990,6 @@
       {
         v4 = 255;
         v1 = 128;
-LABEL_32:
         v2 = 0;
         return TargetColor(v2, v1, v4);
       }
@@ -3026,7 +3002,6 @@
     {
       v4 = 0;
       v1 = 85;
-LABEL_23:
       v2 = 255;
       return TargetColor(v2, v1, v4);
     }
@@ -3117,9 +3092,9 @@
       {
         if ( v4 != 1 )
         {
-          if ( v4 != 0 || pActor->sNPC_ID )
-            continue;
-          goto LABEL_12;
+          if ( v4 == 0 && pActor->sNPC_ID == 0 )
+			pActor->sNPC_ID = 0;
+		  continue;
         }
       }
       if ( pActor->sNPC_ID > 0 && pActor->sNPC_ID < 5000 )
@@ -3132,9 +3107,7 @@
         pActor->sNPC_ID = v14;
         continue;
       }
-LABEL_12:
       pActor->sNPC_ID = 0;
-//LABEL_13:
       //++v15;
       //v2 += 836;
     //}
@@ -4032,14 +4005,12 @@
       else
       {
         if ( !pRenderer->pRenderD3D && !pRenderer->UsingDirect3D() || !AreRenderSurfacesOk() )
-          //goto LABEL_20;
         {
           EndPaint(hWnd, &Paint);
           return 0;
         }
       }
       pRenderer->Present();
-//LABEL_20:
       EndPaint(hWnd, &Paint);
       return 0;
     }
@@ -4324,25 +4295,27 @@
     || RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition)
     || RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v13, &dwDisposition)
     || RegCreateKeyExA(v13, "1.0", 0, "", 0, 0xF003Fu, 0, &v14, &dwDisposition) )
-    goto LABEL_7;
-  if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) )
+  {
+    result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen);
+  }
+  else if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) )
   {
     RegCloseKey(v14);
     v14 = 0;
-LABEL_7:
     result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen);
-    goto LABEL_8;
-  }
-  v4 = RegCloseKey;
-  RegCloseKey(v14);
-  v14 = 0;
-  RegCloseKey(v13);
-  v13 = 0;
-  RegCloseKey(phkResult);
-  phkResult = 0;
-  result = RegCloseKey(hKey);
-  hKey = 0;
-LABEL_8:
+  }
+  else
+  {
+	v4 = RegCloseKey;
+	RegCloseKey(v14);
+	v14 = 0;
+	RegCloseKey(v13);
+	v13 = 0;
+	RegCloseKey(phkResult);
+	phkResult = 0;
+	result = RegCloseKey(hKey);
+	hKey = 0;
+  }
   if ( v14 )
     result = v4(v14);
   if ( v13 )
@@ -4503,7 +4476,6 @@
     if ( a3 == 2 )
     {
       v12 = 0;
-LABEL_9:
       EndDialog(hDlg, v12);
       return 1;
     }
@@ -4516,7 +4488,8 @@
   if ( v4 )
   {
     v12 = 1;
-    goto LABEL_9;
+    EndDialog(hDlg, v12);
+    return 1;
   }
   return 0;
 }
@@ -5424,7 +5397,6 @@
     {
       MainMenu_Loop();
       uGameState = GAME_STATE_PLAYING;
-//LABEL_21:
       while ( 1 )
       {
         if (uGameState == GAME_FINISHED ||
@@ -5480,30 +5452,29 @@
         if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu)
         {
           uGameState = GAME_STATE_PLAYING;
+		  pGame->Loop();
         }
         else
         {
-          if (GetCurrentMenuID() != MENU_10)
-            goto LABEL_49;
-          pMouse->Activate(0);
-
-          pParty->Reset();
-          pParty->CreateDefaultParty(1);
-          crt_init_globals_46271C();
-          extern OPENFILENAMEA ofn;
-          if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) )
-          {
-            pMouse->Activate(1);
-
-            break;
-          }
-          _chdir("..\\");
-          strcpy(pCurrentMapName.data(), ofn.lpstrFileTitle);
-          pMouse->Activate(1);
+          if (GetCurrentMenuID() == MENU_10)
+		  {
+			  pMouse->Activate(0);
+
+			  pParty->Reset();
+			  pParty->CreateDefaultParty(1);
+			  crt_init_globals_46271C();
+			  extern OPENFILENAMEA ofn;
+			  if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) )
+			  {
+				pMouse->Activate(1);
+				break;
+			  }
+			  _chdir("..\\");
+			  strcpy(pCurrentMapName.data(), ofn.lpstrFileTitle);
+			  pMouse->Activate(1);
+			  pGame->Loop();
+		  }
         }
-//LABEL_48:
-        pGame->Loop();
-LABEL_49:
         if ( uGameState == GAME_STATE_LOADING_GAME )
         {
           SetCurrentMenuID(MENU_5);
@@ -6091,13 +6062,13 @@
   v29 = 640 * v3;
   while ( 2 )
   {
-    v31 = 100;
-    v6 = &pRenderer->pActiveZBuffer[v2 + v5 - v4 / 2];
+    v6 = &pRenderer->pActiveZBuffer[v2 + v5 - v4 / 2]-1;
     v7 = v0;
-    while ( 1 )
-    {
+    //while ( 1 )
+    for( int i = 0; i < 100; i++)
+	{
+	  ++v6;
       v8 = *v6;
-      --v31;
       if ( (unsigned int)*v6 <= 0x2000000 )
       {
         v9 = 0;
@@ -6130,17 +6101,13 @@
           }
         }
       }
-      if ( !v31 )
-        break;
-      ++v6;
-    }
+     }
     v4 = -1;
     ++v30;
     v5 = v29 + 640;
     v29 += 640;
-    if ( v30 < v28 )
-      continue;
-    break;
+    if ( v30 >= v28 )
+      break;
   }
   v12 = 0;
   v10 = v0 == 0;
@@ -6183,45 +6150,51 @@
       if ( !(pSpriteObjects[v20].uAttributes & 0x10) )
       {
         v23 = pSpriteObjects[v20].stru_24.GetDisplayName();
-LABEL_36:
         v24 = v23;
-        goto LABEL_51;
-      }
-      goto LABEL_41;
-    }
-    if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Actor)
-    {
-      if ( v20 >= 0xBB8 )
-        return 0;
-      v24 = (const char *)&pActors[v20];
-      goto LABEL_51;
-    }
-    if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Decoration)
-      break;
-    if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_BModel)
-    {
-      if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
-      {
-        v21 = &pIndoor->pFaces[v20];
-        if ( !(BYTE3(v21->uAttributes) & 2) )
-          goto LABEL_41;
-        v22 = pIndoor->pFaceExtras[v21->uFaceExtraID].uEventID;
-      }
-      else
-      {
-        if ( (dword_720020_zvalues[v18] & 0xFFFFu) >> 9 >= pOutdoor->uNumBModels )
-          goto LABEL_41;
-        v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[v20 & 0x3F].sCogTriggeredID;
-      }
-      if ( v22 )
-      {
-        v23 = GetEventHintString(v22);
-        if ( v23 )
-          goto LABEL_36;
+	    GameUI_SetFooterString(v24);
+	    return v19;
       }
     }
-LABEL_41:
-    ++v18;
+    else
+	{
+		if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Actor)
+		{
+		  if ( v20 >= 0xBB8 )
+			return 0;
+		  v24 = (const char *)&pActors[v20];
+		  GameUI_SetFooterString(v24);
+		  return v19;
+		}
+		if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Decoration)
+		  break;
+		if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_BModel)
+		{
+		  if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+		  {
+			v21 = &pIndoor->pFaces[v20];
+			if ( BYTE3(v21->uAttributes) & 2 )
+				v22 = pIndoor->pFaceExtras[v21->uFaceExtraID].uEventID;
+		  }
+		  else
+		  {
+			if ( (dword_720020_zvalues[v18] & 0xFFFFu) >> 9 < pOutdoor->uNumBModels )
+			{
+				v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[v20 & 0x3F].sCogTriggeredID;
+				if ( v22 )
+				{
+					v23 = GetEventHintString(v22);
+					if ( v23 )
+					{
+						v24 = v23;
+						GameUI_SetFooterString(v24);
+						return v19;
+					}
+				}
+			}
+		  }
+		}
+	}
+	++v18;
     if ( v18 >= v0 )
       return 0;
   }
@@ -6233,13 +6206,14 @@
     v23 = GetEventHintString(v27);
     if ( !v23 )
       return v19;
-    goto LABEL_36;
+	v24 = v23;
+	GameUI_SetFooterString(v24);
+	return v19;
   }
   if ( v25->IsInteractive() )
     v24 = pNPCTopics[stru_5E4C90._decor_events[v26->_idx_in_stru123 - 75] + 379].pTopic;
   else
     v24 = pDecorationList->pDecorations[v26->uDecorationDescID].field_20;
-LABEL_51:
   GameUI_SetFooterString(v24);
   return v19;
 }
@@ -6275,11 +6249,11 @@
 //----- (0046BFFA) --------------------------------------------------------
 bool __fastcall _46BFFA_check_object_intercept(unsigned int uLayingItemID, signed int a2)
 {
-  SpriteObject *v2; // esi@1
+  //SpriteObject *v2; // esi@1
   ObjectDesc *v3; // ebx@1
   unsigned __int16 v5; // cx@9
-  unsigned __int16 v6; // cx@14
-  signed int v7; // edx@14
+  //unsigned __int16 v6; // cx@14
+  //signed int v7; // edx@14
   unsigned int v8; // eax@19
   unsigned int v9; // edi@19
   signed int v10; // ebx@19
@@ -6287,7 +6261,7 @@
   unsigned __int16 v12; // ax@23
   int v13; // eax@27
   unsigned int v14; // ebx@33
-  unsigned __int16 v15; // ax@35
+  //unsigned __int16 v15; // ax@35
   int v16; // eax@36
   unsigned int v17; // eax@37
   __int16 v18; // di@37
@@ -6345,11 +6319,11 @@
   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 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
@@ -6373,11 +6347,11 @@
   unsigned __int16 v98; // ax@191
   unsigned int v99; // ecx@191
   char v100; // ST18_1@198
-  int v101; // ST14_4@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
+  //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
@@ -6388,7 +6362,7 @@
   unsigned __int16 v113; // si@241
   int v114; // eax@242
   int v115; // eax@245
-  signed int v116; // eax@245
+  //signed int v116; // eax@245
   unsigned __int16 v117; // ax@251
   unsigned int v118; // ecx@251
   signed int v119; // ebx@251
@@ -6398,14 +6372,14 @@
   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
+  //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
+  //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
@@ -6421,63 +6395,64 @@
   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
+  //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[v2->uObjectDescID];
+  //v2 = &pSpriteObjects[uLayingItemID];
+  v3 = &pObjectList->pObjects[pSpriteObjects[uLayingItemID].uObjectDescID];
   v145 = a2;
   v151 = PID_TYPE(a2);
   if ( PID_TYPE(a2) == OBJECT_Actor)
   {
-    if ( PID_TYPE(v2->spell_caster_pid) == OBJECT_Actor && !pActors[PID_ID(v2->spell_caster_pid)].GetActorsRelation(&pActors[PID_ID(a2)]) )
+    if ( PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) == OBJECT_Actor 
+      && !pActors[PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid)].GetActorsRelation(&pActors[PID_ID(a2)]) )
       return 1;
   }
   else
   {
-    if ( PID_TYPE(a2) == OBJECT_Player && PID_TYPE(v2->spell_caster_pid) == OBJECT_Player)
+    if ( PID_TYPE(a2) == OBJECT_Player && PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) == OBJECT_Player)
       return 1;
   }
   if ( pParty->bTurnBasedModeOn == 1 )
   {
-    v5 = v2->uAttributes;
+    v5 = pSpriteObjects[uLayingItemID].uAttributes;
     if ( v5 & 4 )
     {
       --pTurnEngine->field_1C;
-      v2->uAttributes = v5 & 0xFFFB;
+      pSpriteObjects[uLayingItemID].uAttributes = v5 & 0xFFFB;
     }
   }
-  if ( v151 == OBJECT_BModel && PID_TYPE(v2->spell_caster_pid) != OBJECT_Player)
+  if ( v151 == OBJECT_BModel && PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) != OBJECT_Player)
       {
-      if (PID_ID(v2->spell_caster_pid)<500)  //bugfix  PID_ID(v2->spell_caster_pid)==1000
-         BYTE2(pActors[PID_ID(v2->spell_caster_pid)].uAttributes) |= 4;
+      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;
       }
 
-  v6 = v2->uType;
-  v7 = v2->uType;
-  if ( v7 > 3060 )
-  {
-    if ( v7 > 6090 )
+  //v6 = v2->uType;
+  //v7 = v2->uType;
+  if ( pSpriteObjects[uLayingItemID].uType > 3060 )
+  {
+    if ( pSpriteObjects[uLayingItemID].uType > 6090 )
     {
-      if ( v7 > 8090 )
+      if ( pSpriteObjects[uLayingItemID].uType > 8090 )
       {
-        if ( v7 == 9010 )
+        if ( pSpriteObjects[uLayingItemID].uType == 9010 )
           goto LABEL_247;
-        if ( v7 != 9030 )
+        if ( pSpriteObjects[uLayingItemID].uType != 9030 )
         {
-          if ( v7 != 9040 )
+          if ( pSpriteObjects[uLayingItemID].uType != 9040 )
           {
-            if ( v7 != 9080 )
+            if ( pSpriteObjects[uLayingItemID].uType != 9080 )
               return 0;
 LABEL_191:
-            v98 = v6 + 1;
+            v98 = pSpriteObjects[uLayingItemID].uType + 1;
             v99 = pObjectList->uNumObjects;
             v32 = 0;
-            v2->uType = v98;
+            pSpriteObjects[uLayingItemID].uType = v98;
             v146 = 0;
             if ( (signed int)v99 > 0 )
             {
@@ -6487,19 +6462,76 @@
                 ++v146;
                 v144 += 56;
                 if ( v146 >= (signed int)v99 )
-                  goto LABEL_195;
+                {
+                  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;
+                  stru_50FE08.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;
+                }
               }
-              goto LABEL_80;
+              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;
+              stru_50FE08.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;
             }
-LABEL_195:
-            v46 = 0;
-            goto LABEL_196;
+            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;
+            stru_50FE08.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;
           }
           goto LABEL_93;
         }
 LABEL_172:
         v143 = 17030;
-        switch ( v6 )
+        switch ( pSpriteObjects[uLayingItemID].uType )
         {
           case 0x1798u:
             v143 = 15040;
@@ -6514,14 +6546,17 @@
         v138 = 1;
         if ( v151 != OBJECT_Actor)
         {
-          if ( v6 != 9030 || v2->spell_skill != 4 )
-            goto LABEL_246;
-          v2->_46BEF1_apply_spells_aoe();
+          if ( pSpriteObjects[uLayingItemID].uType != 9030 || pSpriteObjects[uLayingItemID].spell_skill != 4 )
+		  {
+			  SpriteObject::OnInteraction(v153);
+			  return 0;
+		  }
+		  pSpriteObjects[uLayingItemID]._46BEF1_apply_spells_aoe();
 LABEL_233:
           if ( !v138 )
           {
             v109 = pObjectList->uNumObjects;
-            ++v2->uType;
+            ++pSpriteObjects[uLayingItemID].uType;
             v110 = 0;
             if ( (signed int)v109 <= 0 )
             {
@@ -6531,7 +6566,7 @@
             else
             {
               v111 = (char *)&pObjectList->pObjects->uObjectID;
-              while ( v2->uType != *(short *)v111 )
+              while ( pSpriteObjects[uLayingItemID].uType != *(short *)v111 )
               {
                 ++v110;
                 v111 += 56;
@@ -6540,41 +6575,34 @@
               }
               v112 = v110;
             }
-            v2->uObjectDescID = v112;
+            pSpriteObjects[uLayingItemID].uObjectDescID = v112;
             if ( !v112 )
               SpriteObject::OnInteraction(v153);
-            v2->vVelocity.z = 0;
-            v2->vVelocity.y = 0;
-            v2->vVelocity.x = 0;
-            v2->uSpriteFrameID = 0;
-            v113 = v2->uSoundID;
+            pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+            pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+            pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+            pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
+            v113 = pSpriteObjects[uLayingItemID].uSoundID;
             if ( v113 )
               v114 = (signed __int16)v113 + 4;
             else
               v114 = 0;
-            v133 = 0;
-            v131 = 0;
-            v130 = v114;
             v115 = 8 * v153;
-            v129 = 0;
-            v128 = -1;
             LOBYTE(v115) = PID(OBJECT_Item,v153);
-            v127 = 0;
-            v126 = v115;
-            v116 = v143;
-            goto LABEL_269;
+            v125 = v143 + 1;
+            pAudioPlayer->PlaySound((SoundID)v125, v115, 0, -1, 0, v114, 0, 0);
+            return 0;
           }
-LABEL_246:
           SpriteObject::OnInteraction(v153);
           return 0;
         }
         v106 = v145;
         v150 = 0;
         v139 = PID_ID(v106);
-        v137 = v2->spell_level;
-        v152 = v2->spell_skill;
-        v136 = v2->spell_id;
-        if ( v6 == 9030 )
+        v137 = pSpriteObjects[uLayingItemID].spell_level;
+        v152 = pSpriteObjects[uLayingItemID].spell_skill;
+        v136 = pSpriteObjects[uLayingItemID].spell_id;
+        if ( pSpriteObjects[uLayingItemID].uType == 9030 )
         {
           v150 = 2;
           if ( v152 == 2 )
@@ -6588,48 +6616,44 @@
           }
           BYTE2(pActors[v139].uAttributes) |= 8u;
         }
-        if ( v7 == 6040 )
+        if ( pSpriteObjects[uLayingItemID].uType == 6040 )
         {
           v135 = 7;
         }
         else
         {
-          if ( v7 == 8030 )
+          if ( pSpriteObjects[uLayingItemID].uType == 8030 )
           {
             v135 = 9;
           }
           else
           {
-            if ( v7 != 9030 )
+            if ( pSpriteObjects[uLayingItemID].uType != 9030 )
             {
               v107 = v136;
 LABEL_222:
-              if ( v6 != 9030 || v152 != 4 )
+              if ( pSpriteObjects[uLayingItemID].uType != 9030 || v152 != 4 )
               {
                 v108 = v139;
                 if ( stru_50C198.GetMagicalResistance(&pActors[v139], v107) )
                 {
                   v138 = 0;
-                  if ( v2->uType == 8030 )
+                  if ( pSpriteObjects[uLayingItemID].uType == 8030 )
                   {
                     pActors[v108].uAIState = Standing;
                     pActors[v108].UpdateAnimation();
                   }
-                  pActors[v108].pActorBuffs[v136].Apply(
-                    pParty->uTimePlayed + (signed int)(signed __int64)((double)(v137 << 7) * 0.033333335),
-                    v152,
-                    v150,
-                    0,
-                    0);
+                  pActors[v108].pActorBuffs[v136].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(v137 << 7) * 0.033333335),
+                    v152, v150, 0, 0);
                 }
               }
               else
               {
-                v2->_46BEF1_apply_spells_aoe();
+                pSpriteObjects[uLayingItemID]._46BEF1_apply_spells_aoe();
               }
-              v2->spell_level = 0;
-              v2->spell_skill = 0;
-              v2->spell_id = 0;
+              pSpriteObjects[uLayingItemID].spell_level = 0;
+              pSpriteObjects[uLayingItemID].spell_skill = 0;
+              pSpriteObjects[uLayingItemID].spell_id = 0;
               goto LABEL_233;
             }
             v135 = 10;
@@ -6638,42 +6662,60 @@
         v107 = v135;
         goto LABEL_222;
       }
-      if ( v7 == 8090 || v7 == 7030 || v7 == 7090 || v7 == 8000 )
+      if ( pSpriteObjects[uLayingItemID].uType == 8090 || pSpriteObjects[uLayingItemID].uType == 7030 || pSpriteObjects[uLayingItemID].uType == 7090 || pSpriteObjects[uLayingItemID].uType == 8000 )
         goto LABEL_93;
-      if ( v7 == 8010 )
+      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;
-        ++v2->uType;
+        ++pSpriteObjects[uLayingItemID].uType;
         v9 = 0;
         v52 = 0;
         if ( (signed int)v93 > 0 )
         {
           v94 = (char *)&pObjectList->pObjects->uObjectID;
-          while ( v2->uType != *(short *)v94 )
+          while ( pSpriteObjects[uLayingItemID].uType != *(short *)v94 )
           {
             ++v52;
             v94 += 56;
             if ( v52 >= (signed int)v93 )
               goto LABEL_181;
           }
-          goto LABEL_202;
+          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;
         }
         goto LABEL_181;
       }
-      v79 = v7 == 8030;
+      v79 = pSpriteObjects[uLayingItemID].uType == 8030;
     }
     else
     {
-      if ( v7 == 6090 )
+      if ( pSpriteObjects[uLayingItemID].uType == 6090 )
         goto LABEL_93;
-      if ( v7 <= 4070 )
+      if ( pSpriteObjects[uLayingItemID].uType <= 4070 )
       {
-        if ( v7 != 4070 )
+        if ( pSpriteObjects[uLayingItemID].uType != 4070 )
         {
-          v48 = v7 - 3090;
+          v48 = pSpriteObjects[uLayingItemID].uType - 3090;
           if ( v48 )
           {
             v49 = v48 - 2;
@@ -6686,13 +6728,13 @@
               v44 = v45 == 0;
               goto LABEL_91;
             }
-            v54 = v6 - 1;
+            v54 = pSpriteObjects[uLayingItemID].uType - 1;
             v55 = pObjectList->uNumObjects;
             v9 = 0;
             v56 = 0;
             v44 = pObjectList->uNumObjects == 0;
             v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-            v2->uType = v54;
+            pSpriteObjects[uLayingItemID].uType = v54;
             if ( v20 | v44 )
             {
 LABEL_102:
@@ -6710,45 +6752,31 @@
               }
               v58 = v56;
             }
-            v2->uObjectDescID = v58;
+            pSpriteObjects[uLayingItemID].uObjectDescID = v58;
             if ( !v58 )
               SpriteObject::OnInteraction(v153);
-            v14 = v153;
-            v2->vVelocity.z = 0;
-            v2->vVelocity.y = 0;
-            v2->vVelocity.x = 0;
-            v2->uSpriteFrameID = 0;
+            pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+            pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+            pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+            pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
             sub_43A97E(v153, v145);
-LABEL_35:
-            v15 = v2->uSoundID;
-            if ( v15 == (short)v9 )
+            if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v9 )
               v16 = 0;
             else
-              v16 = (signed __int16)v15 + 4;
-            v133 = v9;
-            v131 = v9;
-            v130 = v16;
-            v92 = v14;
-LABEL_267:
-            v124 = 8 * v92;
-            v129 = v9;
-            v128 = -1;
+              v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
+            v124 = 8 * v153;
             LOBYTE(v124) = v124 | 2;
-            v127 = v9;
-            v126 = v124;
-LABEL_268:
-            v116 = word_4EE088_sound_ids[v2->spell_id - 1];
-LABEL_269:
-            v125 = v116 + 1;
-            goto LABEL_29;
+            v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id] + 1;
+            pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v16, v9, v9);
+            return 0;
           }
-          v59 = v6 + 2;
+          v59 = pSpriteObjects[uLayingItemID].uType + 2;
           v60 = pObjectList->uNumObjects;
           v9 = 0;
           v61 = 0;
           v44 = pObjectList->uNumObjects == 0;
           v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-          v2->uType = v59;
+          pSpriteObjects[uLayingItemID].uType = v59;
           if ( v20 | v44 )
           {
 LABEL_111:
@@ -6766,14 +6794,14 @@
             }
             v63 = v61;
           }
-          v2->uObjectDescID = v63;
+          pSpriteObjects[uLayingItemID].uObjectDescID = v63;
           if ( !v63 )
             SpriteObject::OnInteraction(v153);
-          v64 = v2->uFacing - stru_5C6E00->uIntegerDoublePi;
-          v44 = v2->spell_skill == 4;
-          v2->vVelocity.z = 0;
-          v2->vVelocity.y = 0;
-          v2->vVelocity.x = 0;
+          v64 = pSpriteObjects[uLayingItemID].uFacing - stru_5C6E00->uIntegerDoublePi;
+          v44 = pSpriteObjects[uLayingItemID].spell_skill == 4;
+          pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+          pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+          pSpriteObjects[uLayingItemID].vVelocity.x = 0;
           v65 = 7;
           if ( v44 )
             v65 = 9;
@@ -6783,25 +6811,30 @@
             do
             {
               v64 += (signed int)stru_5C6E00->uIntegerHalfPi >> 1;
-              v2->Create(v64, 0, 1000, 0);
+              pSpriteObjects[uLayingItemID].Create(v64, 0, 1000, 0);
               --v141;
             }
             while ( v141 );
           }
-LABEL_160:
-          v14 = v153;
-LABEL_34:
-          SpriteObject::OnInteraction(v14);
-          goto LABEL_35;
+          SpriteObject::OnInteraction(v153);
+          if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v9 )
+            v16 = 0;
+          else
+            v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
+          v124 = 8 * v153;
+          LOBYTE(v124) = v124 | 2;
+          v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id] + 1;
+          pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v16, v9, v9);
+          return 0;
         }
         if ( v151 == 6 || v151 == 5 || (v66 = 0, !v151) )
           return 1;
-        v67 = v6 + 1;
+        v67 = pSpriteObjects[uLayingItemID].uType + 1;
         v68 = pObjectList->uNumObjects;
         v69 = 0;
         v44 = pObjectList->uNumObjects == 0;
         v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-        v2->uType = v67;
+        pSpriteObjects[uLayingItemID].uType = v67;
         if ( v20 | v44 )
         {
 LABEL_128:
@@ -6819,45 +6852,34 @@
           }
           v71 = v69;
         }
-        v2->uObjectDescID = v71;
+        pSpriteObjects[uLayingItemID].uObjectDescID = v71;
         if ( !v71 )
           SpriteObject::OnInteraction(v153);
         v134 = 0;
         v72 = v153;
         v132 = 0;
-LABEL_132:
-        v73 = v2->vPosition.z;
-        v74 = v2->vPosition.y;
-        v75 = PID(OBJECT_Item,v72);
-        v2->vVelocity.z = v66;
-        v2->vVelocity.y = v66;
-        v76 = v2->vPosition.x;
-        v2->vVelocity.x = v66;
-        v2->uSpriteFrameID = v66;
-        stru_50FE08.Add(v75, 512, v76, v74, v73, v132, v134);
-        v77 = v2->uSoundID;
-        if ( v77 == (short)v66 )
+        pSpriteObjects[uLayingItemID].vVelocity.z = v66;
+        pSpriteObjects[uLayingItemID].vVelocity.y = v66;
+        pSpriteObjects[uLayingItemID].vVelocity.x = v66;
+        pSpriteObjects[uLayingItemID].uSpriteFrameID = v66;
+        stru_50FE08.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 )
           v78 = 0;
         else
-          v78 = (signed __int16)v77 + 4;
-        v133 = v66;
-        v131 = v66;
-        v130 = v78;
-        v129 = v66;
-        v128 = -1;
-        v127 = v66;
-        v126 = v75;
-        goto LABEL_268;
+          v78 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
+        v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
+        pAudioPlayer->PlaySound((SoundID)v125, pSpriteObjects[uLayingItemID].vPosition.x, v66, -1, v66, v78, v66, v66);
+        return 0;
       }
-      if ( v7 == 4090 )
+      if ( pSpriteObjects[uLayingItemID].uType == 4090 )
       {
-        v84 = v6 + 2;
+        v84 = pSpriteObjects[uLayingItemID].uType + 2;
         v85 = pObjectList->uNumObjects;
         v9 = 0;
         v86 = 0;
         v44 = pObjectList->uNumObjects == 0;
         v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-        v2->uType = v84;
+        pSpriteObjects[uLayingItemID].uType = v84;
         if ( v20 | v44 )
         {
 LABEL_155:
@@ -6875,13 +6897,13 @@
           }
           v88 = v86;
         }
-        v2->uObjectDescID = v88;
+        pSpriteObjects[uLayingItemID].uObjectDescID = v88;
         if ( !v88 )
           SpriteObject::OnInteraction(v153);
-        v89 = v2->uFacing - stru_5C6E00->uIntegerDoublePi;
-        v2->vVelocity.z = 0;
-        v2->vVelocity.y = 0;
-        v2->vVelocity.x = 0;
+        v89 = pSpriteObjects[uLayingItemID].uFacing - stru_5C6E00->uIntegerDoublePi;
+        pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+        pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+        pSpriteObjects[uLayingItemID].vVelocity.x = 0;
         v142 = v89;
         v148 = 7;
         do
@@ -6891,20 +6913,29 @@
           pRnd->SetRange(5, 500);
           v91 = pRnd->GetInRange();
           v142 += (signed int)stru_5C6E00->uIntegerHalfPi >> 1;
-          v2->Create(v90 + v142, 0, v91, 0);
+          pSpriteObjects[uLayingItemID].Create(v90 + v142, 0, v91, 0);
           --v148;
         }
         while ( v148 );
-        goto LABEL_160;
+        SpriteObject::OnInteraction(v153);
+        if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v9 )
+          v16 = 0;
+        else
+          v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
+        v124 = 8 * v153;
+        LOBYTE(v124) = v124 | 2;
+        v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id] + 1;
+        pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v16, v9, v9);
+        return 0;
       }
-      if ( v7 == 4092 )
+      if ( pSpriteObjects[uLayingItemID].uType == 4092 )
       {
         v80 = pObjectList->uNumObjects;
         v66 = 0;
         v81 = 0;
         v44 = pObjectList->uNumObjects == 0;
         v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-        v2->uType = 4091;
+        pSpriteObjects[uLayingItemID].uType = 4091;
         if ( v20 | v44 )
         {
 LABEL_144:
@@ -6922,31 +6953,42 @@
           }
           v83 = v81;
         }
-        v2->uObjectDescID = v83;
+        pSpriteObjects[uLayingItemID].uObjectDescID = v83;
         if ( !v83 )
           SpriteObject::OnInteraction(v153);
         v134 = 0;
         v72 = v153;
-        v132 = v2->field_61;
-        goto LABEL_132;
+        v132 = pSpriteObjects[uLayingItemID].field_61;
+        pSpriteObjects[uLayingItemID].vVelocity.z = v66;
+        pSpriteObjects[uLayingItemID].vVelocity.y = v66;
+        pSpriteObjects[uLayingItemID].vVelocity.x = v66;
+        pSpriteObjects[uLayingItemID].uSpriteFrameID = v66;
+        stru_50FE08.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 )
+          v78 = 0;
+        else
+          v78 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
+        v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1;
+        pAudioPlayer->PlaySound((SoundID)v125, pSpriteObjects[uLayingItemID].vPosition.x, v66, -1, v66, v78, v66, v66);
+        return 0;
       }
-      if ( v7 == 4100 || v7 == 6010 )
+      if ( pSpriteObjects[uLayingItemID].uType == 4100 || pSpriteObjects[uLayingItemID].uType == 6010 )
         goto LABEL_93;
-      v79 = v7 == 6040;
+      v79 = pSpriteObjects[uLayingItemID].uType == 6040;
     }
     if ( !v79 )
       return 0;
     goto LABEL_172;
   }
-  if ( v7 == 3060 )
+  if ( pSpriteObjects[uLayingItemID].uType == 3060 )
     goto LABEL_93;
-  if ( v7 <= 555 )
-  {
-    if ( v7 == 555 )
+  if ( pSpriteObjects[uLayingItemID].uType <= 555 )
+  {
+    if ( pSpriteObjects[uLayingItemID].uType == 555 )
     {
       sub_43A97E(v153, v145);
       v23 = pObjectList->uNumObjects;
-      ++v2->uType;
+      ++pSpriteObjects[uLayingItemID].uType;
       v18 = 0;
       v24 = 0;
       if ( (signed int)v23 <= 0 )
@@ -6957,7 +6999,7 @@
       else
       {
         v25 = (char *)&pObjectList->pObjects->uObjectID;
-        while ( v2->uType != *(short *)v25 )
+        while ( pSpriteObjects[uLayingItemID].uType != *(short *)v25 )
         {
           ++v24;
           v25 += 56;
@@ -6967,17 +7009,17 @@
         v22 = v24;
       }
 LABEL_42:
-      v2->uObjectDescID = v22;
+      pSpriteObjects[uLayingItemID].uObjectDescID = v22;
       if ( v22 == v18 )
         SpriteObject::OnInteraction(v153);
-      v2->vVelocity.z = v18;
-      v2->vVelocity.y = v18;
-      v2->vVelocity.x = v18;
-      v2->uSpriteFrameID = v18;
+      pSpriteObjects[uLayingItemID].vVelocity.z = v18;
+      pSpriteObjects[uLayingItemID].vVelocity.y = v18;
+      pSpriteObjects[uLayingItemID].vVelocity.x = v18;
+      pSpriteObjects[uLayingItemID].uSpriteFrameID = v18;
     }
     else
     {
-      switch ( v7 )
+      switch ( pSpriteObjects[uLayingItemID].uType )
       {
         case 500:
         case 505:
@@ -6990,32 +7032,42 @@
         case 540:
           sub_43A97E(v153, v145);
           v8 = pObjectList->uNumObjects;
-          ++v2->uType;
+          ++pSpriteObjects[uLayingItemID].uType;
           v9 = 0;
           v10 = 0;
           if ( (signed int)v8 <= 0 )
-            goto LABEL_23;
+          {
+            v12 = 0;
+            goto LABEL_24;
+          }
           v11 = (char *)&pObjectList->pObjects->uObjectID;
           break;
         case 545:
         case 550:
-          if ( v2->stru_24.uItemID != 405 && v2->stru_24.uSpecEnchantmentType != 3 )
+          if ( pSpriteObjects[uLayingItemID].stru_24.uItemID != 405 && pSpriteObjects[uLayingItemID].stru_24.uSpecEnchantmentType != 3 )
           {
-            v14 = v153;
-            v9 = 0;
-            v2->vVelocity.z = 0;
-            v2->vVelocity.y = 0;
-            v2->vVelocity.x = 0;
-            v2->uSpriteFrameID = 0;
+            pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+            pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+            pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+            pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
             sub_43A97E(v153, v145);
-            goto LABEL_34;
+            SpriteObject::OnInteraction(v153);
+            if ( pSpriteObjects[uLayingItemID].uSoundID == 0 )
+              v16 = 0;
+            else
+              v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4;
+            v124 = 8 * v153;
+            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;
-          v2->uType = 600;
+          pSpriteObjects[uLayingItemID].uType = 600;
           if ( v20 | v44 )
             goto LABEL_41;
           v21 = (char *)&pObjectList->pObjects->uObjectID;
@@ -7031,35 +7083,39 @@
         default:
           return 0;
       }
-      while ( v2->uType != *(short *)v11 )
+      while ( pSpriteObjects[uLayingItemID].uType != *(short *)v11 )
       {
         ++v10;
         v11 += 56;
         if ( v10 >= (signed int)v8 )
         {
-LABEL_23:
           v12 = 0;
           goto LABEL_24;
         }
       }
       v12 = v10;
 LABEL_24:
-      v2->uObjectDescID = v12;
+      pSpriteObjects[uLayingItemID].uObjectDescID = v12;
       if ( !v12 )
         SpriteObject::OnInteraction(v153);
-      v44 = v2->uType == 555;
-      v2->vVelocity.z = 0;
-      v2->vVelocity.y = 0;
-      v2->vVelocity.x = 0;
-      v2->uSpriteFrameID = 0;
+      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 )
-        goto LABEL_27;
+      {
+        v13 = 8 * v153;
+        LOBYTE(v13) = PID(OBJECT_Item,v153);
+        pAudioPlayer->PlaySound(SOUND_8, v13, v9, -1, v9, v9, v9, v9);
+        return 0;
+      }
     }
     return 0;
   }
-  if ( v7 > 1100 )
-  {
-    v41 = v7 - 2030;
+  if ( pSpriteObjects[uLayingItemID].uType > 1100 )
+  {
+    v41 = pSpriteObjects[uLayingItemID].uType - 2030;
     if ( !v41 )
       goto LABEL_247;
     v42 = v41 - 30;
@@ -7077,52 +7133,55 @@
 LABEL_93:
     sub_43A97E(v153, v145);
     v51 = pObjectList->uNumObjects;
-    ++v2->uType;
+    ++pSpriteObjects[uLayingItemID].uType;
     v9 = 0;
     v52 = 0;
     if ( (signed int)v51 > 0 )
     {
       v53 = (char *)&pObjectList->pObjects->uObjectID;
-      while ( v2->uType != *(short *)v53 )
+      while ( pSpriteObjects[uLayingItemID].uType != *(short *)v53 )
       {
         ++v52;
         v53 += 56;
         if ( v52 >= (signed int)v51 )
           goto LABEL_181;
       }
-      goto LABEL_202;
+      v95 = v52;
     }
+	else
+	{
 LABEL_181:
     v95 = 0;
-LABEL_182:
-    v2->uObjectDescID = v95;
+	}
+    pSpriteObjects[uLayingItemID].uObjectDescID = v95;
     if ( v95 == (short)v9 )
       SpriteObject::OnInteraction(v153);
-    v96 = v2->uSoundID;
-    v2->vVelocity.z = v9;
-    v2->vVelocity.y = v9;
-    v2->vVelocity.x = v9;
-    v2->uSpriteFrameID = v9;
+    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;
-    v133 = v9;
-    v131 = v9;
-    v130 = v97;
     v92 = v153;
-    goto LABEL_267;
-  }
-  if ( v7 == 1100 )
+    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 == 1100 )
     goto LABEL_93;
-  v26 = v7 - 600;
+  v26 = pSpriteObjects[uLayingItemID].uType - 600;
   if ( !v26 )
   {
     v33 = pObjectList->uNumObjects;
     v34 = 0;
     v44 = pObjectList->uNumObjects == 0;
     v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-    v2->uType = 601;
+    pSpriteObjects[uLayingItemID].uType = 601;
     if ( v20 | v44 )
     {
 LABEL_69:
@@ -7140,30 +7199,24 @@
       }
       v36 = v34;
     }
-    v2->uObjectDescID = v36;
+    pSpriteObjects[uLayingItemID].uObjectDescID = v36;
     if ( !v36 )
       SpriteObject::OnInteraction(v153);
-    v37 = v2->vPosition.z;
-    v2->vVelocity.z = 0;
+    v37 = pSpriteObjects[uLayingItemID].vPosition.z;
+    pSpriteObjects[uLayingItemID].vVelocity.z = 0;
     v38 = 8 * v153;
-    v39 = v2->vPosition.y;
+    v39 = pSpriteObjects[uLayingItemID].vPosition.y;
     LOBYTE(v38) = PID(OBJECT_Item,v153);
-    v2->vVelocity.y = 0;
-    v2->vVelocity.x = 0;
-    v40 = v2->vPosition.x;
-    v2->uSpriteFrameID = 0;
+    pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+    pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+    v40 = pSpriteObjects[uLayingItemID].vPosition.x;
+    pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
     v147 = v38;
     stru_50FE08.Add(v38, 512, v40, v39, v37, 0, 0);
     if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE)
-      trail_particle_generator.GenerateTrailParticles(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v3->uParticleTrailColor);
-    v133 = 0;
-    v131 = 0;
-    v130 = 0;
-    v129 = 0;
-    v128 = -1;
-    v127 = 0;
-    v126 = v147;
-    goto LABEL_28;
+      trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v3->uParticleTrailColor);
+    pAudioPlayer->PlaySound(SOUND_8, v147, 0, -1, 0, 0, 0, 0);
+    return 0;
   }
   v27 = v26 - 410;
   if ( !v27 )
@@ -7179,10 +7232,10 @@
 LABEL_59:
     if ( v151 != 3 )
     {
-      v30 = v6 + 1;
+      v30 = pSpriteObjects[uLayingItemID].uType + 1;
       v31 = pObjectList->uNumObjects;
       v32 = 0;
-      v2->uType = v30;
+      pSpriteObjects[uLayingItemID].uType = v30;
       v146 = 0;
       if ( (signed int)v31 > 0 )
       {
@@ -7192,47 +7245,73 @@
           ++v146;
           v140 += 56;
           if ( v146 >= (signed int)v31 )
-            goto LABEL_195;
+          {
+            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;
+            stru_50FE08.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;
+          }
         }
-LABEL_80:
         v46 = v146;
-LABEL_196:
-        v2->uObjectDescID = v46;
+        pSpriteObjects[uLayingItemID].uObjectDescID = v46;
         if ( v46 == (short)v32 )
           SpriteObject::OnInteraction(v153);
-        v100 = v2->field_61;
-        v101 = v2->vPosition.z;
-        v2->uSpriteFrameID = v32;
+        v100 = pSpriteObjects[uLayingItemID].field_61;
+        pSpriteObjects[uLayingItemID].uSpriteFrameID = v32;
         v102 = 8 * v153;
-        v103 = v2->vPosition.y;
         LOBYTE(v102) = PID(OBJECT_Item,v153);
-        v2->vVelocity.x = v32;
-        v2->vVelocity.y = v32;
-        v104 = v2->vPosition.x;
-        v2->vVelocity.z = v32;
-        v149 = v102;
-        stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32);
+        pSpriteObjects[uLayingItemID].vVelocity.x = v32;
+        pSpriteObjects[uLayingItemID].vVelocity.y = v32;
+        pSpriteObjects[uLayingItemID].vVelocity.z = v32;
+        stru_50FE08.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(
-            v2->vPosition.x,
-            v2->vPosition.y,
-            v2->vPosition.z,
-            v3->uParticleTrailColor);
-        v105 = v2->uSoundID;
-        if ( v105 == (short)v32 )
+          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)v105 + 4;
-        v133 = v32;
-        v131 = v32;
-        v130 = v47;
-        v129 = v32;
-        v128 = -1;
-        v127 = v32;
-        v126 = v149;
-        goto LABEL_268;
+          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;
       }
-      goto LABEL_195;
+      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;
+      stru_50FE08.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;
     }
     return 1;
   }
@@ -7243,33 +7322,48 @@
   {
     sub_43A97E(v153, v145);
     v122 = pObjectList->uNumObjects;
-    ++v2->uType;
+    ++pSpriteObjects[uLayingItemID].uType;
     v52 = 0;
     if ( (signed int)v122 > 0 )
     {
       v123 = (char *)&pObjectList->pObjects->uObjectID;
-      while ( v2->uType != *(short *)v123 )
+      while ( pSpriteObjects[uLayingItemID].uType != *(short *)v123 )
       {
         ++v52;
         v123 += 56;
         if ( v52 >= (signed int)v122 )
           goto LABEL_181;
       }
-LABEL_202:
       v95 = v52;
-      goto LABEL_182;
+      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;
     }
     goto LABEL_181;
   }
-  v117 = v6 + 1;
+  v117 = pSpriteObjects[uLayingItemID].uType + 1;
   v118 = pObjectList->uNumObjects;
   v119 = 0;
   v44 = pObjectList->uNumObjects == 0;
   v20 = (pObjectList->uNumObjects & 0x80000000u) != 0;
-  v2->uType = v117;
+  pSpriteObjects[uLayingItemID].uType = v117;
   if ( v20 | v44 )
   {
-LABEL_255:
     v121 = 0;
   }
   else
@@ -7280,30 +7374,32 @@
       ++v119;
       v120 += 56;
       if ( v119 >= (signed int)v118 )
-        goto LABEL_255;
+      {
+        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;
   }
-  v2->uObjectDescID = v121;
+  pSpriteObjects[uLayingItemID].uObjectDescID = v121;
   if ( !v121 )
     SpriteObject::OnInteraction(v153);
-  v2->vVelocity.z = 0;
-  v2->vVelocity.y = 0;
-  v2->vVelocity.x = 0;
-  v2->uSpriteFrameID = 0;
-LABEL_27:
-  v133 = v9;
-  v131 = v9;
-  v130 = v9;
+  pSpriteObjects[uLayingItemID].vVelocity.z = 0;
+  pSpriteObjects[uLayingItemID].vVelocity.y = 0;
+  pSpriteObjects[uLayingItemID].vVelocity.x = 0;
+  pSpriteObjects[uLayingItemID].uSpriteFrameID = 0;
   v13 = 8 * v153;
-  v129 = v9;
-  v128 = -1;
   LOBYTE(v13) = PID(OBJECT_Item,v153);
-  v127 = v9;
-  v126 = v13;
-LABEL_28:
-  v125 = 8;
-LABEL_29:
-  pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133);
+  pAudioPlayer->PlaySound(SOUND_8, v13, v9, -1, v9, v9, v9, v9);
   return 0;
 }
--- a/mm7_3.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/mm7_3.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -1816,37 +1816,38 @@
   pParty->sRotationX = _view_angle;
   if ( bJumping )
   {
-    pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength();
+	pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength();
+	if ( bJumping != v36 && pParty->uFallSpeed <= v36 )
+	{
+		if ( pParty->uFallSpeed < -500 && !pParty->bFlying )
+		{
+			v41 = &pPlayers[1];
+			do
+			{
+				if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 
+					(*v41)->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0);
+				++v41;
+			}
+			while ( (signed int)v41 <= (signed int)&pPlayers[4] );
+		}
+	}
+	else
+		pParty->uFallStartY = party_z;
   }
   else
   {
     if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 32768 )
     {
       pParty->uFallSpeed -= pEventTimer->uTimeElapsed * GetGravityStrength();
-      goto LABEL_92;
+      pParty->uFallStartY = party_z;
     }
-    if (pParty->uFlags & PARTY_FLAGS_1_LANDING)
-      goto LABEL_92;
-    pParty->uFallSpeed = 0;
-  }
-  if ( bJumping != v36 && pParty->uFallSpeed <= v36 )
-  {
-    if ( pParty->uFallSpeed < -500 && !pParty->bFlying )
-    {
-      v41 = &pPlayers[1];
-      do
-      {
-        if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 
-          (*v41)->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0);
-        ++v41;
-      }
-      while ( (signed int)v41 <= (signed int)&pPlayers[4] );
-    }
-    goto LABEL_93;
-  }
-LABEL_92:
-  pParty->uFallStartY = party_z;
-LABEL_93:
+	else
+	{
+		if (! (pParty->uFlags & PARTY_FLAGS_1_LANDING) )
+		  pParty->uFallSpeed = 0;
+		pParty->uFallStartY = party_z;
+	}
+  }
   if ( v2 * v2 + v1 * v1 < 400 )
   {
     v1 = 0;
@@ -1923,9 +1924,8 @@
         && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime)) )
         pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
       viewparams->bRedrawGameUI = 1;
-      goto LABEL_152;
     }
-    if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
+	else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
     {
       v53 = integer_sqrt(v2 * v2 + v1 * v1);
       v80 = v53;
@@ -1955,64 +1955,69 @@
           }
           if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
             uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
-          goto LABEL_152;
         }
-        v46 = pParty->uFallSpeed * v44->pFacePlane_old.vNormal.z;
-        v47 = v45 == 4;
-        v48 = v44->pFacePlane_old.vNormal.x;
-        if ( !v47 )
-        {
-          v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
-          if ( stru_721530.field_64 >> 3 > v80 )
-            v80 = stru_721530.field_64 >> 3;
-          v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
-          v81 = v44->pFacePlane_old.vNormal.y;
-          v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
-          v82 = v44->pFacePlane_old.vNormal.z;
-          v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
-          v2 += v50;
-          pParty->uFallSpeed += v82;
-          v74 = v44->pFacePlane_old.vNormal.z;
-          v51 = v44->pFacePlane_old.vNormal.y;
-          v69 = v44->pFacePlane_old.vNormal.x;
-          v80 = v51;
-          v1 += v81;
-          v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16);
-          if ( v52 > 0 )
-          {
-            new_party_x += v52 * v69 >> 16;
-            new_party_y += v52 * v80 >> 16;
-            v87 += v52 * v74 >> 16;
-          }
-          v43 = stru_721530.uFaceID;
-          if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
-            uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
-          goto LABEL_152;
-        }
-        v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
-        if ( stru_721530.field_64 >> 3 > v80 )
-          v80 = stru_721530.field_64 >> 3;
-        v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
-        v81 = v44->pFacePlane_old.vNormal.y;
-        v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
-        v82 = v44->pFacePlane_old.vNormal.z;
-        v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
-        v2 += v49;
-        v1 += v81;
-        pParty->uFallSpeed += v82;
-        if ( v2 * v2 + v1 * v1 >= 400 )
-        {
-          v43 = stru_721530.uFaceID;
-          if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
-            uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
-          goto LABEL_152;
-        }
-        v2 = 0;
-        v1 = 0;
-        pParty->uFallSpeed = 0;
+		else
+		{
+			v46 = pParty->uFallSpeed * v44->pFacePlane_old.vNormal.z;
+			v47 = v45 == 4;
+			v48 = v44->pFacePlane_old.vNormal.x;
+			if ( !v47 )
+			{
+			  v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
+			  if ( stru_721530.field_64 >> 3 > v80 )
+				v80 = stru_721530.field_64 >> 3;
+			  v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
+			  v81 = v44->pFacePlane_old.vNormal.y;
+			  v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
+			  v82 = v44->pFacePlane_old.vNormal.z;
+			  v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
+			  v2 += v50;
+			  pParty->uFallSpeed += v82;
+			  v74 = v44->pFacePlane_old.vNormal.z;
+			  v51 = v44->pFacePlane_old.vNormal.y;
+			  v69 = v44->pFacePlane_old.vNormal.x;
+			  v80 = v51;
+			  v1 += v81;
+			  v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16);
+			  if ( v52 > 0 )
+			  {
+				new_party_x += v52 * v69 >> 16;
+				new_party_y += v52 * v80 >> 16;
+				v87 += v52 * v74 >> 16;
+			  }
+			  v43 = stru_721530.uFaceID;
+			  if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
+				uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
+			}
+			else
+			{
+				v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16;
+				if ( stru_721530.field_64 >> 3 > v80 )
+				  v80 = stru_721530.field_64 >> 3;
+				v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16;
+				v81 = v44->pFacePlane_old.vNormal.y;
+				v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16;
+				v82 = v44->pFacePlane_old.vNormal.z;
+				v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16;
+				v2 += v49;
+				v1 += v81;
+				pParty->uFallSpeed += v82;
+				if ( v2 * v2 + v1 * v1 >= 400 )
+				{
+				  v43 = stru_721530.uFaceID;
+				  if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 )
+					uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID;
+				}
+				else
+				{
+					v2 = 0;
+					v1 = 0;
+					pParty->uFallSpeed = 0;
+				}
+			}
+		}
       }
     }
-LABEL_152:
     v2 = (unsigned __int64)(58500i64 * v2) >> 16;
     v1 = (unsigned __int64)(58500i64 * v1) >> 16;
     ++v83;
@@ -2028,8 +2033,11 @@
     if ( integer_sqrt((pParty->vPosition.x - new_party_x) * (pParty->vPosition.x - new_party_x) + (pParty->vPosition.y - new_party_y)
          * (pParty->vPosition.y - new_party_y) + (pParty->vPosition.z - new_party_z)
          * (pParty->vPosition.z - new_party_z)) <= 16 )
-      goto LABEL_188;
-    if ( v72 && (!bJumping || jumping_up) )
+	{
+      pAudioPlayer->_4AA258(804);
+      pParty->walk_sound_timer = 64;
+	}
+    else if ( v72 && (!bJumping || jumping_up) )
     {
       v66 = 0;
       v64 = 0;
@@ -2045,13 +2053,16 @@
           v57 = (SoundID)50;
         else
           v57 = (SoundID)64;
-        goto LABEL_175;
+        pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66);
       }
-      v57 = (SoundID)63;
-      v56 = pAudioPlayer;
-      goto LABEL_175;
+	  else
+	  {
+		  v57 = (SoundID)63;
+		  v56 = pAudioPlayer;
+		  pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66);
+	  }
     }
-    if ( v78 && (!bJumping || jumping_up) )
+    else if ( v78 && (!bJumping || jumping_up) )
     {
       v66 = 0;
       v64 = 0;
@@ -2064,19 +2075,19 @@
       {
         v57 = (SoundID)102;
         v56 = pAudioPlayer;
-        goto LABEL_175;
       }
-      v56 = pAudioPlayer;
-      if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 )
-        v57 = (SoundID)89;
-      else
-        v57 = (SoundID)103;
-LABEL_175:
+	  else
+	  {
+		  v56 = pAudioPlayer;
+		  if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 )
+			v57 = (SoundID)89;
+		  else
+			v57 = (SoundID)103;
+	  }
       pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66);
     }
     else
     {
-LABEL_188:
       pAudioPlayer->_4AA258(804);
       pParty->walk_sound_timer = 64;
     }
@@ -2099,39 +2110,11 @@
 //----- (00473893) --------------------------------------------------------
 void ODM_ProcessPartyActions()
 {
-  //int _zero; // esi@1
   int v1; // edi@1
   int v2; // ebx@1
   int v3; // eax@14
-  //Player **v4; // esi@21
-  //int v5; // eax@24
   int v6; // esi@45
   ODMFace *v7; // ecx@45
-  //unsigned int v8; // eax@71
-  //double v9; // st7@72
-  //signed __int64 v10; // qax@74
-  //double v11; // st7@75
-  //int v12; // ecx@77
-  //int v13; // eax@84
-  //double v14; // st7@84
-  //int v15; // eax@87
-  //double v16; // st7@87
-  //int v17; // eax@88
-  //double v18; // st7@88
-  //int v19; // eax@89
-  //double v20; // st7@89
-  //int v21; // eax@92
-  //double v22; // st7@92
-  //int v23; // eax@96
-  //double v24; // st7@96
-  //int v25; // eax@97
-  //double v26; // st7@97
-  //int v27; // eax@98
-  //double v28; // st7@98
-  //signed __int64 v29; // qax@98
-  //unsigned int v30; // eax@103
-  int v31; // eax@130
-  //int v32; // ecx@141
   signed int v33; // eax@143
   int v34; // esi@143
   int v35; // esi@147
@@ -2140,19 +2123,17 @@
   signed int v38; // eax@159
   signed int i; // esi@159
   int v40; // esi@162
-  //Player **v41; // esi@172
   bool v42; // eax@180
   signed int v43; // ecx@184
   signed int v44; // edx@184
   int v45; // ecx@200
-  BSPModel *v46; // eax@203
-  ODMFace *v47; // esi@203
+  BSPModel *pModel; // eax@203
+  ODMFace *pODMFace; // esi@203
   int v48; // eax@203
   char v49; // zf@203
   char v50; // sf@203
   unsigned __int8 v51; // of@203
   int v52; // eax@203
-  unsigned __int8 v53; // dl@205
   BSPModel *v54; // eax@215
   int v55; // eax@217
   signed int v56; // ebx@228
@@ -2162,8 +2143,6 @@
   BSPModel *v60; // eax@228
   unsigned __int64 v61; // qax@228
   int v62; // eax@241
-  signed int v63; // ST04_4@255
-  signed int v64; // eax@255
   unsigned int v65; // ebx@263
   unsigned int v66; // esi@263
   int v67; // eax@263
@@ -2173,8 +2152,6 @@
   int v71; // esi@271
   int v72; // edi@271
   int v73; // eax@271
-  Player **v74; // esi@283
-  int v75; // eax@284
   unsigned int v76; // edi@293
   bool v77; // edx@297
   bool v78; // ecx@303
@@ -2182,9 +2159,7 @@
   __int16 v80; // dx@317
   int v81; // ebx@318
   int v82; // ecx@318
-  int v83; // eax@321
-  Player **v84; // esi@333
-  int v85; // eax@334
+  int pTerrainHeight; // eax@321
   int v86; // [sp-20h] [bp-B4h]@246
   int v87; // [sp-20h] [bp-B4h]@248
   signed int v88; // [sp-1Ch] [bp-B0h]@246
@@ -2192,23 +2167,16 @@
   signed int v90; // [sp-14h] [bp-A8h]@246
   signed int v91; // [sp-10h] [bp-A4h]@246
   int v92; // [sp-Ch] [bp-A0h]@246
-  //int v93; // [sp-8h] [bp-9Ch]@104
   unsigned int v94; // [sp-8h] [bp-9Ch]@246
-  //int v95; // [sp-4h] [bp-98h]@104
   int v96; // [sp-4h] [bp-98h]@246
   int v97; // [sp+Ch] [bp-88h]@180
   Vec3_int_ v98;
-  //int v98; // [sp+10h] [bp-84h]@147
-  //int v99; // [sp+14h] [bp-80h]@147
-  //int v100; // [sp+18h] [bp-7Ch]@147
   bool v101; // [sp+1Ch] [bp-78h]@33
   int v102; // [sp+20h] [bp-74h]@1
   int v103; // [sp+24h] [bp-70h]@1
   int bFeatherFall; // [sp+28h] [bp-6Ch]@4
   int v105; // [sp+2Ch] [bp-68h]@24
   int bWaterWalk; // [sp+30h] [bp-64h]@1
-  //bool v107; // [sp+34h] [bp-60h]@30
-  //int v108; // [sp+38h] [bp-5Ch]@1
   int v109; // [sp+3Ch] [bp-58h]@28
   int v110; // [sp+40h] [bp-54h]@180
   int v111; // [sp+44h] [bp-50h]@14
@@ -2219,20 +2187,15 @@
   int pX; // [sp+58h] [bp-3Ch]@1
   int pY; // [sp+5Ch] [bp-38h]@1
   int v118; // [sp+60h] [bp-34h]@1
-  //Player **v119; // [sp+64h] [bp-30h]@4
   int _angle_x; // [sp+68h] [bp-2Ch]@48
-  int v121; // [sp+6Ch] [bp-28h]@1
   unsigned int v122; // [sp+70h] [bp-24h]@180
   int pZ; // [sp+74h] [bp-20h]@1
   int v124; // [sp+78h] [bp-1Ch]@1
   int _angle_y; // [sp+7Ch] [bp-18h]@48
   int v126; // [sp+80h] [bp-14h]@48
-  BSPModel *v127; // [sp+84h] [bp-10h]@1
   int v128; // [sp+88h] [bp-Ch]@1
   int v129; // [sp+8Ch] [bp-8h]@92
-  //int v130; // [sp+90h] [bp-4h]@14
-
-  v121 = pParty->uFallSpeed;
+
   pZ = pParty->vPosition.z;
   v1 = 0;
   v103 = 0;
@@ -2248,7 +2211,7 @@
   v114 = 0;
   v124 = 0;
   v102 = 0;
-  v127 = 0;
+  pModel = 0;
   bWaterWalk = 0;
   if (!pParty->FeatherFallActive())
   {
@@ -2390,7 +2353,7 @@
               }
               v1 = 0;
               v2 = 0;
-              v121 = 0;
+              pParty->uFallSpeed = 0;
               *(float *)&v128 = 0.0;
               if ( v102 && pZ < v109 && (signed int)(pParty->uPartyHeight + pZ) >= v109 )
               {
@@ -2405,7 +2368,7 @@
                 v113 = pParty->field_6F0;
               }
               pParty->uFallSpeed = 0;
-              v127 = (BSPModel *)1;
+              pModel = (BSPModel *)1;
             }
           }
       }
@@ -2422,9 +2385,9 @@
             pZ -= 30;
             v113 -= 30;
             pParty->uFallSpeed = 0;
-            v121 = 0;
+            //pParty->uFallSpeed = 0;
             pParty->bFlying = 1;
-            v127 = (BSPModel *)1;
+            pModel = (BSPModel *)1;
             if ( pZ <= v111 )
             {
               pParty->bFlying = 0;
@@ -2529,7 +2492,7 @@
         float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0),
               cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0);
 
-        int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;        
+        int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;
         int dy = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;
 
         if (pParty->bFlying)
@@ -2603,7 +2566,6 @@
       }
       break;
 
-      
       case PARTY_CenterView:
         _angle_x = 0;
       break;
@@ -2629,7 +2591,7 @@
         {
           v126 = pParty->field_24 << 6;
           bJumping = 1;
-          v121 = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)v121);
+          pParty->uFallSpeed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)pParty->uFallSpeed);
         }
       break;
 
@@ -2655,30 +2617,26 @@
   {
     if ( pParty->bFlying )
     {
-//LABEL_130:
-      v31 = GetTickCount();
-      v126 = stru_5C6E00->Cos(v31);
+      v126 = stru_5C6E00->Cos(GetTickCount());
       v129 = (unsigned __int64)(4i64 * v126) >> 16;
       pZ = v113 + v129;
-      if ( v127 )
+      if ( pModel )
         pZ = v113;
       if (pParty->FlyActive())
         stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] &= 0xFEu;
       pParty->uFallStartY = pZ;
-      //goto LABEL_141;
     }
-	else
-	{
-		if ( is_on_water && v121 )
-		  sub_42F960_create_object(pX, pY, v111);
-		v121 = 0;
-		pZ = v111;
-		pParty->uFallStartY = v111;
-	    v113 = pZ;
-	    if (pParty->FlyActive())
-		  stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] |= 1u;
-
-	}
+    else
+    {
+      if ( is_on_water && pParty->uFallSpeed )
+        sub_42F960_create_object(pX, pY, v111);
+      pParty->uFallSpeed = 0;
+      pZ = v111;
+      pParty->uFallStartY = v111;
+      v113 = pZ;
+      if (pParty->FlyActive())
+        stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] |= 1u;
+    }
   }
   else
   {
@@ -2690,12 +2648,12 @@
   if (bJumping && !pParty->bFlying)
   {
     v33 = -(pEventTimer->uTimeElapsed * GetGravityStrength());
-    v34 = v121 + 2 * v33;
-    v121 += 2 * v33;
+    v34 = pParty->uFallSpeed + 2 * v33;
+    pParty->uFallSpeed += 2 * v33;
   }
   else if (!partyAtHighSlope)
   {
-    v34 = v121;
+    v34 = pParty->uFallSpeed;
   }
   else if (!bJumping)
   {
@@ -2706,17 +2664,17 @@
 		// and falling to the gravity, gradually sliding downwards. nice trick
 		pZ = v111;
 		ODM_GetTerrainNormalAt(pX, pY, &v98);
-		v35 = v121 + -8 * pEventTimer->uTimeElapsed * GetGravityStrength();
+		v35 = pParty->uFallSpeed + -8 * pEventTimer->uTimeElapsed * GetGravityStrength();
 		v129 = abs((signed __int64)v2 * v98.x + (signed __int64)v1 * v98.y + (signed __int64)v35 * v98.z) >> 16;
 		v2 += (unsigned __int64)(v129 * (signed __int64)v98.x) >> 16;
 		v1 += (unsigned __int64)(v129 * (signed __int64)v98.y) >> 16;
 		v34 = v35 + ((unsigned __int64)(v129 * (signed __int64)v98.z) >> 16);
 		v128 = v1;
-		v121 = v34;
+		pParty->uFallSpeed = v34;
 	}
   }
   else
-	  v34 = v121;
+	  v34 = pParty->uFallSpeed;
 
 //LABEL_164:
   if(bJumping)
@@ -2765,7 +2723,7 @@
     stru_721530.normal.z = stru_721530.prolly_normal_d + pZ + 1;
     stru_721530.field_34.z = stru_721530.field_C + pZ + 1;
     stru_721530.field_20 = v128;
-    stru_721530.field_24 = v121;
+    stru_721530.field_24 = pParty->uFallSpeed;
     v36 = 0;
     stru_721530.uSectorID = 0;
     if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3 )
@@ -2789,14 +2747,14 @@
     {
       _angle_x = pX + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16);
       _angle_y = pY + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16);
-      v127 = (BSPModel *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16);
+      pModel = (BSPModel *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16);
       v40 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + pZ;
     }
     v122 = v40;
     ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0);
     v129 = ODM_GetFloorLevel(_angle_x, pY, v40, pParty->uPartyHeight, &is_on_water, &v97, 0);
     auto v119 = ODM_GetFloorLevel(pX, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &v110, 0);
-    v127 = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, pY);
+    pModel = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, pY);
     v42 = IsTerrainSlopeTooHigh(pX, _angle_y);
     is_not_on_bmodel = false;
     v118 = v42;
@@ -2812,7 +2770,7 @@
 	}
 	else
 	{
-		if ( v127 && v129 > pZ )
+		if ( pModel && v129 > pZ )
 		  v44 = 0;
 		if ( v118 && v119 > pZ )
 		  v43 = 0;
@@ -2826,8 +2784,8 @@
 		  pY = _angle_y;
 		else
 		{
-			v127 = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0);
-			if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)v127 <= pZ )
+			pModel = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0);
+			if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)pModel <= pZ )
 			{
 			  v43 = 1;
 			  pX = _angle_x;
@@ -2858,11 +2816,11 @@
 
       viewparams->bRedrawGameUI = 1;
 		v2 = (unsigned __int64)(58500i64 * v2) >> 16;
-		v127 = (BSPModel *)58500;
+		pModel = (BSPModel *)58500;
 		v128 = (unsigned __int64)(58500i64 * v128) >> 16;
-		v122 = (unsigned __int64)(58500i64 * v121) >> 16;
+		v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
 		++v126;
-		v121 = (unsigned __int64)(58500i64 * v121) >> 16;
+		pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
 		continue;
 	}
     if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
@@ -2873,12 +2831,12 @@
                                _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y);
       v129 = v57;
       v58 = (BSPModel *)stru_5C6E00->Cos(v57);
-      v127 = v58;
+      pModel = v58;
       v59 = (signed int)v58 * (signed __int64)v56;
       v122 = v59 >> 16;
       v2 = v59 >> 16;
       v60 = (BSPModel *)stru_5C6E00->Sin(v129);
-      v127 = v60;
+      pModel = v60;
       v61 = (signed int)v60 * (signed __int64)v118;
       v122 = v61 >> 16;
       v128 = v61 >> 16;
@@ -2888,128 +2846,125 @@
       if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
       {
         pParty->bFlying = 0;
-        v46 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9];
-        v127 = v46;
-		v47 = &v46->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F];
-        v48 = v47->pBoundingBox.z2 - v47->pBoundingBox.z1;
+        pModel = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9];
+        //v127 = v46;
+        pODMFace = &pModel->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F];
+        v48 = pODMFace->pBoundingBox.z2 - pODMFace->pBoundingBox.z1;
         v51 = __OFSUB__(v48, 32);
         v49 = v48 == 32;
         v50 = v48 - 32 < 0;
-        v52 = v47->pFacePlane.vNormal.z;
+        v52 = pODMFace->pFacePlane.vNormal.z;
         v129 = (unsigned __int8)(v50 ^ v51 | v49);
         v119 = v52 < 46378;
         if ( bUnderwater == 1 )
           v119 = 0;
-        v53 = v47->uPolygonType;
-        if ( v53 == 3 )
+        if ( pODMFace->uPolygonType == POLYGON_Floor )
         {
-			if ( v121 < 0 )
-				v121 = 0;
-			pZ = v127->pVertices.pVertices[v47->pVertexIDs[0]].z + 1;
-			if ( v2 * v2 + v128 * v128 < 400 )
-			{
-				v2 = 0;
-				*(float *)&v128 = 0.0;
-			}
-			if ( pParty->floor_face_pid != v45 && (v47->uAttributes & FACE_PRESSURE_PLATE))
-			{
-				pParty->floor_face_pid = v45;
-				v103 = v47->sCogTriggeredID;
-			}
-			v2 = (unsigned __int64)(58500i64 * v2) >> 16;
-			v127 = (BSPModel *)58500;
-			v128 = (unsigned __int64)(58500i64 * v128) >> 16;
-			v122 = (unsigned __int64)(58500i64 * v121) >> 16;
-			++v126;
-			v121 = (unsigned __int64)(58500i64 * v121) >> 16;
-			continue;
+          if ( pParty->uFallSpeed < 0 )
+            pParty->uFallSpeed = 0;
+          pZ = pModel->pVertices.pVertices[pODMFace->pVertexIDs[0]].z + 1;
+          if ( v2 * v2 + v128 * v128 < 400 )
+          {
+            v2 = 0;
+            *(float *)&v128 = 0.0;
+          }
+          if ( pParty->floor_face_pid != v45 && (pODMFace->uAttributes & FACE_PRESSURE_PLATE))
+          {
+            pParty->floor_face_pid = v45;
+            v103 = pODMFace->sCogTriggeredID;
+          }
+          v2 = (unsigned __int64)(58500i64 * v2) >> 16;
+          pModel = (BSPModel *)58500;
+          v128 = (unsigned __int64)(58500i64 * v128) >> 16;
+          v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
+          ++v126;
+          pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
+          continue;
         }
-        if ( !v129 && (v53 != 4 || v119) )
+        if ( !v129 && (pODMFace->uPolygonType != POLYGON_InBetweenFloorAndWall || v119) )//   
         {
-          v118 = abs(v128 * v47->pFacePlane.vNormal.y + v121 * v52 + v2 * v47->pFacePlane.vNormal.x) >> 16;
+          v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + pParty->uFallSpeed * v52 + v2 * pODMFace->pFacePlane.vNormal.x) >> 16;
           if ( stru_721530.field_64 >> 3 > v118 )
             v118 = stru_721530.field_64 >> 3;
-          v129 = v47->pFacePlane.vNormal.x;
-          v129 = (unsigned __int64)(v118 * (signed __int64)v129) >> 16;
-          _walk_speed = v47->pFacePlane.vNormal.y;
-          _walk_speed = (unsigned __int64)(v118 * (signed __int64)_walk_speed) >> 16;
+          v129 = (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.x) >> 16;
+          _walk_speed = (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.y) >> 16;
           v54 = 0;
           if ( !v119 )
           {
-            v127 = (BSPModel *)v47->pFacePlane.vNormal.z;
-            v127 = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)v127) >> 16);
-            v54 = v127;
+            pModel = (BSPModel *)pODMFace->pFacePlane.vNormal.z;
+            pModel = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)pModel) >> 16);
+            v54 = pModel;
           }
-          v121 += (int)v54;
+          pParty->uFallSpeed += (int)v54;
           v128 += _walk_speed;
           v2 += v129;
           v55 = stru_721530.prolly_normal_d
-              - ((signed int)(v47->pFacePlane.dist
-                            + v122 * v47->pFacePlane.vNormal.z
-                            + _angle_y * v47->pFacePlane.vNormal.y
-                            + _angle_x * v47->pFacePlane.vNormal.x) >> 16);
+              - ((signed int)(pODMFace->pFacePlane.dist
+                            + v122 * pODMFace->pFacePlane.vNormal.z
+                            + _angle_y * pODMFace->pFacePlane.vNormal.y
+                            + _angle_x * pODMFace->pFacePlane.vNormal.x) >> 16);
           if ( v55 > 0 )
           {
-            pX = _angle_x + (v47->pFacePlane.vNormal.x * v55 >> 16);
-            pY = _angle_y + (v47->pFacePlane.vNormal.y * v55 >> 16);
+            pX = _angle_x + (pODMFace->pFacePlane.vNormal.x * v55 >> 16);
+            pY = _angle_y + (pODMFace->pFacePlane.vNormal.y * v55 >> 16);
             if ( !v119 )
-              pZ = v122 + (v47->pFacePlane.vNormal.z * v55 >> 16);
+              pZ = v122 + (pODMFace->pFacePlane.vNormal.z * v55 >> 16);
           }
 //LABEL_220:
 			v45 = stru_721530.uFaceID;
-			if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 )
+			if ( pParty->floor_face_pid != v45 && BYTE3(pODMFace->uAttributes) & 4 )
 			{
 				pParty->floor_face_pid = v45;
-				v103 = v47->sCogTriggeredID;
+				v103 = pODMFace->sCogTriggeredID;
 			}
 			v2 = (unsigned __int64)(58500i64 * v2) >> 16;
-			v127 = (BSPModel *)58500;
+			pModel = (BSPModel *)58500;
 			v128 = (unsigned __int64)(58500i64 * v128) >> 16;
-			v122 = (unsigned __int64)(58500i64 * v121) >> 16;
+			v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
 			++v126;
-			v121 = (unsigned __int64)(58500i64 * v121) >> 16;
+			pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
 			continue;
         }
-        v118 = abs(v128 * v47->pFacePlane.vNormal.y + v121 * v52 + v2 * v47->pFacePlane.vNormal.x) >> 16;
+        v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + pParty->uFallSpeed * v52 + v2 * pODMFace->pFacePlane.vNormal.x) >> 16;
         if ( stru_721530.field_64 >> 3 > v118 )
           v118 = stru_721530.field_64 >> 3;
-        v122 = v47->pFacePlane.vNormal.x;
+        v122 = pODMFace->pFacePlane.vNormal.x;
         v122 = (unsigned __int64)(v118 * (signed __int64)(signed int)v122) >> 16;
-        v127 = (BSPModel *)v47->pFacePlane.vNormal.y;
-        v127 = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)v127) >> 16);
-        v129 = v47->pFacePlane.vNormal.z;
+        pModel = (BSPModel *)pODMFace->pFacePlane.vNormal.y;
+        pModel = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)pModel) >> 16);
+        v129 = pODMFace->pFacePlane.vNormal.z;
         v129 = (unsigned __int64)(v118 * (signed __int64)v129) >> 16;
-        v121 += v129;
+        pParty->uFallSpeed += v129;
         v2 += v122;
-        v128 += (int)v127;
+        v128 += (int)pModel;
         if ( v2 * v2 + v128 * v128 >= 400 )
 		{
 			v45 = stru_721530.uFaceID;
-			if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 )
+			if ( pParty->floor_face_pid != v45 && BYTE3(pODMFace->uAttributes) & 4 )
 			{
 				pParty->floor_face_pid = v45;
-				v103 = v47->sCogTriggeredID;
+				v103 = pODMFace->sCogTriggeredID;
 			}
 			v2 = (unsigned __int64)(58500i64 * v2) >> 16;
-			v127 = (BSPModel *)58500;
+			pModel = (BSPModel *)58500;
 			v128 = (unsigned __int64)(58500i64 * v128) >> 16;
-			v122 = (unsigned __int64)(58500i64 * v121) >> 16;
+			v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
 			++v126;
-			v121 = (unsigned __int64)(58500i64 * v121) >> 16;
+			pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
 			continue;
 		}
         v2 = 0;
-        v121 = 0;
+        pParty->uFallSpeed = 0;
         *(float *)&v128 = 0.0;
       }
     }
 //LABEL_234:
     v2 = (unsigned __int64)(58500i64 * v2) >> 16;
-    v127 = (BSPModel *)58500;
+    pModel = (BSPModel *)58500;
     v128 = (unsigned __int64)(58500i64 * v128) >> 16;
-    v122 = (unsigned __int64)(58500i64 * v121) >> 16;
+    v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
     ++v126;
-    v121 = (unsigned __int64)(58500i64 * v121) >> 16;
+    pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16;
   }
   while ( v126 < 100 );
   if ( bWalkSound && pParty->walk_sound_timer <= 0 )
@@ -3029,13 +2984,13 @@
 		  if ( !is_not_on_bmodel
 			&& !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) )
 		  {
-            pAudioPlayer->PlaySound((SoundID)64, 804, 1, -1, 0, 0, 0, 0);
+            pAudioPlayer->PlaySound(SOUND_64, 804, 1, -1, 0, 0, 0, 0);
 		  }
 		  else
 		  {
-			v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
-			v64 = WorldPosToGridCellX(pParty->vPosition.x);
-			v87 = pOutdoor->GetSoundIdByPosition(v64, v63, 1);
+			//v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
+			//v64 = WorldPosToGridCellX(pParty->vPosition.x);
+			v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 1);
 			pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);
 		  }
 		}
@@ -3046,13 +3001,13 @@
 			  if ( is_not_on_bmodel
 				|| BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 )
 			  {
-				v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
-				v64 = WorldPosToGridCellX(pParty->vPosition.x);
-				v87 = pOutdoor->GetSoundIdByPosition(v64, v63, 0);
+				//v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
+				//v64 = WorldPosToGridCellX(pParty->vPosition.x);
+				v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 0);
 				pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);
 			  }
 			  else
-                pAudioPlayer->PlaySound((SoundID)103, 804, 1, -1, 0, 0, 0, 0);
+                pAudioPlayer->PlaySound(SOUND_103, 804, 1, -1, 0, 0, 0, 0);
 			}
 			else
 			{
@@ -3070,7 +3025,7 @@
   v65 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
   v114 = WorldPosToGridCellX(pX);
   v66 = WorldPosToGridCellZ(pY) - 1;
-  v127 = (BSPModel *)((~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1);
+  pModel = (BSPModel *)((~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1);
   v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114, v65) >> 1) & 1;
   v67 = pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v66);
   v68 = 0;
@@ -3084,7 +3039,7 @@
     v70 = pZ;
     v71 = pX;
     v72 = pY;
-    pParty->uFallSpeed = v121;
+    //pParty->uFallSpeed = v121;
     v73 = pZ;
     pParty->vPosition.x = pX;
     pParty->vPosition.y = pY;
@@ -3106,7 +3061,7 @@
         pParty->uFallSpeed = 0;
         v73 = v105;
         pParty->vPosition.z = v105;
-        if ( pParty->uFallStartY - v70 > 512 && !bFeatherFall && v70 <= v105 && !bUnderwater )
+        if ( pParty->uFallStartY - v70 > 512 && !bFeatherFall && v70 <= v105 && !bUnderwater )//Fall to the ground(    )
         {
           if ( pParty->uFlags & PARTY_FLAGS_1_LANDING )
           {
@@ -3114,19 +3069,14 @@
           }
           else
           {
-            v74 = &pPlayers[1];
-            do
+            for ( uint i = 1; i <= 4; ++i )
             {
-              v110 = (*v74)->GetMaxHealth();
-              (*v74)->ReceiveDamage((signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
+              v110 = pPlayers[i]->GetMaxHealth();
+              pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
                 DMGT_PHISYCAL);
-              v75 = (*v74)->GetActualEndurance();
-              v110 = 20 - (*v74)->GetParameterBonus(v75);
-              (*v74)->SetRecoveryTime(
-                (signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
-              ++v74;
+              v110 = 20 - pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualEndurance());
+              pPlayers[i]->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
             }
-            while ( (signed int)v74 <= (signed int)&pPlayers[4] );
             v73 = pParty->vPosition.z;
           }
         }
@@ -3145,14 +3095,14 @@
     return;
   }
   v76 = pParty->bFlying;
-  if ( pParty->bFlying || v101 == 0 || bWaterWalk || !v127 )
+  if ( pParty->bFlying || v101 == 0 || bWaterWalk || !pModel )
     v77 = 1;
   else
     v77 = v122 != 0;
   v114 = 0;
   if ( !pParty->bFlying && v101 != 0 && !bWaterWalk )
   {
-    if ( v127 )
+    if ( pModel )
     {
       v78 = v69 != 0;
     }
@@ -3209,14 +3159,13 @@
     pParty->vPosition.z = 8160;
   }
   LOWORD(pParty->uFlags) &= 0xFDFBu;
-  pParty->uFallSpeed = v121;
+  //pParty->uFallSpeed = v121;
   pParty->field_6F0 = v113;
-  if ( v114 )
-  {
-    v83 = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, &v110, 1);
-    v82 = pParty->vPosition.z;
-    if ( pParty->vPosition.z <= v83 )
-      pParty->uFlags |= 4u;
+  if ( v114 )//party stand to the water(   )
+  {
+    pTerrainHeight = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, &v110, 1);
+    if ( pParty->vPosition.z <= pTerrainHeight + 1 )//   +1
+      pParty->uFlags |= PARTY_FLAGS_1_WATER_DAMAGE;
   }
   if ( !v103
     || (EventProcessor(v103, 0, 1), pParty->vPosition.x == pX)
@@ -3228,7 +3177,7 @@
       v82 = v105;
       pParty->uFallSpeed = 0;
       pParty->vPosition.z = v105;
-      if ( pParty->uFallStartY - v81 > 512 && !bFeatherFall && v81 <= v105 && !bUnderwater )
+      if ( pParty->uFallStartY - v81 > 512 && !bFeatherFall && v81 <= v105 && !bUnderwater )//Fall to the water(    )
       {
         if ( pParty->uFlags & PARTY_FLAGS_1_LANDING )
         {
@@ -3236,19 +3185,14 @@
         }
         else
         {
-          v84 = &pPlayers[1];
-          do
+          for ( uint i = 1; i <= 4; ++i )
           {
-            v110 = (*v84)->GetMaxHealth();
-            (*v84)->ReceiveDamage(
-              (signed int)((pParty->uFallStartY - v81) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
+            v110 = pPlayers[i]->GetMaxHealth();
+            pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - v81) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
               DMGT_PHISYCAL);
-            v85 = (*v84)->GetActualEndurance();
-            v110 = 20 - (*v84)->GetParameterBonus(v85);
-            (*v84)->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
-            ++v84;
+            v110 = 20 - pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualEndurance());
+            pPlayers[i]->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
           }
-          while ( (signed int)v84 <= (signed int)&pPlayers[4] );
           v82 = pParty->vPosition.z;
         }
       }
@@ -3510,7 +3454,7 @@
   v25 = 0;
   v16 = word_720B40_intercepts_zs[0] >= v27;
   if ( v15 <= 0 )
-    goto LABEL_29;
+    return 0;
   do
   {
     if ( v31 >= 2 )
@@ -3545,7 +3489,6 @@
   while ( v25 < v15 );
   result = 1;
   if ( v31 != 1 )
-LABEL_29:
     result = 0;
   return result;
 }
@@ -3648,7 +3591,7 @@
   v21 = 0;
   v12 = word_7209A0_intercepts_ys_plus_ys[0] >= v24;
   if ( v11 <= 0 )
-    goto LABEL_29;
+    return 0;
   do
   {
     if ( a4d >= 2 )
@@ -3683,7 +3626,6 @@
   while ( v21 < v11 );
   result = 1;
   if ( a4d != 1 )
-LABEL_29:
     result = 0;
   return result;
 }
@@ -3882,10 +3824,37 @@
     {
       v5 = v4 - 15;
       if ( *(float *)(v4 - 15) <= (double)a2 && *(float *)(v4 + 1) <= (double)a2 )
-        goto LABEL_11;
+	  {
+        v4 += 16;
+		--v34;
+		if ( !v34 )
+		  return this->uNumVertices = v38;
+		continue;
+	  }
       if ( *(float *)v5 <= (double)a2 )
-        break;
-      if ( *(float *)(v4 + 1) <= (double)a2 )
+	  {
+		v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
+		v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4;
+		v36 = v6;
+		v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11);
+		v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7);
+		*(float *)&v37 = (double)v7 * v6;
+		v8 = *(float *)&v37 + 6.7553994e15;
+		v9 = (unsigned __int8)*v4;
+		*(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36;
+		v10 = *(float *)&v37 + 6.7553994e15;
+		v11 = (unsigned __int8)*(v4 - 2);
+		v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1);
+		v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36;
+		v12 = v39 + 6.7553994e15;
+		v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2);
+		v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36;
+		v14 = v39 + 6.7553994e15;
+		v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8);
+		//this = v35;
+		v5 = (char *)&v30 + 4;
+	  }
+      else if ( *(float *)(v4 + 1) <= (double)a2 )
       {
         v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
         v16 = (unsigned __int8)*v4;
@@ -3918,9 +3887,8 @@
         v40 += 4;
         *v25 = *(int *)v26;
         v25[1] = *(int *)(v26 + 4);
-        goto LABEL_9;
+		v5 = (char *)&v30 + 4;
       }
-LABEL_10:
       v27 = v40;
       ++v38;
       *v40 = *(int *)v5;
@@ -3932,36 +3900,12 @@
       v40 += 4;
       *v27 = *(int *)v28;
       v27[1] = *(int *)(v28 + 4);
-LABEL_11:
       v4 += 16;
       --v34;
       if ( !v34 )
-        goto LABEL_12;
+          return this->uNumVertices = v38;
     }
-    v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
-    v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4;
-    v36 = v6;
-    v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11);
-    v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7);
-    *(float *)&v37 = (double)v7 * v6;
-    v8 = *(float *)&v37 + 6.7553994e15;
-    v9 = (unsigned __int8)*v4;
-    *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36;
-    v10 = *(float *)&v37 + 6.7553994e15;
-    v11 = (unsigned __int8)*(v4 - 2);
-    v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1);
-    v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36;
-    v12 = v39 + 6.7553994e15;
-    v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2);
-    v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36;
-    v14 = v39 + 6.7553994e15;
-    v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8);
-LABEL_9:
-    //this = v35;
-    v5 = (char *)&v30 + 4;
-    goto LABEL_10;
-  }
-LABEL_12:
+  }
   return this->uNumVertices = v38;
 }
 
@@ -4027,10 +3971,37 @@
     {
       v5 = v4 - 15;
       if ( *(float *)(v4 - 15) >= (double)a2 && *(float *)(v4 + 1) >= (double)a2 )
-        goto LABEL_11;
+	  {
+        v4 += 16;
+		--v34;
+		if ( !v34 )
+          return this->uNumVertices = v38;
+		continue;
+	  }
       if ( *(float *)v5 >= (double)a2 )
-        break;
-      if ( *(float *)(v4 + 1) >= (double)a2 )
+	  {
+		v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
+		v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4;
+		v36 = v6;
+		v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11);
+		v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7);
+		*(float *)&v37 = (double)v7 * v6;
+		v8 = *(float *)&v37 + 6.7553994e15;
+		v9 = (unsigned __int8)*v4;
+		*(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36;
+		v10 = *(float *)&v37 + 6.7553994e15;
+		v11 = (unsigned __int8)*(v4 - 2);
+		v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1);
+		v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36;
+		v12 = v39 + 6.7553994e15;
+		v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2);
+		v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36;
+		v14 = v39 + 6.7553994e15;
+		v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8);
+		//this = v35;
+		v5 = (char *)&v30 + 4;
+	  }
+      else if ( *(float *)(v4 + 1) >= (double)a2 )
       {
         v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
         v16 = (unsigned __int8)*v4;
@@ -4063,9 +4034,8 @@
         v40 += 4;
         *v25 = *(int *)v26;
         v25[1] = *(int *)(v26 + 4);
-        goto LABEL_9;
+	    v5 = (char *)&v30 + 4;
       }
-LABEL_10:
       v27 = v40;
       ++v38;
       *v40 = *(int *)v5;
@@ -4077,36 +4047,12 @@
       v40 += 4;
       *v27 = *(int *)v28;
       v27[1] = *(int *)(v28 + 4);
-LABEL_11:
       v4 += 16;
       --v34;
       if ( !v34 )
-        goto LABEL_12;
+          return this->uNumVertices = v38;
     }
-    v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5);
-    v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4;
-    v36 = v6;
-    v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11);
-    v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7);
-    *(float *)&v37 = (double)v7 * v6;
-    v8 = *(float *)&v37 + 6.7553994e15;
-    v9 = (unsigned __int8)*v4;
-    *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36;
-    v10 = *(float *)&v37 + 6.7553994e15;
-    v11 = (unsigned __int8)*(v4 - 2);
-    v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1);
-    v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36;
-    v12 = v39 + 6.7553994e15;
-    v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2);
-    v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36;
-    v14 = v39 + 6.7553994e15;
-    v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8);
-LABEL_9:
-    //this = v35;
-    v5 = (char *)&v30 + 4;
-    goto LABEL_10;
-  }
-LABEL_12:
+  }
   return this->uNumVertices = v38;
 }
 
@@ -4292,7 +4238,10 @@
   }
   v4 = a1->uNumVertices;
   if ( v4 <= 0 )
-    goto LABEL_16;
+  {
+    memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4);
+    return v2->uNumVertices != 0;
+  }
   v5 = (char *)&a1->field_14[20];
   v6 = v4;
   do
@@ -4315,7 +4264,6 @@
       v2->_477927(v10);
       return v2->uNumVertices != 0;
     }
-LABEL_16:
     memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4);
     return v2->uNumVertices != 0;
   }
@@ -4899,12 +4847,10 @@
   {
     v3 = v2->pFacePlane.vNormal.x;
     v4 = -v2->pFacePlane.vNormal.y;
-LABEL_9:
     v5 = 0;
     v11 = 65536;
-    goto LABEL_5;
-  }
-  if ( (v2->pFacePlane.vNormal.x || v2->pFacePlane.vNormal.y) && abs(v2->pFacePlane.vNormal.z) < 59082 )
+  }
+  else if ( (v2->pFacePlane.vNormal.x || v2->pFacePlane.vNormal.y) && abs(v2->pFacePlane.vNormal.z) < 59082 )
   {
     thisa.x = -v2->pFacePlane.vNormal.y;
     thisa.y = v2->pFacePlane.vNormal.x;
@@ -4912,13 +4858,16 @@
     thisa.Normalize_float();
     v4 = thisa.x;
     v3 = thisa.y;
-    goto LABEL_9;
-  }
-  v3 = 0;
-  v4 = 65536;
-  v11 = 0;
-  v5 = -65536;
-LABEL_5:
+    v5 = 0;
+    v11 = 65536;
+  }
+  else
+  {
+	  v3 = 0;
+	  v4 = 65536;
+	  v11 = 0;
+	  v5 = -65536;
+  }
   v6 = v11;
   sTextureDeltaU = v2->sTextureDeltaU;
   v7 = v3;
@@ -5412,14 +5361,12 @@
   int v9; // eax@4
   int v10; // ebx@4
   signed __int64 v11; // qax@6
-  //double v12; // st7@6
   int v13; // edi@6
   int v14; // ecx@6
-  //int v15; // eax@8
   int v16; // eax@12
-  signed __int64 v17; // qtt@13
+  //signed __int64 v17; // qtt@13
   signed int pShading; // ecx@13
-  struct Polygon pSky; // [sp+14h] [bp-150h]@1
+  struct Polygon pSkyPolygon; // [sp+14h] [bp-150h]@1
   float v28; // [sp+12Ch] [bp-38h]@2
   int v29; // [sp+130h] [bp-34h]@4
   int v30; // [sp+134h] [bp-30h]@1
@@ -5427,11 +5374,11 @@
   int v33; // [sp+140h] [bp-24h]@2
   int v34; // [sp+144h] [bp-20h]@1
   int v35; // [sp+148h] [bp-1Ch]@4
-  int v36; // [sp+14Ch] [bp-18h]@2
+  int screen_center_x; // [sp+14Ch] [bp-18h]@2
   int v37; // [sp+154h] [bp-10h]@8
   int v38; // [sp+158h] [bp-Ch]@1
   int v39; // [sp+15Ch] [bp-8h]@4
-  int v40; // [sp+160h] [bp-4h]@7
+  //int v40; // [sp+160h] [bp-4h]@7
   
   extern bool new_sky;
   if (new_sky)
@@ -5441,48 +5388,59 @@
   }
 
   v30 = ((double)(pOutdoorCamera->int_fov_rad * pIndoorCamera->pos.z)
-        / ((double)pOutdoorCamera->int_fov_rad + 8192.0) + pViewport->uScreenCenterY);
+        / ((double)pOutdoorCamera->int_fov_rad + 8192.0) + pViewport->uScreenCenterY);//184     
   v38 = pViewport->uScreenCenterY - pOutdoorCamera->int_fov_rad /
        (pOutdoorCamera->shading_dist_mist * cos(pIndoorCamera->sRotationX * 0.003066406352445483) + 0.0000001000000011686097) *
-       (pOutdoorCamera->shading_dist_mist * -sin(pIndoorCamera->sRotationX * 0.003066406352445483) - pIndoorCamera->pos.z);
-
-  pSky._48607B(&stru_8019C8);
-  pSky.ptr_38->sky_48694B();
-  pSky.uTileBitmapID = pOutdoor->uSky_TextureID;// 
-  pSky.pTexture = (Texture *)(pOutdoor->uSky_TextureID != -1 ? &pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID] : 0);// 
+       (pOutdoorCamera->shading_dist_mist * -sin(pIndoorCamera->sRotationX * 0.003066406352445483) - pIndoorCamera->pos.z);//61 / 184 / 310    
+
+  pSkyPolygon.Create_48607B(&stru_8019C8);
+  pSkyPolygon.ptr_38->Inverse_sky_48694B();//maybe creating skydome(   )
+  pSkyPolygon.uTileBitmapID = pOutdoor->uSky_TextureID;// 
+  pSkyPolygon.pTexture = (Texture *)(pOutdoor->uSky_TextureID != -1 ? &pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID] : 0);// 
   if (pOutdoor->uSky_TextureID == -1)
     return;
 
-  pSky.dimming_level = 0;//
-  pSky.uNumVertices = 4;// 
-
-  //centering()---------------------------------------------------------------
-  pSky.v_18.x = -stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16);//-3216
-  pSky.v_18.y = 0;
-  pSky.v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16);//-65457
-  //---------------------------------------------------------------------------
-
-  pSky.field_24 = 0x2000000;
-
-  pSky.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;
-  pSky.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;
+  pSkyPolygon.dimming_level = 0;//
+  pSkyPolygon.uNumVertices = 4;// 
+
+  //centering()--  ----------------------------------------//
+  pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16);//-3216, : -28020, : 22078
+  pSkyPolygon.v_18.y = 0;
+  pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16);//-65457, : -59244, : -61705
+  //---------------------------------------------------------------------------//
+
+  pSkyPolygon.field_24 = 0x2000000;
+
+  pSkyPolygon.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;//60928
+  pSkyPolygon.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;
   
   //sky position( )----------------------------------------------
-  array_50AC10[0].vWorldViewProjX = pViewport->uViewportTL_X;
-  array_50AC10[0].vWorldViewProjY = pViewport->uViewportTL_Y;
-
-  array_50AC10[1].vWorldViewProjX = pViewport->uViewportTL_X;
-  array_50AC10[1].vWorldViewProjY = v38;
-
-  array_50AC10[2].vWorldViewProjX = pViewport->uViewportBR_X;
-  array_50AC10[2].vWorldViewProjY = v38;
-
-  array_50AC10[3].vWorldViewProjX = pViewport->uViewportBR_X;
-  array_50AC10[3].vWorldViewProjY = pViewport->uViewportTL_Y;
+  //                X
+  // 0._____________________________.3
+  //  |8,8                    468,8 |
+  //  |                             |
+  //  |                             |
+  // Y|                             |
+  //  |                             |
+  //  |8,?                    468,? |
+  // 1._____________________________.2
+  // 
+
+  array_50AC10[0].vWorldViewProjX = pViewport->uViewportTL_X;//8
+  array_50AC10[0].vWorldViewProjY = pViewport->uViewportTL_Y;//8
+
+  array_50AC10[1].vWorldViewProjX = pViewport->uViewportTL_X;//8
+  array_50AC10[1].vWorldViewProjY = v38;//61 / 184 / 310
+
+  array_50AC10[2].vWorldViewProjX = pViewport->uViewportBR_X;//468
+  array_50AC10[2].vWorldViewProjY = v38;//61 / 184 / 310
+
+  array_50AC10[3].vWorldViewProjX = pViewport->uViewportBR_X;//468
+  array_50AC10[3].vWorldViewProjY = pViewport->uViewportTL_Y;//8
   //--------------------------------------------------------------------------
 
   //pParty->sRotationY / 2048.0f
-  // move sky( )--------------include-----------------------------
+  // move sky( )--------------include()---------------------
     float t = (GetTickCount() % 96000) / 96000.0f;
     array_50AC10[0].u = t - pParty->sRotationY / 1024.0f;
     array_50AC10[0].v = t - pParty->sRotationX / 512.0f;
@@ -5495,25 +5453,31 @@
 
     array_50AC10[3].u = 1 + t - pParty->sRotationY / 1024.0f;
     array_50AC10[3].v = t - pParty->sRotationX / 512.0f;
-  //--------------------------------------------------------------------------
+  //--------------------------------------------------------------------------//
 
   //rotate skydome(  )--------------------------------------
-  v36 = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5;//  230
-  v33 = 65536 / (signed int)(v36 / tan(0.6457717418670654) + 0.5);//214
-
-  for (uint i = 0; i < pSky.uNumVertices; ++i)
+  //       .    2   65536 .   0  
+  //   ,  16384(04000) -    ...
+
+  //  ------------------------------------------------
+  // ----------------------------------------------------------
+  screen_center_x = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2;//   X = 230
+  v33 = 65536 / (signed int)(screen_center_x / tan(0.6457717418670654) + 0.5);//360 : (      ) = 214
+  //--------------------------------------------------------------------------
+
+  for (uint i = 0; i < pSkyPolygon.uNumVertices; ++i)
   {
     v29 = floorf(array_50AC10[i].vWorldViewProjY + 0.5f);//8
-    v39 = (unsigned __int64)(pSky.ptr_38->field_14 * v33 * (v30 - v29)) / 65536;//0
-    v8 = v39 + pSky.ptr_38->field_C;//0
-
-    v39 = (unsigned __int64)(pSky.ptr_38->field_20 * v33 * (v30 - v29)) / 65536;//0
-    v36 = v39 + pSky.ptr_38->field_18;//65536
-
-    v9 = (unsigned __int64)(pSky.v_18.z * v33 * (v30 - v29)) / 65536;//27917
-    v10 = pSky.v_18.x + v9;//24701
-    v39 = pSky.v_18.x + v9;//24701
-    if ( pSky.v_18.x + v9 > 0 )
+    v39 = (unsigned __int64)(pSkyPolygon.ptr_38->field_14 * v33 * (v30 - v29)) / 65536;//0
+    v8 = v39 + pSkyPolygon.ptr_38->field_C;//0
+
+    v39 = (unsigned __int64)(pSkyPolygon.ptr_38->field_20 * v33 * (v30 - v29)) / 65536;//0
+    screen_center_x = v39 + pSkyPolygon.ptr_38->field_18;//65536
+
+    v9 = (unsigned __int64)(pSkyPolygon.v_18.z * v33 * (v30 - v29)) / 65536;//27917
+    v10 = pSkyPolygon.v_18.x + v9;//24701
+    v39 = pSkyPolygon.v_18.x + v9;//24701
+    if ( pSkyPolygon.v_18.x + v9 > 0 )
     {
       v10 = 0;
       v39 = 0;
@@ -5522,73 +5486,71 @@
     v38 = v10;
     //v12 = array_50AC10[i].vWorldViewProjY - 1.0;
     v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)array_50AC10[i].vWorldViewProjX);
-    v34 = -pSky.field_24;
+    v34 = -pSkyPolygon.field_24;
     v32 = (signed __int64)array_50AC10[i].vWorldViewProjY - 1.0;
     v14 = v33 * (v30 - v32);
 
     while ( 1 )
     {
-      v40 = v14;
+      //v40 = v14;
       if ( !v10 )
       {
-        v37 = pSky.v_18.z;
-        v16 = (unsigned __int64)(pSky.v_18.z * (signed __int64)v14) >> 16;
+        v37 = pSkyPolygon.v_18.z;
+        v16 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)v14) >> 16;
         --v32;
         v14 += v33;
-        v10 = pSky.v_18.x + v16;
-        v39 = pSky.v_18.x + v16;
-        v38 = pSky.v_18.x + v16;
+        v10 = pSkyPolygon.v_18.x + v16;
+        v39 = pSkyPolygon.v_18.x + v16;
+        v38 = pSkyPolygon.v_18.x + v16;
         break;
       }
-      v37 = abs(v34 >> 14);
+      v37 = abs(v34 >> 14);//2048
       if ( abs(v34 >> 14) <= abs(v10) || v32 <= pViewport->uViewportTL_Y )
       {
         if ( v39 <= 0 )
           break;
       }
-      v14 = v40;
-      v37 = pSky.v_18.z;
-      v16 = (unsigned __int64)(pSky.v_18.z * v14) >> 16;
+      //v14 = v40;
+      v37 = pSkyPolygon.v_18.z;
+      v16 = (unsigned __int64)(pSkyPolygon.v_18.z * v14) >> 16;
       --v32;
       v14 += v33;
-      v10 = pSky.v_18.x + v16;
-      v39 = pSky.v_18.x + v16;
-      v38 = pSky.v_18.x + v16;
+      v10 = pSkyPolygon.v_18.x + v16;
+      v39 = pSkyPolygon.v_18.x + v16;
+      v38 = pSkyPolygon.v_18.x + v16;
       break;
     }
 
-    LODWORD(v17) = v34 << 16;
-    HIDWORD(v17) = v34 >> 16;
-    pShading = v17 / v38;
+    pShading = fixpoint_div(v34, v38);
     if ( pShading < 0 )
       pShading = pOutdoorCamera->shading_dist_mist;
 
-    v37 += ((unsigned __int64)(pSky.ptr_38->field_10 * v13) >> 16);
-    v36 += ((unsigned __int64)(pSky.ptr_38->field_1C * v13) >> 16);
+    v37 += ((unsigned __int64)(pSkyPolygon.ptr_38->field_10 * v13) >> 16);
+    screen_center_x += ((unsigned __int64)(pSkyPolygon.ptr_38->field_1C * v13) >> 16);
     v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(v37, pShading) / 8;
-    v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(v36, pShading) / 8;
+    screen_center_x = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(screen_center_x, pShading) / 8;
 
     //array_50AC10[i].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist;
     //array_50AC10[i].vWorldPosition.x = v36 / (pSky.pTexture->uTextureHeight * 65536.0);
     //array_50AC10[i].vWorldPosition.y = 1.0 / (pOutdoorCamera->shading_dist_mist >> 16);
     //array_50AC10[i].vWorldPosition.z = v35 / (pSky.pTexture->uTextureWidth * 65536.0);
-    //array_50AC10[i]._rhw = 1.0f / (v18 >> 16);
-    //array_50AC10[i].u = (double)v35 / (65536.0 * pSky.pTexture->uTextureWidth);
-    //array_50AC10[i].v = (double)v36 / (65536.0 * pSky.pTexture->uTextureHeight);
+    //array_50AC10[i]._rhw = 1.0f / (pShading >> 16);
+    //array_50AC10[i].u = (double)v35 / (65536.0 * pSkyPolygon.pTexture->uTextureWidth);
+    //array_50AC10[i].v = (double)screen_center_x / (65536.0 * pSkyPolygon.pTexture->uTextureHeight);
   //-----------------------------------------------------------------------------------------
 
     array_50AC10[i]._rhw = 1.0f;
   }
   //if ( i  == _this.uNumVertices - 1 )
   //{
-    pRenderer->DrawSkyPolygon(pSky.uNumVertices, &pSky, pBitmaps_LOD->pHardwareTextures[pSky.uTileBitmapID]);
+    pRenderer->DrawSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[pSkyPolygon.uTileBitmapID]);
 
     array_50AC10[0].vWorldViewProjY = v38;
     array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0;
     array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0;
     array_50AC10[3].vWorldViewProjY = v38;
 
-    pRenderer->DrawSkyPolygon(pSky.uNumVertices, &pSky, pBitmaps_LOD->pHardwareTextures[pSky.uTileBitmapID]);
+    pRenderer->DrawSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[pSkyPolygon.uTileBitmapID]);
   //}
 }
 
@@ -5765,7 +5727,6 @@
 {
   int v3; // ecx@1
   double v5; // st7@10
-  signed int v6; // esi@10
   signed int v7; // ecx@11
   double v8; // st6@12
   double v9; // st7@15
@@ -5781,44 +5742,73 @@
   if ( v3 )
   {
     v5 = (double)day_fogrange_1;
-    v6 = 216;
     if ( a3 < v5 )
-      goto LABEL_11;
-    v8 = (double)day_fogrange_2;
-    if ( a3 > v8 )
-    {
-LABEL_13:
-      v7 = v6;
-      goto LABEL_19;
-    }
-    v7 = (signed __int64)((a3 - v5) / (v8 - v5) * 216.0);
+	{
+      v7 = 0;
+      if ( a3 == 0.0 )
+	  {
+		v7 = 216;
+	  }
+	  goto LABEL_21;
+	}
+	else
+	{
+		v8 = (double)day_fogrange_2;
+		if ( a3 > v8 )
+		{
+		  v7 = 216;
+ 		  if ( a3 == 0.0 )
+		  {
+			v7 = 216;
+		  }
+		  goto LABEL_21;
+		}
+		v7 = (signed __int64)((a3 - v5) / (v8 - v5) * 216.0);
+	}
   }
   else
   {
     v9 = (double)day_fogrange_1;
-    v6 = 216;
     if ( a3 < v9 )
     {
-LABEL_11:
       v7 = 0;
-      goto LABEL_19;
+	  if ( a3 == 0.0 )
+	  {
+		v7 = 216;
+	  }
+      goto LABEL_21;
     }
-    v10 = (double)day_fogrange_2;
-    if ( a3 > v10 )
-      goto LABEL_13;
-    v11 = (a3 - v9) * 216.0 / (v10 - v9);
-    v12 = v11 + 6.7553994e15;
-    v7 = LODWORD(v12);
-  }
-  if ( v7 > v6 )
-  {
-LABEL_20:
-    v7 = v6;
-    goto LABEL_21;
-  }
-LABEL_19:
-  if ( a3 == 0.0 )
-    goto LABEL_20;
+	else
+	{
+		v10 = (double)day_fogrange_2;
+		if ( a3 > v10 )
+		{  
+		  v7 = 216;
+		  if ( a3 == 0.0 )
+		  {
+			v7 = 216;
+		  }
+		  goto LABEL_21;
+		}
+		else
+		{
+			v11 = (a3 - v9) * 216.0 / (v10 - v9);
+			v12 = v11 + 6.7553994e15;
+			v7 = LODWORD(v12);
+		}
+	}
+  }
+  if ( v7 > 216 )
+  {
+    v7 = 216;
+  }
+  else
+  {
+	  if ( a3 == 0.0 )
+	  {
+		v7 = 216;
+	  }
+  }
 LABEL_21:
   if ( a2 )
     v7 = 248;
@@ -6218,7 +6208,7 @@
 }
 
 //----- (0048607B) --------------------------------------------------------
-void Polygon::_48607B(stru149 *a2)
+void Polygon::Create_48607B(stru149 *a2)
 {
   this->pTexture = 0;
   this->ptr_38 = a2;
@@ -6360,29 +6350,17 @@
 }
 
 //----- (0048694B) --------------------------------------------------------
-int stru149::sky_48694B()
+void stru149::Inverse_sky_48694B()
 {
-  int v1; // eax@1
-  int v2; // ST04_4@1
-  int v3; // ST00_4@1
-  int v4; // eax@1
-  int v5; // ST0C_4@1
-  int result; // eax@1
-
-  v1 = this->field_C;
   this->field_18 = -this->field_18;
   this->field_1C = -this->field_1C;
   this->field_20 = -this->field_20;
-  v2 = (unsigned __int64)(v1 * (signed __int64)this->field_0_party_dir_x) >> 16;
-  v3 = this->field_18;
-  v4 = this->field_0_party_dir_x;
-  this->field_24 = v2
+  this->field_24 = ((unsigned __int64)(this->field_C * (signed __int64)this->field_0_party_dir_x) >> 16)
                  + ((unsigned __int64)(this->field_10 * (signed __int64)this->field_4_party_dir_y) >> 16)
                  + ((unsigned __int64)(this->field_14 * (signed __int64)this->field_8) >> 16);
-  v5 = (unsigned __int64)(v3 * (signed __int64)v4) >> 16;
-  result = (unsigned __int64)(this->field_1C * (signed __int64)this->field_4_party_dir_y) >> 16;
-  this->field_28 = v5 + result + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16);
-  return result;
+  this->field_28 = ((unsigned __int64)(this->field_18 * (signed __int64)this->field_0_party_dir_x) >> 16)
+                 + ((unsigned __int64)(this->field_1C * (signed __int64)this->field_4_party_dir_y) >> 16)
+                 + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16);
 }
 
 //----- (0044100D) --------------------------------------------------------
--- a/mm7_4.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/mm7_4.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -389,37 +389,41 @@
   }
   v22 = 0;
   v38 = v5;
-  if ( v39 <= (signed int)v5 )
-    goto LABEL_54;
-  v23 = 0;
-  do
+  if ( v39 > (signed int)v5 )
   {
-    v24 = dword_720F20[v5 / 4];
-    v25 = *(int *)((char *)dword_720F20.data() + v23);
-    if ( v24 == v25 )
-      goto LABEL_50;
-    if ( v25 > a3 + 15 )
-    {
-      if ( v24 >= v25 )
-        goto LABEL_51;
-LABEL_50:
-      v22 = v38;
-      v23 = v5;
-      goto LABEL_51;
-    }
-    if ( v24 > v25 && v24 <= a3 + 15 )
-      goto LABEL_50;
-LABEL_51:
-    ++v38;
-    v5 += 4;
+	  v23 = 0;
+	  do
+	  {
+		v24 = dword_720F20[v5 / 4];
+		v25 = *(int *)((char *)dword_720F20.data() + v23);
+		if ( v24 == v25 )
+		{
+		  v22 = v38;
+		  v23 = v5;
+		}
+		else if ( v25 > a3 + 15 )
+		{
+		  if ( v24 < v25 )
+		  {
+			  v22 = v38;
+			  v23 = v5;
+		  }
+		}
+		else if ( v24 > v25 && v24 <= a3 + 15 )
+		{
+		  v22 = v38;
+		  v23 = v5;
+		}
+		++v38;
+		v5 += 4;
+	  }
+	  while ( v38 < v39 );
+	  if ( v22 )
+	  {
+		*(int *)a4 = dword_720E80[v22] | (dword_720ED0[v22] << 6);
+		return dword_720F20[v22];
+	  }
   }
-  while ( v38 < v39 );
-  if ( v22 )
-  {
-    *(int *)a4 = dword_720E80[v22] | (dword_720ED0[v22] << 6);
-    return dword_720F20[v22];
-  }
-LABEL_54:
   *(int *)a4 = 0;
   return dword_720F20[v22];
 }
@@ -1104,9 +1108,9 @@
   //void *v10; // esi@25
   unsigned int v11; // ecx@27
   signed int v12; // edi@29
-  Player *v13; // ecx@30
-  Player *v14; // esi@35
-  double v15; // st7@35
+  //Player *v13; // ecx@30
+  //Player *v14; // esi@35
+  //double v15; // st7@35
   Player **v16; // esi@43
   Player *v17; // edi@44
   double v18; // st7@44
@@ -1149,7 +1153,7 @@
   //unsigned int v55; // [sp-8h] [bp-38h]@18
   unsigned int v56; // [sp-8h] [bp-38h]@55
   //int v57; // [sp-4h] [bp-34h]@18
-  int v58; // [sp-4h] [bp-34h]@33
+  //int v58; // [sp-4h] [bp-34h]@33
   int v59; // [sp-4h] [bp-34h]@55
   //unsigned int v60; // [sp+10h] [bp-20h]@1
   unsigned int v61; // [sp+14h] [bp-1Ch]@1
@@ -1219,45 +1223,46 @@
   }
 
   v11 = LODWORD(pParty->uTimePlayed);
-  if ( pParty->uFlags & 4 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed )
+  if ( pParty->uFlags & 4 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed )//water damage error
   {
-    v12 = 1;
+    //v12 = 1;
     pParty->field_6FC = LODWORD(pParty->uTimePlayed) + 128;
     viewparams->bRedrawGameUI = 1;
-    while ( 1 )
+    //while ( 1 )
+    for ( v12 = 1; v12 <= 4; ++v12 )
     {
       if ( pPlayers[v12]->WearsItem(ITEM_RELIC_HARECS_LEATHER, EQUIP_ARMOUR)
         || pPlayers[v12]->HasEnchantedItemEquipped(71)
         || pPlayers[v12]->pPlayerBuffs[23].uExpireTime > 0 )
       {
-        v58 = 0;
+        //v58 = 0;
+        pPlayers[v12]->PlayEmotion(CHARACTER_EXPRESSION_37, 0);
       }
       else
       {
-        v58 = 0;
+        //v58 = 0;
         if ( !sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(v12) )
         {
-          v14 = pPlayers[v12];
-          v15 = (double)pPlayers[v12]->GetMaxHealth() * 0.1;
-          v14->ReceiveDamage((signed __int64)v15, DMGT_FIRE);
+          //v14 = pPlayers[v12];
+          //v15 = (double)pPlayers[v12]->GetMaxHealth() * 0.1;
+          pPlayers[v12]->ReceiveDamage((signed __int64)pPlayers[v12]->GetMaxHealth() * 0.1, DMGT_FIRE);
           if ( pParty->uFlags & 4 )
           {
             strcpy(GameUI_Footer_TimedString.data(), pGlobalTXT_LocalizationStrings[660]);
             GameUI_Footer_TimeLeft = 128;
           }
-          goto LABEL_39;
         }
-        v13 = pPlayers[v12];
+		else
+			pPlayers[v12]->PlayEmotion(CHARACTER_EXPRESSION_37, 0);
       }
-      v13->PlayEmotion(CHARACTER_EXPRESSION_37, v58);
-LABEL_39:
-      ++v12;
-      if ( v12 > 4 )
-      {
-        v11 = LODWORD(pParty->uTimePlayed);
-        break;
+      //++v12;
+      //if ( v12 > 4 )
+      //{
+        //v11 = LODWORD(pParty->uTimePlayed);
+        //break;
       }
-    }
+      v11 = LODWORD(pParty->uTimePlayed);
+    //}
   }
   if ( pParty->uFlags & 0x200 && pParty->field_6FC < (signed __int64)__PAIR__(HIDWORD(pParty->uTimePlayed), v11) )
   {
@@ -1299,18 +1304,19 @@
     if ( v21->GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0) + v22 + v21->uEndurance >= 1
       || (signed __int64)v21->pPlayerBuffs[11].uExpireTime > 0 )
     {
-      if ( v22 >= 1 )
-        goto LABEL_59;
-      v59 = 0;
-      v56 = 13;
+      if ( v22 < 1 )
+	  {
+		  v59 = 0;
+		  v56 = 13;
+		  v21->SetCondition(v56, v59);
+	  }
     }
     else
     {
       v59 = 0;
       v56 = 14;
+	  v21->SetCondition(v56, v59);
     }
-    v21->SetCondition(v56, v59);
-LABEL_59:
     v23 = (int)&v21->field_E0;
     if ( v21->field_E0 )
     {
@@ -1598,7 +1604,6 @@
   result = 0;
   if ( (signed int)this->uNumFrames <= 0 )
   {
-LABEL_5:
     result = 0;
   }
   else
@@ -1609,7 +1614,7 @@
       ++result;
       ++v4;
       if ( (signed int)result >= (signed int)_uNumFrames )
-        goto LABEL_5;
+        return 0;
     }
   }
   return result;
@@ -1851,7 +1856,11 @@
     dword_AE336C = a1;
     v10 = 0;
     if ( (signed int)pNPCStats->uNumNPCNames[v4] <= 0 )
-      goto LABEL_17;
+	{
+		v3 = rand() % (signed int)pNPCStats->uNumNPCNames[v4];
+	}
+	else
+	{
     v9 = (int **)((char *)pNPCStats->pNPCNames + v4 * 4);
     do
     {
@@ -1870,8 +1879,8 @@
     if ( v8 && v8 != v7 )
       v3 = v8 + rand() % (v7 - v8);
     else
-LABEL_17:
       v3 = rand() % (signed int)pNPCStats->uNumNPCNames[v4];
+	}
   }
   dword_AE3370 = v3;
   return pNPCStats->pNPCNames[0][v11 + 2 * v3];
@@ -2093,10 +2102,34 @@
             goto _continue_strcat;
           case 11:
             v25 = GetPartyReputation();
-            goto LABEL_46;
+                        if ( v25 >= 25 )
+            {
+              v11 = pGlobalTXT_LocalizationStrings[379];
+            }
+            else
+            {
+              if ( v25 < 6 )
+              {
+                if ( v25 >= -5 )
+                {
+                  v11 = pGlobalTXT_LocalizationStrings[399];
+                }
+                else
+                {
+                  if ( v25 < -24 )
+                    v11 = pGlobalTXT_LocalizationStrings[434];
+                  else
+                    v11 = pGlobalTXT_LocalizationStrings[402];
+                }
+              }
+              else
+              {
+                v11 = pGlobalTXT_LocalizationStrings[392];
+              }
+            }
+            goto _continue_strcat;
           case 12:
             v25 = npc->rep;
-LABEL_46:
             if ( v25 >= 25 )
             {
               v11 = pGlobalTXT_LocalizationStrings[379];
--- a/mm7_5.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/mm7_5.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -112,10 +112,10 @@
   int v56; // edx@432
   int v57; // eax@432
   Player *pPlayer; // edx@442
-  unsigned int v59; // eax@445
+  unsigned int pMapNum; // eax@445
   signed int v60; // ST64_4@459
-  NPCData *pNPCData2; // eax@467
-  unsigned __int64 v62; // kr00_8@467
+  //NPCData *pNPCData2; // eax@467
+  //unsigned __int64 v62; // kr00_8@467
   __int16 v63; // dx@479
   unsigned int v64; // eax@486
   int v65; // ecx@486
@@ -205,7 +205,7 @@
   int v155; // [sp-4h] [bp-600h]@165
   int v156; // [sp-4h] [bp-600h]@204
   //const char *v157; // [sp-4h] [bp-600h]@444
-  unsigned int v158; // [sp-4h] [bp-600h]@449
+  //unsigned int v158; // [sp-4h] [bp-600h]@449
   //__int16 v159; // [sp-4h] [bp-600h]@550
   int v160; // [sp-4h] [bp-600h]@599
   const char *v161; // [sp-4h] [bp-600h]@637
@@ -232,7 +232,7 @@
   signed int thisb; // [sp+14h] [bp-5E8h]@272
   Player *pPlayer7; // [sp+14h] [bp-5E8h]@373
   Player *pPlayer8; // [sp+14h] [bp-5E8h]@377
-  char *thise; // [sp+14h] [bp-5E8h]@445
+  char *pMapName; // [sp+14h] [bp-5E8h]@445
   Player *pPlayer9; // [sp+14h] [bp-5E8h]@455
   int thisg; // [sp+14h] [bp-5E8h]@467
   int thish; // [sp+14h] [bp-5E8h]@528
@@ -259,7 +259,7 @@
   POINT v209; // [sp+78h] [bp-584h]@777
   POINT v210; // [sp+80h] [bp-57Ch]@397
   POINT v211; // [sp+88h] [bp-574h]@704
-  __int64 v212; // [sp+90h] [bp-56Ch]@467
+  //__int64 v212; // [sp+90h] [bp-56Ch]@467
   int v213; // [sp+98h] [bp-564h]@385
   char pLevelName[32]; // [sp+9Ch] [bp-560h]@380
   char pOut[32]; // [sp+BCh] [bp-540h]@370
@@ -1666,7 +1666,7 @@
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           dword_50CDC8 = 1;
           sub_42FBDD();
-          pNPCData4 = (NPCData *)GetTravelTime();
+          //pNPCData4 = (NPCData *)GetTravelTime();
           strcpy(pOutdoor->pLevelFilename, pCurrentMapName.data());
           if ( bUnderwater != 1 && pParty->bFlying
             || pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pOut, 20) != 1 )
@@ -1695,11 +1695,11 @@
             ++pGameLoadingUI_ProgressBar->uProgressMax;
             SaveGame(1, 0);
             pGameLoadingUI_ProgressBar->Progress();
-            RestAndHeal(1440 * (signed int)pNPCData4);
+            RestAndHeal(1440 * (signed int)GetTravelTime());
             if ( pParty->uNumFoodRations )
             {
               pParty->RestAndHeal();
-              if ( ((pParty->uNumFoodRations - (signed int)pNPCData4) & 0x80000000u) != 0 )
+              if ( ((pParty->uNumFoodRations - (signed int)GetTravelTime()) & 0x80000000u) != 0 )
               {
                 pPlayer7 = pParty->pPlayers;
                 do
@@ -1710,7 +1710,7 @@
                 while ( (signed int)pPlayer7 < (signed int)pParty->pHirelings );
                 ++pParty->days_played_without_rest;
               }
-              Party::TakeFood((unsigned int)pNPCData4);
+              Party::TakeFood((unsigned int)GetTravelTime());
             }
             else
             {
@@ -1964,26 +1964,25 @@
           uNumSeconds = (unsigned int)&pPlayer->pInstalledBeacons[uMessageParam];
           if ( bRecallingBeacon )
           {
-            if ( !*((int *)&pSavegameThumbnails.data()->pPixels + 10 * uMessageParam) )
+            if ( !*((int *)&pSavegameThumbnails[10 * uMessageParam].pPixels ) )
               continue;
-            v173 = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(pPlayer->pInstalledBeacons[uMessageParam].field_18))].pName;
+            v173 = pMapStats->pInfos[sub_410D99_get_map_index(pPlayer->pInstalledBeacons[uMessageParam].SaveFileID)].pName;
             sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[474], v173);// "Recall to %s"
             GameUI_SetFooterString(pTmpBuf.data());
             continue;
           }
-          v59 = pMapStats->GetMapInfo(pCurrentMapName.data());
-          thise = "Not in Map Stats";
-          if ( v59 )
-            thise = pMapStats->pInfos[v59].pName;
-          if ( !*((int *)&pSavegameThumbnails.data()->pPixels + 10 * uMessageParam) || !v59 )
+          pMapNum = pMapStats->GetMapInfo(pCurrentMapName.data());
+          pMapName = "Not in Map Stats";
+          if ( pMapNum )
+            pMapName = pMapStats->pInfos[pMapNum].pName;
+          if ( !*((int *)&pSavegameThumbnails[10 * uMessageParam].pPixels ) || !pMapNum )
           {
-            sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[476], thise);// "Set to %s"
+            sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[476], pMapName);// "Set to %s"
             GameUI_SetFooterString(pTmpBuf.data());
             continue;
           }
           v174 = pMapStats->pInfos[sub_410D99_get_map_index(*(short *)(uNumSeconds + 26))].pName;
-          v158 = (unsigned int)thise;
-          sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[475], v158, v174);// "Set %s over %s"
+          sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[475], (unsigned int)pMapName, v174);// "Set %s over %s"
           GameUI_SetFooterString(pTmpBuf.data());
           continue;
         case UIMSG_CloseAfterInstallBeacon:
@@ -1998,8 +1997,7 @@
           continue;
         case UIMSG_InstallBeacon:
           pPlayer9 = pPlayers[_506348_current_lloyd_playerid + 1];
-          pNPCData4 = (NPCData *)&pPlayer9->pInstalledBeacons[uMessageParam];
-          if ( !*(_QWORD *)&pNPCData4->pName && bRecallingBeacon )
+          if ( !pPlayer9->pInstalledBeacons[uMessageParam].uBeaconTime && bRecallingBeacon )
             continue;
           byte_506360 = 1;
           pPlayer9->CanCastSpell(uRequiredMana);
@@ -2017,38 +2015,30 @@
           pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[dword_506338], 0, 0, -1, 0, dword_50633C, 0, 0);
           if ( bRecallingBeacon )
           {
-            if ( _stricmp(pCurrentMapName.data(), (const char *)&pGames_LOD->pSubIndices[HIWORD(pNPCData4->uProfession)]) )
+            if ( _stricmp(pCurrentMapName.data(), (const char *)&pGames_LOD->pSubIndices[pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID]) )
             {
               SaveGame(1, 0);
               OnMapLeave();
-              strcpy(pCurrentMapName.data(), (const char *)&pGames_LOD->pSubIndices[HIWORD(pNPCData4->uProfession)]);
+              strcpy(pCurrentMapName.data(), (const char *)&pGames_LOD->pSubIndices[pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID]);
               dword_6BE364_game_settings_1 |= 1;
               uGameState = GAME_STATE_2;
-              _5B65A8_npcdata_uflags_or_other = pNPCData4->uFlags;
-              _5B65AC_npcdata_fame_or_other = pNPCData4->fame;
-              _5B65B0_npcdata_rep_or_other = pNPCData4->rep;
-              _5B65B4_npcdata_loword_house_or_other = LOWORD(pNPCData4->Location2D);
-              _5B65B8_npcdata_hiword_house_or_other = HIWORD(pNPCData4->Location2D);
+              _5B65A8_npcdata_uflags_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X;
+              _5B65AC_npcdata_fame_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y;
+              _5B65B0_npcdata_rep_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z;
+              _5B65B4_npcdata_loword_house_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X;
+              _5B65B8_npcdata_hiword_house_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y;
               dword_5B65C0 = 1;
             }
             else
             {
-              pParty->vPosition.x = pNPCData4->uFlags;
-              pParty->vPosition.y = pNPCData4->fame;
-              pParty->vPosition.z = pNPCData4->rep;
+              pParty->vPosition.x = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X;
+              pParty->vPosition.y = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y;
+              pParty->vPosition.z = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z;
               pParty->uFallStartY = pParty->vPosition.z;
-              pParty->sRotationY = LOWORD(pNPCData4->Location2D);
-              pParty->sRotationX = HIWORD(pNPCData4->Location2D);
+              pParty->sRotationY = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X;
+              pParty->sRotationX = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y;
             }
             pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-            /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-            {
-              pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
-              pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0;
-              *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-              ++pMessageQueue_50CBD0->uNumMessages;
-            }*/
-            //crt_deconstruct_ptr_6A0118();
             pBooksWindow->Release();
             pGUIWindow_CurrentMenu->Release();
             pBooksWindow = 0;
@@ -2059,28 +2049,19 @@
             sprintf(a1, "data\\lloyd%d%d.pcx", _506348_current_lloyd_playerid + 1, uMessageParam + 1);
             SaveScreenshot(a1);
             LoadThumbnailLloydTexture(uMessageParam, _506348_current_lloyd_playerid + 1);
-            v212 = qword_506350 << 7;
-            pNPCData2 = pNPCData4;
-            thisg = 0;
-            v62 = pParty->uTimePlayed + (signed __int64)((double)(qword_506350 << 7) * 0.033333335);
-            pNPCData4->pName = (char *)v62;
-            pNPCData2->uPortraitID = HIDWORD(v62);
-            pNPCData2->uFlags = pParty->vPosition.x;
-            pNPCData2->fame = pParty->vPosition.y;
-            pNPCData2->rep = pParty->vPosition.z;
-            LOWORD(pNPCData2->Location2D) = LOWORD(pParty->sRotationY);
-            HIWORD(pNPCData2->Location2D) = LOWORD(pParty->sRotationX);
+            pPlayer9->pInstalledBeacons[uMessageParam].uBeaconTime = pParty->uTimePlayed + (signed __int64)((double)(qword_506350 << 7) * 0.033333335);
+            pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X = pParty->vPosition.x;
+            pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y = pParty->vPosition.y;
+            pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z = pParty->vPosition.z;
+            pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X = LOWORD(pParty->sRotationY);
+            pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y = LOWORD(pParty->sRotationX);
             if ( (signed int)pGames_LOD->uNumSubDirs / 2 <= 0 )
               continue;
-            uAction = 0;
-            while ( _stricmp((const char *)pGames_LOD->pSubIndices + uAction, pCurrentMapName.data()) )
+            for ( thisg = 0; thisg < (signed int)pGames_LOD->uNumSubDirs / 2; ++thisg )
             {
-              ++thisg;
-              uAction += 32;
-              if ( thisg >= (signed int)pGames_LOD->uNumSubDirs / 2 )
-                continue;
+              if ( !_stricmp((const char *)pGames_LOD->pSubIndices[thisg].pFilename, pCurrentMapName.data()) )
+                pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID = thisg;
             }
-            HIWORD(pNPCData4->uProfession) = thisg;
           }
           continue;
         case UIMSG_ClickTownInTP:
@@ -3017,8 +2998,8 @@
           continue;
         case UIMSG_ShowStatus_Funds:
           v174 = (char *)pParty->uNumGoldInBank;
-          v158 = pParty->uNumGold + pParty->uNumGoldInBank;
-          sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[489], v158, v174);// "You have %d total gold, %d in the Bank"
+          //v158 = pParty->uNumGold + pParty->uNumGoldInBank;
+          sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[489], pParty->uNumGold + pParty->uNumGoldInBank, v174);// "You have %d total gold, %d in the Bank"
           GameUI_SetFooterString(pTmpBuf.data());
           continue;
         case UIMSG_ShowStatus_DateTime:
@@ -4712,7 +4693,7 @@
   v19 = 0;
   v29 = 0;
   if ( v17 <= 0 )
-    goto LABEL_29;
+    return 0;
   do
   {
     if ( a3a >= 2 )
@@ -4747,7 +4728,6 @@
   while ( v29 < v28 );
   result = 1;
   if ( a3a != 1 )
-LABEL_29:
     result = 0;
   return result;
 }
@@ -4847,7 +4827,7 @@
   v25 = 0;
   v16 = dword_4F5B24_ys[1] >= a3;
   if ( v15 <= 0 )
-    goto LABEL_29;
+    return 0;
   do
   {
     if ( a5a >= 2 )
@@ -4882,7 +4862,6 @@
   while ( v25 < v15 );
   result = 1;
   if ( a5a != 1 )
-LABEL_29:
     result = 0;
   return result;
 }
@@ -5193,14 +5172,22 @@
         {
           v35 = v27->uAttributes;
           if ( v35 & 2 || (v51 & 0x80000000u) != 0 || (signed int)v51 > 12 || (signed int)v28 >= 500 )
-            goto LABEL_92;
+		  {
+			pMouse->RemoveHoldingItem();
+			dword_50CDCC = 1;
+			return;
+		  }
           LOWORD(v35) = v35 | 0x210;
           v27->uAttributes = v35;
         }
         else
         {
           if ( (signed int)pParty->pPickedItem.uItemID <= 245 )
-            goto LABEL_92;
+		  {
+			pMouse->RemoveHoldingItem();
+			dword_50CDCC = 1;
+			return;
+		  }
           if ( (signed int)pParty->pPickedItem.uItemID <= 250 )
           {
             v27->UpdateTempBonus(pParty->uTimePlayed);
@@ -5211,7 +5198,11 @@
               || v27->uEnchantmentType
               || v51 && v51 != 1 && v51 != 2
               || (signed int)v33 >= 500 )
-              goto LABEL_92;
+			{
+				pMouse->RemoveHoldingItem();
+				dword_50CDCC = 1;
+				return;
+			}
             v34 = *(int *)&aSbwb00[4 * pParty->pPickedItem.uItemID + 4];
             a2.y = (int)v29 << 7;
             v31 = (double)(signed int)((int)v29 << 7);
@@ -5227,7 +5218,11 @@
               || v27->uEnchantmentType
               || v51 && v51 != 1 && v51 != 2
               || (signed int)v30 >= 500 )
-              goto LABEL_92;
+			{
+				pMouse->RemoveHoldingItem();
+				dword_50CDCC = 1;
+				return;
+			}
             a2.y = (int)v29 << 7;
             v27->uSpecEnchantmentType = 40;
             v31 = (double)a2.y;
@@ -5240,7 +5235,9 @@
           v27->uAttributes = v32;
         }
         _50C9A8_item_enchantment_timer = 256;
-        goto LABEL_92;
+		pMouse->RemoveHoldingItem();
+		dword_50CDCC = 1;
+		return;
       }
       v36 = (70.0 - (double)pParty->pPickedItem.uEnchantmentType) * 0.01;
       if ( v36 < 0.0 )
@@ -5254,7 +5251,9 @@
       v37 = (signed __int64)((double)a2.y - v36 * (double)a2.y);
       v27->uMaxCharges = v37;
       v27->uNumCharges = (unsigned __int8)v37;
-      goto LABEL_92;
+		pMouse->RemoveHoldingItem();
+		dword_50CDCC = 1;
+		return;
     }
     v14 = v13 - 222;
     v15 = pParty->pPickedItem.uItemID - 222;
@@ -5395,9 +5394,16 @@
               if ( !(pItemsTable->pItems[*(int *)(v22 + 532) ].uItemID_Rep_St) )
                 *(int *)(v22 + 552) |= 1u;
               if ( !dword_4E455C )
-                goto LABEL_92;
+			  {
+				pMouse->RemoveHoldingItem();
+				dword_50CDCC = 1;
+				return;
+			  }
               v0->PlaySound(SPEECH_16, 0);
-              goto LABEL_91;
+			  dword_4E455C = 0;
+			  pMouse->RemoveHoldingItem();
+			  dword_50CDCC = 1;
+			  return;
             }
             if ( v45 )
             {
@@ -5436,10 +5442,8 @@
       if ( v0->CanAct() )
         v0->PlaySound(SPEECH_17, 0);
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[444], 2u);
-LABEL_91:
       dword_4E455C = 0;
     }
-LABEL_92:
     pMouse->RemoveHoldingItem();
     dword_50CDCC = 1;
     return;
--- a/mm7_6.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/mm7_6.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -127,7 +127,20 @@
         {
           v11 = 0;
           v12 = *(float *)v4 == *((float *)v7 - 5);
-          goto LABEL_19;
+          if ( ! (v12 | v11) )
+		  {
+			  v26 += 48;
+			  ++v24;
+			  v25 += 48;
+			  v27 += 48;
+			  v28 += 48;
+			  v5 += 48;
+			  v4 += 48;
+			  ++v22;
+			  v23 += 48;
+			  v21 = v5;
+			  v20 = v4;
+		  }
         }
       }
       else
@@ -136,13 +149,22 @@
         {
           v11 = 0;
           v12 = *(float *)v4 == *((float *)v7 + 7);
-LABEL_19:
-          if ( v12 | v11 )
-            goto LABEL_21;
-          goto LABEL_20;
+          if ( !(v12 | v11) )
+		  {
+			  v26 += 48;
+			  ++v24;
+			  v25 += 48;
+			  v27 += 48;
+			  v28 += 48;
+			  v5 += 48;
+			  v4 += 48;
+			  ++v22;
+			  v23 += 48;
+			  v21 = v5;
+			  v20 = v4;
+		  }
         }
       }
-LABEL_20:
       v26 += 48;
       ++v24;
       v25 += 48;
@@ -155,7 +177,6 @@
       v21 = v5;
       v20 = v4;
     }
-LABEL_21:
     if ( v19 )
     {
       v13 = v24;
@@ -328,28 +349,34 @@
   v14 = 0;
   if ( v3 )
   {
-    if ( !pActor->pMonsterInfo.uTreasureDiceRolls )
-      goto LABEL_9;
-    do
-    {
-      ++v2;
-      v14 += rand() % pActor->pMonsterInfo.uTreasureDiceSides + 1;
-    }
-    while ( v2 < pActor->pMonsterInfo.uTreasureDiceRolls );
+    if ( pActor->pMonsterInfo.uTreasureDiceRolls )
+	{
+		do
+		{
+		  ++v2;
+		  v14 += rand() % pActor->pMonsterInfo.uTreasureDiceSides + 1;
+		}
+		while ( v2 < pActor->pMonsterInfo.uTreasureDiceRolls );
+		if ( v14 )
+		{
+		  party_finds_gold(v14, 0);
+		  viewparams->bRedrawGameUI = 1;
+		}
+	}
   }
   else
   {
-    if ( pItemsTable->pItems[pActor->array_000234[3].uItemID].uEquipType != 18 )
-      goto LABEL_9;
-    v14 = pActor->array_000234[3].uSpecEnchantmentType;
-    pActor->array_000234[3].Reset();
+    if ( pItemsTable->pItems[pActor->array_000234[3].uItemID].uEquipType == 18 )
+	{
+		v14 = pActor->array_000234[3].uSpecEnchantmentType;
+		pActor->array_000234[3].Reset();
+		if ( v14 )
+		{
+		  party_finds_gold(v14, 0);
+		  viewparams->bRedrawGameUI = 1;
+		}
+	}
   }
-  if ( v14 )
-  {
-    party_finds_gold(v14, 0);
-    viewparams->bRedrawGameUI = 1;
-  }
-LABEL_9:
   if ( pActor->uCarriedItemID )
   {
     Dst.Reset();
@@ -394,7 +421,6 @@
       }
       pActor->array_000234[1].Reset();
     }
-LABEL_55:
     pActor->Remove();
     return;
   }
@@ -455,7 +481,9 @@
     pActor->array_000234[1].Reset();
   }
   if ( !v13 || rand() % 100 < 90 )
-    goto LABEL_55;
+  {
+    pActor->Remove();
+  }
 }
 
 //----- (00426E10) --------------------------------------------------------
@@ -624,7 +652,7 @@
     }
     while ( v17 ^ v18 );
     if ( v2 )
-      goto LABEL_61;
+      return v23[rand() % v2];
   }
   v19 = 0;
   do
@@ -636,7 +664,6 @@
   }
   while ( v19 < 4 );
   if ( v2 )
-LABEL_61:
     result = v23[rand() % v2];
   else
     result = 0;
@@ -860,6 +887,8 @@
   {
     v14 = a4 + v9;
     v15 = ((v7 + 15) >> 1) + v7 + 15;
+	v13 = __OFSUB__(v14, v15);
+    v12 = v14 - v15 < 0;
   }
   else
   {
@@ -869,14 +898,15 @@
       v11 = v7 + 15;
       v13 = __OFSUB__(v10, v11);
       v12 = v10 - v11 < 0;
-      goto LABEL_16;
     }
-    v14 = a4 + v9;
-    v15 = 2 * v7 + 30;
+	else
+	{
+      v14 = a4 + v9;
+      v15 = 2 * v7 + 30;
+	  v13 = __OFSUB__(v14, v15);
+      v12 = v14 - v15 < 0;
+	}
   }
-  v13 = __OFSUB__(v14, v15);
-  v12 = v14 - v15 < 0;
-LABEL_16:
   if ( v12 ^ v13 )
     result = 0;
   else
@@ -981,25 +1011,29 @@
       break;
     case 0:
       v6 = pActor->pMonsterInfo.uResFire;
-      goto LABEL_12;
+      v4 = v5;
+      break;
     case 1:
       v6 = pActor->pMonsterInfo.uResAir;
-      goto LABEL_12;
+      v4 = v5;
+      break;
     case 2:
       v6 = pActor->pMonsterInfo.uResWater;
-      goto LABEL_12;
+      v4 = v5;
+      break;
     case 3:
       v6 = pActor->pMonsterInfo.uResEarth;
-      goto LABEL_12;
+      v4 = v5;
+      break;
     case 6:
       v6 = pActor->pMonsterInfo.uResSpirit;
       break;
     case 7:
       v6 = pActor->pMonsterInfo.uResMind;
-      goto LABEL_12;
+      v4 = v5;
+      break;
     case 8:
       v6 = pActor->pMonsterInfo.uResBody;
-LABEL_12:
       v4 = v5;
       break;
     case 9:
@@ -1050,52 +1084,41 @@
     case 0u:
       v3 = pActor;
       v4 = pActor->pMonsterInfo.uResFire;
-      goto LABEL_12;
     case 1u:
       v3 = pActor;
       v4 = pActor->pMonsterInfo.uResAir;
-      goto LABEL_12;
     case 2u:
       v3 = pActor;
       v4 = pActor->pMonsterInfo.uResWater;
-      goto LABEL_12;
     case 3u:
       v3 = pActor;
       v4 = pActor->pMonsterInfo.uResEarth;
-      goto LABEL_12;
     case 7u:
       v3 = pActor;
       v4 = pActor->pMonsterInfo.uResMind;
-      goto LABEL_12;
     case 6u:
       v3 = pActor;
       v4 = pActor->pMonsterInfo.uResSpirit;
-      goto LABEL_12;
     case 8u:
       v3 = pActor;
       v4 = pActor->pMonsterInfo.uResBody;
-      goto LABEL_12;
     case 9u:
       v3 = pActor;
       v4 = pActor->pMonsterInfo.uResLight;
-      goto LABEL_12;
     case 0xAu:
       v3 = pActor;
       v4 = pActor->pMonsterInfo.uResDark;
-      goto LABEL_12;
     case 4u:
       v3 = pActor;
       v4 = pActor->pMonsterInfo.uResPhysical;
-LABEL_12:
-      if ( v4 < 200 )
-        result = rand() % (signed int)(((unsigned int)v3->pMonsterInfo.uLevel >> 2) + v4 + 30) < 30;
-      else
-        result = 0;
       break;
     default:
-      result = 1;
-      break;
+      return 1;
   }
+  if ( v4 < 200 )
+	result = rand() % (signed int)(((unsigned int)v3->pMonsterInfo.uLevel >> 2) + v4 + 30) < 30;
+  else
+	result = 0;
   return result;
 }
 
@@ -1549,7 +1572,6 @@
   v13 = 0;
   if ( (signed int)uNumActors <= 0 )
   {
-LABEL_20:
     result = 0;
   }
   else
@@ -1597,7 +1619,7 @@
       ++v13;
       ++v1;
       if ( v13 >= (signed int)uNumActors )
-        goto LABEL_20;
+        return 0;
     }
     result = 1;
   }
--- a/stru6.cpp	Sat Aug 03 00:00:10 2013 +0600
+++ b/stru6.cpp	Sat Aug 03 00:00:31 2013 +0600
@@ -846,7 +846,7 @@
   {
     __debugbreak(); // find out what kind of spells are these
 					// when summoned light elemental attacks
-
+	//cast spell from trees in Avlee
       result -= 500;
       switch ( result )
       {