changeset 909:becbb0b11b7d

Слияние
author Ritor1
date Mon, 22 Apr 2013 09:25:22 +0600
parents e2c1cb9b46f6 (current diff) f3ccfc765502 (diff)
children 8cd0b155bebe
files mm7_4.cpp
diffstat 11 files changed, 90 insertions(+), 134 deletions(-) [+]
line wrap: on
line diff
--- a/GUIWindow.h	Mon Apr 22 09:25:05 2013 +0600
+++ b/GUIWindow.h	Mon Apr 22 09:25:22 2013 +0600
@@ -76,13 +76,13 @@
   UIMSG_ShowStatus_Player = 94,
   UIMSG_Wait5Minutes  = 95,
   UIMSG_Wait1Hour = 96,
-  UIMSG_61 = 97,
+  UIMSG_Rest8Hour = 97,
 
   UIMSG_ShowStatus_Food = 100,
   UIMSG_ShowStatus_Funds = 101,
 
-  UIMSG_68 = 104,
-  UIMSG_69 = 105,
+  UIMSG_RestWindow = 104,
+  UIMSG_SpellBookWindow = 105,
   UIMSG_QuickReference = 106,
   UIMSG_GameMenuButton = 107,
 
@@ -190,7 +190,7 @@
   UIMSG_Game_Action = 404,
   UIMSG_SelectShopDialogueOption = 405,
 
-  UIMSG_OpenRestUI = 409,
+  UIMSG_RentRoom = 409,
   UIMSG_19A = 410,
   UIMSG_TransitionUI_Confirm = 411,
   UIMSG_19C = 412,
--- a/Items.cpp	Mon Apr 22 09:25:05 2013 +0600
+++ b/Items.cpp	Mon Apr 22 09:25:22 2013 +0600
@@ -307,7 +307,6 @@
   pItemsTXT_Raw = NULL;
 }
 
-
 //----- (00456D84) --------------------------------------------------------
 void ItemsTable::Initialize()
 	{
--- a/UIHouses.cpp	Mon Apr 22 09:25:05 2013 +0600
+++ b/UIHouses.cpp	Mon Apr 22 09:25:22 2013 +0600
@@ -2597,7 +2597,7 @@
       if ( pParty->uNumGold >= (unsigned int)pOutString )
       {
         Party::TakeGold((unsigned int)pOutString);
-        v27 = (int)window_SpeakInHouse->ptr_1C;
+        v27 = (int)window_SpeakInHouse->ptr_1C;//107
         PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
         dialog_menu_id = HOUSE_DIALOGUE_NULL;
         sub_4BD8B5();
@@ -2607,7 +2607,7 @@
         window_SpeakInHouse = 0;
         if ( pMessageQueue_50CBD0->uNumMessages )
           pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
-        pMessageQueue_50CBD0->pMessages[0].eType = UIMSG_OpenRestUI;
+        pMessageQueue_50CBD0->pMessages[0].eType = UIMSG_RentRoom;
         pMessageQueue_50CBD0->pMessages[0].param = v27;
         pMessageQueue_50CBD0->pMessages[0].field_8 = 1;
         ++pMessageQueue_50CBD0->uNumMessages;
@@ -3896,7 +3896,6 @@
   int v33; // eax@34
   int v35; // eax@35
   char *v36; // edx@36
-  GUIWindow *v37; // edi@42
   signed int v38; // esi@42
   unsigned int v39; // esi@44
   int v40; // eax@44
@@ -4137,7 +4136,6 @@
       pItemCount = 0;
       do
       {
-        // if ( (char *)pParty->field_C59C[9 * (v68 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] != v11 )
         if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][(signed int)v68].uItemID)
         ++pItemCount;
         ++v68;
@@ -4158,7 +4156,7 @@
         if ( dialog_menu_id == 2 )
           selected_item = &pParty->StandartItemsInShops[window_SpeakInHouse->par1C][v74-1];
         else
-          selected_item = &pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v74-1];//(ItemGen *)&pParty->field_C59C[v76 + 724];
+          selected_item = &pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v74 - 1];
         if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0 )
           v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->_490EEE(selected_item, 2, window_SpeakInHouse->par1C, 2)];
         else
@@ -4221,7 +4219,7 @@
          pMouse->GetCursorPos(&v137)->x <= 13) || pMouse->GetCursorPos(&v129)->x >= 462 
          || (v10 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount), v11 = 0, !v10) )
            return;
