changeset 1751:b6212ecbc140

Слияние
author Ritor1
date Mon, 30 Sep 2013 09:30:42 +0600
parents bae4ffd25a03 (current diff) f305a00a6d98 (diff)
children 07c7f446a929
files UI/UITransition.cpp
diffstat 2 files changed, 348 insertions(+), 751 deletions(-) [+]
line wrap: on
line diff
--- a/UI/UIShops.cpp	Mon Sep 30 09:30:31 2013 +0600
+++ b/UI/UIShops.cpp	Mon Sep 30 09:30:42 2013 +0600
@@ -341,133 +341,23 @@
 //----- (004BA928) --------------------------------------------------------
 void  ArmorShopDialog()
 {
-  signed int v1; // esi@8
-  unsigned int v2; // eax@10
-  ItemGen *v3; // eax@11
-  char *v5; // ecx@12
-  char *v6; // eax@13
-  int v8; // eax@15
-  signed int v9; // esi@17
-  unsigned int v10; // eax@19
-  char *v11; // edi@19
-  int v12; // ST08_4@20
-  int v13; // eax@20
-  char *v15; // ecx@20
-  char **v16; // edi@22
+  int phrases_id; // eax@20
   int all_text_height; // ebx@22
-  char **v18; // esi@22
-  int v19; // eax@23
-  GUIWindow *v20; // ecx@24
-  int v21; // eax@24
-  int v22; // edx@24
+  int v146; // [sp+E4h] [bp-20h]@24
   int v23; // ebx@24
-  unsigned __int8 v24; // sf@24
   GUIButton *pButton; // eax@26
-  unsigned int v28; // ecx@26
-  int v29; // edx@26
-  signed int v31; // esi@31
-  unsigned int v32; // eax@33
-  //int v33; // eax@34
-  int v35; // eax@35
-  char *v36; // edx@36
   signed int v38; // esi@42
-  unsigned int v39; // esi@44
-  int v40; // eax@44
-  unsigned int v41; // eax@45
-  int v42; // eax@47
-  int v43; // ecx@52
-  int v46; // eax@54
-  unsigned int v49; // ecx@56
-  int v51; // eax@56
-  int v53; // eax@60
-  int textureH; // eax@60
-  signed int textureW; // ebx@65
-  Texture *v56; // eax@67
-  unsigned int pY_item; // edi@68
-  Texture *v58; // ST1C_4@68
   int v59; // eax@68
-  int v60; // edi@69
-  signed int v61; // ebx@73
-  Texture *v62; // eax@75
-  int v63; // edi@76
-  Texture *v64; // ST1C_4@76
-  unsigned int v65; // ST18_4@76
-  int v66; // eax@76
-  int v67; // edi@77
-  signed int v68; // ecx@81
   const char *pText; // ecx@91
-  void *v72; // eax@95
-  POINT *v73; // esi@97
-  int v74; // ecx@97
-  int v75; // eax@98
-  int v76; // ecx@98
   ItemGen *selected_item; // ecx@99
-  unsigned __int8 v78; // bl@104
-  int v80; // ebx@105
-  char **v81; // esi@105
-  int v82; // eax@106
-  int v86; // ebx@107
-  int pTextHeight; // eax@109
-  unsigned int v90; // ecx@109
   int pNumString; // edx@109
   unsigned __int16 pTextColor; // ax@109
-  signed int v93; // edx@114
-  POINT *v94; // edi@120
-  __int32 v95; // ecx@120
-  void *v96; // ST14_4@122
-  unsigned __int8 v97; // bl@122
-  //ItemGen *v98; // ST10_4@122
-  int v99; // eax@122
-  char *v100; // eax@122
-  const char *v101; // ST18_4@122
-  unsigned __int16 v102; // ST14_2@122
-  int v103; // eax@122
-  signed int v104; // edi@123
-  Texture *v105; // eax@125
-  int v106; // ebx@126
-  unsigned int v108; // ST18_4@126
-  int v109; // eax@126
-  int v110; // ebx@127
-  GUIWindow *v111; // [sp-18h] [bp-11Ch]@36
-  unsigned int v112; // [sp-14h] [bp-118h]@13
-  int v113; // [sp-14h] [bp-118h]@36
-  unsigned int v115; // [sp-10h] [bp-114h]@13
-  ItemGen *v116; // [sp-10h] [bp-114h]@20
-  int v117; // [sp-10h] [bp-114h]@36
-  unsigned __int16 v119; // [sp-Ch] [bp-110h]@13
-  char *v121; // [sp-8h] [bp-10Ch]@13
-  int v122; // [sp-8h] [bp-10Ch]@20
-  unsigned int v123; // [sp-4h] [bp-108h]@13
-  __int64 *v124; // [sp-4h] [bp-108h]@20
-  int v125; // [sp-4h] [bp-108h]@68
-  int v126; // [sp-4h] [bp-108h]@76
-  int v127; // [sp-4h] [bp-108h]@126
-  POINT v128; // [sp+Ch] [bp-F8h]@8
-  POINT v129; // [sp+14h] [bp-F0h]@18
-  char v130; // [sp+1Ch] [bp-E8h]@120
-  POINT a2; // [sp+24h] [bp-E0h]@8
-  POINT v132; // [sp+2Ch] [bp-D8h]@120
-  POINT v133; // [sp+34h] [bp-D0h]@17
-  POINT v134; // [sp+3Ch] [bp-C8h]@97
-  POINT v135; // [sp+44h] [bp-C0h]@31
   POINT mouse; // [sp+4Ch] [bp-B8h]@97
-  POINT v137; // [sp+54h] [bp-B0h]@17
-  POINT v138; // [sp+5Ch] [bp-A8h]@32
-  POINT v139; // [sp+64h] [bp-A0h]@17
-  POINT v140; // [sp+6Ch] [bp-98h]@31
-  POINT v141; // [sp+74h] [bp-90h]@8
-  POINT v142; // [sp+7Ch] [bp-88h]@31
-  POINT v143; // [sp+84h] [bp-80h]@9
   GUIWindow dialog_window; // [sp+8Ch] [bp-78h]@1
-  int v146; // [sp+E4h] [bp-20h]@24
-  //int pYellowColor; // [sp+E8h] [bp-1Ch]@1
-  //int pWhiteColor; // [sp+ECh] [bp-18h]@1
   __int32 pItemCount; // [sp+F0h] [bp-14h]@8
-  int v152; // [sp+FCh] [bp-8h]@24
   int item_x; // [sp+100h] [bp-4h]@44
-  int th;
-  short text_color;
-  int pActiveButton;
+  int pPrice;
+  unsigned int v153;
 
   memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window));
   dialog_window.uFrameX = 483;
@@ -551,12 +441,12 @@
         {
           pText = BuildDialogueString((char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 2)],
                                  uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), v36, 3);
+          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
         }
         else
         {
           pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); //"Steal %24"
-          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), v36, 3);
+          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
         }
         return;
       }
