changeset 552:bee46636df95

Merge
author Nomad
date Mon, 04 Mar 2013 20:29:31 +0200
parents 3b4a24fcd5a0 (current diff) c314e671d29c (diff)
children b8339415fa98 9caf59edb1ee
files Actor.cpp
diffstat 17 files changed, 1805 insertions(+), 1911 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Mon Mar 04 20:28:08 2013 +0200
+++ b/Actor.cpp	Mon Mar 04 20:29:31 2013 +0200
@@ -94,14 +94,14 @@
 }
 
 //----- (004485A7) --------------------------------------------------------
-void Actor::GiveItem(unsigned int uActorID, unsigned int uItemID, unsigned int bGive)
+void Actor::GiveItem(signed int uActorID, unsigned int uItemID, unsigned int bGive)
 {
   unsigned int v3; // eax@3
   char *v4; // ecx@3
-  unsigned int *v5; // eax@8
+  int *v5; // eax@8
   ItemGen *v6; // ecx@12
 
-  if ( (uActorID & 0x80000000u) == 0 && (signed int)uActorID <= (signed int)(uNumActors - 1) )
+  if ( (uActorID >= 0) && (signed int)uActorID <= (signed int)(uNumActors - 1) )
   {
     v3 = uActorID;
     v4 = (char *)&pActors[uActorID].uCarriedItemID;
--- a/Actor.h	Mon Mar 04 20:28:08 2013 +0200
+++ b/Actor.h	Mon Mar 04 20:29:31 2013 +0200
@@ -229,7 +229,7 @@
   static void AggroSurroundingPeasants(unsigned int uActorID, int a2);
   static bool ArePeasantsOfSameFaction(Actor *a1, Actor *a2);
   static bool StealFrom(unsigned int uActorID);
-  static void GiveItem(unsigned int uActorID, unsigned int uItemID, unsigned int bGive);
+  static void GiveItem(signed int uActorID, unsigned int uItemID, unsigned int bGive);
   static void ToggleFlag(signed int uActorID, unsigned int uFlag, int bToggle);
   static void ApplyFineForKillingPeasant(unsigned int uActorID);
   static void DrawHealthBar(Actor *a1, struct GUIWindow *a2);
--- a/Chest.cpp	Mon Mar 04 20:28:08 2013 +0200
+++ b/Chest.cpp	Mon Mar 04 20:29:31 2013 +0200
@@ -29,12 +29,15 @@
 Chest pChests[20];
 
 
-
+const int pChestPixelOffsetX[8]  = {42, 18, 18, 42, 42, 42, 18, 42};
+const int pChestPixelOffsetY[8]  = {34, 30, 30, 34, 34, 34, 30, 34};
+const int pChestWidthsByType[8]  = {9, 9, 9, 9, 9, 9, 9, 9};
+const int pChestHeightsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9};
 
 
 //----- (0042041E) --------------------------------------------------------
-bool Chest::Open(unsigned int uChestID)
-{
+bool Chest::Open( signed int uChestID )
+    {
   //char *v1; // edi@5
   unsigned int v2; // eax@8
   GUIWindow *v3; // eax@15
@@ -79,7 +82,9 @@
 
   //a4 = uChestID;
   assert(uChestID < 20);
-  auto chest = pChests + uChestID;
+  if ((uChestID <0)&&(uChestID >=20) )
+      return false;
+  auto chest = &pChests[uChestID];
 
   ++pIcons_LOD->uTexturePacksCount;
   if (!pIcons_LOD->uNumPrevLoadedFiles)
@@ -89,7 +94,7 @@
   //v1 = (char *)&pChests[uChestID].uFlags;
   //v34 = v1;
   if (!chest->Initialized())
-    Chest::_420284(uChestID);
+    Chest::PlaceItems(uChestID);
 
   if ( !uActiveCharacter )
     return 0;
@@ -233,22 +238,11 @@
       pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0);
   }
   dword_507CD8 = 0;
-  v3 = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Chest, a4, 0);
-  pGUIWindow_CurrentMenu = v3;
-  pChestWindow = v3;
-  pBtn_ExitCancel = v3->CreateButton(
-                 0x1D7u,
-                 0x1BDu,
-                 0xA9u,
-                 0x23u,
-                 1,
-                 0,
-                 0x71u,
-                 0,
-                 0,
-                 pGlobalTXT_LocalizationStrings[79],// Exit
-                 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
-                 0);
+
+  pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Chest, uChestID, 0);
+  pChestWindow = pGUIWindow_CurrentMenu;
+  pBtn_ExitCancel = pChestWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1,  0,  0x71u,  0, 0,  pGlobalTXT_LocalizationStrings[79],// Exit
+                 (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0),   0);
   pChestWindow->CreateButton(7u, 8u, 460u, 343u, 1, 0, 0xCu, 0, 0, "", 0);
   pCurrentScreen = SCREEN_CHEST;
   pEventTimer->Pause();
@@ -257,188 +251,165 @@
 
 //----- (0042092D) --------------------------------------------------------
 void Chest::DrawChestUI(unsigned int uChestID)
-{
-  Render *v1; // edi@1
-  unsigned int v2; // ebx@1
-  unsigned int v3; // ebx@1
-  int v4; // eax@1
-  unsigned int v5; // eax@1
-  int v6; // ecx@3
-  unsigned int v7; // eax@4
-  Texture *v8; // esi@4
-  signed int v9; // ecx@4
-  signed int v10; // edx@4
-  signed int v11; // eax@4
-  int v12; // eax@6
-  int v13; // eax@6
-  unsigned int v14; // ST34_4@8
-  int v15; // edi@8
-  int *v16; // [sp+Ch] [bp-28h]@1
-  int v17; // [sp+10h] [bp-24h]@4
-  int v18; // [sp+14h] [bp-20h]@1
-  signed int v19; // [sp+18h] [bp-1Ch]@1
-  int v20; // [sp+1Ch] [bp-18h]@1
-  signed int v21; // [sp+20h] [bp-14h]@1
-  char *v22; // [sp+2Ch] [bp-8h]@2
-  signed int v23; // [sp+30h] [bp-4h]@1
+    {
+
+    int chestBitmapId; // eax@1
+    unsigned int v5; // eax@1
+    int chest_item_index; // ecx@3
+    unsigned int item_texture_id; // eax@4
+    Texture *item_texture; // esi@4
+    signed int itemPixelWidth; // ecx@4
+    signed int itemPixelHeght; // edx@4
+    signed int v11; // eax@4
+    int v12; // eax@6
+    int v13; // eax@6
+    unsigned int itemPixelPosX; // ST34_4@8
+    int itemPixelPosY; // edi@8
+    int *v16; // [sp+Ch] [bp-28h]@1
+    int v17; // [sp+10h] [bp-24h]@4
+    int chest_offs_y; // [sp+14h] [bp-20h]@1
+    signed int chestHeghtCells; // [sp+18h] [bp-1Ch]@1
+    int chest_offs_x; // [sp+1Ch] [bp-18h]@1
+    signed int chestWidthCells; // [sp+20h] [bp-14h]@1
+    signed int item_counter; // [sp+30h] [bp-4h]@1
 
-  v1 = pRenderer;
-  v2 = uChestID;
-  v16 = pRenderer->pActiveZBuffer;
-  pRenderer->ClearZBuffer(0, 479);
-  v3 = v2;
-  v4 = pChests[v3].uChestBitmapID;
-  v20 = pChestSmthn1ByType[v4];
-  v18 = pChestSmthn2ByType[v4];
-  v21 = pChestWidthsByType[v4];
-  v19 = pChestHeightsByType[v4];
-  sprintf(pTmpBuf, "chest%02d", pChestList->pChests[pChests[v3].uChestBitmapID].uTextureID);
-  v5 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE);
-  pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0));
-  v23 = 0;
-  if ( v21 * v19 > 0 )
-  {
-    v22 = (char *)pChests[v3].pInventoryIndices;
-    do
-    {
-      v6 = *(short *)v22;
-      if ( v6 > 0 )
-      {
-        v17 = v18 + 32 * v23 / v19;
-        v7 = pIcons_LOD->LoadTexture(
-               pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName,
-               TEXTURE_16BIT_PALETTE);
-        v8 = (Texture *)(v7 != -1 ? &pIcons_LOD->pTextures[v7] : 0);
-        v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
-        v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureHeight : 26);
-        v11 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
-        if ( v9 < 14 )
-          v11 = 14;
-        v12 = v11 - 14;
-        LOBYTE(v12) = v12 & 0xE0;
-        v13 = v12 + 32;
-        if ( (signed int)v8->uTextureHeight < 14 )
-          v10 = 14;
-        v14 = v20 + 32 * v23 % v21 + ((v13 - v9) >> 1);
-        v15 = v17 + ((((v10 - 14) & 0xFFFFFFE0) - v8->uTextureHeight + 32) >> 1);
-        pRenderer->DrawTextureTransparent(
-          v14,
-          v17 + ((((v10 - 14) & 0xFFFFFFE0) - v8->uTextureHeight + 32) >> 1),
-          v8);
-        sub_40F92A(&v16[v14 + pSRZBufferLineOffsets[v15]], v8, v23 + 1);
-        v1 = pRenderer;
-      }
-      ++v23;
-      v22 += 2;
+    v16 = pRenderer->pActiveZBuffer;
+    pRenderer->ClearZBuffer(0, 479);
+    chestBitmapId = pChests[uChestID].uChestBitmapID;
+    chest_offs_x = pChestPixelOffsetX[chestBitmapId];
+    chest_offs_y = pChestPixelOffsetY[chestBitmapId];
+    chestWidthCells = pChestWidthsByType[chestBitmapId];
+    chestHeghtCells = pChestHeightsByType[chestBitmapId];
+    sprintf(pTmpBuf, "chest%02d", pChestList->pChests[chestBitmapId].uTextureID);
+    v5 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE);
+    pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0));
+
+    for (item_counter = 0; item_counter< chestWidthCells * chestHeghtCells; ++item_counter)
+        {
+        chest_item_index = pChests[uChestID].pInventoryIndices[item_counter];
+        if ( chest_item_index > 0 )
+            {
+            item_texture_id = pIcons_LOD->LoadTexture(
+                //pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName,
+                pItemsTable->pItems[pChests[uChestID].igChestItems[chest_item_index-1].uItemID].pIconName, TEXTURE_16BIT_PALETTE);
+            item_texture = (Texture *)(item_texture_id != -1 ? &pIcons_LOD->pTextures[item_texture_id] : 0);
+            itemPixelWidth = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureWidth : 24);
+            itemPixelHeght = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureHeight : 26);
+            if ( itemPixelWidth < 14 )
+                itemPixelWidth = 14;
+            v12 = itemPixelWidth - 14;
+            v12 = v12 & 0xFFFFFFE0;
+            v13 = v12 + 32;
+            if ( itemPixelHeght < 14 )
+                itemPixelHeght = 14;
+            itemPixelPosX = chest_offs_x + 32 * (item_counter % chestWidthCells) + ((v13 - itemPixelWidth) >> 1);
+            itemPixelPosY = chest_offs_y + 32 * (item_counter / chestHeghtCells) +
+                ((((itemPixelHeght - 14) & 0xFFFFFFE0) - item_texture->uTextureHeight + 32) >> 1);
+            pRenderer->DrawTextureTransparent(  itemPixelPosX,   itemPixelPosY,  item_texture);
+            sub_40F92A(&v16[itemPixelPosX + pSRZBufferLineOffsets[itemPixelPosY]], item_texture, item_counter + 1);
+            }
+        }
+    pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY,
+        (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0));
     }
-    while ( v23 < v21 * v19 );
-  }
-  pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY,
-    (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
-}
 
 
 //----- (0041FE71) --------------------------------------------------------
-int Chest::CanPlaceItemAt(signed int a1, int a2, unsigned int uChestID)
-{
-  int v3; // eax@1
-  unsigned int v4; // eax@1
-  Texture *v5; // ecx@1
-  signed int v6; // eax@1
-  signed int v7; // edi@3
-  signed int v8; // eax@3
-  int v9; // edi@3
-  int v10; // ebx@5
-  int v11; // esi@9
-  int v12; // edx@10
-  int v13; // ecx@11
-  char *v14; // eax@12
-  int v16; // [sp+Ch] [bp-Ch]@1
-  signed int v17; // [sp+10h] [bp-8h]@1
-  signed int v18; // [sp+14h] [bp-4h]@1
+bool Chest::CanPlaceItemAt( signed int test_cell_position, int item_id, unsigned int uChestID )
+    {
+    int v3; // eax@1
+    unsigned int item_texture_id; // eax@1
+    Texture *item_texture; // ecx@1
+    signed int v6; // eax@1
+    signed int v7; // edi@3
+    signed int v8; // eax@3
+    int texture_cell_width; // edi@3
+    int texture_cell_height; // ebx@5
+    int _row; // esi@9
+    int _cell_rows; // edx@10
+    int _column; // ecx@11
+    char *v14; // eax@12
+    int chest_cell_heght; // [sp+Ch] [bp-Ch]@1
+    signed int v17; // [sp+10h] [bp-8h]@1
+    signed int chest_cell_width; // [sp+14h] [bp-4h]@1
 
-  v17 = a1;
-  v3 = pChests[uChestID].uChestBitmapID;
-  v16 = pChestHeightsByType[v3];
-  v18 = pChestWidthsByType[v3];
-  v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[a2].pIconName, TEXTURE_16BIT_PALETTE);
-  v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0);
-  v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24);
-  if ( v6 < 14 )
-    v6 = 14;
-  v7 = v6 - 14;
-  v8 = v5->uTextureHeight;
-  v9 = (v7 >> 5) + 1;
-  if ( v8 < 14 )
-    v8 = 14;
-  v10 = ((v8 - 14) >> 5) + 1;
-  if ( !areWeLoadingTexture )
-  {
-    v5->Release();
-    pIcons_LOD->_40F9C5();
-  }
-  if ( v9 + v17 % v18 <= v18 && v10 + v17 / v18 <= v16 )
-  {
-    v11 = 0;
-    if ( v10 <= 0 )
-      return 1;
-    v12 = 0;
-    while ( 1 )
-    {
-      v13 = 0;
-      if ( v9 > 0 )
-        break;
-LABEL_15:
-      v12 += v18;
-      ++v11;
-      if ( v11 >= v10 )
-        return 1;
+    chest_cell_heght = pChestHeightsByType[pChests[uChestID].uChestBitmapID];
+    chest_cell_width = pChestWidthsByType[pChests[uChestID].uChestBitmapID];
+    item_texture_id = pIcons_LOD->LoadTexture(pItemsTable->pItems[item_id].pIconName, TEXTURE_16BIT_PALETTE);
+    item_texture = (Texture *)(item_texture_id != -1 ? (int)&pIcons_LOD->pTextures[item_texture_id] : 0);
+    v6 = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureWidth : 24);
+    if ( v6 < 14 )
+        v6 = 14;
+    texture_cell_width = (v6 - 14 >> 5) + 1;
+    v8 = item_texture->uTextureHeight;
+    if ( v8 < 14 )
+        v8 = 14;
+    texture_cell_height = ((v8 - 14) >> 5) + 1;
+    if ( !areWeLoadingTexture )
+        {
+        item_texture->Release();
+        pIcons_LOD->_40F9C5();
+        }
+    if ( (texture_cell_width + test_cell_position % chest_cell_width <= chest_cell_width) && 
+        (texture_cell_height + test_cell_position / chest_cell_width <= chest_cell_heght) )
+        { //we not put over borders
+        _row = 0;
+        if ( texture_cell_height <= 0 )
+            return true;
+        _cell_rows = 0;
+        while ( 1 )
+            {
+            _column = 0;
+            if ( texture_cell_width > 0 )
+                {
+                while ( pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]==0)
+                    {
+                    ++_column;
+                    if ( _column >= texture_cell_width )
+                        break;
+                    }
+                if (pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]!=0)
+                    return false;
+                }
+            _cell_rows += chest_cell_width;
+            ++_row;
+            if ( _row >= texture_cell_height )
+                return true;
+            }
+
+        }
+    return false;
     }
-    v14 = (char *)&pChests[0].pInventoryIndices[v17 + v12 + 2662 * uChestID];
-    while ( !*(short *)v14 )
-    {
-      ++v13;
-      v14 += 2;
-      if ( v13 >= v9 )
-        goto LABEL_15;
-    }
-  }
-  return 0;
-}
 // 506128: using guessed type int areWeLoadingTexture;
 
 //----- (0041FF64) --------------------------------------------------------
-int Chest::_41FF64(unsigned int uChestID)
+int Chest::CountChestItems(unsigned int uChestID)
 {
-  unsigned int v1; // ecx@1
-  signed int result; // eax@1
-  int v3; // edx@1
-  ItemGen *pItem; // ecx@2
-
-  v1 = uChestID;
-  result = 0;
-  v3 = pChestWidthsByType[pChests[v1].uChestBitmapID] * pChestHeightsByType[pChests[v1].uChestBitmapID];
-  if ( v3 <= 0 )
+  signed int item_count; // eax@1
+  int max_items; // edx@1
+  item_count = 0;
+  max_items = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID];
+  if ( max_items <= 0 )
   {
-LABEL_5:
-    result = -1;
+    item_count = -1;
   }
   else
   {
-    pItem = pChests[v1].mm7__vector_pItems;
-    while ( pItem->uItemID )
+    while ( pChests[uChestID].igChestItems[item_count].uItemID )
     {
-      ++result;
-      ++pItem;
-      if ( result >= v3 )
-        goto LABEL_5;
+      ++item_count;
+      if ( item_count >= max_items )
+          {
+          item_count = -1;
+          break;
+          }
     }
   }
-  return result;
+  return item_count;
 }
 
 //----- (0041FFA2) --------------------------------------------------------
-int Chest::_41FFA2(int a1, ItemGen *a2, unsigned int uChestID)
+int Chest::PutItemInChest(int position, ItemGen *put_item, unsigned int uChestID)
 {
   int v3; // eax@1
   ItemGen *v4; // edi@1
@@ -455,7 +426,7 @@
   int v15; // edi@21
   int i; // ecx@21
   ItemGen *Src; // [sp+Ch] [bp-18h]@1
-  signed int v18; // [sp+10h] [bp-14h]@2
+  signed int item_in_chest_count; // [sp+10h] [bp-14h]@2
   int v19; // [sp+14h] [bp-10h]@1
   int v20; // [sp+18h] [bp-Ch]@19
   signed int v21; // [sp+1Ch] [bp-8h]@1
@@ -464,19 +435,19 @@
 
   v21 = 0;
   v3 = pChests[uChestID].uChestBitmapID;
-  v4 = a2;
+  v4 = put_item;
   v5 = pChestWidthsByType[v3] * pChestHeightsByType[v3];
-  Src = a2;
+  Src = put_item;
   v19 = pChestWidthsByType[v3];
-  if ( a1 == -1 )
+  if ( position == -1 )
   {
-    v18 = _41FF64(uChestID);
-    if ( v18 == -1 )
+    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, (unsigned int)pChestWindow->ptr_1C) )
+      while ( !Chest::CanPlaceItemAt(v22, v4->uItemID, pChestWindow->par1C) )
       {
         ++v22;
         if ( v22 >= v5 )
@@ -515,7 +486,7 @@
       {
         if ( (signed int)v12 > 0 )
         {
-          v14 = &pChests[0].pInventoryIndices[v21 + v23 + 2662 * uChestID];
+          v14 = &pChests[uChestID].pInventoryIndices[v21 + v23];
           LOWORD(v8) = -1 - v21;
           v8 <<= 16;
           LOWORD(v8) = -1 - v21;
@@ -532,8 +503,8 @@
       }
       while ( v20 );
     }
-    pChests[0].pInventoryIndices[v21 + 2662 * uChestID] = v18 + 1;
-    memcpy(&pChests[uChestID].mm7__vector_pItems[v18], Src, 0x24u);
+    pChests[uChestID].pInventoryIndices[v21] = item_in_chest_count + 1;
+    memcpy(&pChests[uChestID].igChestItems[item_in_chest_count], put_item, sizeof(ItemGen));
     result = v21 + 1;
   }
   else
@@ -545,159 +516,110 @@
 // 506128: using guessed type int areWeLoadingTexture;
 
 //----- (0042013E) --------------------------------------------------------
-unsigned int Chest::PlaceItemAt(unsigned int a1, unsigned int uItemIdx, unsigned int uChestID)
-{
-  int v3; // esi@1
-  unsigned int v4; // ebx@1
-  int uItemID; // edi@1
-  int v6; // edx@4
-  unsigned int v7; // eax@5
-  Texture *v8; // ecx@5
-  signed int v9; // eax@5
-  signed int v10; // edi@7
-  unsigned int v11; // ebx@7
-  int v12; // edi@9
-  int v13; // edx@12
-  void *v14; // edi@14
-  int v15; // edi@14
-  int i; // ecx@14
-  unsigned int result; // eax@18
-  __int16 v18; // [sp+Ch] [bp-10h]@1
-  int v19; // [sp+10h] [bp-Ch]@11
-  int v20; // [sp+14h] [bp-8h]@12
-  unsigned int v21; // [sp+18h] [bp-4h]@1
+void Chest::PlaceItemAt( unsigned int put_cell_pos, unsigned int item_at_cell, unsigned int uChestID )
+    {
+
+    int uItemID; // edi@1
+    int v6; // edx@4
+    unsigned int v7; // eax@5
+    Texture *v8; // ecx@5
+    signed int v9; // eax@5
+    signed int v10; // edi@7
+    unsigned int texture_cell_width; // ebx@7
+    int textute_cell_height; // edi@9
+    int chest_cell_row_pos; // edx@12
+    int chest_cell_width; // [sp+10h] [bp-Ch]@11
 
-  v3 = 5324 * uChestID;
-  v21 = a1;
-  v4 = 5324 * uChestID + 36 * uItemIdx;
-  v18 = uItemIdx;
-  uItemID = *(unsigned int *)((char *)&pChests[0].mm7__vector_pItems[0].uItemID + v4);
-  pItemsTable->SetSpecialBonus((ItemGen *)((char *)pChests[0].mm7__vector_pItems + v4));
-  if ( uItemID >= 135 && uItemID <= 159 && !*(int *)((char *)&pChests[0].mm7__vector_pItems[0].uNumCharges + v4) )
-  {
-    v6 = rand() % 21 + 10;
-    *(int *)((char *)&pChests[0].mm7__vector_pItems[0].uNumCharges + v4) = v6;
-    *(&pChests[0].mm7__vector_pItems[0].uMaxCharges + v4) = v6;
-  }
-  v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-  v8 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0);
-  v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
-  if ( v9 < 14 )
-    v9 = 14;
-  v10 = v8->uTextureHeight;
-  v11 = ((v9 - 14) >> 5) + 1;
-  if ( v10 < 14 )
-    v10 = 14;
-  v12 = ((v10 - 14) >> 5) + 1;
-  if ( !areWeLoadingTexture )
-  {
-    v8->Release();
-    pIcons_LOD->_40F9C5();
-  }
-  v19 = pChestWidthsByType[*(unsigned __int16 *)((char *)&pChests[0].uChestBitmapID + v3)];
-  if ( v12 > 0 )
-  {
-    v13 = 0;
-    v20 = v12;
-    do
-    {
-      if ( (signed int)v11 > 0 )
-      {
-        v14 = &pChests[0].pInventoryIndices[v21 + v13 + 2662 * uChestID];
-        LOWORD(v3) = -1 - v21;
-        v3 <<= 16;
-        LOWORD(v3) = -1 - v21;
-        memset32(v14, v3, v11 >> 1);
-        v15 = (int)((char *)v14 + 4 * (v11 >> 1));
-        for ( i = v11 & 1; i; --i )
+    uItemID = pChests[ uChestID].igChestItems[item_at_cell].uItemID;
+    pItemsTable->SetSpecialBonus(&pChests[ uChestID].igChestItems[item_at_cell]);
+    if ( uItemID >= 135 && uItemID <= 159 && !pChests[ uChestID].igChestItems[item_at_cell].uNumCharges)
         {
-          *(short *)v15 = v3;
-          v15 += 2;
+        v6 = rand() % 21 + 10;
+        pChests[ uChestID].igChestItems[item_at_cell].uNumCharges = v6;
+        pChests[ uChestID].igChestItems[item_at_cell].uMaxCharges = v6;
         }
-      }
-      v13 += v19;
-      --v20;
+    v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
+    v8 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0);
+    v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
+    if ( v9 < 14 )
+        v9 = 14;
+    v10 = v8->uTextureHeight;
+    texture_cell_width = ((v9 - 14) >> 5) + 1;
+    if ( v10 < 14 )
+        v10 = 14;
+    textute_cell_height = ((v10 - 14) >> 5) + 1;
+    if ( !areWeLoadingTexture )
+        {
+        v8->Release();
+        pIcons_LOD->_40F9C5();
+        }
+    chest_cell_width = pChestWidthsByType[pChests[ uChestID].uChestBitmapID];
+    chest_cell_row_pos = 0;
+    for(int i=0; i<textute_cell_height; ++i) 
+        { 
+        for (int j=0; j<texture_cell_width; ++j)
+            {
+            pChests[uChestID].pInventoryIndices[put_cell_pos + chest_cell_row_pos+j]=(signed __int16)-(put_cell_pos+1);
+            } 
+        chest_cell_row_pos += chest_cell_width;
+        }
+    pChests[uChestID].pInventoryIndices[put_cell_pos] = item_at_cell + 1;
     }
-    while ( v20 );
-  }
-  result = v21 + 2662 * uChestID;
-  pChests[0].pInventoryIndices[result] = v18 + 1;
-  return result;
-}
 // 506128: using guessed type int areWeLoadingTexture;
 
 //----- (00420284) --------------------------------------------------------