-      v116 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v10-1];
+      v116 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v10 - 1];
       v13 = pPlayers[uActiveCharacter]->_490EEE(v116, 2, window_SpeakInHouse->par1C, 3);
       v15 = (char *)pMerchantsSellPhrases[pPlayers[uActiveCharacter]->_490EEE(v116, 2, window_SpeakInHouse->par1C, 3)];
       v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *) window_SpeakInHouse->par1C, 3, 0);
@@ -4352,20 +4350,18 @@
       if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
         return;
       v152 = 0;
-      v37 = pDialogueWindow;
-      //v38 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.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 = v37->pStartingPosActiveItem;
-      v40 = v37->pNumPresenceButton;
+      v39 = pDialogueWindow->pStartingPosActiveItem;
+      v40 = pDialogueWindow->pNumPresenceButton;
       v153 = 0;
       if ( (signed int)v39 < (signed int)(v39 + v40) )
       {
         do
         {
-          v41 = v37->GetControl(v39)->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);
@@ -4374,7 +4370,7 @@
           }
           ++v39;
         }
-        while ( (signed int)v39 < v37->pNumPresenceButton + v37->pStartingPosActiveItem );
+        while ( (signed int)v39 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
         if ( v153 )
         {
           sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], pActiveButton);
@@ -4383,14 +4379,14 @@
           if ( (149 - v152) / v153 > 32 )
             pActiveButton = 32;
           v43 = (149 - v153 * (signed int)pActiveButton - v152) / 2 - (signed int)pActiveButton / 2 + 162;
-          v152 = v37->pStartingPosActiveItem;
+          v152 = pDialogueWindow->pStartingPosActiveItem;
           v146 = v43;
-          if ( v152 < v152 + v37->pNumPresenceButton )
+          if ( v152 < v152 + pDialogueWindow->pNumPresenceButton )
           {
             v153 = 2;
             do
             {
-              pButton = v37->GetControl(v152);
+              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] )
               {
@@ -4412,9 +4408,9 @@
                   pTextColor = pWhiteColor;
                 dialog_window.DrawTitleText(pFontArrus, 0, v49, pTextColor, pSkillNames[v46], 3);
               }
-              v53 = v37->pStartingPosActiveItem;
+              v53 = pDialogueWindow->pStartingPosActiveItem;
               ++v152;
-              textureH = v37->pNumPresenceButton + v53;
+              textureH = pDialogueWindow->pNumPresenceButton + v53;
               ++v153;
             }
             while ( v152 < textureH );
@@ -4518,7 +4514,6 @@
     {
       if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
       {
-        //v3 = (int)(&currPlayer->uIntelligence + dword_F8B19C); //test skill
         if ( pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] )
         {
           sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[403], pClassNames[dialog_menu_id - 16]); //"You already know the %s skill"
@@ -4549,11 +4544,9 @@
     do
     {
       if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v6].uItemID)
-                   // if ( *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v6 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)) )
       {
         pRenderer->DrawTextureTransparent(v63, 0x5Au, ItemsInShopTexture[v6]);
         ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 230528), ItemsInShopTexture[v6], v6 + 1);
-                   //currPlayer = v58;
       }
       v63 += 70;
       v62 += 280;
@@ -5927,7 +5920,7 @@
       return;
     }
   }
-  pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
+  pRenderer->DrawTextureIndexed(8, 8, ShopTexture);
   v3 = 0;
   v49 = 0;
   v122 = 0;