@@ -573,43 +463,34 @@
       {
         if ( pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][i].uItemID )
         {
-          //v62 = ItemsInShopTexture[i];
           if ( i >= 4 )
           {
-            //v67 = 90 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2);
             pRenderer->DrawTextureTransparent(item_x + (90 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) - 420, 126, ItemsInShopTexture[i]);
-            v66 = item_x + (90 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + 80220;
+            v59 = item_x + (90 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + 80220;
           }
           else
           {
-            //v63 = 98 - ItemsInShopTexture[i]->uTextureHeight;
-            //v64 = ItemsInShopTexture[i];
-            //v65 = 98 - ItemsInShopTexture[i]->uTextureHeight;
-            //v152 = 86 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2);
             pRenderer->DrawTextureTransparent(86 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2) + item_x, 98 - ItemsInShopTexture[i]->uTextureHeight, ItemsInShopTexture[i]);
-            v66 = (86 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_x + 640 * (98 - ItemsInShopTexture[i]->uTextureHeight);
+            v59 = (86 - ((signed int)ItemsInShopTexture[i]->uTextureWidth / 2)) + item_x + 640 * (98 - ItemsInShopTexture[i]->uTextureHeight);
           }
-          ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v66], ItemsInShopTexture[i], i + 1);
+          ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v59], ItemsInShopTexture[i], i + 1);
         }
         item_x += 105;
       }
       if ( !HouseUI_CheckIfPlayerCanInteract() )
         return;
-      v68 = 0;
       pItemCount = 0;
-      do
+      for ( uint i = 0; i < 6; ++i )
       {
-        if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][(signed int)v68].uItemID)
-        ++pItemCount;
-        ++v68;
+        if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][i].uItemID)
+          ++pItemCount;
       }
-      while ( v68 < 6 );
-      if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0 )
+      if ( !GetAsyncKeyState(17) || !pPlayers[uActiveCharacter]->CanSteal() )
         pText = pGlobalTXT_LocalizationStrings[196]; //Select the Special Item to Buy"
       else
         pText = pGlobalTXT_LocalizationStrings[185];
       DrawTextAtStatusBar(pText, 0);
-      if ( (char *)pItemCount != 0 )
+      if ( pItemCount )
       {
         pMouse->GetCursorPos(&mouse);
         if ( !(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) )
@@ -619,19 +500,24 @@
           selected_item = &pParty->StandartItemsInShops[window_SpeakInHouse->par1C][(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) - 1];
         else
           selected_item = &pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) - 1];
-        if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0 )
-          v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 2)];
+        if ( !GetAsyncKeyState(17) || !pPlayers[uActiveCharacter]->CanSteal() )
+        {
+          pText = BuildDialogueString((char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 2)],
+                 uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
+          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+        }
         else
-          v15 = pGlobalTXT_LocalizationStrings[181]; //"Steal %24"
-        v36 = BuildDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-        v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138;
-        dialog_window.DrawTitleText(pFontArrus, 0, v115, TargetColor(0xFFu, 0xFFu, 0xFFu), v36, 3);
+        {
+          pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);//"Steal %24"
+          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+        }
         return;
       }
       dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C]- pParty->uTimePlayed);
       return;
     }
     break;
+
     case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT:
     {
       draw_leather();
@@ -642,34 +528,27 @@
       all_text_height = 0;
       for ( int i = 0; i < 3; ++i )
         all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0);
-      v152 = (174 - all_text_height) / 3;
-      v86 = (3 * (58 - v152) - all_text_height) / 2 - v152 / 2 + 138;
-      v24 = -pDialogueWindow->pNumPresenceButton < 0;
-      pActiveButton = pDialogueWindow->pStartingPosActiveItem;
-      if ( v24 ^ (pDialogueWindow->pStartingPosActiveItem > pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton) )
+      v146 = (174 - all_text_height) / 3;
+      v23 = (3 * (58 - v146) - all_text_height) / 2 - v146 / 2 + 138;
+      pNumString = 0;
+      for ( int i = pDialogueWindow->pStartingPosActiveItem;
+                i  < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
       {
-        pNumString = 0;
-        do
-        {
-          pButton = pDialogueWindow->GetControl((unsigned int)pActiveButton);
-          pButton->uY = v152 + v86;
-          pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0);
-          v90 = pButton->uY;
-          pButton->uHeight = pTextHeight;
-          v86 = v90 + pTextHeight - 1;
-          pButton->uW = v86;
-          pTextColor = TargetColor(0xE1u, 0xCDu, 0x23u);
-          if ( pDialogueWindow->pCurrentPosActiveItem != pActiveButton )
-            pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
-          dialog_window.DrawTitleText(pFontArrus, 0, v90, pTextColor, pShopOptions[pNumString], 3);
-          ++pNumString;
-          ++pActiveButton;
-        }
-        while ( (signed int)pActiveButton < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
+        pButton = pDialogueWindow->GetControl(i);
+        pButton->uY = v146 + v23;
+        pButton->uHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0);
+        v23 = pButton->uY + pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0) - 1;
+        pButton->uW = v23;
+        pTextColor = TargetColor(0xE1u, 0xCDu, 0x23u);
+        if ( pDialogueWindow->pCurrentPosActiveItem != i )
+          pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
+        dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[pNumString], 3);
+        ++pNumString;
       }
       return;
     }
     break;
+
     case HOUSE_DIALOGUE_SHOP_SELL:
     {
       draw_leather();
@@ -677,16 +556,16 @@
       DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);//"Select the Item to Sell"
       if ( !HouseUI_CheckIfPlayerCanInteract())
         return;
-      if((v9 = pMouse->GetCursorPos(&v139)->x - 14, pItemCount = (v9 >> 5) + 14 * ((pMouse->GetCursorPos(&v133)->y - 17) >> 5),
-         pMouse->GetCursorPos(&v137)->x <= 13) || pMouse->GetCursorPos(&v129)->x >= 462 
-         || (v10 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount), v11 = 0, !v10) )
+      pMouse->GetCursorPos(&mouse);
+      v153 = ((mouse.x - 14) >> 5) + 14 * ((mouse.y - 17) >> 5);
+      if ( mouse.x <= 13 || mouse.x >= 462 )
+        return;
+      if ( !pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153) )
            return;
-      v116 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItemList[v10 - 1];
-      v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 3);
-      v15 = (char *)pMerchantsSellPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 3)];
-      v36 = BuildDialogueString(v15, uActiveCharacter - 1, v116, (char *) window_SpeakInHouse->par1C, 3, 0);
-      v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138;
-      dialog_window.DrawTitleText(pFontArrus, 0, v115, TargetColor(0xFFu, 0xFFu, 0xFFu), v36, 3);
+      selected_item = &pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153) - 1];
+      pText = BuildDialogueString((char *)pMerchantsSellPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 3)],
+              uActiveCharacter - 1, selected_item, (char *) window_SpeakInHouse->par1C, 3, 0);
+      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
       return;
     }
     break;