-char *Chest::_420284(unsigned int uChestID)
-{
-  int v1; // ebx@1
-  unsigned int v2; // esi@1
-  unsigned int v3; // esi@1
-  int uChestArea; // edi@1
-  int v5; // eax@2
-  int v6; // ebx@11
-  char *result; // eax@18
-  char Dst[144]; // [sp+Ch] [bp-A0h]@1
-  int v9; // [sp+9Ch] [bp-10h]@10
-  unsigned int v10; // [sp+A0h] [bp-Ch]@1
-  unsigned int v11; // [sp+A4h] [bp-8h]@8
-  ItemGen *v12; // [sp+A8h] [bp-4h]@9
-
-  v1 = 0;
-  v2 = uChestID;
-  v10 = uChestID;
-  pRenderer->ClearZBuffer(0, 479);
-  v3 = v2;
-  uChestArea = pChestWidthsByType[pChests[v3].uChestBitmapID] * pChestHeightsByType[pChests[v3].uChestBitmapID];
-  memset(Dst, 0, 0x90u);
-  if ( uChestArea > 0 )
-  {
-    do
+void Chest::PlaceItems( unsigned int uChestID )
     {
-      do
-        v5 = (unsigned __int8)rand();
-      while ( v5 >= uChestArea );
-      while ( Dst[v5] )
-      {
-        ++v5;
-        if ( v5 == uChestArea )
-          v5 = 0;
-      }
-      Dst[v5] = v1++;
+    int uChestArea; // edi@1
+    int random_chest_pos; // eax@2
+    int test_position; // ebx@11
+    char chest_cells_map[144]; // [sp+Ch] [bp-A0h]@1
+    int chest_item_id; // [sp+9Ch] [bp-10h]@10
+    unsigned int items_counter; // [sp+A4h] [bp-8h]@8
+
+    pRenderer->ClearZBuffer(0, 479);
+    uChestArea = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID];
+    memset(chest_cells_map, 0, 144);
+    //fill cell map at random positions
+    for (items_counter = 0; items_counter<uChestArea; ++items_counter)
+        {
+        //get random position in chest
+        do
+        random_chest_pos = (unsigned __int8)rand();
+        while ( random_chest_pos >= uChestArea );
+        //if this pos occupied move to next
+        while ( chest_cells_map[random_chest_pos] )
+            {
+            ++random_chest_pos;
+            if ( random_chest_pos == uChestArea )
+                random_chest_pos = 0;
+            }
+        chest_cells_map[random_chest_pos] = items_counter;
+        }
+    items_counter = 0;
+
+    for (items_counter = 0; items_counter<uChestArea; ++items_counter)
+        {
+        chest_item_id = pChests[uChestID].igChestItems[items_counter].uItemID;
+        if ( chest_item_id )
+            {
+            test_position = 0;
+            while ( !Chest::CanPlaceItemAt((unsigned __int8)chest_cells_map[test_position], chest_item_id, uChestID) )
+                {
+                ++test_position;
+                if ( test_position >= uChestArea )
+                    break;
+                }
+            if(test_position<uChestArea)
+                {
+                Chest::PlaceItemAt((unsigned __int8)chest_cells_map[test_position], items_counter, uChestID);
+                if ( pChests[uChestID].uFlags & 4 )
+                    pChests[uChestID].igChestItems[items_counter].SetIdentified();
+                }
+            }
+        }
+    pChests[uChestID].SetInitialized(true);
     }
-    while ( v1 < uChestArea );
-  }
-  v11 = 0;
-  if ( uChestArea > 0 )
-  {
-	v12 = pChests[v3].mm7__vector_pItems;//&pChests[v3].mm7__vector_pItems[0].uAttributes;
-    do
-    {
-	  v9 = v12->uItemID;
-      if ( v9 )
-      {
-        v6 = 0;
-        while ( !Chest::CanPlaceItemAt((unsigned __int8)Dst[v6], v9, v10) )
-        {
-          ++v6;
-          if ( v6 >= uChestArea )
-            break;
-        }
-		if(v6<uChestArea)
-		{
-			Chest::PlaceItemAt((unsigned __int8)Dst[v6], v11, v10);
-			if ( pChests[v3].uFlags & 4 )
-				v12->SetIdentified();
-		}
-      }
-      ++v11;
-      ++v12;
-    }
-    while ( (signed int)v11 < uChestArea );
-  }
-  result = (char *)&pChests[v3].uFlags;
-  pChests[v3].uFlags = pChests[v3].uFlags & 0xFFFB | 2;
-  return result;
-}
 // 420284: using guessed type char Dst[144];
 
 //----- (00458B03) --------------------------------------------------------
@@ -801,3 +723,83 @@
   fclose(File);
   return 1;
 }
+
+//----- (00420B13) --------------------------------------------------------
+void __fastcall sub_420B13(int a1, int a2)
+    {
+    void *v2; // eax@1
+    ItemGen *v3; // ebx@1
+    unsigned int v4; // eax@1
+    Texture *v5; // ecx@1
+    signed int v6; // eax@1
+    signed int v7; // edi@3
+    signed int v8; // eax@3
+    int v9; // edi@3
+    int v10; // eax@5
+    int v11; // esi@8
+    unsigned int v12; // ecx@10
+    void *v13; // edi@10
+    unsigned __int8 v14; // cf@10
+    int v15; // edi@10
+    int i; // ecx@10
+    int v17; // [sp+Ch] [bp-14h]@1
+    int v18; // [sp+10h] [bp-10h]@3
+    int v19; // [sp+14h] [bp-Ch]@1
+    void *v20; // [sp+18h] [bp-8h]@1
+    int v21; // [sp+1Ch] [bp-4h]@5
+    int v22; // [sp+1Ch] [bp-4h]@8
+
+    v19 = a2;
+    v2 = pChestWindow->ptr_1C;
+    v20 = v2;
+    v2 = (void *)(5324 * (int)v2);
+    v3 = (ItemGen *)((char *)v2 + 36 * a1 + (int)((char *)pChests + 4));
+    v17 = pChestWidthsByType[*(short *)((char *)v2 + (int)pChests)];
+    v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v3->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
+    v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0);
+    v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24);
+    if ( v6 < 14 )
+        v6 = 14;
+    v7 = v6 - 14;
+    v8 = v5->uTextureHeight;
+    v9 = (v7 >> 5) + 1;
+    v18 = v9;
+    if ( v8 < 14 )
+        v8 = 14;
+    v10 = ((v8 - 14) >> 5) + 1;
+    v21 = v10;
+    if ( !areWeLoadingTexture )
+        {
+        v5->Release();
+        pIcons_LOD->_40F9C5();
+        v10 = v21;
+        }
+    if ( v10 > 0 )
+        {
+        v11 = 0;
+        v22 = v10;
+        do
+            {
+            if ( v9 > 0 )
+                {
+                v12 = v9;
+                v13 = &pChests[0].pInventoryIndices[v19 + v11 + 2662 * (int)v20];
+                v14 = v12 & 1;
+                v12 >>= 1;
+                memset(v13, 0, 4 * v12);
+                v15 = (int)((char *)v13 + 4 * v12);
+                for ( i = v14; i; --i )
+                    {
+                    *(short *)v15 = 0;
+                    v15 += 2;
+                    }
+                v9 = v18;
+                }
+            v11 += v17;
+            --v22;
+            }
+            while ( v22 );
+        }
+    v3->Reset();
+    }
+// 506128: using guessed type int areWeLoadingTexture;
--- a/Chest.h	Mon Mar 04 20:28:08 2013 +0200
+++ b/Chest.h	Mon Mar 04 20:29:31 2013 +0200
@@ -47,29 +47,29 @@
 
 /*   65 */
 #pragma pack(push, 1)
-struct Chest
+struct Chest //0x14cc
 {
   inline bool Initialized() const    {return uFlags & CHEST_ITEMS_PLACED;}
   inline void SetInitialized(bool b) {if (b) uFlags |= CHEST_ITEMS_PLACED; else uFlags &= ~CHEST_ITEMS_PLACED;}
   inline bool Trapped() const        {return uFlags & CHEST_TRAPPED;}
 
-  static int CanPlaceItemAt(signed int a1, int a2, unsigned int uChestID);
-  static int _41FF64(unsigned int uChestID);
-  static int _41FFA2(int a1, ItemGen *a2, unsigned int uChestID);
-  static unsigned int PlaceItemAt(unsigned int a1, unsigned int uItemIdx, unsigned int uChestID);
-  static char *_420284(unsigned int uChestID);
-  static bool Open(unsigned int uChestID);
+  static bool CanPlaceItemAt(signed int a1, int a2, unsigned int uChestID);
+  static int CountChestItems(unsigned int uChestID);
+  static int PutItemInChest(int a1, ItemGen *a2, unsigned int uChestID);
+  static void PlaceItemAt(unsigned int put_cell_pos, unsigned int uItemIdx, unsigned int uChestID);
+  static void PlaceItems(unsigned int uChestID);
+  static bool Open(signed int uChestID);
   static void DrawChestUI(unsigned int uChestID);
   static void ToggleFlag(unsigned int uChestID, unsigned __int16 uFlag, unsigned int bToggle);
 
-  unsigned __int16 uChestBitmapID;
-  unsigned __int16 uFlags;
-  struct ItemGen mm7__vector_pItems[140];
-  __int16 pInventoryIndices[140];
+  unsigned __int16 uChestBitmapID; //0
+  unsigned __int16 uFlags; //2
+  struct ItemGen igChestItems[140]; //4
+  signed __int16 pInventoryIndices[140]; //0x13b4
 };
 #pragma pack(pop)
 
-
+void __fastcall sub_420B13(int a1, int a2);
 
 
 extern size_t uNumChests; // idb
--- a/Events.cpp	Mon Mar 04 20:28:08 2013 +0200
+++ b/Events.cpp	Mon Mar 04 20:29:31 2013 +0200
@@ -338,9 +338,6 @@
 					{
 					++curr_seq_num;
 					v4 = v124;
-					
-					//v6 = v123;
-					//v7 = "";
 					break;
 					}
 				v124 = -1;
@@ -533,19 +530,16 @@
 					{
 					v26 = (LevelDecoration *)activeLevelDecoration;
 					stru_5E4C90._decor_events[activeLevelDecoration ->_idx_in_stru123] = 0;
-					LOBYTE(v26->field_2) |= 0x20u;
+					v26->field_2 |= 0x0020;
 					}
 				++curr_seq_num;
 				v4 = v124;
-				
-				//v6 = v123;
-				//v7 = "";
+
 				break;
 			case EVENT_SetNPCGreeting:
-				v27 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
-				v28 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
+				v27 = EVT_DWORD(_evt->v5);
 				pNPCStats->pNewNPCData[v27].uFlags &= 0xFFFFFFFCu;
-				pNPCStats->pNewNPCData[v27].greet = v28;
+				pNPCStats->pNewNPCData[v27].greet = EVT_DWORD(_evt->v9);
 				++curr_seq_num;
 				v4 = v124;
 				
@@ -629,39 +623,26 @@
 				//v7 = "";
 				break;
 			case EVENT_NPCSetItem:
-				sub_448518_npc_set_item(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
-					_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13);
+				sub_448518_npc_set_item(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13);
 				++curr_seq_num;
 				v4 = v124;
-				
-				//v6 = v123;
-				//v7 = "";
+
 				break;
 			case EVENT_SetActorItem:
-				Actor::GiveItem(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
-					_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13);
+				Actor::GiveItem(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13);
 				++curr_seq_num;
 				v4 = v124;
-				
-				//v6 = v123;
-				//v7 = "";
 				break;
 			case EVENT_SetNPCGroupNews:
 				pNPCStats->pGroups_copy[_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)] = _evt->v9 + ((uint)_evt->v10 << 8);
 				++curr_seq_num;
 				v4 = v124;
-				
-				//v6 = v123;
-				//v7 = "";
 				break;
 			case EVENT_SetActorGroup:
 				__debugbreak();
 				*(&pActors[0].uGroup + 0x11000000 * _evt->v8 + 209 * (_evt->v5 + ((_evt->v6 + ((uint)_evt->v7 << 8)) << 8))) = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
 				++curr_seq_num;
 				v4 = v124;
-				
-				//v6 = v123;
-				//v7 = "";
 				break;
 			case EVENT_ChangeGroup:
 				v38 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
@@ -712,11 +693,11 @@
 			case EVENT_MoveNPC:
 				{
 
-				pNPCStats->pNewNPCData[_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)].Location2D = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8);
+				pNPCStats->pNewNPCData[EVT_DWORD(_evt->v5)].Location2D =EVT_DWORD(_evt->v9);
 				if ( window_SpeakInHouse )
 					{
-					v46 = window_SpeakInHouse->ptr_1C;
-					if ( v46 == (void *)165 )
+	
+					if ( window_SpeakInHouse->par1C == 165 )
 						{
 						sub_4BD8B5();
 						pVideoPlayer->Unload();
@@ -726,9 +707,8 @@
 						if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) )
 							{
 							pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0);
-							v47 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0);
-							window_SpeakInHouse = v47;
-							v48 = v47->pControlsHead;
+							window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0);
+							v48 = window_SpeakInHouse->pControlsHead;
 							if ( v48 )
 								{
 								do
@@ -738,33 +718,29 @@
 									v48 = v49;
 									}
 									while ( v49 );
-									v47 = window_SpeakInHouse;
 								}
-							v47->pControlsHead = 0;
+							window_SpeakInHouse->pControlsHead = 0;
 							window_SpeakInHouse->pControlsTail = 0;
 							window_SpeakInHouse->uNumControls = 0;
 							}
 						}
 					else
 						{
-						if ( v46 == (void *)553 )
+						if ( window_SpeakInHouse->par1C == 553 )
 							pVideoPlayer->bLoopPlaying = 0;
 						}
 					}
-				++curr_seq_num;
+				
 				}
+                ++curr_seq_num;
 				v4 = v124;
-				
-				//v6 = v123;
-				//v7 = "";
+
 				break;
 			case EVENT_Jmp:
 				curr_seq_num = _evt->v5 - 1;
 				++curr_seq_num;
-				//v4 = -1;
-				
-				//v6 = v123;
-				//v7 = "";
+				v4 = -1;
+
 				break;
 			case EVENT_ShowFace:
 				if ( _evt->v5 <= 3u ) //someone 
@@ -780,9 +756,7 @@
 					pParty->pPlayers[rand() % 4].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0);
 					++curr_seq_num;
 					v4 = v124;
-					
-					//v6 = v123;
-					//v7 = "";
+
 					break;
 			case EVENT_CharacterAnimation:
 				if ( _evt->v5 <= 3u ) //someone
@@ -795,18 +769,13 @@
 				else	//random
 					pParty->pPlayers[rand() % 4].PlaySound((PlayerSpeech) _evt->v6, 0);
 				++curr_seq_num;
-					v4 = v124;
-					
-					//v6 = v123;
-					//v7 = "";
+				v4 = v124;
+
 				break;
 			case EVENT_ForPartyMember:
 				player_choose = _evt->v5;
 				++curr_seq_num;
 				v4 = v124;
-				
-				//v6 = v123;
-				//v7 = "";
 				break;
 			case EVENT_SummonItem:
 				sub_42F7EB_DropItemAt(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
@@ -866,8 +835,6 @@
 				}
 				++curr_seq_num;
 				v4 = v124;
-				//v6 = v123;
-				//v7 = "";
 				break;
 			case EVENT_IsActorAlive:
 				 if  (IsActorAlive(EVT_BYTE(_evt->v5), EVT_DWORD(_evt->v6), EVT_BYTE(_evt->v10)))
@@ -882,106 +849,66 @@
 				pValue = EVT_DWORD(_evt->v7);
 				if ( EVT_WORD(_evt->v5) == VAR_PlayerItemInHands )
 				{
-					v64 = 0;
-					if ( pParty->pPickedItem.uItemID == pValue )
+					if ( pParty->pPickedItem.uItemID == pValue )//In hand
 					{
 						pMouse->RemoveHoldingItem();
 						++curr_seq_num;
 						v4 = v124;
-						
-						//v6 = v123;
-						//v7 = "";
 						break;
 					}
-					v65 = 0;
-					v66 = pPlayers[uActiveCharacter];
-					v67 = (int)v66->pInventoryIndices;
-					do
+					v67 = (int)pPlayers[uActiveCharacter]->pInventoryIndices;
+					for ( v65 = 0; v65 < 126; ++v65 )
 					{
-						if ( (int)&v66->pInventoryItems[v67] == pValue )
+						if ( (int)&pPlayers[uActiveCharacter]->pInventoryItems[v67] == pValue )
 						{
-							v66->RemoveItemAtInventoryIndex(v65);
+							pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v65);
 							++curr_seq_num;
 							v4 = v124;
-							
-							//v6 = v123;
-							//v7 = "";
 							break;
 						}
-						++v65;
 						v67 += 4;
 					}
 					while ( (signed int)v65 < 126 );
-						v68 = 0;
-						v69 = (int)&v66->pEquipment;
-						do
+					v69 = (int)&pPlayers[uActiveCharacter]->pEquipment;
+					for ( v68 = 0; v68 < 16; ++v68 )
+					{
+						if ( *(int *)v69 && (int)&pPlayers[uActiveCharacter]->pInventoryItems[v69] == pValue )
 						{
-							if ( *(int *)v69 && (int)&v66->pInventoryItems[v69] == pValue )
+							*(&pPlayers[uActiveCharacter]->pEquipment.uOffHand + v68) = 0;
+							++curr_seq_num;
+							v4 = v124;
+							break;
+						}
+						v69 += 4;
+					}
+					for (int i = 1; i < 5; i++)
+					{
+						v72 = (int)pPlayers[i]->pInventoryIndices;
+						for ( int v71 = 0; v71 < 126; ++v71 )
+						{
+							if ( (int)&pPlayers[i]->pInventoryItems[v72] == pValue )
 							{
-								*(&v66->pEquipment.uOffHand + v68) = 0;
-								++curr_seq_num;
-								v4 = v124;
-								
-								//v6 = v123;
-								//v7 = "";
+								pPlayers[i]->RemoveItemAtInventoryIndex(v71);
 								break;
 							}
-							++v68;
-							v69 += 4;
+							v72 += 4;
 						}
-						while ( v68 < 16 );
-							pPlayer = pPlayers[1];
-							while ( 1 )
-							{
-								v70 = pPlayer;
-								if ( !v64 )
-								{
-									v71 = 0;
-									v72 = (int)v70->pInventoryIndices;
-									do
-									{
-										if ( (int)&v70->pInventoryItems[v72] == pValue )
-										{
-											v70->RemoveItemAtInventoryIndex(v71);
-											goto LABEL_169;
-										}
-										++v71;
-										v72 += 4;
-									}
-									while ( (signed int)v71 < 126 );
-										v73 = 0;
-										v74 = (int)&v70->pEquipment;
-										while ( !*(int *)v74 || (int)&v70->pInventoryItems[v74] != pValue )
-										{
-											++v73;
-											v74 += 4;
-											if ( v73 >= 16 )
-												goto LABEL_170;
-										}
-										*(&v70->pEquipment.uOffHand + v73) = 0;
-LABEL_169:
-										v64 = 1;
-								}
-LABEL_170:
-								pPlayer += 4;
-								if ( pPlayer > pPlayers[4] )
-								{
-									//++curr_seq_num;
-									v4 = v124;
-									
-									//v6 = v123;
-									//v7 = "";
-									break;
-								}
-							}
+						v73 = 0;
+						v74 = (int)&pPlayers[i]->pEquipment;
+						while ( !*(int *)v74 || (int)&pPlayer->pInventoryItems[v74] != pValue )
+						{
+							++v73;
+							v74 += 4;
+							if ( v73 >= 16 )
+								break;
+						}
+						*(&pPlayers[i]->pEquipment.uOffHand + v73) = 0;
 					}
+				}
 				if ( player_choose <= 3 )
 				{
 					pPlayer = &pParty->pPlayers[player_choose];
 					pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
-					++curr_seq_num;
-					v4 = v124;
-					break;
 				}
 				else if ( player_choose == 4 ) //active
 				{
@@ -989,9 +916,6 @@
 					{
 						pPlayer = pPlayers[uActiveCharacter];
 						pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
-						++curr_seq_num;
-						v4 = v124;
-						break;
 					}
 				}
 				else 	if ( player_choose == 5 )//all
@@ -1000,32 +924,25 @@
 					for(int i = 0; i < 4; ++i)
 					{
 						if ( pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) )
-						{
-							++curr_seq_num;
 							break;
-						}
 					}
 					++v130;
-					break;
 				}
 				else if ( player_choose == 6 ) //random
 				{
 					player_choose = rand() % 4;
 					pPlayer = &pParty->pPlayers[player_choose];
 					pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
-					++curr_seq_num;
-					v4 = v124;
-					break;
 				}
+				++curr_seq_num;
+				v4 = v124;
+				break;
 			case EVENT_Set:
 				pValue = EVT_DWORD(_evt->v7);
 				if ( player_choose <= 3 )
 				{
 					pPlayer = &pParty->pPlayers[player_choose];
 					pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
-					++curr_seq_num;
-					v4 = v124;
-					break;
 				}
 				else if ( player_choose == 4 ) //active
 				{
@@ -1033,40 +950,31 @@
 					{
 						pPlayer = pPlayers[uActiveCharacter];
 						pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
-						++curr_seq_num;
-						v4 = v124;
-						break;
 					}
 				}
 				else if ( player_choose == 5 )//all
 				{
+                  //recheck v130
 					for(int i = 1; i < 5; ++i)
 						pPlayers[i]->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
-					++curr_seq_num;
-					v4 = v124;
-					break;
+
 				}
 				else if ( player_choose == 6 ) //random
 				{
 					player_choose = rand() % 4;
 					pPlayer = &pParty->pPlayers[player_choose];
 					pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
-					++curr_seq_num;
-					v4 = v124;
-					break;
+
 				}