@@ -5935,8 +5928,7 @@
   {
     do
     {
-     // if ( pParty->field_777C[9 * (v49 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
-	 if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v49].uItemID)
+      if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v49].uItemID)
       {
         v50 = ItemsInShopTexture[v49];
         v51 = 152 - v50->uTextureHeight;
@@ -5968,8 +5960,7 @@
     v122 = 0;
     do
     {
-      //if ( pParty->field_777C[9 * (v122 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] )
-	if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v122+1].uItemID)
+      if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v122 + 1].uItemID)
       {
         v54 = ItemsInShopTexture[v122 + 6];
         v55 = 306 - v54->uTextureHeight;
@@ -6113,32 +6104,17 @@
       v71 = (pRenderer->pActiveZBuffer[result] & 0xFFFF) - 1;
       v117 = v71;
       v72 = (int)window_SpeakInHouse->ptr_1C;
-     // v73 = 9 * (v71 + 12 * v72);
       v74 = (ItemGen *)&pParty->StandartItemsInShops[v72][v71];
       if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
-       // v74 = (ItemGen *)&pParty->field_C59C[v73 + 724];
-	      v74 =&pParty->SpecialItemsInShops[v72][v71];
+        v74 =&pParty->SpecialItemsInShops[v72][v71];
       if ( v67 && Str )
-      {
         v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24"
-        v96 = 0;
-        v94 = 2;
-        v93 = window_SpeakInHouse->ptr_1C;
-        v90 = v74;
-        v9 = uActiveCharacter - 1;
-      }
       else
       {
-        v96 = 0;
-        v94 = 2;
-        v93 = window_SpeakInHouse->ptr_1C;
-        v90 = v74;
-        uPlayerID = uActiveCharacter - 1;
         v75 = _this->_490EEE(v74, 3, v72, 2);
-        v9 = uPlayerID;
         v10 = (char *)pMerchantsBuyPhrases[v75];
       }
-      v30 = BuilDialogueString(v10, v9, v90, (char *)v93, v94, v96);
+      v30 = BuilDialogueString(v10, uActiveCharacter - 1, v74, (char *)window_SpeakInHouse->ptr_1C, 2, 0);
       v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138;
       dialog_window.DrawTitleText(pFontArrus, v3, v6, m_text_color, v30, 3);
       return;
--- a/UIMainMenu.cpp	Mon Apr 22 09:25:05 2013 +0600
+++ b/UIMainMenu.cpp	Mon Apr 22 09:25:22 2013 +0600
@@ -217,13 +217,13 @@
     pBtn_CastSpell = pPrimaryWindow->CreateButton(0x1DCu, 0x1C2u,
         (uTextureID_Btn_CastSpell != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_CastSpell].uTextureWidth : 24),
         (uTextureID_Btn_CastSpell != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_CastSpell].uTextureHeight : 26),
-        1, 0, UIMSG_69, 0, 0x43u, pGlobalTXT_LocalizationStrings[38],
+        1, 0, UIMSG_SpellBookWindow, 0, 0x43u, pGlobalTXT_LocalizationStrings[38],
         (Texture *)(uTextureID_Btn_CastSpell != -1 ? &pIcons_LOD->pTextures[uTextureID_Btn_CastSpell] : 0),
         0);
     pBtn_Rest = pPrimaryWindow->CreateButton(0x206u, 0x1C2u,
         (uTextureID_Btn_Rest != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_Rest].uTextureWidth : 24),
         (uTextureID_Btn_Rest != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_Rest].uTextureHeight : 26),
-        1, 0, UIMSG_68, 0, 0x52u, pGlobalTXT_LocalizationStrings[182],
+        1, 0, UIMSG_RestWindow, 0, 0x52u, pGlobalTXT_LocalizationStrings[182],
         (Texture *)(uTextureID_Btn_Rest != -1 ? &pIcons_LOD->pTextures[uTextureID_Btn_Rest] : 0), 0);
     pBtn_QuickReference = pPrimaryWindow->CreateButton(0x230u, 0x1C2u,
         (uTextureID_Btn_QuickReference != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_QuickReference].uTextureWidth : 24),
--- a/UIPopup.cpp	Mon Apr 22 09:25:05 2013 +0600
+++ b/UIPopup.cpp	Mon Apr 22 09:25:22 2013 +0600
@@ -2144,12 +2144,11 @@
             break;
             }
         case SCREEN_HOUSE:
-            {
-            if ( (signed int)pY < 345 && (signed int)pX < 469 )
-                sub_4B1A2D();//identify item in inventory
-            break;
-            }
-
+        {
+          if ( (signed int)pY < 345 && (signed int)pX < 469 )
+            ShowPopupShopItem();
+          break;
+        }
         case SCREEN_PARTY_CREATION:
             {
             pWindow.Hint = 0;
--- a/UIRest.cpp	Mon Apr 22 09:25:05 2013 +0600
+++ b/UIRest.cpp	Mon Apr 22 09:25:22 2013 +0600
@@ -127,7 +127,7 @@
         37u,
         1,
         0,
-        UIMSG_61,
+        UIMSG_Rest8Hour,
         0,
         0x52u,
         "",
--- a/mm7_2.cpp	Mon Apr 22 09:25:05 2013 +0600
+++ b/mm7_2.cpp	Mon Apr 22 09:25:22 2013 +0600
@@ -1041,7 +1041,7 @@
         || (v15 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79), !v15) )
           return;
       v16 = window_SpeakInHouse;