@@ -697,28 +576,20 @@
       DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0); //"Select the Item to Identify"	
       if ( HouseUI_CheckIfPlayerCanInteract() )
       {
-        v1 = pMouse->GetCursorPos(&a2)->x - 14;
-        pItemCount = (v1 >> 5) + 14 * ((pMouse->GetCursorPos(&v128)->y - 17) >> 5);
-        if ( pMouse->GetCursorPos(&v141)->x > 13 )
+        pMouse->GetCursorPos(&mouse);
+        v153 = ((mouse.x - 14) >> 5) + 14 * ((mouse.y - 17) >> 5);
+        if ( mouse.x > 13 && mouse.x < 462 )
         {
-          if ( pMouse->GetCursorPos(&v143)->x < 462 )
+          if ( pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153) )
           {
-            v2 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount);
-            if ( v2 )
-            {
-              v3 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItemList[v2-1];
-              if (v3->IsIdentified())
-                v5 = "%24";
-              else
-              {
-                v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v3, BuildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 4);
-                v5 = (char *)pMerchantsIdentifyPhrases[v8];
-              }
-              v6 = BuildDialogueString(v5, uActiveCharacter - 1, v3, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
-              v115 = (174 - pFontArrus->CalcTextHeight(v6, &dialog_window, 0, 0)) / 2 + 138;
-              dialog_window.DrawTitleText(pFontArrus, 0, v115, TargetColor(0xFFu, 0xFFu, 0xFFu), v6, 3);
-              return;
-            }
+            selected_item = &pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153)-1];
+            if (selected_item->IsIdentified())
+              pText = BuildDialogueString("%24", uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
+            else
+              pText = BuildDialogueString((char *)pMerchantsIdentifyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop,
+                    (int)window_SpeakInHouse->ptr_1C, 4)], uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
+            dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+            return;
           }
         }
       }
@@ -731,281 +602,113 @@
       DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0);
       if ( !HouseUI_CheckIfPlayerCanInteract())
         return;
-      if( (v31 = pMouse->GetCursorPos(&v135)->x - 14,
-          pItemCount = (v31 >> 5) + 14 * ((pMouse->GetCursorPos(&v142)->y - 17) >> 5),
-            pMouse->GetCursorPos(&v140)->x <= 13)
-            || pMouse->GetCursorPos(&v138)->x >= 462
-            || (v32 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount), v11 = 0, !v32)
-            || (!(pPlayers[uActiveCharacter]->pOwnItems[v32-1].uAttributes& 2)) )
+      pMouse->GetCursorPos(&mouse);
+      v153 = ((mouse.x -14) >> 5) + 14 * ((mouse.y - 17) >> 5);
+      if( mouse.x <= 13 || mouse.x >= 462 )
         return;
-      //__debugbreak(); // warning C4700: uninitialized local variable 'v33' used
-      v116 = &pPlayers[uActiveCharacter]->pInventoryItemList[v32 - 1];
-      v35 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[v32 - 1], BuildingType_ArmorShop, window_SpeakInHouse->par1C, 5);
-      v15 = (char *)pMerchantsRepairPhrases[v35];
-      v36 = BuildDialogueString(v15, uActiveCharacter - 1, v116, (char *)window_SpeakInHouse->ptr_1C, 5, 0);
-      v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138;
-      dialog_window.DrawTitleText(pFontArrus, 0, v115, TargetColor(0xFFu, 0xFFu, 0xFFu), v36, 3);
+      if ( !pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153)
+       || (!(pPlayers[uActiveCharacter]->pOwnItems[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153) - 1].uAttributes& 2)) )
+        return;
+      selected_item = &pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153) - 1];
+      phrases_id = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v153) - 1],
+             BuildingType_ArmorShop, window_SpeakInHouse->par1C, 5);
+      pText = BuildDialogueString((char *)pMerchantsRepairPhrases[phrases_id], uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 5, 0);
+      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
       return;
     }
     break;
-    case HOUSE_DIALOGUE_SHOP_6: //buy standart ???
-    {
-      pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
-      DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[195], 0); //"Select the Item to Buy"
-      if ( !HouseUI_CheckIfPlayerCanInteract() )
-        return;
-      pItemCount = 0;
-      for( int i = 0; i < 6 ; ++i )
-        if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][i].uItemID)
-          ++pItemCount;
-      if ( pItemCount )
-      {
-        v94 = pMouse->GetCursorPos(&v132);
-        pItemCount = pRenderer->pActiveZBuffer[v94->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v130)->y]];
-        v95 = pItemCount;
-        if ( pItemCount && pItemCount != -65536 )
-        {
-          --pItemCount;
-          v97 = uActiveCharacter - 1;
-      //__debugbreak(); // warning C4700: uninitialized local variable 'v98' used
-          v99 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v95-1], BuildingType_ArmorShop,	window_SpeakInHouse->par1C,	2);
-          v100 = BuildDialogueString((char *)pMerchantsBuyPhrases[v99], uActiveCharacter - 1, &pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v95-1], (char *)window_SpeakInHouse->par1C, 2, 0);
-          v103 = pFontArrus->CalcTextHeight(v100, &dialog_window, 0, 0);
-          dialog_window.DrawTitleText(pFontArrus, 0, (174 - v103) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), v100, 3);
-        }
-        v104 = 0;
-        int v153 = 0;
-        do
-        {
-          //if ( pParty->field_C59C[9 * (v104 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
-          if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v104].uItemID)
-          {
-            v105 = ItemsInShopTexture[v104];
-            if ( v104 >= 4 )
-            {
-              v110 = 90 - ((signed int)v105->uTextureWidth >> 1);
-              pRenderer->DrawTextureTransparent(v153 + v110 - 420, 0x7Eu, ItemsInShopTexture[v104]);
-              v127 = v104 + 1;
-              v109 = v153 + v110 + 80220;
-            }
-            else
-            {
-              v106 = 98 - v105->uTextureHeight;
-              v108 = 98 - v105->uTextureHeight;
-              v152 = 86 - ((signed int)v105->uTextureWidth >> 1);
-              pRenderer->DrawTextureTransparent(v152 + v153, v108, ItemsInShopTexture[v104]);
-              v127 = v104 + 1;
-              v109 = v152 + v153 + 640 * v106;
-            }
-            ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v109], ItemsInShopTexture[v104], v127);
-          }
-          v153 += 105;
-          ++v104;
-        }
-        while ( v104 < 8 );
-        return;
-      }
-      dialog_window.DrawCurrentTime(pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C]-  pParty->uTimePlayed);
-      return;
-    }
-    break;
+
     case HOUSE_DIALOGUE_LEARN_SKILLS:
     {
       if (!HouseUI_CheckIfPlayerCanInteract() )
         return;
-      v152 = 0;
+      uint item_num = 0;
       v38 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
-      pActiveButton = v38 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
-      if ( (signed int)pActiveButton < v38 / 3 )
-        pActiveButton = v38 / 3;
-      v39 = pDialogueWindow->pStartingPosActiveItem;
-      v40 = pDialogueWindow->pNumPresenceButton;
-      int v153 = 0;
-      if ( (signed int)v39 < (signed int)(v39 + v40) )
+      pPrice = v38 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
+      if ( (signed int)pPrice < v38 / 3 )
+        pPrice = v38 / 3;
+      all_text_height = 0;
+      for ( int i = pDialogueWindow->pStartingPosActiveItem;
+                  i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
       {
-        do
+        if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pDialogueWindow->GetControl(i)->msg_param - 36]
+             && !pPlayers[uActiveCharacter]->pActiveSkills[pDialogueWindow->GetControl(i)->msg_param - 36] )
         {
-          v41 = pDialogueWindow->GetControl(v39)->msg_param - 36;
-          if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v41] && !pPlayers[uActiveCharacter]->pActiveSkills[v41] )
-          {
-            v42 = pFontArrus->CalcTextHeight(pSkillNames[v41], &dialog_window, 0, 0);
-            v152 += v42;
-            ++v153;
-          }
-          ++v39;
+          all_text_height += pFontArrus->CalcTextHeight(pSkillNames[pDialogueWindow->GetControl(i)->msg_param - 36], &dialog_window, 0, 0);
+          item_num ++;
         }