+                ++curr_seq_num;
+                v4 = v124;
+                break;
 			case EVENT_Add:
 				pValue = EVT_DWORD(_evt->v7);
 				if ( player_choose <= 3 )
 				{
 					pPlayer = &pParty->pPlayers[player_choose];
 					pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
-					v83 = EVT_WORD(_evt->v5);
-					if ( v83 == 21 || v83 == 22 || v83 == 23 || v83 == 24 )
-						viewparams->bRedrawGameUI = 1;
-					++curr_seq_num;
-					v4 = v124;
-					break;
 				}
 				else if ( player_choose == 4 ) //active
 				{
@@ -1074,12 +982,6 @@
 					{
 						pPlayer = pPlayers[uActiveCharacter];
 						pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
-						v83 = EVT_WORD(_evt->v5);
-						if ( v83 == 21 || v83 == 22 || v83 == 23 || v83 == 24 )
-							viewparams->bRedrawGameUI = 1;
-						++curr_seq_num;
-						v4 = v124;
-						break;
 					}
 				}
 				else if ( player_choose == 5 )//all
@@ -1087,29 +989,24 @@
 					//v130 = 0;
 					for(int i = 1; i < 5; ++i)
 						pPlayers[i]->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
-					v83 = EVT_WORD(_evt->v5);
-					if ( v83 == 21 || v83 == 22 || v83 == 23 || v83 == 24 )
-						viewparams->bRedrawGameUI = 1;
-					++curr_seq_num;
-					v4 = v124;
-					break;
+
 				}
 				else if ( player_choose == 6 ) //random
 				{
 					player_choose = rand() % 4;
 					pPlayer = &pParty->pPlayers[player_choose];
 					pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
-					v83 = EVT_WORD(_evt->v5);
-					if ( v83 == 21 || v83 == 22 || v83 == 23 || v83 == 24 )
-						viewparams->bRedrawGameUI = 1;
-					++curr_seq_num;
-					v4 = v124;
-					break;
 				}
+                v83 = EVT_WORD(_evt->v5);
+                if ( v83 == 21 || v83 == 22 || v83 == 23 || v83 == 24 )
+                    viewparams->bRedrawGameUI = 1;
+                ++curr_seq_num;
+                v4 = v124;
+                break;
 			case EVENT_InputString:
 				if ( !start_event_seq_number )
 					{
-					strcpy(GameUI_StatusBar_TimedString, &pLevelStr[pLevelStrOffsets[_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)]]);
+					strcpy(GameUI_StatusBar_TimedString, &pLevelStr[pLevelStrOffsets[EVT_DWORD(_evt->v5 )]]);
 					v105 = curr_seq_num;
 					v121 = 26;
 LABEL_295:
@@ -1140,14 +1037,16 @@
 				//v124 = -1;
 				v11 = (unsigned __int8)*(&_evt->v5 + rand() % ((_evt->v5 != 0) + (_evt->v6 != 0) + (_evt->v7 != 0) + (_evt->v8 != 0) + (_evt->v9 != 0)
 					+ (_evt->v10 != 0)));
-				goto LABEL_131;
+                curr_seq_num = v11 - 1;
+                   ++curr_seq_num;
+                   v4 = v124;
 			case EVENT_ReceiveDamage:
-				v85 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
+				v85 = EVT_DWORD(_evt->v7 );
 				v86 = _evt->v5;
 				if ( (unsigned __int8)v86 <= 3u )
 					{
 					v119 = _evt->v6;
-					v115 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
+					v115 = EVT_DWORD(_evt->v7 );
 					v89 = (unsigned __int8)v86;
 					goto LABEL_233;
 					}
@@ -1164,13 +1063,13 @@
 						}
 					v119 = _evt->v6;
 					v88 = pPlayers[uActiveCharacter];
-					v115 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
+					v115 = EVT_DWORD(_evt->v7 );
 					goto LABEL_234;
 					}
 				if ( v86 != 5 )
 					{
 					v119 = _evt->v6;
-					v115 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10<< 8)) << 8)) << 8);
+					v115 = EVT_DWORD(_evt->v7 );
 					v89 = rand() % 4;
 LABEL_233:
 					v88 = &pParty->pPlayers[v89];
@@ -1197,7 +1096,7 @@
 					//v7 = "";
 					break;
 			case EVENT_ToggleIndoorLight:
-				pIndoor->ToggleLight(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), _evt->v9);
+				pIndoor->ToggleLight(EVT_DWORD(_evt->v5 ), _evt->v9);
 				++curr_seq_num;
 				v4 = v124;
 				
@@ -1205,8 +1104,7 @@
 				//v7 = "";
 				break;
 			case EVENT_SetFacesBit:
-				sub_44892E_set_faces_bit(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
-					_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13);
+				sub_44892E_set_faces_bit(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13);
 				++curr_seq_num;
 				v4 = v124;
 				
@@ -1214,8 +1112,7 @@
 				//v7 = "";
 				break;
 			case EVENT_ToggleChestFlag:
-				Chest::ToggleFlag(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
-					_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13);
+				Chest::ToggleFlag(EVT_DWORD(_evt->v5 ),	EVT_DWORD(_evt->v9 ), _evt->v13);
 				++curr_seq_num;
 				v4 = v124;
 				
@@ -1223,8 +1120,7 @@
 				//v7 = "";
 				break;
 			case EVENT_ToggleActorFlag:
-				Actor::ToggleFlag(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
-					_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), _evt->v13);
+				Actor::ToggleFlag(EVT_DWORD(_evt->v5 ),	EVT_DWORD(_evt->v9 ), _evt->v13);
 				++curr_seq_num;
 				v4 = v124;
 				
@@ -1232,10 +1128,7 @@
 				//v7 = "";
 				break;
 			case EVENT_ToggleActorGroupFlag:
-				ToggleActorGroupFlag(
-					_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8),
-					_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8),
-					_evt->v13);
+				ToggleActorGroupFlag(EVT_DWORD(_evt->v5 ),	EVT_DWORD(_evt->v9 ), _evt->v13);
 				++curr_seq_num;
 				v4 = v124;
 				
@@ -1252,30 +1145,18 @@
 				//v7 = "";
 				break;
 			case EVENT_StatusText:
-				v90 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
+				v90 = EVT_DWORD(_evt->v5 );
 				if ( activeLevelDecoration )
 					{
-					if ( activeLevelDecoration == (void*)1 )
+					if ( activeLevelDecoration == (LevelDecoration*)1 )
 						{
 						ptr_F8B1E8 = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90];
-						++curr_seq_num;
-						v4 = v124;
-						
-						//v6 = v123;
-						//v7 = "";
-						break;
 						}
 					if ( canShowMessages == 1 )
 						{
 						v91 = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90];
 						//LABEL_248:
 						ShowStatusBarString(v91, 2u);
-						++curr_seq_num;
-						v4 = v124;
-						
-						//v6 = v123;
-						//v7 = "";
-						break;
 						}
 					}
 				else
@@ -1284,12 +1165,6 @@
 						{
 						v91 = &pLevelStr[pLevelStrOffsets[v90]];
 						ShowStatusBarString(v91, 2u);
-						++curr_seq_num;
-						v4 = v124;
-						
-						//v6 = v123;
-						//v7 = "";
-						break;
 						}
 					}
 				++curr_seq_num;
@@ -1299,7 +1174,7 @@
 				//v7 = "";
 				break;
 			case EVENT_ShowMessage:
-				v92 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
+				v92 = EVT_DWORD(_evt->v5 );
 				if ( activeLevelDecoration )
 					{
 					v93 = (char *)pNPCTopics[v92-1].pText;//(&dword_721664)[8 * v92];
@@ -1317,20 +1192,15 @@
 				//v7 = "";
 				break;
 			case EVENT_CastSpell:
-				sub_448DF8_cast_spell(_evt->v5, _evt->v6, _evt->v7, _evt->v8 + ((_evt->v9 + ((_evt->v10 + ((uint)_evt->v11 << 8)) << 8)) << 8),
-					_evt->v12 + ((_evt->v13 + ((_evt->v14 + ((uint)_evt->v15 << 8)) << 8)) << 8),
-					_evt->v16 + ((_evt->v17 + ((_evt->v18 + ((uint)_evt->v19 << 8)) << 8)) << 8),
-					_evt->v20 + ((_evt->v21 + ((_evt->v22 + ((uint)_evt->v23 << 8)) << 8)) << 8),
-					_evt->v24 + ((_evt->v25 + ((_evt->v26 + ((uint)_evt->v27 << 8)) << 8)) << 8),
-					_evt->v28 + ((_evt->v29 + ((_evt->v30 + ((uint)_evt->v31 << 8)) << 8)) << 8));
+				sub_448DF8_cast_spell(_evt->v5, _evt->v6, _evt->v7, EVT_DWORD(_evt->v8 ),
+                    EVT_DWORD(_evt->v12 ), EVT_DWORD(_evt->v16 ), EVT_DWORD(_evt->v20 ),
+                    EVT_DWORD(_evt->v24 ), EVT_DWORD(_evt->v28 ));
 				++curr_seq_num;
 				v4 = v124;
-				
-				//v6 = v123;
-				//v7 = "";
+			
 				break;
 			case EVENT_SetTexture:
-				sub_44861E_set_texture(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), (char *)&_evt->v9);
+				sub_44861E_set_texture(EVT_DWORD(_evt->v5 ), (char *)&_evt->v9);
 				++curr_seq_num;
 				v4 = v124;
 				
@@ -1338,7 +1208,7 @@
 				//v7 = "";
 				break;
 			case EVENT_SetSprite:
-				SetDecorationSprite(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), _evt->v9, (char *)&_evt->v10);
+				SetDecorationSprite(EVT_DWORD(_evt->v5 ), _evt->v9, (char *)&_evt->v10);
 				++curr_seq_num;
 				v4 = v124;
 				
@@ -1346,12 +1216,9 @@
 				//v7 = "";
 				break;
 			case EVENT_SummonMonsters:
-				sub_448CF4_spawn_monsters(_evt->v5, _evt->v6, _evt->v7,
-					_evt->v8 + ((_evt->v9 + ((_evt->v10 + ((uint)_evt->v11 << 8)) << 8)) << 8),
-					_evt->v12 + ((_evt->v13 + ((_evt->v14 + ((uint)_evt->v15 << 8)) << 8)) << 8),
-					_evt->v16 + ((_evt->v17 + ((_evt->v18 + ((uint)_evt->v19 << 8)) << 8)) << 8),
-					_evt->v20 + ((_evt->v21 + ((_evt->v22 + ((uint)_evt->v23 << 8)) << 8)) << 8),
-					_evt->v24 + ((_evt->v25 + ((_evt->v26 + ((uint)_evt->v27 << 8)) << 8)) << 8));
+				sub_448CF4_spawn_monsters(_evt->v5, _evt->v6, _evt->v7,EVT_DWORD(_evt->v8 ),
+                    EVT_DWORD(_evt->v12 ), EVT_DWORD(_evt->v16 ), EVT_DWORD(_evt->v20 ),
+                    EVT_DWORD(_evt->v24 ));
 				++curr_seq_num;
 				v4 = v124;
 				
@@ -1520,13 +1387,13 @@
 					pAudioPlayer->PlaySound(SOUND_EnteringAHouse, 814, 0, -1, 0, 0, 0, 0);
 					v104 = 187;
 					if ( uCurrentHouse_Animation != 167 )
-						v104 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
+						v104 = EVT_DWORD(_evt->v5);
 					window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, v104, 0);
 					window_SpeakInHouse->CreateButton( 61, 424, 31, 0, 2, 94, 0x6Eu, 1, 49, "", 0);
 					window_SpeakInHouse->CreateButton(177, 424, 31, 0, 2, 94, 0x6Eu, 2, 50, "", 0);
 					window_SpeakInHouse->CreateButton(292, 424, 31, 0, 2, 94, 0x6Eu, 3, 51, "", 0);
 					window_SpeakInHouse->CreateButton(407, 424, 31, 0, 2, 94, 0x6Eu, 4, 52, "", 0);
-					window_SpeakInHouse->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
+					window_SpeakInHouse->CreateButton(  0,   0,  0, 0, 1,  0, 0xB0u, 0, 9u, "", 0);
 					}
 				++curr_seq_num;
 				v4 = v124;
--- a/GUIWindow.cpp	Mon Mar 04 20:28:08 2013 +0200
+++ b/GUIWindow.cpp	Mon Mar 04 20:29:31 2013 +0200
@@ -1211,7 +1211,7 @@
   }
   else
   {
-    pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uTextureID_506438]);
+    pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]);
   }
 }
 
@@ -1794,7 +1794,7 @@
           pMainScreenNum = pCurrentScreen;
           pCurrentScreen = SCREEN_NPC_DIALOGUE;
           pBtn_ExitCancel = pWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], //"Exit"
-                         (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0);
+                         (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0);
           if ( pWindow->par1C != 1 )
           {
             num_menu_buttons = 0;
@@ -1916,7 +1916,7 @@
   {
     pCurrentScreen = SCREEN_HOUSE;
     pBtn_ExitCancel = pWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[80],//Выйти из здания
-                   (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), 0);
+                   (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0);
     v25 = uNumDialogueNPCPortraits;
     v26 = 0;
     if ( uNumDialogueNPCPortraits > 0 )
--- a/Items.cpp	Mon Mar 04 20:28:08 2013 +0200
+++ b/Items.cpp	Mon Mar 04 20:29:31 2013 +0200
@@ -25,9 +25,9 @@
 	};
 
 
-char uItemsAmountPerShopType[5]={ 0, 6, 8, 12, 12};
+const char uItemsAmountPerShopType[5]={ 0, 6, 8, 12, 12};
 
-ITEM_VARIATION shopWeap_variation_ord[15] ={
+const ITEM_VARIATION shopWeap_variation_ord[15] ={
 	{ 0, { 0, 0, 0, 0 }},
 	{ 1, { 23, 27, 20, 20 }},
 	{ 1, { 23, 24, 28, 20 }},
@@ -44,7 +44,7 @@
 	{ 2, { 30, 26, 26, 26 }},
 	{ 2, { 28, 25, 28, 29 }}};
 
-ITEM_VARIATION shopArmr_variation_ord[28] ={
+const ITEM_VARIATION shopArmr_variation_ord[28] ={
 	{ 1, { 35, 35, 38, 38 }},
 	{ 1, { 31, 31, 31, 34 }},
 	{ 1, { 35, 35, 38, 38 }},
@@ -76,10 +76,10 @@
 
 
 
-unsigned __int16 shopMagic_treasure_lvl[14]= {0, 1, 1, 2, 2, 4, 4, 3, 2, 2, 2, 2, 2, 2};
-unsigned __int16 shopAlch_treasure_lvl[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 2, 2, 2, 2};
+const unsigned __int16 shopMagic_treasure_lvl[14]= {0, 1, 1, 2, 2, 4, 4, 3, 2, 2, 2, 2, 2, 2};
+const unsigned __int16 shopAlch_treasure_lvl[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 2, 2, 2, 2};
 
-ITEM_VARIATION shopWeap_variation_spc[15]={
+const ITEM_VARIATION shopWeap_variation_spc[15]={
 	{ 0, { 0, 0, 0, 0 }},
 	{ 2, { 25, 30, 20, 20}},
 	{ 2, { 23, 24, 28, 20}},
@@ -96,7 +96,7 @@
 	{ 4, { 30, 26, 26, 26}},
 	{ 4, { 28, 25, 28, 29}}};
 
-ITEM_VARIATION shopArmr_variation_spc[28]={
+const ITEM_VARIATION shopArmr_variation_spc[28]={
 	{ 2, { 35, 35, 38, 38 }},
 	{ 2, { 31, 31, 31, 34 }},
 	{ 2, { 35, 35, 38, 38 }},
@@ -127,8 +127,18 @@
 	{ 5, { 33, 33, 33, 33 }}
 	};
 
-unsigned __int16 shopMagicSpc_treasure_lvl[14]  =  {0, 2, 2, 3, 3, 5, 5, 4, 3, 3, 3, 3, 3, 3};
-unsigned __int16 shopAlchSpc_treasure_lvl[13]   =  {0, 2, 2, 3, 3, 4, 4, 5, 5, 3, 2, 2, 2};
+const unsigned __int16 shopMagicSpc_treasure_lvl[14]  =  {0, 2, 2, 3, 3, 5, 5, 4, 3, 3, 3, 3, 3, 3};
+const unsigned __int16 shopAlchSpc_treasure_lvl[13]   =  {0, 2, 2, 3, 3, 4, 4, 5, 5, 3, 2, 2, 2};
+
+
+char byte_4E8168[7][14]={  //byte_4E8178
+    { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 
+    { 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
+    { 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3},
+    { 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4},
+    { 2, 2, 2, 2, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5},
+    { 2, 2, 2, 2, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6},
+    { 2, 2, 2, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}};
 
 int  sub_4BE571(int a1, int *a2, int a3, int a4);
 
@@ -2043,8 +2053,8 @@
 
 
 //----- (00450218) --------------------------------------------------------
-void __cdecl sub_450218_prolly_generate_chests_loot()
-	{
+void sub_450218_prolly_generate_chests_loot()
+    {
 	unsigned int v0; // eax@1
 	Chest *v1; // ebx@1
 	MapInfo *v2; // esi@1
@@ -2076,14 +2086,13 @@
 	v2 = &pMapStats->pInfos[v0];
 	v21 = pChests;
 	v20 = &pMapStats->pInfos[v0];
-	do
+    for(int i=0; i<20;++i)
 		{
-		v3 = v1->mm7__vector_pItems;
-		v23 = 140;
-		do
+		for(int j=0; j<140;++j)
 			{
-			if ( (v3->uItemID & 0x80000000u) == 0 )
-				goto LABEL_56;
+            v3 = &pChests[i].igChestItems[j];
+			if ( v3->uItemID < 0 )
+                {
 			v4 = rand() % 5 + 1;
 			v5 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 2];
 			v6 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob+1];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 3];
@@ -2091,6 +2100,13 @@
 			v8 = v6 - v5 + 1;
 			v9 = v5 + v7 % v8;
 			v19 = v5 + v7 % v8;
+           /* switch (v9)
+                {
+            default:
+
+                }*/
+
+
 			if ( v9 < 7 )
 				{
 				if ( v18 < 20 )
@@ -2146,7 +2162,7 @@
 											v13 = v12;
 											if ( v12 >= 140 )
 												goto LABEL_52;
-											v14 = &v21->mm7__vector_pItems[v12];
+											v14 = &v21->igChestItems[v12];
 											while ( v14->uItemID )
 												{
 												++v13;
@@ -2226,17 +2242,14 @@
 				goto LABEL_25;
 				}
 			v3->GenerateArtifact();
+            
 LABEL_55:
 			v2 = v20;
-LABEL_56:
-			++v3;
-			--v23;
-			}
-			while ( v23 );
-			v1 = v21 + 1;
-			++v21;
+LABEL_56: ;
+                }
+			}			
 		}
-		while ( (signed int)v21 < (signed int)&uNumChests );
+		
 	}
 
 
--- a/Items.h	Mon Mar 04 20:28:08 2013 +0200
+++ b/Items.h	Mon Mar 04 20:29:31 2013 +0200
@@ -116,7 +116,7 @@
 
 /*   64 */
 #pragma pack(push, 1)
-struct ItemGen
+struct ItemGen //0x24
 {
   //----- (0042EB25) --------------------------------------------------------
   inline ItemGen()
@@ -139,7 +139,7 @@
 
 
 
-  unsigned int uItemID;
+  int uItemID;
   int uEncantmentType;
   int _bonus_strength;
   int uSpecEnchantmentType; // 25: +5 levels
@@ -290,7 +290,7 @@
 void GenerateStandartShopItems();
 void GenerateSpecialShopItems();
 
-
+extern const char uItemsAmountPerShopType[]; // weak
 extern ItemGen *ptr_50C9A4;
 
 extern struct ItemsTable *pItemsTable;
--- a/MM7.vcxproj.filters	Mon Mar 04 20:28:08 2013 +0200
+++ b/MM7.vcxproj.filters	Mon Mar 04 20:29:31 2013 +0200
@@ -127,7 +127,6 @@
     <ClInclude Include="mm7_data.h" />
     <ClInclude Include="Allocator.h" />
     <ClInclude Include="IndoorCamera.h" />
-    <ClInclude Include="LayingItem.h" />
     <ClInclude Include="Viewport.h" />
     <ClInclude Include="MapInfo.h" />
     <ClInclude Include="PlayerFrameTable.h" />
@@ -202,6 +201,7 @@
     <ClInclude Include="resource.h" />
     <ClInclude Include="stru346.h" />
     <ClInclude Include="texts.h" />
+    <ClInclude Include="SpriteObject.h" />
   </ItemGroup>
   <ItemGroup>
     <Filter Include="lib">
@@ -258,7 +258,6 @@
     <ClCompile Include="stru6.cpp" />
     <ClCompile Include="AudioPlayer.cpp" />
     <ClCompile Include="GUIButton.cpp" />
-    <ClCompile Include="LayingItem.cpp" />
     <ClCompile Include="VideoPlayer.cpp" />
     <ClCompile Include="GUIProgressBar.cpp" />
     <ClCompile Include="TileFrameTable.h" />
@@ -321,6 +320,7 @@
     <ClCompile Include="texts.cpp" />
     <ClCompile Include="mm7text_ru.cpp" />
     <ClCompile Include="NPC.cpp" />
+    <ClCompile Include="SpriteObject.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="Might and Magic Trilogy.rc" />
--- a/Party.h	Mon Mar 04 20:28:08 2013 +0200
+++ b/Party.h	Mon Mar 04 20:29:31 2013 +0200
@@ -120,6 +120,8 @@
   int field_4F0[38];
   char field_588[2];
   __int64 _s_times[21]; //5d8 440h+8*51
+  __int64 field_632[8];
+  char field_672[6];
  // char pIsArtifactFound[8];
 };
 #pragma pack(pop)
@@ -277,6 +279,7 @@
   ItemGen StandartItemsInShops[53][12];
   ItemGen SpecialItemsInShops[53][12];   //D0EC
   ItemGen SpellBooksInGuilds[32][12];
+  char field_1605C[24];
   char pHireling1Name[100];
   char pHireling2Name[100];
   int armageddon_timer;
--- a/mm7_1.cpp	Mon Mar 04 20:28:08 2013 +0200
+++ b/mm7_1.cpp	Mon Mar 04 20:29:31 2013 +0200
@@ -2233,8 +2233,8 @@
 
 
 //----- (0041D895) --------------------------------------------------------
-void GameUI_DrawItemInfo(ItemGen *ecx0)
-{
+void GameUI_DrawItemInfo( struct ItemGen* inspect_item )
+    {
   ItemGen *v1; // esi@1
   unsigned int v2; // eax@3
   //char *v3; // edi@5
@@ -2242,7 +2242,6 @@
   //unsigned int v5; // esi@5
   signed int v6; // eax@5
   int v7; // edx@5
-  ItemGen *v8; // ecx@10
   //unsigned int v9; // eax@12
   char v10; // zf@16
   ItemGen *v11; // eax@16
@@ -2264,7 +2263,7 @@
   int v27; // eax@67
   const char *v28; // edi@69
   int v29; // eax@70
-  char *v30; // edi@78
+  char v30; // edi@78
   const char *v31; // eax@78
   int v32; // ecx@81
   unsigned int v33; // eax@81
@@ -2296,7 +2295,7 @@
   int v59; // [sp-8h] [bp-280h]@56
   int v60; // [sp-8h] [bp-280h]@58
   unsigned int v61; // [sp-8h] [bp-280h]@110
-  char a1[300]; // [sp+8h] [bp-270h]@40
+  char out_text[300]; // [sp+8h] [bp-270h]@40
   //char Dest[100]; // [sp+6Ch] [bp-20Ch]@40
   //char v64[100]; // [sp+D0h] [bp-1A8h]@40
   char v65[120]; // [sp+134h] [bp-144h]@92
@@ -2314,31 +2313,30 @@
   //char *v76; // [sp+1FCh] [bp-7Ch]@5
   int v77; // [sp+200h] [bp-78h]@12
   int v78; // [sp+204h] [bp-74h]@5
-  GUIWindow v79; // [sp+208h] [bp-70h]@2
+  GUIWindow wHintWindow; // [sp+208h] [bp-70h]@2
   POINT a2; // [sp+25Ch] [bp-1Ch]@2
   int v81; // [sp+264h] [bp-14h]@5
-  GUIFont *v82; // [sp+268h] [bp-10h]@1
-  char *v83; // [sp+26Ch] [bp-Ch]@18
+ // GUIFont *pFontComic; // [sp+268h] [bp-10h]@1
+  PlayerSpeech v83; // [sp+26Ch] [bp-Ch]@18
+  char* v84;
+  int v85;
   char *Str; // [sp+270h] [bp-8h]@65
-  ItemGen *_this; // [sp+274h] [bp-4h]@1
-
-  v1 = ecx0;
-  _this = ecx0;
+
+  v1 = inspect_item;
   var88 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-  v82 = pFontComic;
-  if (!v1->uItemID)
+  if (!inspect_item->uItemID)
     return;
 
-    v79.Hint = 0;
-    v79.uFrameWidth = 384;
-    v79.uFrameHeight = 180;
-    v79.uFrameY = 40;
+    wHintWindow.Hint = 0;
+    wHintWindow.uFrameWidth = 384;
+    wHintWindow.uFrameHeight = 180;
+    wHintWindow.uFrameY = 40;
     if ( pMouse->GetCursorPos(&a2)->x <= 320 )
       v2 = pMouse->GetCursorPos(&a2)->x + 30;
     else
-      v2 = pMouse->GetCursorPos(&a2)->x - v79.uFrameWidth - 30;
-    v79.uFrameX = v2;
-    auto item_desc = &pItemsTable->pItems[_this->uItemID];
+      v2 = pMouse->GetCursorPos(&a2)->x - wHintWindow.uFrameWidth - 30;
+    wHintWindow.uFrameX = v2;
+    auto item_desc = &pItemsTable->pItems[inspect_item->uItemID];
     //v3 = (char *)&pItemsTable->pItems[_this->uItemID].pIconName;
     //v76 = v3;
     //v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[_this->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
@@ -2357,33 +2355,32 @@
       v81 = 0;
     else
       v81 >>= 1;
-    v8 = _this;
     if ( !item_desc->uItemID_Rep_St )
-      _this->SetIdentified();
+      inspect_item->SetIdentified();
     //v9 = v8->uAttributes;
     v77 = 0;
     //a2.y = v8->uAttributes & 2;
-    if (pItemsTable->pItems[v8->uItemID].uEquipType == EQUIP_GOLD)
-      v77 = v8->uSpecEnchantmentType;
+    if (pItemsTable->pItems[inspect_item->uItemID].uEquipType == EQUIP_GOLD)
+      v77 = inspect_item->uSpecEnchantmentType;
     if ( uActiveCharacter )
     {
-      if (!v8->Identified())
+     //try to identify
+      if (!inspect_item->Identified())
       {
-        v10 = pPlayers[uActiveCharacter]->CanIdentify(_this) == 1;
-        v11 = _this;
-        if ( v10 )
-          _this->SetIdentified();
-        v10 = !v11->Identified();
-        v83 = (char *)9;
-        if ( v10 )
+
+        v11 = inspect_item;
+        if ( pPlayers[uActiveCharacter]->CanIdentify(inspect_item) == 1 )
+          inspect_item->SetIdentified();
+        v83 = SPEECH_9;
+        if ( !inspect_item->Identified() )
         {
-          ShowStatusBarString(pGlobalTXT_LocalizationStrings[446], 2u);
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[446], 2u);//"Identify Failed"
         }
         else
         {
-          v83 = (char *)SPEECH_8;
-          if ( _this->GetValue() < 100 * (pPlayers[uActiveCharacter]->uLevel + 5) )
-            v83 = (char *)SPEECH_7;
+          v83 = SPEECH_8;
+          if ( inspect_item->GetValue() < 100 * (pPlayers[uActiveCharacter]->uLevel + 5) )
+            v83 = SPEECH_7;
         }
         if ( dword_4E455C )
         {
@@ -2391,96 +2388,95 @@
           dword_4E455C = 0;
         }
       }
-      _this->UpdateTempBonus(pParty->uTimePlayed);
-      if (v8->Broken())
+      inspect_item->UpdateTempBonus(pParty->uTimePlayed);
+      if (inspect_item->Broken())
       {
-        v10 = pPlayers[uActiveCharacter]->CanRepair(_this) == 1;
-        v12 = _this;
-        if ( v10 )
-          _this->uAttributes = _this->uAttributes & 0xFFFFFFFD | 1;
-        v10 = !v12->Broken();
-        v83 = (char *)SPEECH_11;
-        if ( v10 )
-          v83 = (char *)SPEECH_10;
+        if ( pPlayers[uActiveCharacter]->CanRepair(inspect_item) == 1 )
+          inspect_item->uAttributes = inspect_item->uAttributes & 0xFFFFFFFD | 1;
+        v83 = SPEECH_11;
+        if ( !inspect_item->Broken() )
+          v83 = SPEECH_10;
         else
-          ShowStatusBarString(pGlobalTXT_LocalizationStrings[448], 2u);
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[448], 2u);//"Repair Failed"
         if ( dword_4E455C )
         {
-          pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)(int)v83, 0);
+          pPlayers[uActiveCharacter]->PlaySound(v83, 0);
           dword_4E455C = 0;
         }
       }
     }
     //v13 = _this->uAttributes;
     //v14 = _this->Identified();
-    a2.y = _this->Identified();
-    if (_this->Broken())
+    //a2.y = inspect_item->Identified();
+    if (inspect_item->Broken())
     {
-      v79.DrawMessageBox(0);
+      wHintWindow.DrawMessageBox(0);
       //v15 = &;
-      pRenderer->Clip(v79.uFrameX + 12,                   v79.uFrameY + 12,
-                      v79.uFrameX + v79.uFrameWidth - 12, v79.uFrameY + v79.uFrameHeight - 12);
-      v79.uFrameWidth -= 24;
-      v79.uFrameHeight -= 12;
-      v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
-      v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
-      pRenderer->DrawTransparentRedShade(v79.uFrameX + v78, v81 + v79.uFrameY + 30, v73);
-      if ( a2.y )
-        v16 = _this->GetIdentifiedName();
+      pRenderer->Clip(wHintWindow.uFrameX + 12, wHintWindow.uFrameY + 12,
+                      wHintWindow.uFrameX + wHintWindow.uFrameWidth - 12, 
+                      wHintWindow.uFrameY + wHintWindow.uFrameHeight - 12);
+      wHintWindow.uFrameWidth -= 24;
+      wHintWindow.uFrameHeight -= 12;
+      wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1;
+      wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1;
+      pRenderer->DrawTransparentRedShade(wHintWindow.uFrameX + v78, v81 + wHintWindow.uFrameY + 30, v73);
+      if ( inspect_item->Identified())
+        v16 = inspect_item->GetIdentifiedName();
       else
         v16 = item_desc->pUnidentifiedName;
-      v79.DrawTitleText(pFontArrus, 0, 0xCu, var88, v16, 3u);
-      v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[32], &v79, 0, 0);
-      v57 = 3;
-      v52 = pGlobalTXT_LocalizationStrings[32];
-      goto LABEL_37;
-    }
-    if (!_this->Identified())
-    {
-      v79.DrawMessageBox(0);
-      //v15 = pRenderer;
-      pRenderer->Clip(v79.uFrameX + 12,                   v79.uFrameY + 12,
-                      v79.uFrameX + v79.uFrameWidth - 12, v79.uFrameY + v79.uFrameHeight - 12);
-      v79.uFrameWidth -= 24;
-      v79.uFrameHeight -= 12;
-      v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
-      v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
-      pRenderer->DrawTextureTransparent(v79.uFrameX + v78, v81 + v79.uFrameY + 30, v73);
-      v79.DrawTitleText(pFontArrus, 0, 0xCu, var88, item_desc->pUnidentifiedName, 3u);
-      v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[232], &v79, 0, 0);
-      v57 = 3;
-      v52 = pGlobalTXT_LocalizationStrings[232];
-LABEL_37:
+      wHintWindow.DrawTitleText(pFontArrus, 0, 0xCu, var88, v16, 3u);
+      v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[32], &wHintWindow, 0, 0); //"Broken Item"
       v18 = v17 >> 1;
       v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x19u, 0x19u);