-      if ( sub_4BDAAF(&pPlayers[uActiveCharacter]->pInventoryItems[v15-1], (int)window_SpeakInHouse->ptr_1C) )
+      if ( MerchandiseTest(&pPlayers[uActiveCharacter]->pInventoryItems[v15-1], (int)window_SpeakInHouse->ptr_1C) )
       {
         dword_F8B1E4 = 1;
         pPlayers[uActiveCharacter]->SalesProcess(v79, v15 - 1, (int)v16->ptr_1C);
@@ -1070,7 +1070,7 @@
           if ( !(*(char *)(v12 + 20) & 1) )
           {
             _this = (ItemGen *)window_SpeakInHouse->ptr_1C;
-            if ( sub_4BDAAF((ItemGen *)v12, (int)_this) )
+            if ( MerchandiseTest((ItemGen *)v12, (int)_this) )
             {
               if ( pParty->uNumGold >= v80 )
               {
@@ -1117,7 +1117,7 @@
             if ( !v7 )
             {
               _this = (ItemGen *)window_SpeakInHouse->ptr_1C;
-              if ( sub_4BDAAF((ItemGen *)v3, (int)_this) )
+              if ( MerchandiseTest((ItemGen *)v3, (int)_this) )
               {
                 if ( pParty->uNumGold >= v80 )
                 {
@@ -9018,13 +9018,12 @@
           uGameState = 0;
           continue;
         }
-        if ( uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)
-          __debugbreak();
-        /*{
+        if ( uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)// from the loaded game
+        {
           pAudioPlayer->StopChannels(-1, -1);
           uGameState = 0;
           break;
-        }*/
+        }
       }
       if (!bNoSound && pAudioPlayer->hAILRedbook)
       {
--- a/mm7_4.cpp	Mon Apr 22 09:25:05 2013 +0600
+++ b/mm7_4.cpp	Mon Apr 22 09:25:22 2013 +0600
@@ -6265,11 +6265,9 @@
 }
 // F8B1E0: using guessed type int dword_F8B1E0;
 
-//view  item details  in shop?
 //----- (004B1A2D) --------------------------------------------------------
-void __cdecl sub_4B1A2D()
+void __cdecl ShowPopupShopItem()
 {
-  //Player *v0; // edi@1
   POINT *v1; // esi@5
   unsigned int v2; // eax@5
   int v3; // ecx@5
@@ -6287,9 +6285,7 @@
   POINT  v15; // [sp+30h] [bp-1Ch]@17
   POINT v16; // [sp+38h] [bp-14h]@5
   POINT a2; // [sp+40h] [bp-Ch]@5
-  int v18; // [sp+48h] [bp-4h]@5
-
-  //v0 = pPlayers[uActiveCharacter];
+
   if ( in_current_building_type <= 0 )
     return;
   if ( in_current_building_type <= BildingType_AlchemistShop )
@@ -6301,14 +6297,12 @@
       if ( dialog_menu_id <= HOUSE_DIALOGUE_SHOP_REPAIR || dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT )
       {
         v8 = pMouse->GetCursorPos(&v15)->x - 14;
-        v18 = (v8 >> 5) + 14 * ((pMouse->GetCursorPos(&v14)->y - 17) >> 5);
+        v5 = (v8 >> 5) + 14 * ((pMouse->GetCursorPos(&v14)->y - 17) >> 5);
         if ( pMouse->GetCursorPos(&v13)->x <= 13
           || pMouse->GetCursorPos(&v12)->x >= 462
-          || (v9 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&v18)) == 0 )
+          || (v9 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&v5)) == 0 )
           return;
-        v7 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v9-1];
-LABEL_15:
-        GameUI_DrawItemInfo(v7);
+        GameUI_DrawItemInfo(&pPlayers[uActiveCharacter]->pInventoryItems[v9 - 1]);
         return;
       }
       if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_SPECIAL )
@@ -6316,23 +6310,22 @@
     }
     v4 = pMouse->GetCursorPos(&v11);
     v5 = pRenderer->pActiveZBuffer[v4->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v10)->y]] & 0xFFFF;
-    v18 = v5;
     if ( !v5 )
       return;
     v6 = 9 * (v5 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C);
     v7 = (ItemGen *)((char *)&pParty->pPickedItem + 4 * v6 + 4);
     if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