-        while ( (signed int)v39 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
-        if ( v153 )
+      }
+      if ( item_num )
+      {
+        sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pPrice);
+        dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3);
+        v146 = (149 - all_text_height) / item_num;
+        if ( (149 - all_text_height) / item_num > 32 )
+          v146 = 32;
+        v23 = (149 - v146 * item_num - all_text_height) / 2 - v146 / 2 + 162;
+        for ( int i = pDialogueWindow->pStartingPosActiveItem;
+                  i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
         {
-          sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pActiveButton);
-          dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3);
-          pActiveButton = (149 - v152) / v153;
-          if ( (149 - v152) / v153 > 32 )
-            pActiveButton = 32;
-          v43 = (149 - v153 * (signed int)pActiveButton - v152) / 2 - (signed int)pActiveButton / 2 + 162;
-          v152 = pDialogueWindow->pStartingPosActiveItem;
-          v146 = v43;
-          if ( v152 < v152 + pDialogueWindow->pNumPresenceButton )
+          pButton = pDialogueWindow->GetControl(i);
+          if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pButton->msg_param - 36]
+            || pPlayers[uActiveCharacter]->pActiveSkills[pButton->msg_param - 36] )
           {
-            v153 = 2;
-            do
-            {
-              pButton = pDialogueWindow->GetControl(v152);
-              v46 = pButton->msg_param - 36;
-              if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v46] || pPlayers[uActiveCharacter]->pActiveSkills[v46] )
-              {
-                pButton->uW = 0;
-                pButton->uHeight = 0;
-                pButton->uY = 0;
-              }
-              else
-              {
-                pButton->uY = (unsigned int)((char *)pActiveButton + v146);
-                pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v46], &dialog_window, 0, 0);
-                v49 = pButton->uY;
-                pButton->uHeight = pTextHeight;
-                v51 = v49 + pTextHeight - 1;
-                pButton->uW = v51;
-                v146 = v51;
-                pTextColor = TargetColor(0xE1u, 0xCDu, 0x23u);
-                if ( pDialogueWindow->pCurrentPosActiveItem != v153 )
-                  pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
-                dialog_window.DrawTitleText(pFontArrus, 0, v49, pTextColor, pSkillNames[v46], 3);
-              }
-              v53 = pDialogueWindow->pStartingPosActiveItem;
-              ++v152;
-              textureH = pDialogueWindow->pNumPresenceButton + v53;
-              ++v153;
-            }
-            while ( v152 < textureH );
+            pButton->uW = 0;
+            pButton->uHeight = 0;
+            pButton->uY = 0;
           }
-          return;
+          else
+          {
+            pButton->uY = v146 + v23;
+            pButton->uHeight = pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0);
+            v23 = pButton->uY + pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0) - 1;
+            pButton->uW = v23;
+            pTextColor = TargetColor(0xE1u, 0xCDu, 0x23u);
+            if ( pDialogueWindow->pCurrentPosActiveItem != i )
+              pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
+            dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pSkillNames[pButton->msg_param - 36], 3);
+          }
         }
+        return;
       }
       sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); //"Seek knowledge elsewhere %s the %s"
       strcat(pTmpBuf.data(), "\n \n");
       strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further."
-      v115 = (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138;
-      dialog_window.DrawTitleText(pFontArrus, 0, v115, TargetColor(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3);
+      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3);
       return;
     }
     break;