-      v79.DrawTitleText(pFontArrus, 0x64u, ((signed int)v79.uFrameHeight >> 1) - v18, v19, v52, v57);
+      wHintWindow.DrawTitleText(pFontArrus, 0x64u, ((signed int)wHintWindow.uFrameHeight >> 1) - v18, v19, pGlobalTXT_LocalizationStrings[32], 3); //"Broken Item"
+       goto LABEL_116;
+    }
+    if (!inspect_item->Identified())
+    {
+      wHintWindow.DrawMessageBox(0);
+      pRenderer->Clip(wHintWindow.uFrameX + 12,  wHintWindow.uFrameY + 12,
+                      wHintWindow.uFrameX + wHintWindow.uFrameWidth - 12, 
+                      wHintWindow.uFrameY + wHintWindow.uFrameHeight - 12);
+      wHintWindow.uFrameWidth -= 24;
+      wHintWindow.uFrameHeight -= 12;
+      wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1;
+      wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1;
+      pRenderer->DrawTextureTransparent(wHintWindow.uFrameX + v78, v81 + wHintWindow.uFrameY + 30, v73);
+      wHintWindow.DrawTitleText(pFontArrus, 0, 0xCu, var88, item_desc->pUnidentifiedName, 3u);
+      v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[232], &wHintWindow, 0, 0); ///"Not Identified"
+      v18 = v17 >> 1;
+      v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x19u, 0x19u);
+      wHintWindow.DrawTitleText(pFontArrus, 0x64u, ((signed int)wHintWindow.uFrameHeight >> 1) - v18, v19, pGlobalTXT_LocalizationStrings[232], 3);
       goto LABEL_116;
     }
 
-    sprintfex(a1, pGlobalTXT_LocalizationStrings[463], item_desc->pUnidentifiedName);
-    a1[100] = 0;
-    a1[200] = 0;
+    sprintfex(out_text, pGlobalTXT_LocalizationStrings[463], item_desc->pUnidentifiedName); //"Type: %s"
+    out_text[100] = 0;
+    out_text[200] = 0;
     //v20 = item_desc->uEquipType;
     switch (item_desc->uEquipType)
     {
       case EQUIP_ONE_OR_TWO_HANDS:
       case EQUIP_TWO_HANDED:
-        sprintfex(a1 + 100, "%s: +%d   %s: %dd%d", pGlobalTXT_LocalizationStrings[18], (int)item_desc->uDamageMod, pGlobalTXT_LocalizationStrings[53], (int)item_desc->uDamageDice, (int)item_desc->uDamageRoll);
+        sprintfex(out_text + 100, "%s: +%d   %s: %dd%d", pGlobalTXT_LocalizationStrings[LOCSTR_ATTACK],
+            (int)item_desc->uDamageMod, pGlobalTXT_LocalizationStrings[53], (int)item_desc->uDamageDice, (int)item_desc->uDamageRoll); //"Damage"
         if (item_desc->uDamageMod)
         {
           char mod[16];
           sprintf(mod, "+%d", (int)item_desc->uDamageMod);
-          strcat(a1 + 100, mod);
+          strcat(out_text + 100, mod);
         }
       break;
 
       case EQUIP_BOW:
-        sprintfex(a1 + 100, "%s: +%d   %s: %dd%d", pGlobalTXT_LocalizationStrings[203], (int)item_desc->uDamageMod, pGlobalTXT_LocalizationStrings[53], (int)item_desc->uDamageDice, (int)item_desc->uDamageRoll);
+        sprintfex(out_text + 100, "%s: +%d   %s: %dd%d", pGlobalTXT_LocalizationStrings[203], //"Shoot"
+            (int)item_desc->uDamageMod, pGlobalTXT_LocalizationStrings[53], //"Damage"
+            (int)item_desc->uDamageDice, (int)item_desc->uDamageRoll);
         if (item_desc->uDamageMod)
         {
           char mod[16];
           sprintf(mod, "+%d", (int)item_desc->uDamageMod);
-          strcat(a1 + 100, mod);
+          strcat(out_text + 100, mod);
         }
       break;
 
@@ -2493,215 +2489,203 @@
       case EQUIP_BOOTS:
       case EQUIP_RING:
       case EQUIP_AMULET:
-        if (item_desc->uDamageDice)
-          sprintfex(a1 + 100, "%s: +%d", pGlobalTXT_LocalizationStrings[11], item_desc->uDamageDice + item_desc->uDamageMod);
+        if (item_desc->uDamageDice) //"Armor"	
+          sprintfex(out_text + 100, "%s: +%d", pGlobalTXT_LocalizationStrings[11], item_desc->uDamageDice + item_desc->uDamageMod);
       break;
+      case EQUIP_POTION:
+          if ( inspect_item->uEncantmentType )
+              sprintf(out_text + 200,  "%s: %d",pGlobalTXT_LocalizationStrings[449] , inspect_item->uEncantmentType); //"Power"
+          break;
+      case EQUIP_REAGENT:
+         sprintf(out_text + 200, "%s: %d", pGlobalTXT_LocalizationStrings[449], pItemsTable->pItems[inspect_item->uItemID].uDamageDice); //"Power"
+         break;
     }
 
     if ( v77 )
       goto LABEL_65;
     //v23 = item_desc->uEquipType;
-    if (item_desc->uEquipType == 14)
-    {
-      v24 = _this->uEncantmentType;
-      if ( v24 )
-        goto LABEL_56;
-LABEL_65:
-      v79.uFrameWidth -= 12;
-      a2.y = 3;
-      v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
-      v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
-      Str = (char *)(3 * (LOBYTE(pFontArrus->uFontHeight) + 8));
-      v83 = a1;
-      do
-      {
-        if ( *v83 )
-        {
-          v27 = v82->CalcTextHeight(v83, &v79, 100, 0);
-          Str += v27 + 3;
-        }
-        v83 += 100;
-        --a2.y;
-      }
-      while ( a2.y );
-      v28 = item_desc->pDescription;
-      if ( *v28 )
-      {
-        v29 = pFontSmallnum->CalcTextHeight(v28, &v79, 100, 0);
-        Str += v29;
-      }
-      v79.uFrameHeight = v73->uTextureHeight + v81 + 54;
-      if ( (signed int)Str > (signed int)v79.uFrameHeight )
-        v79.uFrameHeight = (unsigned int)Str;
-      if ( _this->uAttributes & 8 && (_this->uSpecEnchantmentType || _this->uEncantmentType) )
-        v79.uFrameHeight += LOBYTE(v82->uFontHeight);
-      v83 = 0;
-      if ( LOBYTE(pFontArrus->uFontHeight) )
-      {
-        v79.uFrameWidth -= 24;
-        v30 = (char *)LOBYTE(pFontArrus->uFontHeight);
-        v31 = _this->GetIdentifiedName();
-        if ( pFontArrus->CalcTextHeight(v31, &v79, 0, 0) / (signed int)v30 )
-          v83 = v30;
-        v79.uFrameWidth += 24;
-      }
-      v79.uFrameWidth += 12;
-      v79.uFrameHeight += (unsigned int)v83;
-      v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
-      v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
-      v79.DrawMessageBox(0);
-      //v15 = pRenderer;
-      pRenderer->Clip(v79.uFrameX + 12,                   v79.uFrameY + 12,
-                      v79.uFrameX + v79.uFrameWidth - 12, v79.uFrameY + v79.uFrameHeight - 12);
-      v79.uFrameWidth -= 12;
-      v32 = v73->uTextureHeight;
-      v33 = v79.uFrameHeight;
-      v79.uFrameHeight -= 12;
-      v79.uFrameZ = v79.uFrameX + v79.uFrameWidth - 1;
-      v79.uFrameW = v79.uFrameY + v79.uFrameHeight - 1;
-      pRenderer->DrawTextureTransparent(
-        v79.uFrameX + v78,
-        v79.uFrameY + (signed int)(v33 - v32) / 2,
-        v73);
-      a2.y = 3;
-      v34 = (int)(v83 + 35);
-      Str = a1;
-      do
-      {
-        if ( *Str )
-        {
-          v79.DrawText(v82, 100, v34, 0, Str, 0, 0, 0);
-          v34 += v82->CalcTextHeight(Str, &v79, 100, 0) + 3;
-        }
-        Str += 100;
-        --a2.y;
-      }
-      while ( a2.y );
-      v35 = item_desc->pDescription;
-      if ( *v35 )
-        v79.DrawText(pFontSmallnum, 100, v34, 0, v35, 0, 0, 0);
-      v79.uFrameX += 12;
-      v79.uFrameWidth -= 24;
-      v36 = _this->GetIdentifiedName();
-      v79.DrawTitleText(pFontArrus, 0, 0xCu, var88, v36, 3u);
-      v79.uFrameWidth += 24;
-      v79.uFrameX -= 12;
-      if ( v77 )
-      {
-        sprintf(pTmpBuf, "%s: %lu", pGlobalTXT_LocalizationStrings[465], v77);
-        v40 = v82;
-        v61 = 0;
-        v56 = 0;
-        v51 = 0;
-        v47 = pTmpBuf;
-        v44 = 0;
-        v42 = v79.uFrameHeight - LOBYTE(v82->uFontHeight);
-        v41 = 100;
-      }
-      else
+    
+
+    if ( inspect_item->uEncantmentType )
+     {
+        sprintf(out_text + 200, "%s: %s +%d", pGlobalTXT_LocalizationStrings[210],
+             pItemsTable->pEnchantments[inspect_item->uEncantmentType-1].pOfName, inspect_item->_bonus_strength); //"Special"
+    }
+    else  if ( inspect_item->uSpecEnchantmentType )
       {
-        if ( _this->uAttributes & 8 && (_this->uSpecEnchantmentType || _this->uEncantmentType) )
-        {
-          sub_493F79(&v67, _this->uExpireTime - pParty->uTimePlayed);
-          strcpy(pTmpBuf, "Duration:");
-          Str = (char *)(v67.field_18_expire_year - game_starting_year);
-          if (v67.field_18_expire_year != 1168 )
-          {
-            sprintf(v65, " %d:yr", v67.field_18_expire_year - game_starting_year);
-            strcat(pTmpBuf, v65);
-          }
-          if ( (((v67.field_14_exprie_month || Str) && ((sprintf(v65, " %d:mo", v67.field_14_exprie_month), strcat(pTmpBuf, v65), v67.field_14_exprie_month) || Str) || v67.field_C_expire_day)
-             && ((sprintf(v65, " %d:dy", v67.field_C_expire_day), strcat(pTmpBuf, v65), v67.field_14_exprie_month) || Str || v67.field_C_expire_day)
-             || v67.field_8_expire_hour)
-            && ((sprintf(v65, " %d:hr", v67.field_8_expire_hour), strcat(pTmpBuf, v65), v67.field_14_exprie_month) || Str || v67.field_C_expire_day || v67.field_8_expire_hour)
-            || v67.field_4_expire_minute )
-          {
-            sprintf(v65, " %d:mn", v67.field_4_expire_minute);
-            strcat(pTmpBuf, v65);
-          }
-          v79.DrawText(v82, 100, v79.uFrameHeight - 2 * LOBYTE(v82->uFontHeight), 0, pTmpBuf, 0, 0, 0);
-        }
-        v37 = _this->GetValue();
-        sprintf(pTmpBuf, "%s: %lu", pGlobalTXT_LocalizationStrings[465], v37);
-        v79.DrawText(v82, 100, v79.uFrameHeight - LOBYTE(v82->uFontHeight), 0, pTmpBuf, 0, 0, 0);
-        v38 = _this->uAttributes;
-        if ( BYTE1(v38) & 1 )
-        {
-          v61 = 0;
-          v56 = 0;
-          v51 = 0;
-          v47 = pGlobalTXT_LocalizationStrings[187];
-        }
-        else
-        {
-          if ( !(BYTE1(v38) & 2) )
-            goto LABEL_116;
-          v61 = 0;
-          v56 = 0;
-          v51 = 0;
-          v47 = pGlobalTXT_LocalizationStrings[651];
-        }
-        LOWORD(v38) = LOWORD(pRenderer->uTargetRMask);
-        v44 = v38;
-        v42 = v79.uFrameHeight - LOBYTE(v82->uFontHeight);
-        v39 = v82->GetLineWidth(pTmpBuf);
-        v40 = v82;
-        v41 = v39 + 132;
+      
+          
+        sprintf(out_text + 200, "%s: %s", pGlobalTXT_LocalizationStrings[210], 
+            pItemsTable->pSpecialEnchantments[inspect_item->uSpecEnchantmentType-1].pNameAdd, inspect_item->_bonus_strength);
       }
-      v79.DrawText(v40, v41, v42, v44, v47, v51, v56, v61);
+    
+    else if ( inspect_item->uNumCharges )
+        {
+        sprintf(out_text + 200, "%s: %lu", pGlobalTXT_LocalizationStrings[464], inspect_item->uNumCharges); //"Charges"
+
+        }
+
+LABEL_65:
+    wHintWindow.uFrameWidth -= 12;
+    v85 = 3;
+    wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1;
+    wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1;
+    Str = (char *)(3 * (LOBYTE(pFontArrus->uFontHeight) + 8));
+    v84 = &out_text[0];
+    do
+        {
+        if ( *v84 )
+            {
+            v27 = pFontComic->CalcTextHeight(v84, &wHintWindow, 100, 0);
+            Str += v27 + 3;
+            }
+        v84 += 100;
+        --v85;
+        }
+        while ( v85 );
+        v28 = item_desc->pDescription;
+        if ( *v28 )
+            {
+            v29 = pFontSmallnum->CalcTextHeight(v28, &wHintWindow, 100, 0);
+            Str += v29;
+            }
+        wHintWindow.uFrameHeight = v73->uTextureHeight + v81 + 54;
+        if ( (signed int)Str > (signed int)wHintWindow.uFrameHeight )
+            wHintWindow.uFrameHeight = (unsigned int)Str;
+        if ( inspect_item->uAttributes & 8 && (inspect_item->uSpecEnchantmentType || inspect_item->uEncantmentType) )
+            wHintWindow.uFrameHeight += LOBYTE(pFontComic->uFontHeight);
+        v85 = 0;
+        if ( pFontArrus->uFontHeight )
+            {
+            wHintWindow.uFrameWidth -= 24;
+            v30 = pFontArrus->uFontHeight;
+            v31 = inspect_item->GetIdentifiedName();
+            if ( pFontArrus->CalcTextHeight(v31, &wHintWindow, 0, 0) / (signed int)v30 )
+                v85 = v30;
+            wHintWindow.uFrameWidth += 24;
+            }
+        wHintWindow.uFrameWidth += 12;
+        wHintWindow.uFrameHeight += (unsigned int)v85;
+        wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1;
+        wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1;
+        wHintWindow.DrawMessageBox(0);
+        //v15 = pRenderer;
+        pRenderer->Clip(wHintWindow.uFrameX + 12,                   wHintWindow.uFrameY + 12,
+            wHintWindow.uFrameX + wHintWindow.uFrameWidth - 12, wHintWindow.uFrameY + wHintWindow.uFrameHeight - 12);
+        wHintWindow.uFrameWidth -= 12;
+        v32 = v73->uTextureHeight;
+        v33 = wHintWindow.uFrameHeight;
+        wHintWindow.uFrameHeight -= 12;
+        wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1;
+        wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1;
+        pRenderer->DrawTextureTransparent(
+            wHintWindow.uFrameX + v78,
+            wHintWindow.uFrameY + (signed int)(v33 - v32) / 2,
+            v73);
+        
+        v34 = (int)(v85 + 35);
+         v85 = 3;
+        Str = out_text;
+        do
+            {
+            if ( *Str )
+                {
+                wHintWindow.DrawText(pFontComic, 100, v34, 0, Str, 0, 0, 0);
+                v34 += pFontComic->CalcTextHeight(Str, &wHintWindow, 100, 0) + 3;
+                }
+            Str += 100;
+            --v85;
+            }
+            while (v85 );
+            v35 = item_desc->pDescription;
+            if ( *v35 )
+                wHintWindow.DrawText(pFontSmallnum, 100, v34, 0, v35, 0, 0, 0);
+            wHintWindow.uFrameX += 12;
+            wHintWindow.uFrameWidth -= 24;
+            v36 = inspect_item->GetIdentifiedName();
+            wHintWindow.DrawTitleText(pFontArrus, 0, 0xCu, var88, v36, 3u);
+            wHintWindow.uFrameWidth += 24;
+            wHintWindow.uFrameX -= 12;
+            if ( v77 )
+                {
+                sprintf(pTmpBuf, "%s: %lu", pGlobalTXT_LocalizationStrings[465], v77);//"Value"
+                v40 = pFontComic;
+                v61 = 0;
+                v56 = 0;
+                v51 = 0;
+                v47 = pTmpBuf;
+                v44 = 0;
+                v42 = wHintWindow.uFrameHeight - LOBYTE(pFontComic->uFontHeight);
+                v41 = 100;
+                }
+            else
+                {
+                if ( (inspect_item->uAttributes & 8) && (inspect_item->uSpecEnchantmentType || inspect_item->uEncantmentType) )
+                    {
+                    sub_493F79(&v67, inspect_item->uExpireTime - pParty->uTimePlayed);
+                    strcpy(pTmpBuf, "Duration:");
+                    Str = (char *)(v67.field_18_expire_year - game_starting_year);
+                    if (v67.field_18_expire_year != 1168 )
+                        {
+                        sprintf(v65, " %d:yr", v67.field_18_expire_year - game_starting_year);
+                        strcat(pTmpBuf, v65);
+                        }
+                    if ( (((v67.field_14_exprie_month || Str) && 
+                        ((sprintf(v65, " %d:mo", v67.field_14_exprie_month), strcat(pTmpBuf, v65), v67.field_14_exprie_month) || Str) 
+                        || v67.field_C_expire_day)
+                        && ((sprintf(v65, " %d:dy", v67.field_C_expire_day), strcat(pTmpBuf, v65), v67.field_14_exprie_month) || Str || 
+                        v67.field_C_expire_day)
+                        || v67.field_8_expire_hour)
+                        && ((sprintf(v65, " %d:hr", v67.field_8_expire_hour), strcat(pTmpBuf, v65), v67.field_14_exprie_month) || Str || 
+                        v67.field_C_expire_day || v67.field_8_expire_hour)
+                        || v67.field_4_expire_minute )
+                        {
+                        sprintf(v65, " %d:mn", v67.field_4_expire_minute);
+                        strcat(pTmpBuf, v65);
+                        }
+                    wHintWindow.DrawText(pFontComic, 100, wHintWindow.uFrameHeight - 2 * LOBYTE(pFontComic->uFontHeight), 0, pTmpBuf, 0, 0, 0);
+                    }
+                v37 = inspect_item->GetValue();
+                sprintf(pTmpBuf, "%s: %lu", pGlobalTXT_LocalizationStrings[465], v37);
+                wHintWindow.DrawText(pFontComic, 100, wHintWindow.uFrameHeight - LOBYTE(pFontComic->uFontHeight), 0, pTmpBuf, 0, 0, 0);
+                v38 = inspect_item->uAttributes;
+                if ( BYTE1(v38) & 1 )
+                    {
+                    v61 = 0;
+                    v56 = 0;
+                    v51 = 0;
+                    v47 = pGlobalTXT_LocalizationStrings[187]; //"Stolen"
+                    }
+                else
+                    {
+                    if ( !(BYTE1(v38) & 2) )
+                        goto LABEL_116;
+                    v61 = 0;
+                    v56 = 0;
+                    v51 = 0;
+                    v47 = pGlobalTXT_LocalizationStrings[651]; //"Hardened"
+                    }
+                LOWORD(v38) = LOWORD(pRenderer->uTargetRMask);
+                v44 = v38;
+                v42 = wHintWindow.uFrameHeight - LOBYTE(pFontComic->uFontHeight);
+                v39 = pFontComic->GetLineWidth(pTmpBuf);
+                v40 = pFontComic;
+                v41 = v39 + 132;
+                }
+            wHintWindow.DrawText(v40, v41, v42, v44, v47, v51, v56, v61);
 LABEL_116:
-      pRenderer->ResetClip();
-      if ( !areWeLoadingTexture )
-      {
-        v73->Release();
-        pIcons_LOD->_40F9C5();
-      }
-      return;
-    }
-    if (item_desc->uEquipType == 13)
-    {
-      v24 = pItemsTable->pItems[_this->uItemID].uDamageDice;
-LABEL_56:
-      v59 = v24;
-      v54 = pGlobalTXT_LocalizationStrings[449];
-      v49 = "%s: %d";
-LABEL_64:
-      sprintf(a1 + 200, v49, v54, v59);
-      goto LABEL_65;
-    }
-    v25 = _this->uEncantmentType;
-    if ( v25 )
-    {
-      v60 = _this->_bonus_strength;
-      v55 = *((int *)&pItemsTable->pItems[799].uDamageMod + 5 * v25);
-      v50 = pGlobalTXT_LocalizationStrings[210];
-      v46 = "%s: %s +%d";
-    }
-    else
-    {
-      v26 = _this->uSpecEnchantmentType;
-      if ( !v26 )
-      {
-        if ( _this->uNumCharges )
-        {
-          v59 = _this->uNumCharges;
-          v54 = pGlobalTXT_LocalizationStrings[464];
-          v49 = "%s: %lu";
-          goto LABEL_64;
-        }
-        goto LABEL_65;
-      }
-      v60 = _this->_bonus_strength;
-      v55 = *((int *)&pItemsTable->pEnchantments[23].pBonusStat + 7 * v26);
-      v50 = pGlobalTXT_LocalizationStrings[210];
-      v46 = "%s: %s";
-    }
-    sprintf(a1 + 200, v46, v50, v55, v60);
-    goto LABEL_65;
+            pRenderer->ResetClip();
+            if ( !areWeLoadingTexture )
+                {
+                v73->Release();
+                pIcons_LOD->_40F9C5();
+                }
+            return;
 }
 // 4E455C: using guessed type int dword_4E455C;
 // 506128: using guessed type int areWeLoadingTexture;
 