-   //   v7 = (ItemGen *)&pParty->field_C59C[v6 + 715];
-		v7 =&pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v5 - 1];
-    goto LABEL_15;
+      v7 = &pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v5 - 1];
+    GameUI_DrawItemInfo(v7);
+    return;
   }
   if ( in_current_building_type <= BildingType_16 && dialog_menu_id == HOUSE_DIALOGUE_GUILD_BUY_BOOKS )
   {
     v1 = pMouse->GetCursorPos(&a2);
     v2 = v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v16)->y];
     v3 = pRenderer->pActiveZBuffer[v2] & 0xFFFF;
-    v18 = pRenderer->pActiveZBuffer[v2] & 0xFFFF;
-    if ( v18 )
+    v5 = pRenderer->pActiveZBuffer[v2] & 0xFFFF;
+    if ( v5 )
       sub_4B1523((int *)&pParty->pPlayers[1].uExpressionTimeLength + 9 * (v3 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C));
   }
 }
@@ -6406,7 +6399,6 @@
           return;
       }
       v1 = (unsigned int)window_SpeakInHouse->ptr_1C;
-LABEL_28:
       PlayHouseSound(v1, (HouseSoundID)v0);
       return;
     }
@@ -6418,7 +6410,8 @@
         if ( !dword_F8B1E4 )
           return;
         v0 = 4;
-        goto LABEL_28;
+        PlayHouseSound(v1, (HouseSoundID)v0);
+        return;
       }
       PlayHouseSound(v1, (HouseSoundID)(dword_F8B1E4 + 3));
       if ( !dword_F8B1E4 && !qword_A750D8 )
@@ -6437,7 +6430,8 @@
           qword_A750D8 = 256i64;
           word_A750E0 = 80;
           v4 = LOWORD(v7[rand() % v5]);
-          goto LABEL_16;
+          word_A750E2 = v4;
+          return;
         }
       }
     }
@@ -6459,7 +6453,6 @@
           qword_A750D8 = 256i64;
           word_A750E0 = 80;
           v4 = LOWORD(v7[rand() % v2]);
-LABEL_16:
           word_A750E2 = v4;
           return;
         }
@@ -8243,12 +8236,8 @@
 }
 
 //----- (004BDAAF) --------------------------------------------------------