+    default:
+      __debugbreak();
   }
 }
 //----- (004B9CC6) --------------------------------------------------------
 void  AlchemistDialog()
 {
-  int v0;
-  int pNumActiveItem; // eax@7
+  int index; // eax@7
   signed int v5; // esi@9
-  unsigned int v6; // esi@11
-  int v7; // eax@11
-  unsigned int v8; // eax@12
-  int v9; // eax@14
-  int v10; // ecx@19
-  int v13; // eax@21
-  char *v14; // eax@23
-  int v15; // eax@23
-  unsigned int v16; // ecx@23
-  int v17; // edx@23
   int v18; // eax@23
-  int v20; // eax@27
-  char *v21; // edx@29
-  int v22; // esi@30
-  char **v23; // edi@30
-  int v24; // eax@31
-  int v26; // edx@32
-  int v27; // edi@32
-  unsigned __int8 v28; // sf@32
-  const char **v30; // eax@34
-  int v31; // eax@34
-  unsigned int v32; // ecx@34
-  int v34; // eax@34
-  signed int v36; // esi@39
-  ItemGen *v37; // eax@42
-  char *v38; // ecx@43
-  unsigned __int8 v39; // dl@44
-  int v40; // eax@46
-  int v41; // ST08_4@47
-  int v42; // eax@47
-  signed int v43; // esi@49
-  int v44; // ST08_4@52
-  int v45; // eax@52
-  Texture *v46; // ecx@55
+  char *pText; // edx@29
   unsigned int v47; // edi@55
   unsigned int v48; // esi@57
-  int v49; // edx@61
-  Texture *v50; // ecx@67
   unsigned int v51; // edi@67
   unsigned int v52; // esi@69
-  int v53; // edx@73
-  Texture *v54; // ecx@79
-  unsigned int v55; // edi@79
-  unsigned int v56; // esi@81
-  int v57; // edx@85
-  Texture *v58; // ecx@91
-  unsigned int v59; // edi@91
-  unsigned int v60; // esi@93
-  int v61; // edx@97
-  signed int v62; // ecx@102
-  SHORT v63; // di@110
-  bool v64; // eax@110
-  const char *v65; // ecx@112
-  POINT *v66; // esi@117
-  int v67; // ecx@118
-  int v68; // eax@118
-  int v69; // ecx@118
-  ItemGen *v70; // esi@118
+  ItemGen *item; // esi@118
   int v71; // eax@123
   int all_text_height; // edi@125
-  char **v73; // esi@125
-  int v74; // eax@126
-  int pItemNum;
-  int v76; // edx@127
-  int v77; // edi@127
   GUIButton *pButton; // esi@129
-  const char **v79; // eax@129
-  int pTextHeight; // eax@129
-  unsigned int v81; // ecx@129
   unsigned int pColorText; // ax@129
-  int v85; // [sp-14h] [bp-ECh]@29
-  int v86; // [sp-10h] [bp-E8h]@29
-  ItemGen *v87; // [sp-10h] [bp-E8h]@43
-  unsigned __int16 v88; // [sp-Ch] [bp-E4h]@29
-  void *v89; // [sp-Ch] [bp-E4h]@43
-  char *v90; // [sp-8h] [bp-E0h]@29
-  int v91; // [sp-8h] [bp-E0h]@42
-  unsigned int v92; // [sp-4h] [bp-DCh]@29
-  __int64 *v93; // [sp-4h] [bp-DCh]@42
-  POINT v94; // [sp+Ch] [bp-CCh]@39
-  POINT v95; // [sp+14h] [bp-C4h]@49
-  POINT v96; // [sp+1Ch] [bp-BCh]@117
-  POINT v97; // [sp+24h] [bp-B4h]@40
-  POINT v98; // [sp+2Ch] [bp-ACh]@117
-  POINT v99; // [sp+34h] [bp-A4h]@49
-  POINT v100; // [sp+3Ch] [bp-9Ch]@50
-  POINT v101; // [sp+44h] [bp-94h]@39
-  POINT v102; // [sp+4Ch] [bp-8Ch]@49
-  POINT a2; // [sp+54h] [bp-84h]@39
+  POINT mouse; // [sp+2Ch] [bp-ACh]@117
   GUIWindow dialog_window; // [sp+5Ch] [bp-7Ch]@1
   int v105; // [sp+B0h] [bp-28h]@19
-  int pColorYellow; // [sp+B4h] [bp-24h]@1
-  int Str; // [sp+B8h] [bp-20h]@23
-  int pColorWhite; // [sp+BCh] [bp-1Ch]@1
-  __int32 v109; // [sp+C0h] [bp-18h]@39
-  Player *pPlayer; // [sp+C4h] [bp-14h]@1
   int pNumString; // [sp+C8h] [bp-10h]@9
-  unsigned int v112; // [sp+CCh] [bp-Ch]@9
-  unsigned __int8 v113; // [sp+D3h] [bp-5h]@47
-  int v114; // [sp+D4h] [bp-4h]@11
+  int item_num; // [sp+D4h] [bp-4h]@11
+  int pPrice;
 
-  pPlayer = pPlayers[uActiveCharacter];
   memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window));
   dialog_window.uFrameX = 483;
   dialog_window.uFrameWidth = 148;
   dialog_window.uFrameZ = 334;
-  pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu);
-  pColorYellow = TargetColor(0xE1u, 0xCDu, 0x23u);
   switch(dialog_menu_id)
   {
     case HOUSE_DIALOGUE_MAIN:
@@ -1017,85 +720,68 @@
         pShopOptions[2] = pGlobalTXT_LocalizationStrings[159];
         pShopOptions[3] = pGlobalTXT_LocalizationStrings[160];
         all_text_height = 0;
-        for (int i = 0; i < 4; ++i)//while ( (signed int)v15 < (signed int)&unk_F8B1C8 );
+        for ( int i = 0; i < 4; ++i )
           all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0);
-        Str = (174 - all_text_height) / 4;
-        pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
-        v76 = pNumActiveItem + pDialogueWindow->pNumPresenceButton;
-        v77 = (174 - 4 * (174 - all_text_height) / 4 - all_text_height) / 2 - (174 - all_text_height) / 4 / 2 + 138;
-        v28 = -pDialogueWindow->pNumPresenceButton < 0;
-        if ( v28 ^ (pNumActiveItem > v76) )
+        v18 = (174 - all_text_height) / 4;
+        v105 = (174 - 4 * (174 - all_text_height) / 4 - all_text_height) / 2 - (174 - all_text_height) / 4 / 2 + 138;
+        pNumString = 0;
+        for ( int i = pDialogueWindow->pStartingPosActiveItem;
+                  i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
         {
-          pItemNum = 2;
-          pNumString = 0;
-          do
-          {
-            pButton = pDialogueWindow->GetControl(pItemNum);
-            pButton->uY = Str + v77;
-            pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
-            pButton->uHeight = pTextHeight;
-            v77 = pButton->uY + pTextHeight - 1;
-            pButton->uW = v77;
-            pColorText = pColorYellow;
-            if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
-              pColorText = pColorWhite;
-            dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
-            ++pItemNum;
-            ++pNumString;
-            pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
-          }
-          while ( pItemNum < pNumActiveItem );
+          pButton = pDialogueWindow->GetControl(i);
+          pButton->uY = v18 + v105;
+          pButton->uHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
+          v105 = pButton->uY + pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0) - 1;
+          pButton->uW = v105;
+          pColorText = TargetColor(0xE1u, 0xCDu, 0x23u);
+          if ( pDialogueWindow->pCurrentPosActiveItem != i )
+            pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+          dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
+          ++pNumString;
         }
       }
       return;
     }
+
     case HOUSE_DIALOGUE_SHOP_BUY_STANDARD:
     {
       pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
-      v114 = 0;
-      do
+      for ( uint i = 0; i < 6; ++i )
       {
-        if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID)
+        if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID )
         {
-          v46 = ItemsInShopTexture[v114];
-          v47 = 152 - v46->uTextureHeight;
+          v47 = 152 - ItemsInShopTexture[i]->uTextureHeight;
           if ( (signed int)v47 < 1 )
             v47 = 0;
-          v48 = 75 * v114 - v46->uTextureWidth / 2 + 40;
-          if ( v114 )
+          v48 = 75 * i - ItemsInShopTexture[i]->uTextureWidth / 2 + 40;
+          if ( i )
           {
-            if ( v114 == 5 )
+            if ( i == 5 )
             {
-              v49 = ItemsInShopTexture[5]->uTextureWidth;
-              if ( (signed int)v48 > 457 - v49 )
-                v48 = 457 - v49;
+              if ( (signed int)v48 > 457 - ItemsInShopTexture[5]->uTextureWidth )
+                v48 = 457 - ItemsInShopTexture[5]->uTextureWidth;
             }
           }
           else if ( (signed int)v48 < 18 )
             v48 = 18;
-          pRenderer->DrawTextureTransparent(v48, v47, v46);
-          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[v48 + 640 * v47], ItemsInShopTexture[v114], v114 + 1);
+          pRenderer->DrawTextureTransparent(v48, v47, ItemsInShopTexture[i]);
+          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[v48 + 640 * v47], ItemsInShopTexture[i], i + 1);
         }