+
 //----- (0041E360) --------------------------------------------------------
 char *__fastcall MonsterPopup_Draw(unsigned int uActorID, GUIWindow *edx0)
 {
@@ -3817,7 +3801,7 @@
     if ( v1 )
     {
       auto _w = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C
-                                             + 18 * *((short *)&pChests[0].mm7__vector_pItems[139].uExpireTime
+                                             + 18 * *((short *)&pChests[0].igChestItems[139].uExpireTime
                                                + v1 + 2662 * (unsigned int)pChestWindow->ptr_1C + 3));
       v2 = _w->GetDisplayName();
       sub_41C0B8_set_status_string(v2);
@@ -3825,85 +3809,6 @@
   }
 }
 
-//----- (00420B13) --------------------------------------------------------
-void __fastcall sub_420B13(int a1, int a2)
-{
-  void *v2; // eax@1
-  ItemGen *v3; // ebx@1
-  unsigned int v4; // eax@1
-  Texture *v5; // ecx@1
-  signed int v6; // eax@1
-  signed int v7; // edi@3
-  signed int v8; // eax@3
-  int v9; // edi@3
-  int v10; // eax@5
-  int v11; // esi@8
-  unsigned int v12; // ecx@10
-  void *v13; // edi@10
-  unsigned __int8 v14; // cf@10
-  int v15; // edi@10
-  int i; // ecx@10
-  int v17; // [sp+Ch] [bp-14h]@1
-  int v18; // [sp+10h] [bp-10h]@3
-  int v19; // [sp+14h] [bp-Ch]@1
-  void *v20; // [sp+18h] [bp-8h]@1
-  int v21; // [sp+1Ch] [bp-4h]@5
-  int v22; // [sp+1Ch] [bp-4h]@8
-
-  v19 = a2;
-  v2 = pChestWindow->ptr_1C;
-  v20 = v2;
-  v2 = (void *)(5324 * (int)v2);
-  v3 = (ItemGen *)((char *)v2 + 36 * a1 + (int)((char *)pChests + 4));
-  v17 = pChestWidthsByType[*(short *)((char *)v2 + (int)pChests)];
-  v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v3->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-  v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0);
-  v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24);
-  if ( v6 < 14 )
-    v6 = 14;
-  v7 = v6 - 14;
-  v8 = v5->uTextureHeight;
-  v9 = (v7 >> 5) + 1;
-  v18 = v9;
-  if ( v8 < 14 )
-    v8 = 14;
-  v10 = ((v8 - 14) >> 5) + 1;
-  v21 = v10;
-  if ( !areWeLoadingTexture )
-  {
-    v5->Release();
-    pIcons_LOD->_40F9C5();
-    v10 = v21;
-  }
-  if ( v10 > 0 )
-  {
-    v11 = 0;
-    v22 = v10;
-    do
-    {
-      if ( v9 > 0 )
-      {
-        v12 = v9;
-        v13 = &pChests[0].pInventoryIndices[v19 + v11 + 2662 * (int)v20];
-        v14 = v12 & 1;
-        v12 >>= 1;
-        memset(v13, 0, 4 * v12);
-        v15 = (int)((char *)v13 + 4 * v12);
-        for ( i = v14; i; --i )
-        {
-          *(short *)v15 = 0;
-          v15 += 2;
-        }
-        v9 = v18;
-      }
-      v11 += v17;
-      --v22;
-    }
-    while ( v22 );
-  }
-  v3->Reset();
-}
-// 506128: using guessed type int areWeLoadingTexture;
 
 //----- (00420C05) --------------------------------------------------------
 void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal)
@@ -4017,23 +3922,23 @@
 //----- (00420E01) --------------------------------------------------------
 void __cdecl sub_420E01()
 {
-  void *v0; // edi@1
+  int chest_id; // edi@1
   POINT *v1; // esi@2
   int v2; // eax@2
   int v3; // ebx@4
   int v4; // esi@6
   int v5; // ecx@6
   //SpriteObject v6; // [sp+Ch] [bp-80h]@1
-  char v7; // [sp+7Ch] [bp-10h]@2
+  POINT v7; // [sp+7Ch] [bp-10h]@2
   POINT a2; // [sp+84h] [bp-8h]@2
   
   SpriteObject v6; // [sp+Ch] [bp-80h]@1
   //SpriteObject::SpriteObject(&v6);
 
-  v0 = pGUIWindow_CurrentMenu->ptr_1C;
+  chest_id = pGUIWindow_CurrentMenu->par1C;
   if ( pParty->pPickedItem.uItemID )
   {
-    if ( Chest::_41FFA2(-1, &pParty->pPickedItem, (unsigned int)pGUIWindow_CurrentMenu->ptr_1C) )
+    if ( Chest::PutItemInChest(-1, &pParty->pPickedItem, pGUIWindow_CurrentMenu->par1C) )
       pMouse->RemoveHoldingItem();
   }
   else
@@ -4046,16 +3951,15 @@
         v3 = v2 - 1;
       else
         v3 = -1;
-      v4 = pChests[0].pInventoryIndices[v3 + 2662 * (int)v0] - 1;
-      v5 = 5324 * (int)v0 + 36 * v4;
-      if ( pItemsTable->pItems[*(unsigned int *)((char *)&pChests[0].mm7__vector_pItems[0].uItemID + v5)].uEquipType == 18 )
+      v4 = pChests[chest_id].pInventoryIndices[v3] - 1;
+      if ( pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uEquipType == 18 )
       {
-        party_finds_gold(*(int *)((char *)&pChests[0].mm7__vector_pItems[0].uSpecEnchantmentType + v5), 0);
+        party_finds_gold(pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uValue, 0); //recheck
         viewparams->bRedrawGameUI = 1;
       }
       else
       {
-        pParty->SetHoldingItem((ItemGen *)((char *)pChests[0].mm7__vector_pItems + v5));
+        pParty->SetHoldingItem(&pChests[chest_id].igChestItems[v4]);
       }
       sub_420B13(v4, v3);
     }
@@ -5468,7 +5372,7 @@
         pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID);
         pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchC");
         pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID);
-        pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_506438], "ib-bcu-c", 2);
+        pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-c", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc-c", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven-c", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2);
@@ -5504,7 +5408,7 @@
         uTextureID_Btn_Rest = pIcons_LOD->LoadTexture("ib-m2d-c", TEXTURE_16BIT_PALETTE);
         uTextureID_Btn_QuickReference = pIcons_LOD->LoadTexture("ib-m3d-c", TEXTURE_16BIT_PALETTE);
         uTextureID_Btn_GameSettings = pIcons_LOD->LoadTexture("ib-m4d-c", TEXTURE_16BIT_PALETTE);
-        uTextureID_506438 = pIcons_LOD->LoadTexture("ib-bcu-c", TEXTURE_16BIT_PALETTE);
+        uExitCancelTextureId = pIcons_LOD->LoadTexture("ib-bcu-c", TEXTURE_16BIT_PALETTE);
         dword_50796C = pIcons_LOD->LoadTexture("isg-01-c", TEXTURE_16BIT_PALETTE);
         dword_507968 = pIcons_LOD->LoadTexture("isg-02-c", TEXTURE_16BIT_PALETTE);
         dword_507964 = pIcons_LOD->LoadTexture("isg-03-c", TEXTURE_16BIT_PALETTE);
@@ -5553,7 +5457,7 @@
         pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID);
         pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchA");
         pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID);
-        pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_506438], "ib-bcu-a", 2);
+        pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-a", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven", 2);
         pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2);
@@ -5589,7 +5493,7 @@
         uTextureID_Btn_GameSettings = pIcons_LOD->LoadTexture("ib-m4d-a", TEXTURE_16BIT_PALETTE);
         uTextureID_Btn_ZoomIn = pIcons_LOD->LoadTexture("ib-autout-a", TEXTURE_16BIT_PALETTE);
         uTextureID_Btn_ZoomOut = pIcons_LOD->LoadTexture("ib-autin-a", TEXTURE_16BIT_PALETTE);
-        uTextureID_506438 = pIcons_LOD->LoadTexture("ib-bcu-a", TEXTURE_16BIT_PALETTE);
+        uExitCancelTextureId = pIcons_LOD->LoadTexture("ib-bcu-a", TEXTURE_16BIT_PALETTE);
         dword_50796C = pIcons_LOD->LoadTexture("isg-01-a", TEXTURE_16BIT_PALETTE);
         dword_507968 = pIcons_LOD->LoadTexture("isg-02-a", TEXTURE_16BIT_PALETTE);
         dword_507964 = pIcons_LOD->LoadTexture("isg-03-a", TEXTURE_16BIT_PALETTE);
@@ -5649,7 +5553,7 @@
       pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnim_WizardEye->uIconID);
       pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchB");
       pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID);
-      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_506438], "ib-bcu-b", 2);
+      pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uExitCancelTextureId], "ib-bcu-b", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_50795C], "evtnpc-b", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507958], "fr_inven-b", 2);
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Parchment], "parchment", 2);
--- a/mm7_2.cpp	Mon Mar 04 20:28:08 2013 +0200
+++ b/mm7_2.cpp	Mon Mar 04 20:29:31 2013 +0200
@@ -150,141 +150,144 @@
   v30 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
   sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[605], pParty->uFine);
   _this.DrawTitleText(pFontArrus, 0, 0x104u, v30, pTmpBuf, 3u);
-  if ( dword_F8B19C == 1 )
-  {
-    v11 = 1;
-    pOutString = 0;
-    pShopOptions[0] = pGlobalTXT_LocalizationStrings[604];
-    if ( pParty->uFine )
-    {
-      pShopOptions[1] = pGlobalTXT_LocalizationStrings[603];
-      v11 = 2;
-    }
-    for ( i = 0; i < v11; ++i )
-    {
-      v13 = pFontArrus->CalcTextHeight(pShopOptions[i], &_this, 0, 0);
-      pOutString = (GUIFont *)((char *)pOutString + v13);
-    }
-    v29 = (100 - (signed int)pOutString) / v11;
-    v14 = pDialogueWindow;
-    v15 = 80 - v11 * (100 - (signed int)pOutString) / v11 - (signed int)pOutString;
-    v16 = v15 - HIDWORD(v15);
-    LODWORD(v15) = pDialogueWindow->pStartingPosActiveItem;
-    HIDWORD(v15) = v15 + pDialogueWindow->pNumPresenceButton;
-    v17 = (v16 >> 1) - v29 / 2 + 158;
-    v18 = -pDialogueWindow->pNumPresenceButton < 0;
-    pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem;
-    if ( v18 ^ __OFSUB__((int)v15, HIDWORD(v15)) )
-    {
-      v31 = 2;
-      v19 = pShopOptions;
-      do
-      {
-        v20 = v14->GetControl((unsigned int)pOutString);
-        v21 = v20;
-        v20->uY = v29 + v17;
-        v22 = pFontArrus->CalcTextHeight(*v19, &_this, 0, 0);
-        v23 = v21->uY;
-        v21->uHeight = v22;
-        v17 = v23 + v22 - 1;
-        v21->uW = v17;
-        v24 = v30;
-        if ( pDialogueWindow->pCurrentPosActiveItem != v31 )
-          v24 = v28;
-        _this.DrawTitleText(pFontArrus, 0, v23, v24, *v19, 3u);
-        v14 = pDialogueWindow;
-        ++v31;
-        ++v19;
-        pOutString = (GUIFont *)((char *)pOutString + 1);
-      }
-      while ( (signed int)pOutString < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
-    }
-  }
-  else
-  {
-    if ( dword_F8B19C != 99 )
-    {
-      if ( dword_F8B19C != 100 )
-        return;
-      v0 = window_SpeakInHouse;
-      if ( window_SpeakInHouse->field_40 == 1 )
-      {
-        sprintf(pTmpBuf, "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]);
-        _this.DrawTitleText(pFontArrus, 0, 0x92u, v30, pTmpBuf, 3u);
-        _this.DrawTitleText(pFontArrus, 0, 0xBAu, v28, (const char *)pKeyActionMap->pPressedKeysBuffer, 3u);
-        v3 = pFontArrus;
-        v4 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
-        _this.DrawFlashingInputCursor(v4 / 2 + 80, 185, v3);
-        return;
-      }
-      if ( window_SpeakInHouse->field_40 == 2 )
-      {
-        v1 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
-        v2 = v1;
-        if ( v1 <= 0 )
-        {
-LABEL_8:
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-          /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-          {
-            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
-            pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
-            *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-            ++pMessageQueue_50CBD0->uNumMessages;
-          }*/
-          return;
-        }
-        if ( v1 > pParty->uNumGold )
-        {
-          HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
-          v2 = pParty->uNumGold;
-        }
-        if ( v2 > pParty->uFine )
-          v2 = pParty->uFine;
-        Party::TakeGold(v2);
-        pParty->uFine -= v2;
-        if ( pParty->uFine < 0 )
-          pParty->uFine = 0;
-        if ( uActiveCharacter )
-          pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0);
-        v0 = window_SpeakInHouse;
-      }
-      else
-      {
-        if ( window_SpeakInHouse->field_40 != 3 )
-          return;
-      }
-      v0->field_40 = 0;
-      goto LABEL_8;
-    }
-    v5 = &pMonsterStats->pInfos[word_F8B1A0];
-    v6 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-    v7 = v5->pName;
-    v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-    sprintf(pTmpBuf, &byte_4F0F98, v8, v7, v6);
-    sprintf(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * v5->uLevel);
-    ptr_F8B1E8 = pTmpBuf2;
-    memcpy(&a1, pDialogueWindow, sizeof(a1));
-    w.uFrameWidth = 458;
-    w.uFrameZ = 457;
-    pOutString = pFontArrus;
-    v9 = pFontArrus->CalcTextHeight(pTmpBuf2, &w, 13, 0) + 7;
-    if ( 352 - v9 < 8 )
-    {
-      pOutString = pFontCreate;
-      v9 = pFontCreate->CalcTextHeight(ptr_F8B1E8, &w, 13, 0) + 7;
-    }
-
-    auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0);
-    pRenderer->_4A6A68(
-      8u,
-      352 - v9,
-      pTex,
-      (pTex ? pTex->uTextureHeight : 26) - v9);
-    pRenderer->DrawTextureIndexed(8u, 347 - v9, pTexture_591428);
-    v10 = FitTextInAWindow(ptr_F8B1E8, pOutString, &w, 0xDu, 0);
-    a1.DrawText(pOutString, 13, 354 - v9, 0, v10, 0, 0, 0);
-  }
+  switch(dword_F8B19C)
+  {
+	case 1:
+		{
+		v11 = 1;
+		pOutString = 0;
+		pShopOptions[0] = pGlobalTXT_LocalizationStrings[604];
+		if ( pParty->uFine )
+		{
+			pShopOptions[1] = pGlobalTXT_LocalizationStrings[603];
+			v11 = 2;
+		}
+		for ( i = 0; i < v11; ++i )
+		{
+			v13 = pFontArrus->CalcTextHeight(pShopOptions[i], &_this, 0, 0);
+			pOutString = (GUIFont *)((char *)pOutString + v13);
+		}
+		v29 = (100 - (signed int)pOutString) / v11;
+		v14 = pDialogueWindow;
+		v15 = 80 - v11 * (100 - (signed int)pOutString) / v11 - (signed int)pOutString;
+		v16 = v15 - HIDWORD(v15);
+		LODWORD(v15) = pDialogueWindow->pStartingPosActiveItem;
+		HIDWORD(v15) = v15 + pDialogueWindow->pNumPresenceButton;
+		v17 = (v16 >> 1) - v29 / 2 + 158;
+		v18 = -pDialogueWindow->pNumPresenceButton < 0;
+		pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem;
+		if ( v18 ^ __OFSUB__((int)v15, HIDWORD(v15)) )
+		{
+			v31 = 2;
+			v19 = pShopOptions;
+			do
+			{
+				v20 = v14->GetControl((unsigned int)pOutString);
+				v21 = v20;
+				v20->uY = v29 + v17;
+				v22 = pFontArrus->CalcTextHeight(*v19, &_this, 0, 0);
+				v23 = v21->uY;
+				v21->uHeight = v22;
+				v17 = v23 + v22 - 1;
+				v21->uW = v17;
+				v24 = v30;
+				if ( pDialogueWindow->pCurrentPosActiveItem != v31 )
+					v24 = v28;
+				_this.DrawTitleText(pFontArrus, 0, v23, v24, *v19, 3u);
+				v14 = pDialogueWindow;
+				++v31;
+				++v19;
+				pOutString = (GUIFont *)((char *)pOutString + 1);
+			}
+			while ( (signed int)pOutString < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
+		}
+		break;
+		}
+	case 99:
+		{
+		v5 = &pMonsterStats->pInfos[word_F8B1A0];
+		v6 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+		v7 = v5->pName;
+		v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+		sprintf(pTmpBuf, &byte_4F0F98, v8, v7, v6);
+		sprintf(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * v5->uLevel);
+		ptr_F8B1E8 = pTmpBuf2;
+		memcpy(&a1, pDialogueWindow, sizeof(a1));
+		w.uFrameWidth = 458;
+		w.uFrameZ = 457;
+		pOutString = pFontArrus;
+		v9 = pFontArrus->CalcTextHeight(pTmpBuf2, &w, 13, 0) + 7;
+		if ( 352 - v9 < 8 )
+		{
+			pOutString = pFontCreate;
+			v9 = pFontCreate->CalcTextHeight(ptr_F8B1E8, &w, 13, 0) + 7;
+		}
+
+		auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0);
+		pRenderer->_4A6A68(8u, 352 - v9, pTex, (pTex ? pTex->uTextureHeight : 26) - v9);
+		pRenderer->DrawTextureIndexed(8u, 347 - v9, pTexture_591428);
+		v10 = FitTextInAWindow(ptr_F8B1E8, pOutString, &w, 0xDu, 0);
+		a1.DrawText(pOutString, 13, 354 - v9, 0, v10, 0, 0, 0);
+		break;
+		}
+	case 100:
+		{
+		v0 = window_SpeakInHouse;
+		if ( window_SpeakInHouse->field_40 == 1 )
+		{
+			sprintf(pTmpBuf, "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]);
+			_this.DrawTitleText(pFontArrus, 0, 0x92u, v30, pTmpBuf, 3u);
+			_this.DrawTitleText(pFontArrus, 0, 0xBAu, v28, (const char *)pKeyActionMap->pPressedKeysBuffer, 3u);
+			v3 = pFontArrus;
+			v4 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
+			_this.DrawFlashingInputCursor(v4 / 2 + 80, 185, v3);
+			return;
+		}
+		if ( window_SpeakInHouse->field_40 == 2 )
+		{
+			v1 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
+			v2 = v1;
+			if ( v1 <= 0 )
+			{
+			//LABEL_8:
+				pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+				/*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+				{
+				pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
+				pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
+				*(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+				++pMessageQueue_50CBD0->uNumMessages;
+				}*/
+				return;
+			}
+			if ( v1 > pParty->uNumGold )
+			{
+				HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
+				v2 = pParty->uNumGold;
+			}
+			if ( v2 > pParty->uFine )
+				v2 = pParty->uFine;
+			Party::TakeGold(v2);
+			pParty->uFine -= v2;
+			if ( pParty->uFine < 0 )
+				pParty->uFine = 0;
+			if ( uActiveCharacter )
+				pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0);
+			v0 = window_SpeakInHouse;
+		}
+		if ( window_SpeakInHouse->field_40 == 3 )
+		{
+			v0->field_40 = 0;
+			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+		}
+		break;
+		}
+	default:
+		{
+		break;
+		}
+  }
+  return;
 }
 // F8B19C: using guessed type int dword_F8B19C;
 // F8B1A0: using guessed type __int16 word_F8B1A0;