-bool __fastcall sub_4BDAAF(ItemGen *a1, int _2da_idx)
+bool __fastcall MerchandiseTest(ItemGen *item, int _2da_idx)
 {
-  int v2; // edx@1
-  unsigned int v3; // esi@1
-  unsigned int v4; // eax@1
-  signed int v5; // edi@1
   int v6; // edx@8
   int v7; // edx@9
   int v8; // edx@10
@@ -8257,45 +8246,39 @@
   unsigned __int8 v11; // of@16
   bool test;
 
-  auto a2 = _2da_idx;
-  //v2 = p2DEvents_minus1___00[26 * a2];
-  v2 = p2DEvents[a2 - 1].uType;
-  v3 = a1->uItemID;
-  v4 = a1->uItemID;
-  v5 = pItemsTable->pItems[v4].uEquipType;
-  if ( (v2 != 4 || (signed int)v3 < 740 || (signed int)v3 > 771)
-    && ((signed int)v3 >= 600 || (signed int)v3 >= 529 && (signed int)v3 <= 599) || a1->Stolen())
+  if ( (p2DEvents[_2da_idx - 1].uType != 4 || (signed int)item->uItemID < 740 || (signed int)item->uItemID > 771)
+    && ((signed int)item->uItemID >= 600 || (signed int)item->uItemID >= 529 && (signed int)item->uItemID <= 599) || item->Stolen())
     return 0;
-  switch( p2DEvents[a2 - 1].uType )
-  {
-	case BildingType_WeaponShop:
-		{
-		test = v5 <= 2;
-		break;
-		}
-	case BildingType_ArmorShop:
-		{
-		test = v5 >= 3;
-		break;
-		}
-	case BildingType_MagicShop:
-		{
-		test = pItemsTable->pItems[v4].uSkillType == 38 || v5 == 16;
-		break;
-		}
-	case BildingType_AlchemistShop:
-		{
-		__debugbreak(); // need to test
-		test = v5 == 13 || v5 == 14 || (v5 > 14 && !(v5 != 17 || (signed int)v3 < 740) && v3 != 771);
-		break;
-		}
-	default:
-		{
-		test = 0;
-		break;
-		}
-  }
-
+  switch( p2DEvents[_2da_idx - 1].uType )
+  {
+    case BildingType_WeaponShop:
+    {
+      test = pItemsTable->pItems[item->uItemID].uEquipType <= 2;
+      break;
+    }
+    case BildingType_ArmorShop:
+    {
+      test = pItemsTable->pItems[item->uItemID].uEquipType >= 3;
+      break;
+    }
+    case BildingType_MagicShop:
+    {
+      test = pItemsTable->pItems[item->uItemID].uSkillType == 38 || pItemsTable->pItems[item->uItemID].uEquipType == 16;
+      break;
+    }
+    case BildingType_AlchemistShop:
+    {
+      test = pItemsTable->pItems[item->uItemID].uEquipType == 13 || pItemsTable->pItems[item->uItemID].uEquipType == 14 
+            || (pItemsTable->pItems[item->uItemID].uEquipType > 14 && !(pItemsTable->pItems[item->uItemID].uEquipType != 17 
+            || (signed int)item->uItemID < 740) && item->uItemID != 771);
+      break;
+    }
+    default:
+    {
+      test = false;
+      break;
+    }
+  }
   return test;
 /*
   if ( p2DEvents[a2 - 1].uType == 1 )
--- a/mm7_5.cpp	Mon Apr 22 09:25:05 2013 +0600
+++ b/mm7_5.cpp	Mon Apr 22 09:25:22 2013 +0600
@@ -2539,7 +2539,7 @@
           dword_506F14 = v0;
           _506F18_num_hours_to_sleep = 60;
           continue;
-        case UIMSG_OpenRestUI:
+        case UIMSG_RentRoom:
           dword_506F14 = 2;
           RestUI_Initialize();
           v86 = 60 * (_494820_training_time(pParty->uCurrentHour) + 1) - pParty->uCurrentMinute;
@@ -2555,7 +2555,7 @@
           pParty->pPlayers[1].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
           pParty->pPlayers[0].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed;
           continue;
-        case UIMSG_68:
+        case UIMSG_RestWindow:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           if ( pCurrentScreen )
@@ -2620,7 +2620,7 @@
           v176 = 0;
           v160 = 13;
           goto LABEL_619;
-        case UIMSG_61:
+        case UIMSG_Rest8Hour:
           if ( dword_506F14 )
             //goto LABEL_621;
           {
@@ -2913,7 +2913,7 @@
             _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175);
           }
           continue;
-        case UIMSG_69:
+        case UIMSG_SpellBookWindow:
           if ( pTurnEngine->field_4 == 3 )
             continue;
           if ( bUnderwater == 1 )
--- a/mm7_6.cpp	Mon Apr 22 09:25:05 2013 +0600
+++ b/mm7_6.cpp	Mon Apr 22 09:25:22 2013 +0600
@@ -7696,7 +7696,7 @@
     CASE(UIMSG_ToggleAlwaysRun)
     CASE(UIMSG_ToggleFlipOnExit)
     CASE(UIMSG_Game_Action)
-    CASE(UIMSG_OpenRestUI)
+    CASE(UIMSG_RentRoom)
     CASE(UIMSG_TransitionUI_Confirm)
     CASE(UIMSG_OpenKeyMappingOptions)
     CASE(UIMSG_SelectKeyPage1)
--- a/mm7_data.h	Mon Apr 22 09:25:05 2013 +0600
+++ b/mm7_data.h	Mon Apr 22 09:25:22 2013 +0600
@@ -2053,7 +2053,7 @@
 struct Player *__fastcall sub_4B1447_party_fine(int a1, int a2, int a3);
 void __thiscall sub_4B1523(int *_this);
 bool __cdecl sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-void __cdecl sub_4B1A2D();
+void __cdecl ShowPopupShopItem();
 void __stdcall RestAndHeal(__int64 uNumMinutes); // idb
 void __cdecl sub_4B1D27();
 
@@ -2084,7 +2084,7 @@
 void UI_CreateEndConversationButton();
 void __fastcall OnSelectShopDialogueOption(signed int uMessageParam);
 signed int __cdecl sub_4BD8B5();
-bool __fastcall sub_4BDAAF(ItemGen *a1, int _2da_idx);
+bool __fastcall MerchandiseTest(ItemGen *item, int _2da_idx);
 void __cdecl UIShop_Buy_Identify_Repair();