-        ++v114;
       }
-      while ( v114 < 6 );
-      v114 = 0;
-      do
+      for ( uint i = 0; i < 6; ++i )
       {
-        if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114 + 6].uItemID)
+        if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i + 6].uItemID )
         {
-          v50 = ItemsInShopTexture[v114 + 6];
-          v51 = 308 - v50->uTextureHeight;
+          v51 = 308 - ItemsInShopTexture[i + 6]->uTextureHeight;
           if ( (signed int)v51 < 1 )
             v51 = 0;
-          v52 = 75 * v114 - v50->uTextureWidth / 2 + 40;
-          if ( v114 )
+          v52 = 75 * i - ItemsInShopTexture[i + 6]->uTextureWidth / 2 + 40;
+          if ( i )
           {
-            if ( v114 == 5 )
+            if ( i == 5 )
             {
-              v53 = ItemsInShopTexture[11]->uTextureWidth;
-              if ( (signed int)v52 > 457 - v53 )
-                v52 = 457 - v53;
+              if ( (signed int)v52 > 457 - ItemsInShopTexture[11]->uTextureWidth )
+                v52 = 457 - ItemsInShopTexture[11]->uTextureWidth;
             }
           }
           else
@@ -1103,69 +789,133 @@
             if ( (signed int)v52 < 18 )
               v52 = 18;
           }
-          pRenderer->DrawTextureTransparent(v52, v51, v50);
-          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[v52 + 640 * v51], ItemsInShopTexture[v114 + 6], v114 + 7);
+          pRenderer->DrawTextureTransparent(v52, v51, ItemsInShopTexture[i + 6]);
+          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[v52 + 640 * v51], ItemsInShopTexture[i + 6], i + 7);
         }
-        ++v114;
       }
-      while ( v114 < 6 );
       if ( HouseUI_CheckIfPlayerCanInteract() )
       {
-        v62 = 0;
-        v109 = 0;
-        do
+        item_num = 0;
+        for ( uint i = 0; i < 12; ++i )
         {
-          if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID)
-            ++v109;
-          ++v62;
+          if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID)
+            ++item_num;
         }
-        while ( v62 < 12 );
-        v63 = GetAsyncKeyState(17);
-        v64 = pPlayer->CanSteal();
-        Str = v64;
-        if ( v63 && v64 )
-        {
-          v65 = pGlobalTXT_LocalizationStrings[185];
-        }
-        else if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
-        {
-          v65 = pGlobalTXT_LocalizationStrings[195];
-        }
+        if ( GetAsyncKeyState(17) && pPlayers[uActiveCharacter]->CanSteal() )
+          DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[185], 0);
         else
-        {
-          v65 = pGlobalTXT_LocalizationStrings[196];
-        }
-        DrawTextAtStatusBar(v65, 0);
-        if ( !v109 )
+          DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[195], 0);
+        if ( !item_num )
         {
           dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
           return;
         }
-        pMouse->GetCursorPos(&v98);
-        pNumActiveItem = v98.x + pSRZBufferLineOffsets[v98.y];
-        if ( pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF )
+        pMouse->GetCursorPos(&mouse);
+        if ( pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF )
         {
-          v67 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1;
-          v70 = (ItemGen *)&pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v67];
-          if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
-            v70 = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724];
-          if ( !v63 || !Str )
+          item = &pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) - 1];
+          if ( !GetAsyncKeyState(17) || !pPlayers[uActiveCharacter]->CanSteal() )
           {
-            v71 = pPlayer->SelectPhrasesTransaction(v70, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 2);
-            v38 = (char *)pMerchantsBuyPhrases[v71];
+            v71 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 2);
+            pText = BuildDialogueString((char *)pMerchantsBuyPhrases[v71], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
           }
           else
-          {
-            v38 = pGlobalTXT_LocalizationStrings[181];
-          }
-          v21 = BuildDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-          v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0);
-          dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3);
+            pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
+          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
           return ;
         }
       }
       return;
     }
+
+    case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL:
+    {
+      pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
+      for ( uint i = 0; i < 6; ++i )
+      {
+        if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID)
+        {
+          v47 = 152 - ItemsInShopTexture[i]->uTextureHeight;
+          if ( (signed int)v47 < 1 )
+            v47 = 0;
+          v48 = 75 * i - ItemsInShopTexture[i]->uTextureWidth / 2 + 40;
+          if ( i )
+          {
+            if ( i == 5 )
+            {
+              if ( (signed int)v48 > 457 - ItemsInShopTexture[5]->uTextureWidth )
+                v48 = 457 - ItemsInShopTexture[5]->uTextureWidth;
+            }
+          }
+          else
+          {
+            if ( (signed int)v48 < 18 )
+              v48 = 18;
+          }
+          pRenderer->DrawTextureTransparent(v48, v47, ItemsInShopTexture[i]);
+          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[v48 + 640 * v47], ItemsInShopTexture[i], i + 1);
+        }
+      }
+      for ( uint i = 0; i < 6; ++i )
+      {
+        if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)i + 6].uItemID) //not itemid
+        {
+          v51 = 308 - ItemsInShopTexture[i + 6]->uTextureHeight;
+          if ( (signed int)v51 < 1 )
+            v51 = 0;
+          v52 = 75 * i - ItemsInShopTexture[i + 6]->uTextureWidth / 2 + 40;
+          if ( i )
+          {
+            if ( i == 5 )
+            {
+              if ( (signed int)v52 > 457 - ItemsInShopTexture[11]->uTextureWidth )
+                v52 = 457 - ItemsInShopTexture[11]->uTextureWidth;
+            }
+          }
+          else
+          {
+            if ( (signed int)v52 < 18 )
+              v52 = 18;
+          }
+          pRenderer->DrawTextureTransparent(v52, v51, ItemsInShopTexture[i + 6]);
+          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[v52 + 640 * v51], ItemsInShopTexture[i + 6], i + 7);
+        }
+      }
+      if ( HouseUI_CheckIfPlayerCanInteract() )
+      {
+        item_num = 0;
+        for ( uint i = 0; i < 12; ++i )
+        {
+          if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][i].uItemID)
+            ++item_num;
+        }
+        if ( GetAsyncKeyState(17) && pPlayers[uActiveCharacter]->CanSteal() )
+          DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[185], 0);
+        else
+          DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[196], 0);
+        if ( !item_num )
+        {
+          dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
+          return;
+        }
+        pMouse->GetCursorPos(&mouse);
+        if ( pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF )
+        {
+          item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][(pRenderer->pActiveZBuffer[mouse.x + pSRZBufferLineOffsets[mouse.y]] & 0xFFFF) - 1];
+          if ( !GetAsyncKeyState(17) || !pPlayers[uActiveCharacter]->CanSteal() )
+          {
+            v71 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 2);
+            pText = BuildDialogueString((char *)pMerchantsBuyPhrases[v71], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
+          }
+          else
+            pText = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
+          dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
+          return;
+        }
+      }
+      return;
+    }
+
     case HOUSE_DIALOGUE_SHOP_SELL:
     {
       draw_leather();
@@ -1173,17 +923,20 @@
       DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);
       if ( !HouseUI_CheckIfPlayerCanInteract() )
         return;