@@ -316,105 +319,127 @@
   *(int *)v14 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
   sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[25], pParty->uNumGoldInBank);
   _this.DrawTitleText(pFontArrus, 0, 0xDCu, v14[0], pTmpBuf, 3u);
-  if ( dword_F8B19C != 1 )
-  {
-    if ( dword_F8B19C == 7 )
-    {
-      v0 = window_SpeakInHouse;
-      if ( window_SpeakInHouse->field_40 != 1 )
-      {
-        v1 = window_SpeakInHouse->field_40 - 2;
-        if ( window_SpeakInHouse->field_40 == 2 )
-        {
-          v6 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
-          v7 = v6;
-          if ( !v6 )
-          {
-LABEL_17:
-            pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-            /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-            {
-              pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
-              pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
-              *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-              ++pMessageQueue_50CBD0->uNumMessages;
-            }*/
-            return;
-          }
-          if ( v6 > pParty->uNumGold )
-          {
-            HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
-            v7 = pParty->uNumGold;
-          }
-          if ( v7 )
-          {
-            Party::TakeGold(v7);
-            pParty->uNumGoldInBank += v7;
-            if ( uActiveCharacter )
-              pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0);
-          }
-          v0 = window_SpeakInHouse;
-LABEL_16:
-          v0->field_40 = 0;
-          goto LABEL_17;
-        }
-LABEL_15:
-        if ( v1 != 1 )
-          return;
-        goto LABEL_16;
-      }
-      v11 = pGlobalTXT_LocalizationStrings[112];
-      v10 = pGlobalTXT_LocalizationStrings[60];
-    }
-    else
-    {
-      if ( dword_F8B19C != 8 )
-        return;
-      v0 = window_SpeakInHouse;
-      if ( window_SpeakInHouse->field_40 != 1 )
-      {
-        v1 = window_SpeakInHouse->field_40 - 2;
-        if ( window_SpeakInHouse->field_40 == 2 )
-        {
-          window_SpeakInHouse->field_40 = 0;
-          v2 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
-          v3 = v2;
-          if ( v2 )
-          {
-            if ( v2 > pParty->uNumGoldInBank )
-            {
-              HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
-              v3 = pParty->uNumGoldInBank;
-            }
-            if ( v3 )
-            {
-              Party::SetGold(pParty->uNumGold + v3);
-              pParty->uNumGoldInBank -= v3;
-            }
-          }
-          goto LABEL_17;
-        }
-        goto LABEL_15;
-      }
-      v11 = pGlobalTXT_LocalizationStrings[112];
-      v10 = pGlobalTXT_LocalizationStrings[244];
-    }
-    sprintf(pTmpBuf, "%s\n%s", v10, v11);
-    _this.DrawTitleText(pFontArrus, 0, 0x92u, v14[0], pTmpBuf, 3u);
-    _this.DrawTitleText(pFontArrus, 0, 0xBAu, v13[0], (const char *)pKeyActionMap->pPressedKeysBuffer, 3u);
-    v4 = pFontArrus;
-    v5 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
-    _this.DrawFlashingInputCursor(v5 / 2 + 80, 185, v4);
-    return;
-  }
-  v8 = v14[0];
-  if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
-    v8 = v13[0];
-  _this.DrawTitleText(pFontArrus, 0, 0x92u, v8, pGlobalTXT_LocalizationStrings[60], 3u);
-  v9 = v14[0];
-  if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
-    v9 = v13[0];
-  _this.DrawTitleText(pFontArrus, 0, 0xB0u, v9, pGlobalTXT_LocalizationStrings[244], 3u);
+  switch(dword_F8B19C)
+  {
+	case 1:
+		{
+		v8 = v14[0];
+		if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
+			v8 = v13[0];
+		_this.DrawTitleText(pFontArrus, 0, 0x92u, v8, pGlobalTXT_LocalizationStrings[60], 3u);
+		v9 = v14[0];
+		if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
+			v9 = v13[0];
+		_this.DrawTitleText(pFontArrus, 0, 0xB0u, v9, pGlobalTXT_LocalizationStrings[244], 3u);
+		break;
+		}
+	case 7:
+		{
+		v0 = window_SpeakInHouse;
+		if ( window_SpeakInHouse->field_40 != 1 )
+		{
+			v1 = window_SpeakInHouse->field_40 - 2;
+			if ( window_SpeakInHouse->field_40 == 2 )
+			{
+				v6 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
+				v7 = v6;
+				if ( !v6 )
+				{
+//LABEL_17:
+					pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+					/*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+					{
+						pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
+						pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
+						*(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+						++pMessageQueue_50CBD0->uNumMessages;
+					}*/
+					return;
+				}
+				if ( v6 > pParty->uNumGold )
+				{
+					HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
+					v7 = pParty->uNumGold;
+				}
+				if ( v7 )
+				{
+					Party::TakeGold(v7);
+					pParty->uNumGoldInBank += v7;
+					if ( uActiveCharacter )
+						pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0);
+				}
+				v0 = window_SpeakInHouse;
+				v0->field_40 = 0;
+				pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+				return;
+			}
+			if ( v1 != 1 )
+				return;
+			v0->field_40 = 0;
+			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+			return;      
+		}
+		v11 = pGlobalTXT_LocalizationStrings[112];
+		v10 = pGlobalTXT_LocalizationStrings[60];
+		sprintf(pTmpBuf, "%s\n%s", v10, v11);
+		_this.DrawTitleText(pFontArrus, 0, 0x92u, v14[0], pTmpBuf, 3u);
+		_this.DrawTitleText(pFontArrus, 0, 0xBAu, v13[0], (const char *)pKeyActionMap->pPressedKeysBuffer, 3u);
+		v4 = pFontArrus;
+		v5 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
+		_this.DrawFlashingInputCursor(v5 / 2 + 80, 185, v4);
+		break;
+		}
+
+	case 8:
+		{
+		v0 = window_SpeakInHouse;
+		if ( window_SpeakInHouse->field_40 != 1 )
+		{
+			v1 = window_SpeakInHouse->field_40 - 2;
+			if ( window_SpeakInHouse->field_40 == 2 )
+			{
+				window_SpeakInHouse->field_40 = 0;
+				v2 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer);
+				v3 = v2;
+				if ( v2 )
+				{
+					if ( v2 > pParty->uNumGoldInBank )
+					{
+						HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
+						v3 = pParty->uNumGoldInBank;
+					}
+					if ( v3 )
+					{
+						Party::SetGold(pParty->uNumGold + v3);
+						pParty->uNumGoldInBank -= v3;
+					}
+				}
+				pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+				return;
+			}
+			if ( v1 != 1 )
+				return;
+			v0->field_40 = 0;
+			pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+			return;  
+		}
+		v11 = pGlobalTXT_LocalizationStrings[112];
+		v10 = pGlobalTXT_LocalizationStrings[244];
+		sprintf(pTmpBuf, "%s\n%s", v10, v11);
+		_this.DrawTitleText(pFontArrus, 0, 0x92u, v14[0], pTmpBuf, 3u);
+		_this.DrawTitleText(pFontArrus, 0, 0xBAu, v13[0], (const char *)pKeyActionMap->pPressedKeysBuffer, 3u);
+		v4 = pFontArrus;
+		v5 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer);
+		_this.DrawFlashingInputCursor(v5 / 2 + 80, 185, v4);
+		return;
+		break;
+		}
+
+	default:
+		{
+		break;
+		}
+  }
 }
 // F8B19C: using guessed type int dword_F8B19C;
 
@@ -545,41 +570,57 @@
     v7 = 1;
     v83 = 1;
   }
-  if ( dword_F8B19C > 101 )
-  {
-    if ( dword_F8B19C == 102 )
-    {
-      v65 = pFontArrus;
-      pOutString = pFontArrus;
-      strcpy(pTmpBuf, pNPCTopics[354].pText);
-      v78.uFrameWidth = 460;
-      v78.uFrameZ = 452;
-      v62 = v65->CalcTextHeight(pTmpBuf, &v78, 12, 0) + 7;
-      if ( 352 - v62 < 8 )
-      {
-        pOutString = pFontCreate;
-        v62 = pFontCreate->CalcTextHeight(pTmpBuf, &v78, 12, 0) + 7;
-      }
-
-      auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0);
-      pRenderer->_4A6A68(
-        8u,
-        352 - v62,
-        pTex,
-        (pTex ? pTex->uTextureHeight : 26) - v62);
-
-      pRenderer->DrawTextureIndexed(8u, 347 - v62, pTexture_591428);
-      v73 = 0;
-      v70 = 0;
-      v68 = 0;
-      v63 = FitTextInAWindow(pTmpBuf, pOutString, &v78, 0xCu, 0);
-      v64 = pOutString;
-    }
-    else
-    {
-      if ( dword_F8B19C != 103 )
-      {
-        if ( dword_F8B19C != 104 || pArcomageGame->bGameInProgress == 1 )
+  switch(dword_F8B19C)
+  {
+	case 102:
+		{
+		v65 = pFontArrus;
+		pOutString = pFontArrus;
+		strcpy(pTmpBuf, pNPCTopics[354].pText);
+		v78.uFrameWidth = 460;
+		v78.uFrameZ = 452;
+		v62 = v65->CalcTextHeight(pTmpBuf, &v78, 12, 0) + 7;
+		if ( 352 - v62 < 8 )
+		{
+			pOutString = pFontCreate;
+			v62 = pFontCreate->CalcTextHeight(pTmpBuf, &v78, 12, 0) + 7;
+		}
+
+		auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0);
+		pRenderer->_4A6A68(8u, 352 - v62, pTex, (pTex ? pTex->uTextureHeight : 26) - v62);
+
+		pRenderer->DrawTextureIndexed(8u, 347 - v62, pTexture_591428);
+		v73 = 0;
+		v70 = 0;
+		v68 = 0;
+		v63 = FitTextInAWindow(pTmpBuf, pOutString, &v78, 0xCu, 0);
+		v64 = pOutString;
+		window_SpeakInHouse->DrawText(v64, 12, 354 - v62, 0, v63, v68, v70, v73);
+		break;
+		}
+	case 103:
+		{
+		strcpy(pTmpBuf, pNPCTopics[(uint)window_SpeakInHouse->ptr_1C + 247].pText);
+		v78.uFrameWidth = 460;
+		v78.uFrameZ = 452;
+		v61 = pFontArrus->CalcTextHeight(pTmpBuf, &v78, 12, 0);
+		v62 = v61 + 7;
+
+		auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : nullptr);
+		pRenderer->_4A6A68(8u, 352 - (v61 + 7), pTex, (pTex ? pTex->uTextureHeight : 26) - (v61 + 7));
+
+		pRenderer->DrawTextureIndexed(8u, 347 - v62, pTexture_591428);
+		v73 = 0;
+		v70 = 0;
+		v68 = 0;
+		v63 = FitTextInAWindow(pTmpBuf, pFontArrus, &v78, 0xCu, 0);
+		v64 = pFontArrus;
+		window_SpeakInHouse->DrawText(v64, 12, 354 - v62, 0, v63, v68, v70, v73);
+		break;
+		}
+	case 104:
+		{
+		if ( pArcomageGame->bGameInProgress == 1 )
           return;
         v26 = pTmpBuf;
         if ( pArcomageGame->uGameResult )
@@ -594,42 +635,16 @@
           v72 = pGlobalTXT_LocalizationStrings[639];// A tie!
         }
         strcpy(pTmpBuf, v72);
-LABEL_97:
+//LABEL_97:
         v71 = 3;
         v69 = v26;
         v67 = v84[0];
         v66 = (174 - pFontArrus->CalcTextHeight(v26, &v79, 0, 0)) / 2 + 138;
-        goto LABEL_98;
-      }
-      strcpy(pTmpBuf, pNPCTopics[(uint)window_SpeakInHouse->ptr_1C + 247].pText);
-      v78.uFrameWidth = 460;
-      v78.uFrameZ = 452;
-      v61 = pFontArrus->CalcTextHeight(pTmpBuf, &v78, 12, 0);
-      v62 = v61 + 7;
-
-      auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : nullptr);
-      pRenderer->_4A6A68(
-        8u,
-        352 - (v61 + 7),
-        pTex,
-        (pTex ? pTex->uTextureHeight : 26) - (v61 + 7));
-
-      pRenderer->DrawTextureIndexed(8u, 347 - v62, pTexture_591428);
-      v73 = 0;
-      v70 = 0;
-      v68 = 0;
-      v63 = FitTextInAWindow(pTmpBuf, pFontArrus, &v78, 0xCu, 0);
-      v64 = pFontArrus;
-    }
-    window_SpeakInHouse->DrawText(v64, 12, 354 - v62, 0, v63, v68, v70, v73);
-    return;
-  }
-  if ( dword_F8B19C != 101 )
-  {
-    if ( dword_F8B19C != 1 )
-    {
-      if ( dword_F8B19C == 15 )
-      {
+        v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71);
+		break;
+		}
+	case 15:
+		{
         if ( pParty->uNumGold >= (unsigned int)pOutString )
         {
           Party::TakeGold((unsigned int)pOutString);
@@ -652,96 +667,106 @@
           ++pMessageQueue_50CBD0->uNumMessages;
           return;
         }
-      }
-      else
-      {
-        if ( dword_F8B19C != 16 )
-        {
-          if ( dword_F8B19C != 96 || !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
-            return;
-          v8 = pDialogueWindow;
-          *(float *)&v89 = 0.0;
-
-          //v9 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0);
-          v9 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
-
-          pOutString = (GUIFont *)(v9 * (100 - v85->GetMerchant()) / 100);
-          if ( (signed int)pOutString < v9 / 3 )
-            pOutString = (GUIFont *)(v9 / 3);
-          v10 = v8->pStartingPosActiveItem;
-          v11 = v10 + v8->pNumPresenceButton;
-          v86 = 0;
-          if ( (signed int)v10 < v11 )
-          {
-            do
-            {
-              v12 = v8->GetControl(v10)->uControlParam - 36;
-              if ( byte_4ED970_skill_learn_ability_by_class_table[v85->classType][v12] && !v85->pActiveSkills[v12] )
-              {
-                v13 = pFontArrus->CalcTextHeight(pSkillNames[v12], &v79, 0, 0);
-                v89 += v13;
-                ++v86;
-              }
-              ++v10;
-            }
-            while ( (signed int)v10 < v8->pStartingPosActiveItem + v8->pNumPresenceButton );
-            if ( v86 )
-            {
-              sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], pOutString);
-              v79.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
-              pOutString = (GUIFont *)((149 - v89) / v86);
-              if ( (149 - v89) / v86 > 32 )
-                pOutString = (GUIFont *)32;
-              v14 = (149 - v86 * (signed int)pOutString - v89) / 2 - (signed int)pOutString / 2 + 162;
-              v89 = v8->pStartingPosActiveItem;
-              v83 = v14;
-              if ( v89 < v89 + v8->pNumPresenceButton )
-              {
-                v86 = 2;
-                do
-                {
-                  v15 = v8->GetControl(v89);
-                  v16 = v15;
-                  v17 = v15->uControlParam - 36;
-                  if ( !byte_4ED970_skill_learn_ability_by_class_table[v85->classType][v17] || v85->pActiveSkills[v17] )
-                  {
-                    v16->uW = 0;
-                    v16->uHeight = 0;
-                    v16->uY = 0;
-                  }
-                  else
-                  {
-                    v18 = pSkillNames[v17];
-                    v16->uY = (unsigned int)((char *)pOutString + v83);
-                    Str[1] = v18;
-                    v19 = pFontArrus->CalcTextHeight(v18, &v79, 0, 0);
-                    v20 = v16->uY;
-                    v21 = v86;
-                    v16->uHeight = v19;
-                    v22 = v19 + v20 - 1;
-                    v16->uW = v22;
-                    v83 = v22;
-                    v23 = v84[0];
-                    if ( pDialogueWindow->pCurrentPosActiveItem != v21 )
-                      v23 = v81;
-                    v79.DrawTitleText(pFontArrus, 0, v20, v23, Str[1], 3u);
-                  }
-                  v24 = v8->pNumPresenceButton;
-                  ++v89;
-                  v25 = v8->pStartingPosActiveItem + v24;
-                  ++v86;
-                }
-                while ( v89 < v25 );
-              }
-              return;
-            }
-          }
-          v26 = pTmpBuf;
-          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v85->pName, pClassNames[v85->classType]);
-          strcat(pTmpBuf, "\n \n");
-          strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
-          goto LABEL_97;
-        }
+		ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
+        HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 4);
+        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0);
+		break;
+		}
+	case 96:
+		{
+		if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
+			return;
+		v8 = pDialogueWindow;
+		*(float *)&v89 = 0.0;
+
+		//v9 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0);
+		v9 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
+
+		pOutString = (GUIFont *)(v9 * (100 - v85->GetMerchant()) / 100);
+		if ( (signed int)pOutString < v9 / 3 )
+			pOutString = (GUIFont *)(v9 / 3);
+		v10 = v8->pStartingPosActiveItem;
+		v11 = v10 + v8->pNumPresenceButton;
+		v86 = 0;
+		if ( (signed int)v10 < v11 )
+		{
+			do
+			{
+				v12 = v8->GetControl(v10)->uControlParam - 36;
+				if ( byte_4ED970_skill_learn_ability_by_class_table[v85->classType][v12] && !v85->pActiveSkills[v12] )
+				{
+					v13 = pFontArrus->CalcTextHeight(pSkillNames[v12], &v79, 0, 0);
+					v89 += v13;
+					++v86;
+				}
+				++v10;
+			}
+			while ( (signed int)v10 < v8->pStartingPosActiveItem + v8->pNumPresenceButton );
+			if ( v86 )
+			{
+				sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], pOutString);
+				v79.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
+				pOutString = (GUIFont *)((149 - v89) / v86);
+				if ( (149 - v89) / v86 > 32 )
+					pOutString = (GUIFont *)32;
+				v14 = (149 - v86 * (signed int)pOutString - v89) / 2 - (signed int)pOutString / 2 + 162;
+				v89 = v8->pStartingPosActiveItem;
+				v83 = v14;
+				if ( v89 < v89 + v8->pNumPresenceButton )
+				{
+					v86 = 2;
+					do
+					{
+						v15 = v8->GetControl(v89);
+						v16 = v15;
+						v17 = v15->uControlParam - 36;
+						if ( !byte_4ED970_skill_learn_ability_by_class_table[v85->classType][v17] || v85->pActiveSkills[v17] )
+						{
+							v16->uW = 0;
+							v16->uHeight = 0;
+							v16->uY = 0;
+						}
+						else
+						{
+							v18 = pSkillNames[v17];
+							v16->uY = (unsigned int)((char *)pOutString + v83);
+							Str[1] = v18;
+							v19 = pFontArrus->CalcTextHeight(v18, &v79, 0, 0);
+							v20 = v16->uY;
+							v21 = v86;
+							v16->uHeight = v19;
+							v22 = v19 + v20 - 1;
+							v16->uW = v22;
+							v83 = v22;
+							v23 = v84[0];
+							if ( pDialogueWindow->pCurrentPosActiveItem != v21 )
+								v23 = v81;
+							v79.DrawTitleText(pFontArrus, 0, v20, v23, Str[1], 3u);
+						}
+						v24 = v8->pNumPresenceButton;
+						++v89;
+						v25 = v8->pStartingPosActiveItem + v24;
+						++v86;
+					}
+					while ( v89 < v25 );
+				}
+				return;
+			}
+		}
+		v26 = pTmpBuf;
+		sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v85->pName, pClassNames[v85->classType]);
+		strcat(pTmpBuf, "\n \n");
+		strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
+		v71 = 3;
+		v69 = v26;
+		v67 = v84[0];
+		v66 = (174 - pFontArrus->CalcTextHeight(v26, &v79, 0, 0)) / 2 + 138;
+		v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71);
+		return;
+		break;
+		}
+	case 16:
+		{
         *(_QWORD *)Str = pParty->uNumFoodRations;
         //if ( (double)pParty->uNumFoodRations >= p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C] )
         if ( (double)pParty->uNumFoodRations >= p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier )
@@ -749,7 +774,8 @@
           ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2u);
           if ( uActiveCharacter )
             pPlayers[uActiveCharacter]->PlaySound(SPEECH_67, 0);
-          goto LABEL_43;
+          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0);
+          return;
         }
         if ( pParty->uNumGold >= v7 )
         {
@@ -758,172 +784,193 @@
           pParty->uNumFoodRations = (signed __int64)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
           HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 3);
           v5 = 1;
-LABEL_43:
+//LABEL_43:
           pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0);
           return;
           //goto LABEL_51;
         }