-      if ((v43 = pMouse->GetCursorPos(&v99)->x - 14, v109 = (v43 >> 5) + 14 * ((pMouse->GetCursorPos(&v95)->y - 17) >> 5),
-           pMouse->GetCursorPos(&v102)->x <= 13) || pMouse->GetCursorPos(&v100)->x >= 462 
-          || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v109), !pNumActiveItem) )
+      pMouse->GetCursorPos(&mouse);
+      index = ((mouse.x - 14) >> 5) + 14 * ((mouse.y - 17) >> 5);
+      if ( mouse.x <= 13 || mouse.x >= 462 )
+        return;
+      if ( !pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&index) )
           return;
-      v87 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1];
-      v45 = pPlayer->SelectPhrasesTransaction(v87, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 3);
-      v21 = BuildDialogueString((char *)pMerchantsSellPhrases[v45], uActiveCharacter - 1, v87, (char *)window_SpeakInHouse->ptr_1C, 3, 0);
-      pTextHeight = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0);
-      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v21, 3);
+      v71 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&index) - 1],
+             BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 3);
+      pText = BuildDialogueString((char *)pMerchantsSellPhrases[v71], uActiveCharacter - 1, &pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&index) - 1],
+             (char *)window_SpeakInHouse->ptr_1C, 3, 0);
+      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
       return; 
     }
+
     case HOUSE_DIALOGUE_SHOP_IDENTIFY:
     {
       draw_leather();
@@ -1191,25 +944,24 @@
       DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);
       if ( HouseUI_CheckIfPlayerCanInteract() )
         return;
-      if ((v36 = pMouse->GetCursorPos(&a2)->x - 14, v109 = (v36 >> 5) + 14 * ((pMouse->GetCursorPos(&v94)->y - 17) >> 5),
-          pMouse->GetCursorPos(&v101)->x <= 13) || pMouse->GetCursorPos(&v97)->x >= 462
-         || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v109), !pNumActiveItem) )
+      pMouse->GetCursorPos(&mouse);
+      index = ((mouse.x - 14) >> 5) + 14 * ((mouse.y - 17) >> 5);
+      if ( mouse.x <= 13 || mouse.x >= 462 )
+        return;
+      if ( !pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&index) )
         return;
-      v37 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1];
-      if (!v37->IsIdentified())
+      item = &pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&index) - 1];
+      if (!item->IsIdentified())
       {
-        v42 = pPlayer->SelectPhrasesTransaction(v37, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 4);
-        v38 = (char *)pMerchantsIdentifyPhrases[v42];
+        v71 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 4);
+        pText = BuildDialogueString(pMerchantsIdentifyPhrases[v71], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
       }
       else
-      {
-        v38 = "%24";
-      }
-      v21 = BuildDialogueString(v38, uActiveCharacter - 1, v37, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
-      v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0);
-      dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3);
+        pText = BuildDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
+      dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pText, &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xFFu, 0xFFu, 0xFFu), pText, 3);
       return;
     }
+
     case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT:
     {
       draw_leather();
@@ -1219,244 +971,94 @@
       all_text_height = 0;
       for ( int i = 0; i < 2; ++i )
         all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0);
-      Str = (174 - all_text_height) / 2;
-      pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
-      v26 = pNumActiveItem + pDialogueWindow->pNumPresenceButton;
-      v27 = (2 * (87 - (174 - all_text_height) / 2) - all_text_height) / 2 - (174 - all_text_height) / 2 / 2 + 138;
-      v28 = -pDialogueWindow->pNumPresenceButton < 0;
-      if ( v28 ^ (pNumActiveItem > v26) )
+      v18 = (174 - all_text_height) / 2;
+      v105 = (2 * (87 - (174 - all_text_height) / 2) - all_text_height) / 2 - (174 - all_text_height) / 2 / 2 + 138;
+      pNumString = 0;
+      for ( int i = pDialogueWindow->pStartingPosActiveItem;
+                i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
       {
-        pItemNum = 2;
-        pNumString = 0;
-        do
-        {
-          pButton = pDialogueWindow->GetControl(pItemNum);
-          pButton->uY = Str + v27;
-          pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
-          pButton->uHeight = pTextHeight;
-          v27 = pButton->uY + pTextHeight - 1;
-          pButton->uW = v27;
-          pColorText = pColorYellow;
-          if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
-            pColorText = pColorWhite;
-          dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
-          ++pItemNum;
-          ++pNumString;
-          pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
-        }
-        while ( pItemNum < pNumActiveItem );
+        pButton = pDialogueWindow->GetControl(i);
+        pButton->uY = v18 + v105;
+        pButton->uHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0);
+        v105 = pButton->uY + pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0) - 1;
+        pButton->uW = v105;
+        pColorText = TargetColor(0xE1u, 0xCDu, 0x23u);
+        if ( pDialogueWindow->pCurrentPosActiveItem != i )
+          pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+        dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3);
+        ++pNumString;
       }
       return;
     }
-    case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL:
-    {
-      pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
-      v114 = 0;
-      do
-      {
-        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);
-          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[v56 + 640 * v55], ItemsInShopTexture[v114], v114 + 1);
-        }
-        ++v114;
-      }
-      while ( v114 < 6 );
-      v114 = 0;
-      do
-      {
-        if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v114 + 6].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);
-          ZBuffer_DoFill2(&pRenderer->pActiveZBuffer[v60 + 640 * v59], ItemsInShopTexture[v114 + 6], v114 + 7);
-        }
-        ++v114;
-      }
-      while ( v114 < 6 );
-      if ( HouseUI_CheckIfPlayerCanInteract() )
-      {
-        v62 = 0;
-        v109 = 0;
-        do
-        {
-          if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID)
-            ++v109;
-          ++v62;
-        }
-        while ( v62 < 12 );
-        v63 = GetAsyncKeyState(17);
-        v64 = pPlayer->CanSteal();
-        Str = v64;
-        if ( v63 && v64 )
-        {
-          v65 = pGlobalTXT_LocalizationStrings[185];
-        }
-        else
-        {
-          v65 = pGlobalTXT_LocalizationStrings[195];
-          if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
-            v65 = pGlobalTXT_LocalizationStrings[196];
-        }
-        DrawTextAtStatusBar(v65, 0);
-        if ( !v109 )
-        {
-          dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);
-          return;
-        }
-        v66 = pMouse->GetCursorPos(&v98);
-        pNumActiveItem = v66->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v96)->y];
-        if ( pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF )
-        {
-          v67 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1;
-          v109 = v67;
-          v68 = (int)window_SpeakInHouse->ptr_1C;
-          //  v69 = 9 * (v67 + 12 * v68);
-          v70 = (ItemGen *)&pParty->StandartItemsInShops[v68][v67];
-          if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
-            v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724];
-          if ( !v63 || !Str )
-          {
-            v71 = pPlayer->SelectPhrasesTransaction(v70, BuildingType_AlchemistShop, v68, 2);
-            v38 = (char *)pMerchantsBuyPhrases[v71];
-          }
-          else
-          {
-            v38 = pGlobalTXT_LocalizationStrings[181];
-          }
-          v21 = BuildDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
-          v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0);
-          dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3);
-          return;
-        }
-      }
-      return;
-    }
+
     case HOUSE_DIALOGUE_LEARN_SKILLS:
     {
       if (!HouseUI_CheckIfPlayerCanInteract())
         return;
       all_text_height = 0;
       v5 = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
-      pItemNum = v5 * (100 - pPlayer->GetMerchant()) / 100;
-      if ( pItemNum < v5 / 3 )
-        pItemNum = v5 / 3;
-      pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
-      v114 = 0;
-      if ( pNumActiveItem >= pNumActiveItem + pDialogueWindow->pNumPresenceButton )
+      pPrice = v5 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
+      if ( pPrice < v5 / 3 )
+        pPrice = v5 / 3;
+      item_num = 0;
+      for ( int i = pDialogueWindow->pStartingPosActiveItem;
+                i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i )
       {
-        sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]);
+        pButton = pDialogueWindow->GetControl(i);
+        if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pButton->msg_param - 36]
+         && !pPlayers[uActiveCharacter]->pActiveSkills[pButton->msg_param - 36] )
+        {
+          all_text_height = pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0);
+          ++item_num;
+        }
+      }
+      if ( !item_num )
+      {
+        sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);
         strcat(pTmpBuf.data(), "\n \n");
         strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);
-        v40 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0);
-        dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorYellow, pTmpBuf.data(), 3);
-        return;
-      }
-      do
-      {
-        v8 = pDialogueWindow->GetControl(pNumActiveItem)->msg_param - 36;
-        if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v8] && !pPlayer->pActiveSkills[v8] )
-        {
-          all_text_height = pFontArrus->CalcTextHeight(pSkillNames[v8], &dialog_window, 0, 0);
-          ++v114;
-        }
-        ++pNumActiveItem;
-      }
-      while ( pNumActiveItem < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
-      if ( !v114 )
-      {
-        sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]);
-        strcat(pTmpBuf.data(), "\n \n");
-        strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);
-        v40 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0);
-        dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorYellow, pTmpBuf.data(), 3);
+        dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138, TargetColor(0xE1u, 0xCDu, 0x23u), pTmpBuf.data(), 3);
         return;
       }
-      if ( v114 )
+      if ( item_num )
       {
-        sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pItemNum);
+        sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pPrice);
         dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3);
-        v18 = (149 - all_text_height) / v114;
-        if ( (149 - all_text_height) / v114 > 32 )
+        v18 = (149 - all_text_height) / item_num;
+        if ( (149 - all_text_height) / item_num > 32 )
           v18 = 32;
-        pNumActiveItem = pDialogueWindow->pStartingPosActiveItem;
-        v105 = (149 - v114 * v18 - all_text_height) / 2 - v18 / 2 + 162;
-        if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton )
+        v105 = (149 - item_num * v18 - all_text_height) / 2 - v18 / 2 + 162;
+        for ( int i = pDialogueWindow->pStartingPosActiveItem;
+                  i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; i++ )
         {
-          pItemNum = 2;
-          do
+          pButton = pDialogueWindow->GetControl(i);
+          if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][pButton->msg_param - 36]
+             || pPlayers[uActiveCharacter]->pActiveSkills[pButton->msg_param - 36] )
           {
-            pButton = pDialogueWindow->GetControl(pItemNum);
-            v13 = pButton->msg_param - 36;
-            if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v13] || pPlayer->pActiveSkills[v13] )
-            {
-              pButton->uW = 0;
-              pButton->uHeight = 0;
-              pButton->uY = 0;
-            }
-            else
-            {
-              pButton->uY = v18 + v105;
-              pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v13], &dialog_window, 0, 0);
-              pButton->uHeight = pTextHeight;
-              v105 = pButton->uY + pTextHeight - 1;
-              pButton->uW = v105;
-              pColorText = pColorYellow;
-              if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
-                pColorText = pColorWhite;
-              dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[v13], 3);
-            }
-            pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
-            pItemNum++;
+            pButton->uW = 0;
+            pButton->uHeight = 0;
+            pButton->uY = 0;
           }
-          while ( pItemNum < pNumActiveItem );
+          else
+          {
+            pButton->uY = v18 + v105;
+            pButton->uHeight = pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0);
+            v105 = pButton->uY + pFontArrus->CalcTextHeight(pSkillNames[pButton->msg_param - 36], &dialog_window, 0, 0) - 1;
+            pButton->uW = v105;
+            pColorText = TargetColor(0xE1u, 0xCDu, 0x23u);
+            if ( pDialogueWindow->pCurrentPosActiveItem != i )
+              pColorText = TargetColor(0xFFu, 0xFFu, 0xFFu);
+            dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[pButton->msg_param - 36], 3);
+          }
         }
         return;
       }
     }
     default:
-    {
-      return;// (POINT *)dialog_menu_id - 96;
-    }
+      __debugbreak();
   }
 }
+
 //----- (004B4FCF) --------------------------------------------------------
 void MagicShopDialog()
 {
--- a/UI/UITransition.cpp	Mon Sep 30 09:30:31 2013 +0600
+++ b/UI/UITransition.cpp	Mon Sep 30 09:30:42 2013 +0600
@@ -23,7 +23,6 @@
 
 
 
-
 //----- (00444839) --------------------------------------------------------
 void TransitionUI_Load(uint anim_id, uint exit_pic_id, int x, int y, int z, int directiony, int directionx, int a8, const char *pLocationName)
 {
@@ -32,16 +31,12 @@
   unsigned int v14; // eax@8
   const char *v15; // eax@14
   unsigned int v16; // eax@16
-  //unsigned int result; // eax@26
   const char *v18; // [sp-8h] [bp-40h]@9
-  //const char *v19; // [sp-4h] [bp-3Ch]@2
   char *v20; // [sp-4h] [bp-3Ch]@9
   const char *v21; // [sp-4h] [bp-3Ch]@11
   char pContainer[40]; // [sp+Ch] [bp-2Ch]@1
   unsigned int v23; // [sp+34h] [bp-4h]@1
 
-  //v9 = a1;
-  //v10 = a2;
   v23 = IndoorLocation::GetLocationIndex(pLocationName);
   dword_59117C_teleportx = x;
   dword_591178_teleporty = y;