-      }
-      ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
-      HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 4);
-      goto LABEL_43;
-    }
-    if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
-      return;
-    v28 = *(int *)v84;
-    if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
-      v28 = v81;
-    sprintf(Dest, format_4E2DC8, v28);
-    sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[178], pOutString);
-    strcat(Dest, pTmpBuf2);
-    v90 = pFontArrus->CalcTextHeight(Dest, &v79, 0, 0);
-    strcat(Dest, "\n \n");
-    v29 = *(int *)v84;
-    if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
-      v29 = v81;
-    sprintf(a1, format_4E2DC8, v29);
-    sprintf(pTmpBuf2,
-      pGlobalTXT_LocalizationStrings[86],
-      //(signed __int64)p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C],
-      (signed __int64)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier,
-      v83);
-    strcat(a1, pTmpBuf2);
-    v88 = pFontArrus->CalcTextHeight(a1, &v79, 0, 0);
-    strcat(a1, "\n \n");
-    v30 = *(int *)v84;
-    if ( pDialogueWindow->pCurrentPosActiveItem != 4 )
-      v30 = v81;
-    sprintf(v77, format_4E2DC8, v30);
-    strcat(v77, pGlobalTXT_LocalizationStrings[160]);
-    v82 = pFontArrus->CalcTextHeight(v77, &v79, 0, 0);
-    strcat(v77, "\n \n");
-    v75[0] = 0;
-    v87 = 0;
-    v31 = (signed int)window_SpeakInHouse->ptr_1C;
-    if ( v31 >= 108 && v31 <= 120 )
-    {
-      v32 = *(int *)v84;
-      if ( pDialogueWindow->pCurrentPosActiveItem != 5 )
-        v32 = v81;
-      sprintf(v75, format_4E2DC8, v32);
-      strcat(v75, pGlobalTXT_LocalizationStrings[611]);
-      v87 = pFontArrus->CalcTextHeight(v75, &v79, 0, 0);
-    }
-    v33 = pDialogueWindow;
-    Str[1] = (char *)pDialogueWindow;
-    v34 = pDialogueWindow->pStartingPosActiveItem;
-    v35 = v34 + pDialogueWindow->pNumPresenceButton;
-    v36 = LOBYTE(pFontArrus->uFontHeight) - 3;
-    v37 = -pDialogueWindow->pNumPresenceButton < 0;
-    pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem;
-    if ( !(v37 ^ __OFSUB__(v34, v35)) )
-    {
-LABEL_75:
-      sprintf(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75);
-      v71 = 3;
-      v69 = pTmpBuf;
-      v67 = 0;
-      v66 = 146;
-LABEL_98:
-      v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71);
-      return;
-    }
-    while ( 1 )
-    {
-      v38 = v33->GetControl((unsigned int)pOutString);
-      if ( v38->uControlParam == 15 )
-      {
-        v46 = v90;
-        v38->uHeight = v90;
-        v38->uY = 146;
-        v41 = v46 + 145;
-        goto LABEL_73;
-      }
-      if ( v38->uControlParam == 16 )
-      {
-        v44 = v88;
-        v45 = v90 + v36 + 146;
-        v38->uHeight = v88;
-        v38->uY = v45;
-        v41 = v45 + v44 - 1;
-        goto LABEL_73;
-      }
-      if ( v38->uControlParam == 96 )
-        break;
-      if ( v38->uControlParam == 101 )
-      {
-        v39 = v90 + 3 * v36 + v87 + v88 + 146;
-        v33 = (GUIWindow *)Str[1];
-        v40 = v87;
-        v38->uHeight = v87;
-        v38->uY = v39;
-        v41 = v39 + v40 - 1;
-LABEL_73:
-        v38->uW = v41;
-      }
-      v47 = v33->pStartingPosActiveItem;
-      pOutString = (GUIFont *)((char *)pOutString + 1);
-      if ( (signed int)pOutString >= v33->pNumPresenceButton + v47 )
-        goto LABEL_75;
-    }
-    v42 = v90 + v88 + 2 * v36 + 146;
-    v43 = v82;
-    v38->uY = v42;
-    v38->uHeight = v43;
-    v41 = v43 + v42 - 1;
-    goto LABEL_73;
-  }
-  if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
-  {
-    v48 = 2;
-    pShopOptions[0] = pGlobalTXT_LocalizationStrings[620];
-    pOutString = 0;
-    pShopOptions[1] = pGlobalTXT_LocalizationStrings[622];
-    if ( pParty->HasItem(0x28Bu) )
-    {
-      pShopOptions[2] = pGlobalTXT_LocalizationStrings[621];
-      v48 = 3;
-    }
-    for ( i = 0; i < v48; ++i )
-    {
-      v50 = pFontArrus->CalcTextHeight(pShopOptions[i], &v79, 0, 0);
-      pOutString = (GUIFont *)((char *)pOutString + v50);
-    }
-    v86 = (174 - (signed int)pOutString) / v48;
-    v51 = pDialogueWindow;
-    v52 = 174 - v48 * (174 - (signed int)pOutString) / v48 - (signed int)pOutString;
-    v53 = v52 - HIDWORD(v52);
-    LODWORD(v52) = pDialogueWindow->pStartingPosActiveItem;
-    HIDWORD(v52) = v52 + pDialogueWindow->pNumPresenceButton;
-    v54 = (v53 >> 1) - v86 / 2 + 138;
-    v37 = -pDialogueWindow->pNumPresenceButton < 0;
-    v89 = pDialogueWindow->pStartingPosActiveItem;
-    if ( v37 ^ __OFSUB__((int)v52, HIDWORD(v52)) )
-    {
-      v85 = (Player *)2;
-      pOutString = (GUIFont *)pShopOptions;
-      do
-      {
-        v55 = v51->GetControl(v89);
-        v56 = (const char **)pOutString;
-        v55->uY = v86 + v54;
-        v57 = pFontArrus->CalcTextHeight(*v56, &v79, 0, 0);
-        v58 = v55->uY;
-        v59 = v85;
-        v55->uHeight = v57;
-        v54 = v57 + v58 - 1;
-        v55->uW = v54;
-        v60 = v84[0];
-        if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v59 )
-          v60 = v81;
-        v79.DrawTitleText(pFontArrus, 0, v58, v60, *(const char **)&pOutString->cFirstChar, 3u);
-        v51 = pDialogueWindow;
-        v85 = (Player *)((char *)v85 + 1);
-        pOutString = (GUIFont *)((char *)pOutString + 4);
-        ++v89;
-      }
-      while ( v89 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
-    }
+		ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
+        HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 4);
+        pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0);
+		break;
+		}
+	case 1:
+		{
+		if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
+		  return;
+		v28 = *(int *)v84;
+		if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
+		  v28 = v81;
+		sprintf(Dest, format_4E2DC8, v28);
+		sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[178], pOutString);
+		strcat(Dest, pTmpBuf2);
+		v90 = pFontArrus->CalcTextHeight(Dest, &v79, 0, 0);
+		strcat(Dest, "\n \n");
+		v29 = *(int *)v84;
+		if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
+		  v29 = v81;
+		sprintf(a1, format_4E2DC8, v29);
+		sprintf(pTmpBuf2,
+		  pGlobalTXT_LocalizationStrings[86],
+		  //(signed __int64)p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C],
+		  (signed __int64)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier,
+		  v83);
+		strcat(a1, pTmpBuf2);
+		v88 = pFontArrus->CalcTextHeight(a1, &v79, 0, 0);
+		strcat(a1, "\n \n");
+		v30 = *(int *)v84;
+		if ( pDialogueWindow->pCurrentPosActiveItem != 4 )
+		  v30 = v81;
+		sprintf(v77, format_4E2DC8, v30);
+		strcat(v77, pGlobalTXT_LocalizationStrings[160]);
+		v82 = pFontArrus->CalcTextHeight(v77, &v79, 0, 0);
+		strcat(v77, "\n \n");
+		v75[0] = 0;
+		v87 = 0;
+		v31 = (signed int)window_SpeakInHouse->ptr_1C;
+		if ( v31 >= 108 && v31 <= 120 )
+		{
+		  v32 = *(int *)v84;
+		  if ( pDialogueWindow->pCurrentPosActiveItem != 5 )
+			v32 = v81;
+		  sprintf(v75, format_4E2DC8, v32);
+		  strcat(v75, pGlobalTXT_LocalizationStrings[611]);
+		  v87 = pFontArrus->CalcTextHeight(v75, &v79, 0, 0);
+		}
+		v33 = pDialogueWindow;
+		Str[1] = (char *)pDialogueWindow;
+		v34 = pDialogueWindow->pStartingPosActiveItem;
+		v35 = v34 + pDialogueWindow->pNumPresenceButton;
+		v36 = LOBYTE(pFontArrus->uFontHeight) - 3;
+		v37 = -pDialogueWindow->pNumPresenceButton < 0;
+		pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem;
+		if ( !(v37 ^ __OFSUB__(v34, v35)) )
+		{
+	//LABEL_75:
+		  sprintf(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75);
+		  v71 = 3;
+		  v69 = pTmpBuf;
+		  v67 = 0;
+		  v66 = 146;
+	//LABEL_98:
+		  v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71);
+		  return;
+		}
+		while ( 1 )
+		{
+		  v38 = v33->GetControl((unsigned int)pOutString);
+		  if ( v38->uControlParam == 15 )
+		  {
+			v46 = v90;
+			v38->uHeight = v90;
+			v38->uY = 146;
+			v41 = v46 + 145;
+			v38->uW = v41;
+		  }
+		  else if ( v38->uControlParam == 16 )
+		  {
+			v44 = v88;
+			v45 = v90 + v36 + 146;
+			v38->uHeight = v88;
+			v38->uY = v45;
+			v41 = v45 + v44 - 1;
+			v38->uW = v41;
+		  }
+		  else if ( v38->uControlParam == 96 )
+		  {
+			v42 = v90 + v88 + 2 * v36 + 146;
+			v43 = v82;
+			v38->uY = v42;
+			v38->uHeight = v43;
+			v41 = v43 + v42 - 1;
+			v38->uW = v41;
+		  }
+		  else if ( v38->uControlParam == 101 )
+		  {
+			v39 = v90 + 3 * v36 + v87 + v88 + 146;
+			v33 = (GUIWindow *)Str[1];
+			v40 = v87;
+			v38->uHeight = v87;
+			v38->uY = v39;
+			v41 = v39 + v40 - 1;
+	//LABEL_73:
+			v38->uW = v41;
+		  }
+		  v47 = v33->pStartingPosActiveItem;
+		  pOutString = (GUIFont *)((char *)pOutString + 1);
+		  if ( (signed int)pOutString >= v33->pNumPresenceButton + v47 )
+		  {
+			  sprintf(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75);
+			  v71 = 3;
+			  v69 = pTmpBuf;
+			  v67 = 0;
+			  v66 = 146;
+			  v79.DrawTitleText(pFontArrus, 0, v66, v67, v69, v71);
+			  return;
+		  }
+		}
+		break;
+		}
+	case 101:
+		{
+		if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
+		{
+			v48 = 2;
+			pShopOptions[0] = pGlobalTXT_LocalizationStrings[620];
+			pOutString = 0;
+			pShopOptions[1] = pGlobalTXT_LocalizationStrings[622];
+			if ( pParty->HasItem(0x28Bu) )
+			{
+				pShopOptions[2] = pGlobalTXT_LocalizationStrings[621];
+				v48 = 3;
+			}
+			for ( i = 0; i < v48; ++i )
+			{
+				v50 = pFontArrus->CalcTextHeight(pShopOptions[i], &v79, 0, 0);
+				pOutString = (GUIFont *)((char *)pOutString + v50);
+			}
+			v86 = (174 - (signed int)pOutString) / v48;
+			v51 = pDialogueWindow;
+			v52 = 174 - v48 * (174 - (signed int)pOutString) / v48 - (signed int)pOutString;
+			v53 = v52 - HIDWORD(v52);
+			LODWORD(v52) = pDialogueWindow->pStartingPosActiveItem;
+			HIDWORD(v52) = v52 + pDialogueWindow->pNumPresenceButton;
+			v54 = (v53 >> 1) - v86 / 2 + 138;
+			v37 = -pDialogueWindow->pNumPresenceButton < 0;
+			v89 = pDialogueWindow->pStartingPosActiveItem;
+			if ( v37 ^ __OFSUB__((int)v52, HIDWORD(v52)) )
+			{
+				v85 = (Player *)2;
+				pOutString = (GUIFont *)pShopOptions;
+				do
+				{
+					v55 = v51->GetControl(v89);
+					v56 = (const char **)pOutString;
+					v55->uY = v86 + v54;
+					v57 = pFontArrus->CalcTextHeight(*v56, &v79, 0, 0);
+					v58 = v55->uY;
+					v59 = v85;
+					v55->uHeight = v57;
+					v54 = v57 + v58 - 1;
+					v55->uW = v54;
+					v60 = v84[0];
+					if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v59 )
+						v60 = v81;
+					v79.DrawTitleText(pFontArrus, 0, v58, v60, *(const char **)&pOutString->cFirstChar, 3u);
+					v51 = pDialogueWindow;
+					v85 = (Player *)((char *)v85 + 1);
+					pOutString = (GUIFont *)((char *)pOutString + 4);
+					++v89;
+				}
+				while ( v89 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
+			}
+		}
+		break;
+		}
+	default:
+		{
+		break;
+		}
   }
 }
 
@@ -1669,66 +1716,65 @@
   v104.uFrameZ = 334;
   v108 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
   v106 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
-  if ( dword_F8B19C == 1 )
-  {
-    result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-    if ( result )
-    {
-      pShopOptions[0] = pGlobalTXT_LocalizationStrings[134];
-      pShopOptions[1] = pGlobalTXT_LocalizationStrings[152];
-      pShopOptions[2] = pGlobalTXT_LocalizationStrings[159];
-      v72 = 0;
-      pShopOptions[3] = pGlobalTXT_LocalizationStrings[160];
-      v73 = pShopOptions;
-      do
-      {
-        v74 = pFontArrus->CalcTextHeight(*v73, &v104, 0, 0);
-        ++v73;
-        v72 += v74;
-      }
-      while ( (signed int)v73 < (signed int)&unk_F8B1C8 );
-      v75 = pDialogueWindow;
-      Str = (char *)((174 - v72) / 4);
-      result = (POINT *)pDialogueWindow->pStartingPosActiveItem;
-      v76 = (int)((char *)result + pDialogueWindow->pNumPresenceButton);
-      v77 = (174 - 4 * (174 - v72) / 4 - v72) / 2 - (174 - v72) / 4 / 2 + 138;
-      v28 = -pDialogueWindow->pNumPresenceButton < 0;
-      v112 = pDialogueWindow->pStartingPosActiveItem;
-      if ( v28 ^ __OFSUB__((int)result, v76) )
-      {
-        _this = (Player *)2;
-        v111 = (const char **)pShopOptions;
-        do
-        {
-          v78 = v75->GetControl(v112);
-          v79 = v111;
-          v78->uY = (unsigned int)&Str[v77];
-          v80 = pFontArrus->CalcTextHeight(*v79, &v104, 0, 0);
-          v81 = v78->uY;
-          v82 = _this;
-          v78->uHeight = v80;
-          v77 = v81 + v80 - 1;
-          v78->uW = v77;
-          v83 = v106;
-          if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v82 )
-            v83 = v108;
-          v104.DrawTitleText(pFontArrus, 0, v81, v83, *v111, 3u);
-          v75 = pDialogueWindow;
-          _this = (Player *)((char *)_this + 1);
-          ++v111;
-          ++v112;
-          result = (POINT *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
-        }
-        while ( (signed int)v112 < (signed int)result );
-      }
-    }
-  }
-  else
-  {
-    if ( dword_F8B19C != 2 )
-    {
-      if ( dword_F8B19C == 3 )
-      {
+  switch(dword_F8B19C)
+  {
+	case 1:
+		{
+		result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
+		if ( result )
+		{
+		  pShopOptions[0] = pGlobalTXT_LocalizationStrings[134];
+		  pShopOptions[1] = pGlobalTXT_LocalizationStrings[152];
+		  pShopOptions[2] = pGlobalTXT_LocalizationStrings[159];
+		  v72 = 0;
+		  pShopOptions[3] = pGlobalTXT_LocalizationStrings[160];
+		  v73 = pShopOptions;
+		  do
+		  {
+			v74 = pFontArrus->CalcTextHeight(*v73, &v104, 0, 0);
+			++v73;
+			v72 += v74;
+		  }
+		  while ( (signed int)v73 < (signed int)&unk_F8B1C8 );
+		  v75 = pDialogueWindow;
+		  Str = (char *)((174 - v72) / 4);
+		  result = (POINT *)pDialogueWindow->pStartingPosActiveItem;
+		  v76 = (int)((char *)result + pDialogueWindow->pNumPresenceButton);
+		  v77 = (174 - 4 * (174 - v72) / 4 - v72) / 2 - (174 - v72) / 4 / 2 + 138;
+		  v28 = -pDialogueWindow->pNumPresenceButton < 0;
+		  v112 = pDialogueWindow->pStartingPosActiveItem;
+		  if ( v28 ^ __OFSUB__((int)result, v76) )
+		  {
+			_this = (Player *)2;
+			v111 = (const char **)pShopOptions;
+			do
+			{
+			  v78 = v75->GetControl(v112);
+			  v79 = v111;
+			  v78->uY = (unsigned int)&Str[v77];
+			  v80 = pFontArrus->CalcTextHeight(*v79, &v104, 0, 0);
+			  v81 = v78->uY;
+			  v82 = _this;
+			  v78->uHeight = v80;
+			  v77 = v81 + v80 - 1;
+			  v78->uW = v77;
+			  v83 = v106;
+			  if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v82 )
+				v83 = v108;
+			  v104.DrawTitleText(pFontArrus, 0, v81, v83, *v111, 3u);
+			  v75 = pDialogueWindow;
+			  _this = (Player *)((char *)_this + 1);
+			  ++v111;
+			  ++v112;
+			  result = (POINT *)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem);
+			}
+			while ( (signed int)v112 < (signed int)result );
+		  }
+		}
+		return result;
+		}
+	case 3:
+		{
         draw_leather();
         CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
         DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);
@@ -1750,11 +1796,19 @@
         v45 = _this->_490EEE(v87, 4, v44, 3);
         v39 = v113;
         v38 = (char *)pMerchantsSellPhrases[v45];
-        goto LABEL_45;
-      }
-      if ( dword_F8B19C == 4 )
-      {
-        draw_leather();
+        v21 = BuilDialogueString(v38, v39, v87, (char *)v89, v91, v93);
+        v92 = 3;
+        v90 = v21;
+        v88 = v108;
+        v86 = v3;
+        v85 = v3;
+        v84 = &v104;
+        v40 = pFontArrus->CalcTextHeight(v21, v84, v85, v86);
+        return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92);
+		}
+	case 4:
+		{
+		draw_leather();
         CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
         DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);
         result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
@@ -1778,14 +1832,14 @@
           v42 = _this->_490EEE(v37, 4, v41, 4);
           v39 = v113;
           v38 = (char *)pMerchantsIdentifyPhrases[v42];
-          goto LABEL_45;
-        }
-        v89 = window_SpeakInHouse->ptr_1C;
-        v38 = "%24";
-        v87 = v37;
-LABEL_44:
-        v39 = uActiveCharacter - 1;
-LABEL_45:
+        }
+		else
+		{
+			v89 = window_SpeakInHouse->ptr_1C;
+			v38 = "%24";
+			v87 = v37;
+	        v39 = uActiveCharacter - 1;
+		}
         v21 = BuilDialogueString(v38, v39, v87, (char *)v89, v91, v93);
         v92 = 3;
         v90 = v21;
@@ -1793,11 +1847,12 @@
         v86 = v3;
         v85 = v3;
         v84 = &v104;
-        goto LABEL_46;
-      }
-      if ( dword_F8B19C == 94 )
-      {
-        draw_leather();
+        v40 = pFontArrus->CalcTextHeight(v21, v84, v85, v86);
+        return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92);
+		}
+	case 94:
+		{
+		draw_leather();
         CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
         pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];
         pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];
@@ -1846,13 +1901,294 @@
           while ( (signed int)v112 < (signed int)result );
         }
         return result;
-      }
-      if ( dword_F8B19C != 95 )
-      {
-        result = (POINT *)(dword_F8B19C - 96);
-        if ( dword_F8B19C != 96
-          || (result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) == 0 )
-          return result;
+		}
+	case 2:
+		{
+		pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
+		v3 = 0;
+		v114 = 0;
+		do
+		{
+			// if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
+			if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID);
+			{
+				v46 = ItemsInShopTexture[v114];
+				v47 = 152 - v46->uTextureHeight;
+				if ( (signed int)v47 < 1 )
+					v47 = 0;
+				v48 = 75 * v114 - v46->uTextureWidth / 2 + 40;
+				if ( v114 )
+				{
+					if ( v114 == 5 )
+					{
+						v49 = ItemsInShopTexture[5]->uTextureWidth;
+						if ( (signed int)v48 > 457 - v49 )
+						v48 = 457 - v49;
+					}
+				}
+				else if ( (signed int)v48 < 18 )
+					v48 = 18;
+				pRenderer->DrawTextureTransparent(v48, v47, v46);
+				sub_40F92A(&pRenderer->pActiveZBuffer[v48 + 640 * v47], ItemsInShopTexture[v114], v114 + 1);
+	        }
+			++v114;
+		}
+		while ( v114 < 6 );
+		v114 = 0;
+		do
+		{
+			//  if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] )
+			if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114+1].uItemID);
+			{
+			  v50 = ItemsInShopTexture[v114 + 6];
+			  v51 = 308 - v50->uTextureHeight;
+			  if ( (signed int)v51 < 1 )
+				v51 = 0;
+			  v52 = 75 * v114 - v50->uTextureWidth / 2 + 40;
+			  if ( v114 )
+			  {
+				if ( v114 == 5 )
+				{
+				  v53 = ItemsInShopTexture[11]->uTextureWidth;
+				  if ( (signed int)v52 > 457 - v53 )
+					v52 = 457 - v53;
+				}
+			  }
+			  else
+			  {
+				if ( (signed int)v52 < 18 )
+				  v52 = 18;
+			  }
+			  pRenderer->DrawTextureTransparent(v52, v51, v50);
+			  sub_40F92A(&pRenderer->pActiveZBuffer[v52 + 640 * v51], ItemsInShopTexture[v114 + 6], v114 + 7);
+			}
+			++v114;
+		}
+		while ( v114 < 6 );
+		result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
+		if ( result )
+		{
+			v62 = 0;
+			v109 = 0;
+			do
+			{
+			 // if ( pParty->field_777C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
+				if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID);
+					++v109;
+				++v62;
+			}
+			while ( v62 < 12 );
+			v63 = GetAsyncKeyState(17);
+			v64 = _this->CanSteal();
+			Str = (char *)v64;
+			if ( v63 && v64 )
+			{
+				v65 = pGlobalTXT_LocalizationStrings[185];
+			}
+			else if ( dword_F8B19C == 2 )
+			{
+				v65 = pGlobalTXT_LocalizationStrings[195];
+			}
+			else
+			{
+				v65 = pGlobalTXT_LocalizationStrings[196];
+			}
+			DrawTextAtStatusBar(v65, 0);
+			if ( !v109 )
+			{
+				v104.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
+				return 0;
+			}
+			v66 = pMouse->GetCursorPos(&v98);
+			result = (POINT *)(v66->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v96)->y]);
+			if ( pRenderer->pActiveZBuffer[(int)result] & 0xFFFF )
+			{
+				v67 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1;
+				v109 = v67;
+				v68 = (int)window_SpeakInHouse->ptr_1C;
+				//  v69 = 9 * (v67 + 12 * v68);
+				v70 = (ItemGen *)&pParty->StandartItemsInShops[v68][v67];
+				if ( dword_F8B19C != 2 )
+					v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724];
+				if ( !v63 || !Str )
+				{
+					v93 = 0;
+					v91 = 2;
+					v89 = window_SpeakInHouse->ptr_1C;
+					v87 = v70;
+					v113 = uActiveCharacter - 1;
+					v71 = _this->_490EEE(v70, 4, v68, 2);
+					v39 = v113;
+					v38 = (char *)pMerchantsBuyPhrases[v71];
+				}
+				else
+				{
+					v38 = pGlobalTXT_LocalizationStrings[181];
+					v93 = 0;
+					v91 = 2;
+					v89 = window_SpeakInHouse->ptr_1C;
+					v87 = v70;
+					v39 = uActiveCharacter - 1;
+				}
+				v21 = BuilDialogueString(v38, v39, v87, (char *)v89, v91, v93);
+				v92 = 3;
+				v90 = v21;
+				v88 = v108;
+				v86 = v3;
+				v85 = v3;
+				v84 = &v104;
+				v40 = pFontArrus->CalcTextHeight(v21, v84, v85, v86);
+				return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92);
+			}
+		}
+		return result;
+		}
+	case 95:
+		{
+		pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
+		v3 = 0;
+		v114 = 0;
+		do
+		{
+			//if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+			if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID)
+			{
+			  v54 = ItemsInShopTexture[v114];
+			  v55 = 152 - v54->uTextureHeight;
+			  if ( (signed int)v55 < 1 )
+				v55 = 0;
+			  v56 = 75 * v114 - v54->uTextureWidth / 2 + 40;
+			  if ( v114 )
+			  {
+				if ( v114 == 5 )
+				{
+				  v57 = ItemsInShopTexture[5]->uTextureWidth;
+				  if ( (signed int)v56 > 457 - v57 )
+					v56 = 457 - v57;
+				}
+			  }
+			  else
+			  {
+				if ( (signed int)v56 < 18 )
+				  v56 = 18;
+			  }
+			  pRenderer->DrawTextureTransparent(v56, v55, v54);
+			  sub_40F92A(&pRenderer->pActiveZBuffer[v56 + 640 * v55], ItemsInShopTexture[v114], v114 + 1);
+			}
+			++v114;
+		}
+		while ( v114 < 6 );
+		v114 = 0;
+		do
+		{
+		// if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 778] )   //weak 
+			if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v114].uItemID) //not itemid
+			{
+				v58 = ItemsInShopTexture[v114 + 6];
+				v59 = 308 - v58->uTextureHeight;
+				if ( (signed int)v59 < 1 )
+				v59 = 0;
+				v60 = 75 * v114 - v58->uTextureWidth / 2 + 40;
+				if ( v114 )
+				{
+					if ( v114 == 5 )
+					{
+						v61 = ItemsInShopTexture[11]->uTextureWidth;
+						if ( (signed int)v60 > 457 - v61 )
+						v60 = 457 - v61;
+					}
+				}
+				else
+				{
+					if ( (signed int)v60 < 18 )
+						v60 = 18;
+				}
+				pRenderer->DrawTextureTransparent(v60, v59, v58);
+				sub_40F92A(&pRenderer->pActiveZBuffer[v60 + 640 * v59], ItemsInShopTexture[v114 + 6], v114 + 7);
+			}
+			++v114;
+		}
+		while ( v114 < 6 );
+		result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
+		if ( result )
+		{
+			v62 = 0;
+			v109 = 0;
+			do
+			{
+				//if ( pParty->field_C59C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+				if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID)
+					++v109;
+				++v62;
+			}
+			while ( v62 < 12 );
+				v63 = GetAsyncKeyState(17);
+			v64 = _this->CanSteal();
+			Str = (char *)v64;
+			if ( v63 && v64 )
+			{
+				v65 = pGlobalTXT_LocalizationStrings[185];
+			}
+			else
+			{
+				v65 = pGlobalTXT_LocalizationStrings[195];
+				if ( dword_F8B19C != 2 )
+					v65 = pGlobalTXT_LocalizationStrings[196];
+			}
+			DrawTextAtStatusBar(v65, 0);
+			if ( !v109 )
+			{
+				v104.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
+				return 0;
+			}
+			v66 = pMouse->GetCursorPos(&v98);
+			result = (POINT *)(v66->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v96)->y]);
+			if ( pRenderer->pActiveZBuffer[(int)result] & 0xFFFF )
+			{
+				v67 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1;
+				v109 = v67;
+				v68 = (int)window_SpeakInHouse->ptr_1C;
+				//  v69 = 9 * (v67 + 12 * v68);
+				v70 = (ItemGen *)&pParty->StandartItemsInShops[v68][v67];
+				if ( dword_F8B19C != 2 )
+					v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724];
+				if ( !v63 || !Str )
+				{
+					v93 = 0;
+					v91 = 2;
+					v89 = window_SpeakInHouse->ptr_1C;
+					v87 = v70;
+					v113 = uActiveCharacter - 1;
+					v71 = _this->_490EEE(v70, 4, v68, 2);
+					v39 = v113;
+					v38 = (char *)pMerchantsBuyPhrases[v71];
+				}
+				else
+				{
+					v38 = pGlobalTXT_LocalizationStrings[181];
+					v93 = 0;
+					v91 = 2;
+					v89 = window_SpeakInHouse->ptr_1C;
+					v87 = v70;
+					v39 = uActiveCharacter - 1;
+				}
+				v21 = BuilDialogueString(v38, v39, v87, (char *)v89, v91, v93);
+				v92 = 3;
+				v90 = v21;
+				v88 = v108;
+				v86 = v3;
+				v85 = v3;
+				v84 = &v104;
+				v40 = pFontArrus->CalcTextHeight(v21, v84, v85, v86);
+				return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92);
+			}
+		}
+		return result;
+		}
+	case 96:
+		{
+        if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win())
+          return 0;
         v2 = pDialogueWindow;
         v3 = 0;
         v4 = window_SpeakInHouse->ptr_1C;
@@ -1941,221 +2277,14 @@
         v86 = 0;
         v85 = 0;
         v84 = &v104;
-LABEL_46:
         v40 = pFontArrus->CalcTextHeight(v21, v84, v85, v86);
         return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92);
-      }
-    }
-    pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
-    v3 = 0;
-    v114 = 0;
-    if ( dword_F8B19C == 2 )
-    {
-      do
-      {
-       // if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
-	  if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID);
-        {
-          v46 = ItemsInShopTexture[v114];
-          v47 = 152 - v46->uTextureHeight;
-          if ( (signed int)v47 < 1 )
-            v47 = 0;
-          v48 = 75 * v114 - v46->uTextureWidth / 2 + 40;
-          if ( v114 )
-          {
-            if ( v114 == 5 )
-            {
-              v49 = ItemsInShopTexture[5]->uTextureWidth;
-              if ( (signed int)v48 > 457 - v49 )
-                v48 = 457 - v49;
-            }
-          }
-          else
-          {
-            if ( (signed int)v48 < 18 )
-              v48 = 18;
-          }
-          pRenderer->DrawTextureTransparent(v48, v47, v46);
-          sub_40F92A(&pRenderer->pActiveZBuffer[v48 + 640 * v47], ItemsInShopTexture[v114], v114 + 1);
-        }
-        ++v114;
-      }
-      while ( v114 < 6 );
-      v114 = 0;
-      do
-      {
-      //  if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] )
-	  if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114+1].uItemID);
-        {
-          v50 = ItemsInShopTexture[v114 + 6];
-          v51 = 308 - v50->uTextureHeight;
-          if ( (signed int)v51 < 1 )
-            v51 = 0;
-          v52 = 75 * v114 - v50->uTextureWidth / 2 + 40;
-          if ( v114 )
-          {
-            if ( v114 == 5 )
-            {
-              v53 = ItemsInShopTexture[11]->uTextureWidth;
-              if ( (signed int)v52 > 457 - v53 )
-                v52 = 457 - v53;
-            }
-          }
-          else
-          {
-            if ( (signed int)v52 < 18 )
-              v52 = 18;
-          }
-          pRenderer->DrawTextureTransparent(v52, v51, v50);
-          sub_40F92A(&pRenderer->pActiveZBuffer[v52 + 640 * v51], ItemsInShopTexture[v114 + 6], v114 + 7);
-        }
-        ++v114;
-      }
-      while ( v114 < 6 );
-    }
-    else
-    {
-      do
-      {
-        //if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
-	  if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID)
-        {
-          v54 = ItemsInShopTexture[v114];
-          v55 = 152 - v54->uTextureHeight;
-          if ( (signed int)v55 < 1 )
-            v55 = 0;
-          v56 = 75 * v114 - v54->uTextureWidth / 2 + 40;
-          if ( v114 )
-          {
-            if ( v114 == 5 )
-            {
-              v57 = ItemsInShopTexture[5]->uTextureWidth;
-              if ( (signed int)v56 > 457 - v57 )
-                v56 = 457 - v57;
-            }
-          }
-          else
-          {
-            if ( (signed int)v56 < 18 )
-              v56 = 18;
-          }
-          pRenderer->DrawTextureTransparent(v56, v55, v54);
-          sub_40F92A(&pRenderer->pActiveZBuffer[v56 + 640 * v55], ItemsInShopTexture[v114], v114 + 1);
-        }
-        ++v114;
-      }
-      while ( v114 < 6 );
-      v114 = 0;
-      do
-      {
-       // if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 778] )   //weak 
-	     if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v114].uItemID) //not itemid
-        {
-          v58 = ItemsInShopTexture[v114 + 6];
-          v59 = 308 - v58->uTextureHeight;
-          if ( (signed int)v59 < 1 )
-            v59 = 0;
-          v60 = 75 * v114 - v58->uTextureWidth / 2 + 40;
-          if ( v114 )
-          {
-            if ( v114 == 5 )
-            {
-              v61 = ItemsInShopTexture[11]->uTextureWidth;
-              if ( (signed int)v60 > 457 - v61 )
-                v60 = 457 - v61;
-            }
-          }
-          else
-          {
-            if ( (signed int)v60 < 18 )
-              v60 = 18;
-          }
-          pRenderer->DrawTextureTransparent(v60, v59, v58);
-          sub_40F92A(&pRenderer->pActiveZBuffer[v60 + 640 * v59], ItemsInShopTexture[v114 + 6], v114 + 7);
-        }
-        ++v114;
-      }
-      while ( v114 < 6 );
-    }
-    result = (POINT *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-    if ( result )
-    {
-      v62 = 0;
-      v109 = 0;
-      if ( dword_F8B19C == 2 )
-      {
-        do
-        {
-         // if ( pParty->field_777C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
-		if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID);
-            ++v109;
-          ++v62;
-        }
-        while ( v62 < 12 );
-      }
-      else
-      {
-        do
-        {
-          //if ( pParty->field_C59C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
-		if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID)
-            ++v109;
-          ++v62;
-        }
-        while ( v62 < 12 );
-      }
-      v63 = GetAsyncKeyState(17);
-      v64 = _this->CanSteal();
-      Str = (char *)v64;
-      if ( v63 && v64 )
-      {
-        v65 = pGlobalTXT_LocalizationStrings[185];
-      }
-      else
-      {
-        v65 = pGlobalTXT_LocalizationStrings[195];
-        if ( dword_F8B19C != 2 )
-          v65 = pGlobalTXT_LocalizationStrings[196];
-      }
-      DrawTextAtStatusBar(v65, 0);
-      if ( !v109 )
-		  {
-        v104.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
-		return 0;
-		  }
-      v66 = pMouse->GetCursorPos(&v98);
-      result = (POINT *)(v66->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v96)->y]);
-      if ( pRenderer->pActiveZBuffer[(int)result] & 0xFFFF )
-      {
-        v67 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1;
-        v109 = v67;
-        v68 = (int)window_SpeakInHouse->ptr_1C;
-      //  v69 = 9 * (v67 + 12 * v68);
-        v70 = (ItemGen *)&pParty->StandartItemsInShops[v68][v67];
-        if ( dword_F8B19C != 2 )
-          v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724];
-        if ( !v63 || !Str )
-        {
-          v93 = 0;
-          v91 = 2;
-          v89 = window_SpeakInHouse->ptr_1C;
-          v87 = v70;
-          v113 = uActiveCharacter - 1;
-          v71 = _this->_490EEE(v70, 4, v68, 2);
-          v39 = v113;
-          v38 = (char *)pMerchantsBuyPhrases[v71];
-          goto LABEL_45;
-        }
-        v38 = pGlobalTXT_LocalizationStrings[181];
-        v93 = 0;
-        v91 = 2;
-        v89 = window_SpeakInHouse->ptr_1C;
-        v87 = v70;
-        goto LABEL_44;
-      }
-    }
-  }
-  return result;
+		}
+	default:
+		{
+			return (POINT *)dword_F8B19C - 96;
+		}
+  }
 }
 
 
@@ -2191,7 +2320,7 @@
 	GUIButton *v26; // esi@26
 	int v27; // eax@26
 	unsigned int v28; // ecx@26
-	Player *v29; // edx@26
+	int v29; // edx@26
 	unsigned __int16 v30; // ax@26
 	signed int v31; // esi@31
 	unsigned int v32; // eax@33
@@ -2360,12 +2489,12 @@
 					v25->uY = v146 + v23;
 					v27 = pFontArrus->CalcTextHeight(*v16, &v144, 0, 0);
 					v28 = v26->uY;
-					v29 = _this;
+					v29 = th;
 					v26->uHeight = v27;
 					v23 = v28 + v27 - 1;
 					v26->uW = v23;
 					v30 = v147;
-					if ( (Player *)pDialogueWindow->pCurrentPosActiveItem != v29 )
+					if ( pDialogueWindow->pCurrentPosActiveItem != v29 )
 						v30 = v148;
 					v144.DrawTitleText(pFontArrus, 0, v28, v30, *v16, 3u);
 					v20 = pDialogueWindow;
@@ -3159,7 +3288,7 @@
   pDialogueWindow->Release();
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, 0, 0);
   pBtn_ExitCancel = pDialogueWindow->CreateButton(471u, 445u, 169u, 35u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel"
-                 (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0);
+                 (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
   pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, 0, 0x53u, 0, "", 0);
   pDialogueWindow->_41D08F(1, 1, 0, 2);
@@ -3301,7 +3430,7 @@
     pDialogueWindow->pControlsTail = 0;
     pDialogueWindow->uNumControls = 0;
     pBtn_ExitCancel = pDialogueWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79],
-                   (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), 0);
+                   (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0);
     pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x55u, 0, "", 0);
     pDialogueWindow->CreateButton(0x1E0u, 0xBEu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x56u, 0, "", 0);
     pDialogueWindow->CreateButton(0x1E0u, 0xDCu, 0x8Cu, 0x1Eu, 1, 0, 0x88u, 0x57u, 0, "", 0);
@@ -3685,7 +3814,7 @@
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0);
   pBtn_ExitCancel = pDialogueWindow->CreateButton( 471, 445,  169, 35, 1, 0,  0x71u,  0,  0,
                  pGlobalTXT_LocalizationStrings[74],  //"End Conversation"
-                 (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : NULL),
+                 (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : NULL),
                  0);
   return pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, 0x51u, 0, 0, "", 0);
 }
@@ -9330,26 +9459,18 @@
   const char **v4; // ebx@2
   unsigned int result; // eax@6
 
-  v2 = this;
   v3 = 1;
-  if ( (signed int)this->uNumMaps <= 1 )
-  {
-LABEL_6:
-    result = 0;
-  }
-  else
-  {
-    v4 = (const char **)&this->pInfos[1].pFilename;
-    while ( !*v4 || _strcmpi(*v4, Str2) )
+  if ( (signed int)uNumMaps <= 1 )
+     return 0;
+  
+    while ( !*this->pInfos[v3].pFilename || _strcmpi(this->pInfos[v3].pFilename, Str2) )
     {
       ++v3;
-      v4 += 17;
-      if ( (signed int)v3 >= (signed int)v2->uNumMaps )
-        goto LABEL_6;
-    }
-    result = v3;
-  }
-  return result;
+      if ( (signed int)v3 >= (signed int)uNumMaps )
+        return 0;
+    }
+    return v3;
+
 }
 
 //----- (004547E4) --------------------------------------------------------
--- a/mm7_3.cpp	Mon Mar 04 20:28:08 2013 +0200
+++ b/mm7_3.cpp	Mon Mar 04 20:29:31 2013 +0200
@@ -14458,7 +14458,7 @@
       while ( (signed int)v41 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
     }
   }
-  pRenderer->DrawTextureIndexed(471, 445, (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0));
+  pRenderer->DrawTextureIndexed(471, 445, (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : 0));
 }
 
 //----- (004459F9) --------------------------------------------------------
--- a/mm7_4.cpp	Mon Mar 04 20:28:08 2013 +0200
+++ b/mm7_4.cpp	Mon Mar 04 20:29:31 2013 +0200
@@ -10627,7 +10627,7 @@
   pDialogueWindow->Release();
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15E, WINDOW_MainMenu, pEventCode, 0);
   pBtn_ExitCancel = pDialogueWindow->CreateButton(0x1D7, 0x1BD, 0xA9, 0x23, 1, 0, 0x71, 0, 0, pGlobalTXT_LocalizationStrings[34],
-                 (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0);
+                 (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
   pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0xAFu, 0x52u, 0, pGlobalTXT_LocalizationStrings[122], 0);
   pDialogueWindow->_41D08F(1, 1, 0, 2);
@@ -10650,7 +10650,7 @@
   v2 = "";
   pBtn_ExitCancel = pDialogueWindow->CreateButton( 0x1D7u, 0x1BDu, 0xA9u,  0x23u,   1,  0, 0x71u, 0,   0,
                  pGlobalTXT_LocalizationStrings[34],
-                 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
+                 (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0),
                  0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
   if ( contract_approved )
@@ -10683,7 +10683,7 @@
                  0,
                  0,
                  pGlobalTXT_LocalizationStrings[34],
-                 (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),
+                 (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0),
                  0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
   if ( pNPCStats->pProfessions[v1->uProfession].pBenefits)//*(&pNPCStats->field_13A5C + 5 * v1->uProfession) )
@@ -10764,7 +10764,7 @@
     pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0);
     pBtn_ExitCancel = pDialogueWindow->CreateButton(  471u,  445u,  169u, 35u,  1,   0, 0x71u,  0,  0,
                    pGlobalTXT_LocalizationStrings[74],// "End Conversation"
-                   (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),   0);
+                   (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0),   0);
     pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, "", 0);
     if ( pDialogueNPCCount == 1 && dword_591080 )
     {
--- a/mm7_5.cpp	Mon Mar 04 20:28:08 2013 +0200
+++ b/mm7_5.cpp	Mon Mar 04 20:29:31 2013 +0200
@@ -6276,7 +6276,7 @@
   uTextureID_507B04 = uTextureID_right_panel;
   v30 = 0;
   uTextureID_BACKHAND = pIcons_LOD->LoadTexture("BACKHAND", TEXTURE_16BIT_PALETTE);
-  uTextureID_5118C8 = uTextureID_506438;
+  uTextureID_5118C8 = uExitCancelTextureId;
   do
   {
     v42 = v30 + 1;
@@ -13124,7 +13124,7 @@
   pRenderer->DrawTextureTransparent(
     0x1D7u,
     0x1BDu,
-    (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
+    (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0));
   v6.uFrameX = 8;
   v6.uFrameY = 8;
   v6.uFrameWidth = 460;
@@ -14231,7 +14231,7 @@
   enum WindowType pWindowType; // esi@1
 
   pWindowType = (enum WindowType)uBook;
-  pRenderer->DrawTextureIndexed(471u, 445u, (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
+  pRenderer->DrawTextureIndexed(471u, 445u, (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0));
   switch ( pWindowType )
   {
     case WINDOW_Lloyd: // 177
@@ -15497,7 +15497,7 @@
                   draw_leather();
                   CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
                   pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY,
-                    (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0));
+                    (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0));
                 }
               }
             }
@@ -15518,10 +15518,7 @@
         {
           if ( (signed int)v10 < 53 )
           {
-
-
               pParty->field_3C._shop_ban_times[(signed int)v10] = 0;
- 
           }
           continue;
         }
@@ -16255,7 +16252,7 @@
   {
     if ( pCurrentScreen == SCREEN_CHEST )
     {
-      __debugbreak();
+    //  __debugbreak();
       if ( !pPlayers[uActiveCharacter]->CanAct() )
       {
         sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[427],//%s не в состоянии %s
@@ -16275,7 +16272,7 @@
       v9 = pX + pSRZBufferLineOffsets[pY];
       if ( !(pRenderer->pActiveZBuffer[v9] & 0xFFFF) )
         goto LABEL_132;
-      v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + 18* *((short *)&pChests[0].mm7__vector_pItems[139].uExpireTime
+      v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + 18* *((short *)&pChests[0].igChestItems[139].uExpireTime
                        + (pRenderer->pActiveZBuffer[v9] & 0xFFFF) + 2662 * (unsigned int)pChestWindow->ptr_1C + 3));
     }
     else
--- a/mm7_data.cpp	Mon Mar 04 20:28:08 2013 +0200
+++ b/mm7_data.cpp	Mon Mar 04 20:29:31 2013 +0200
@@ -686,10 +686,7 @@
 char _4E2B21_buff_spell_tooltip_colors[80];
 char byte_4E2B70[777]; // weak
 char byte_4E2BC8; // weak
-int pChestSmthn1ByType[8] = {42, 18, 18, 42, 42, 42, 18, 42};
-int pChestSmthn2ByType[8] = {34, 30, 30, 34, 34, 34, 30, 34};
-int pChestWidthsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9};
-int pChestHeightsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9};
+
 char aSS[777]; // idb
 char ascii_4E2C54[6];
 char ascii_4E2C5C[7];
@@ -1105,14 +1102,7 @@
 char aEWorkMsdevMm_7[777]; // idb
 char aGammaControlNo[777]; // idb
 __int16 word_4E8152[11] = {0, 0, 0, 90, 8, 2, 70, 20, 10, 50, 30};
-char byte_4E8168[7][14]={  //byte_4E8178
-	{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 
-	{ 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
-	{ 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3},
-	{ 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4},
-	{ 2, 2, 2, 2, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5},
-	{ 2, 2, 2, 2, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6},
-	{ 2, 2, 2, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}};
+
 char aD3dTextureName[777]; // idb
 char aLogd3d_txt[777]; // idb
 char byte_4E8394[204] =
@@ -1830,7 +1820,7 @@
 int dword_506364; // weak
 Texture *dword_506404[12]; // weak
 Texture *dword_50640C[12]; // weak
-unsigned int uTextureID_506438;
+unsigned int uExitCancelTextureId;
 int dword_50651C; // weak
 int awards_count; // weak
 int awards_count2; // weak
--- a/mm7_data.h	Mon Mar 04 20:28:08 2013 +0200
+++ b/mm7_data.h	Mon Mar 04 20:29:31 2013 +0200
@@ -474,10 +474,7 @@
 extern char _4E2B21_buff_spell_tooltip_colors[80];
 extern char byte_4E2B70[]; // weak
 extern char byte_4E2BC8; // weak
-extern int pChestSmthn1ByType[8];
-extern int pChestSmthn2ByType[8];
-extern int pChestWidthsByType[8];
-extern int pChestHeightsByType[8];
+
 extern char aSS[]; // idb
 extern char ascii_4E2C54[6];
 extern char ascii_4E2C5C[7];
@@ -1005,7 +1002,7 @@
 extern __int16 word_4F0576[]; // weak
 
 //extern __int16 word_4F05AE[]; // weak
-extern char uItemsAmountPerShopType[]; // weak
+
 //extern __int16 word_4F063E[290];
 //extern __int16 word_4F06D8[22];
 extern int guild_mambership_flags[32];
@@ -1153,7 +1150,7 @@
 extern char byte_506360; // weak
 extern int dword_506364; // weak
 extern Texture *dword_50640C[]; // weak
-extern unsigned int uTextureID_506438;
+extern unsigned int uExitCancelTextureId;
 extern int dword_50651C; // weak
 extern int awards_count; // weak
 extern int awards_count2; // weak
@@ -1896,7 +1893,7 @@
 void __cdecl GameUI_DrawStatusBar();
 bool __thiscall sub_41CD4F(unsigned int _this);
 char __fastcall sub_41D20D_buff_remaining_time_string(int ecx0, struct GUIWindow *edx0, __int64 a3, struct GUIFont *a2);
-void GameUI_DrawItemInfo(struct ItemGen *_this); // idb
+void GameUI_DrawItemInfo(struct ItemGen* inspect_item); // idb
 char *__fastcall MonsterPopup_Draw(unsigned int uActorID, struct GUIWindow *edx0);
 void __cdecl nullsub_3(); // idb
 void __cdecl LoadActualSkyFrame();
@@ -1904,7 +1901,7 @@
 void __cdecl RestUI_Initialize();
 void __cdecl RestUI_Draw(); // idb
 void __cdecl sub_42038D();
-void __fastcall sub_420B13(int a1, int a2);
+
 void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal); // idb
 void __cdecl sub_420E01();
 void __cdecl GameUI_WritePointedObjectStatusString();
@@ -2055,7 +2052,7 @@
 // int __cdecl crt_deconstruct_44C42C();
 void SpawnEncounter(struct MapInfo *pMapInfo, struct SpawnPointMM7 *spawn, int a3, int a4, int a5);
 int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3);
-void __cdecl sub_450218_prolly_generate_chests_loot();
+void  sub_450218_prolly_generate_chests_loot();
 signed int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6);
 int __fastcall sub_45063B(struct MapInfo *a1, int a2);
 void RespawnGlobalDecorations();