changeset 749:f39fbeb65b28

Fixed bought items not disappearing from Armourer.
author Nomad
date Fri, 22 Mar 2013 23:26:01 +0200
parents daecb0225226
children 23a07ead5980 e13ce1b0930d
files Items.h Player.cpp Player.h UIHouses.cpp UIHouses.h mm7_1.cpp mm7_2.cpp mm7_4.cpp
diffstat 8 files changed, 114 insertions(+), 107 deletions(-) [+]
line wrap: on
line diff
--- a/Items.h	Fri Mar 22 22:36:26 2013 +0200
+++ b/Items.h	Fri Mar 22 23:26:01 2013 +0200
@@ -128,6 +128,7 @@
   inline bool Identified()    {return uAttributes & ITEM_IDENTIFIED;}
   inline void SetIdentified() {uAttributes |= ITEM_IDENTIFIED;}
   inline bool Stolen()        {return uAttributes & ITEM_STOLEN;}
+  inline void SetStolen()     {uAttributes |= ITEM_STOLEN;}
 
   bool GenerateArtifact();
   unsigned int GetValue();
--- a/Player.cpp	Fri Mar 22 22:36:26 2013 +0200
+++ b/Player.cpp	Fri Mar 22 23:26:01 2013 +0200
@@ -336,16 +336,14 @@
 }
 
 //----- (004B8142) --------------------------------------------------------
-int Player::_4B8142(int a2, float a3)
-{
-  int result; // eax@1
-
-  result = (int)((100 - GetMerchant()) * (unsigned __int64)(signed __int64)((double)a2 * a3)) / 100;
-  if ( result < a2 )
-    result = a2;
-  if ( result < 1 )
-    result = 1;
-  return result;
+int Player::GetBuyingPrice(unsigned int uRealValue, float price_multiplier)
+{
+  uint price = ((100 - GetMerchant()) * (uRealValue * price_multiplier)) / 100;
+  assert (price > 0);
+
+  if (price < uRealValue)
+    price = uRealValue;
+  return price;
 }
 
 //----- (004B8179) --------------------------------------------------------
@@ -1858,7 +1856,7 @@
   v14 = &p2DEvents[a4 - 1].fPriceMultiplier;
   v15 = *v14;
   v16 = pItem->GetValue();
-  v17 = _4B8142(v16, v15);
+  v17 = GetBuyingPrice(v16, v15);
   if ( a5 == 3 )
   {
     v23 = *v14;
--- a/Player.h	Fri Mar 22 22:36:26 2013 +0200
+++ b/Player.h	Fri Mar 22 23:26:01 2013 +0200
@@ -560,7 +560,7 @@
   int _4B8213(int a2, float a3);
   int _4B81C3(int a2, float a3);
   int _4B8179(float a2);
-  int _4B8142(int a2, float a3);
+  int GetBuyingPrice(unsigned int uRealValue, float price_multiplier);
   int _4B8102(int a2, float a3);
   int _4B807C(float a2);
   int _4B8040_condition_time(unsigned int uCondition);
--- a/UIHouses.cpp	Fri Mar 22 22:36:26 2013 +0200
+++ b/UIHouses.cpp	Fri Mar 22 23:26:01 2013 +0200
@@ -627,7 +627,7 @@
   _this.DrawTitleText(pFontArrus, 0, 0x104u, v30, pTmpBuf, 3u);
   switch(dialog_menu_id)
   {
-	case 1:
+	case HOUSE_DIALOGUE_MAIN:
 		{
 		v11 = 1;
 		pOutString = 0;
@@ -678,7 +678,8 @@
 		}
 		break;
 		}
-	case 99:
+
+	case HOUSE_DIALOGUE_TOWNHALL_99:
 		{
 		v5 = &pMonsterStats->pInfos[word_F8B1A0];
 		v6 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
@@ -705,7 +706,7 @@
 		a1.DrawText(pOutString, 13, 354 - v9, 0, v10, 0, 0, 0);
 		break;
 		}
-	case 100:
+	case HOUSE_DIALOGUE_TOWNHALL_100:
 		{
 		v0 = window_SpeakInHouse;
 		if ( window_SpeakInHouse->field_40 == 1 )
@@ -796,7 +797,7 @@
   _this.DrawTitleText(pFontArrus, 0, 0xDCu, v14[0], pTmpBuf, 3u);
   switch(dialog_menu_id)
   {
-	case 1:
+	case HOUSE_DIALOGUE_MAIN:
 		{
 		v8 = v14[0];
 		if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
@@ -808,7 +809,7 @@
 		_this.DrawTitleText(pFontArrus, 0, 0xB0u, v9, pGlobalTXT_LocalizationStrings[244], 3u);
 		break;
 		}
-	case 7:
+	case HOUSE_DIALOGUE_BANK_7:
 		{
 		v0 = window_SpeakInHouse;
 		if ( window_SpeakInHouse->field_40 != 1 )
@@ -865,7 +866,7 @@
 		break;
 		}
 
-	case 8:
+	case HOUSE_DIALOGUE_BANK_8:
 		{
 		v0 = window_SpeakInHouse;
 		if ( window_SpeakInHouse->field_40 != 1 )
@@ -1567,7 +1568,7 @@
         else
         {
           v58 = pGlobalTXT_LocalizationStrings[195];
-          if ( dialog_menu_id != 2 )
+          if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
             v58 = pGlobalTXT_LocalizationStrings[196];
         }
         DrawTextAtStatusBar(v58, 0);
@@ -1582,7 +1583,7 @@
             v61 = (int)window_SpeakInHouse->ptr_1C;
             //  v62 = 9 * (v60 + 12 * v61);
             v63 = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60];
-            if ( dialog_menu_id != 2 )
+            if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
               v63 = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724];
             if ( !v56 || !Str )
             {
@@ -1758,7 +1759,7 @@
         else
         {
           v58 = pGlobalTXT_LocalizationStrings[195];
-          if ( dialog_menu_id != 2 )
+          if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
             v58 = pGlobalTXT_LocalizationStrings[196];
         }
         DrawTextAtStatusBar(v58, 0);
@@ -1773,7 +1774,7 @@
             v61 = (int)window_SpeakInHouse->ptr_1C;
             //  v62 = 9 * (v60 + 12 * v61);
             v63 = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60];
-            if ( dialog_menu_id != 2 )
+            if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
               v63 = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724];
             if ( !v56 || !Str )
             {
@@ -1881,7 +1882,7 @@
     }
     default:
     {
-      if( dialog_menu_id > 5 )
+      if( dialog_menu_id > HOUSE_DIALOGUE_SHOP_REPAIR)
         pNumActiveItem = dialog_menu_id - 96;
       else
         pNumActiveItem = dialog_menu_id - 4;
@@ -2127,7 +2128,7 @@
         {
           v65 = pGlobalTXT_LocalizationStrings[185];
         }
-        else if ( dialog_menu_id == 2 )
+        else if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
         {
           v65 = pGlobalTXT_LocalizationStrings[195];
         }
@@ -2147,7 +2148,7 @@
         {
           v67 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1;
           v70 = (ItemGen *)&pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v67];
-          if ( dialog_menu_id != 2 )
+          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 )
           {
@@ -2332,7 +2333,7 @@
         else
         {
           v65 = pGlobalTXT_LocalizationStrings[195];
-          if ( dialog_menu_id != 2 )
+          if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
             v65 = pGlobalTXT_LocalizationStrings[196];
         }
         DrawTextAtStatusBar(v65, 0);
@@ -2350,7 +2351,7 @@
           v68 = (int)window_SpeakInHouse->ptr_1C;
           //  v69 = 9 * (v67 + 12 * v68);
           v70 = (ItemGen *)&pParty->StandartItemsInShops[v68][v67];
-          if ( dialog_menu_id != 2 )
+          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 )
           {
@@ -2672,7 +2673,7 @@
         v153 = 0;
         for(int i=0; i<8; ++i)
             {
-            if ( pParty->StandartItemsInShops[window_SpeakInHouse->par1C][i].uItemID);
+            if ( pParty->StandartItemsInShops[window_SpeakInHouse->par1C][i].uItemID)
                 {
                 textureW = ItemsInShopTexture[i]->uTextureWidth;
                 textureH = ItemsInShopTexture[i]->uTextureHeight;
@@ -2841,7 +2842,7 @@
         return;
         }
         break;
-    case 6: //buy standart
+    case HOUSE_DIALOGUE_SHOP_6: //buy standart
         {
         pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
         DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[195], 0); //"Select the Item to Buy"
@@ -3223,9 +3224,9 @@
         strcpy(v47, "");
         strcpy(v48, "");
         strcpy(v49, "");
-        if ( dialog_menu_id != 1 )
+        if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN )
             {
-            if ( dialog_menu_id != 18 ) //buy skill
+            if ( dialog_menu_id != HOUSE_DIALOGUE_GULD_BUY_BOOKS ) //buy skill
                 {
                 if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
                     {
@@ -3309,7 +3310,7 @@
 
                             GetAsyncKeyState(17);
                             statusbar_string = pGlobalTXT_LocalizationStrings[195]; //"Select the Item to Buy"
-                            if ( dialog_menu_id != 2 )
+                            if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
                                 statusbar_string = pGlobalTXT_LocalizationStrings[196]; //"Select the Special Item to Buy"	
                             DrawTextAtStatusBar(statusbar_string, 0);
                             if ( !v8 )
@@ -3550,14 +3551,14 @@
     //v2 = pPlayers[uActiveCharacter]->_4B807C(p2DEvents_minus1__20[13 * (unsigned int)v0->ptr_1C]);
     v2 = pPlayers[uActiveCharacter]->_4B807C(p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier);
     HIDWORD(v60) = v2;
-    if ( dialog_menu_id != 1 )
+    if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN )
         {
-        if ( dialog_menu_id != 10 )
+        if ( dialog_menu_id != HOUSE_DIALOGUE_TEMPLE_HEAL )
             {
-            if ( dialog_menu_id != 11 )
+            if ( dialog_menu_id != HOUSE_DIALOGUE_TEMPLE_DONATE )
                 {
 
-                if ( dialog_menu_id == 96 )
+                if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS )
                     {
                     if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
                         {
@@ -3957,12 +3958,12 @@
   result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
   if ( result )
   {
-    if ( dialog_menu_id != 1 )
+    if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN )
     {
-      if ( dialog_menu_id != 17 )
+      if ( dialog_menu_id != HOUSE_DIALOGUE_TRAININGHALL_17 )
       {
         result = dialog_menu_id - 96;
-        if ( dialog_menu_id == 96 )
+        if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS )
         {
           result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
           if ( result )
@@ -4380,9 +4381,9 @@
   dialog_window.uFrameZ = 334;
   m_text_color = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
   hilight_color = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
-  if ( dialog_menu_id > 5 )
+  if ( dialog_menu_id > HOUSE_DIALOGUE_SHOP_REPAIR )
   {
-    if ( dialog_menu_id == 94 )
+    if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT )
     {
       draw_leather();
       CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
@@ -4434,10 +4435,10 @@
       }
       return;
     }
-    if ( dialog_menu_id != 95 )
+    if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_SPECIAL )
     {
-      result = dialog_menu_id - 96;
-      if ( dialog_menu_id == 96 )
+      result = dialog_menu_id - HOUSE_DIALOGUE_LEARN_SKILLS;
+      if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS )
       {
         result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
         if ( result )
@@ -4538,7 +4539,7 @@
   }
   else
   {
-    if ( dialog_menu_id == 5 )
+    if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_REPAIR)
     {
       draw_leather();
       CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
@@ -4564,7 +4565,7 @@
       v10 = (char *)pMerchantsRepairPhrases[v29];
       goto LABEL_35;
     }
-    if ( dialog_menu_id == 1 )
+    if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN)
     {
      /* result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
       if ( result )
@@ -4654,12 +4655,12 @@
 
       return;
     }
-    if ( dialog_menu_id != 2 )
+    if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
     {
-      if ( dialog_menu_id != 3 )
+      if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_SELL)
       {
-        result = dialog_menu_id - 4;
-        if ( dialog_menu_id == 4 )
+        result = dialog_menu_id - HOUSE_DIALOGUE_SHOP_IDENTIFY;
+        if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_IDENTIFY)
         {
           draw_leather();
           CharacterUI_InventoryTab_Draw(uActiveCharacter, 1);
@@ -4747,7 +4748,7 @@
   v3 = 0;
   v49 = 0;
   v122 = 0;
-  if ( dialog_menu_id == 2 )
+  if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
   {
     do
     {
@@ -4882,7 +4883,7 @@
   {
     v66 = 0;
     v117 = 0;
-    if ( dialog_menu_id == 2 )
+    if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
     {
       do
       {
@@ -4913,7 +4914,7 @@
     else
     {
       v69 = pGlobalTXT_LocalizationStrings[195];// "Select the Item to Buy"
-      if ( dialog_menu_id != 2 )
+      if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
         v69 = pGlobalTXT_LocalizationStrings[196];// "Select the Special Item to Buy"
     }
     DrawTextAtStatusBar(v69, 0);
@@ -4931,7 +4932,7 @@
       v72 = (int)window_SpeakInHouse->ptr_1C;
      // v73 = 9 * (v71 + 12 * v72);
       v74 = (ItemGen *)&pParty->StandartItemsInShops[v72][v71];
-      if ( dialog_menu_id != 2 )
+      if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
        // v74 = (ItemGen *)&pParty->field_C59C[v73 + 724];
 	      v74 =&pParty->SpecialItemsInShops[v72][v71];
       if ( v67 && Str )
--- a/UIHouses.h	Fri Mar 22 22:36:26 2013 +0200
+++ b/UIHouses.h	Fri Mar 22 23:26:01 2013 +0200
@@ -10,9 +10,9 @@
   HOUSE_DIALOGUE_SHOP_SELL = 3,
   HOUSE_DIALOGUE_SHOP_IDENTIFY = 4,
   HOUSE_DIALOGUE_SHOP_REPAIR = 5,
-  HOUSE_DIALOGUE_6 = 6,
-  HOUSE_DIALOGUE_7 = 7,
-  HOUSE_DIALOGUE_8 = 8,
+  HOUSE_DIALOGUE_SHOP_6 = 6,
+  HOUSE_DIALOGUE_BANK_7 = 7,
+  HOUSE_DIALOGUE_BANK_8 = 8,
   HOUSE_DIALOGUE_9 = 9,
   HOUSE_DIALOGUE_TEMPLE_HEAL = 10,
   HOUSE_DIALOGUE_TEMPLE_DONATE = 11,
@@ -21,7 +21,7 @@
   HOUSE_DIALOGUE_14 = 14,
   HOUSE_DIALOGUE_TAVERN_REST = 15,
   HOUSE_DIALOGUE_TAVERN_BUY_FOOD = 16,
-  HOUSE_DIALOGUE_17 = 17,
+  HOUSE_DIALOGUE_TRAININGHALL_17 = 17,
   HOUSE_DIALOGUE_GULD_BUY_BOOKS = 18,
   //...
   HOUSE_DIALOGUE_GUILD_LEARN_SKILL = 72,
@@ -29,12 +29,17 @@
   HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT = 94,
   HOUSE_DIALOGUE_SHOP_BUY_SPECIAL = 95,
   HOUSE_DIALOGUE_LEARN_SKILLS = 96,
-  //...
+  HOUSE_DIALOGUE_97 = 97,
+  HOUSE_DIALOGUE_98 = 98,
+  HOUSE_DIALOGUE_TOWNHALL_99 = 99,
+  HOUSE_DIALOGUE_TOWNHALL_100 = 100,
   HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN = 101,
   HOUSE_DIALOGUE_TAVERN_ARCOMAGE_102 = 102,
   HOUSE_DIALOGUE_TAVERN_ARCOMAGE_103 = 103,
   HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RESULT = 104,
 
+  HOUSE_DIALOGUE_108 = 108,
+
   HOUSE_DIALOGUE_OTHER = -1
 };
 
--- a/mm7_1.cpp	Fri Mar 22 22:36:26 2013 +0200
+++ b/mm7_1.cpp	Fri Mar 22 23:26:01 2013 +0200
@@ -969,7 +969,7 @@
     //goto LABEL_28;
     uActiveCharacter = uPlayerID;
     return;
-  if (dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD || dialog_menu_id == HOUSE_DIALOGUE_6)
+  if (dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD || dialog_menu_id == HOUSE_DIALOGUE_SHOP_6)
   {
     __debugbreak(); // fix indexing
     pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
--- a/mm7_2.cpp	Fri Mar 22 22:36:26 2013 +0200
+++ b/mm7_2.cpp	Fri Mar 22 23:26:01 2013 +0200
@@ -889,12 +889,12 @@
     return;
   pRenderer->ClearZBuffer(0, 479);
   //v3 = dword_F8B198;
-  if ( dialog_menu_id != 1 )
+  if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN)
   {
 	v8 = window_SpeakInHouse;
   }
   //else
-  if ( dialog_menu_id == 1 )
+  if (dialog_menu_id == HOUSE_DIALOGUE_MAIN)
   {
 	  if ( in_current_building_type == BildingType_Training )
 	  {
@@ -1918,11 +1918,11 @@
   if ( pDialogueNPCCount )
   {
     v0 = dialog_menu_id;
-    if ( dialog_menu_id != 2
-      && dialog_menu_id != 3
-      && dialog_menu_id != 97
-      && dialog_menu_id != 5
-      && dialog_menu_id != 4
+    if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD
+      && dialog_menu_id != HOUSE_DIALOGUE_SHOP_SELL
+      && dialog_menu_id != HOUSE_DIALOGUE_97
+      && dialog_menu_id != HOUSE_DIALOGUE_SHOP_REPAIR
+      && dialog_menu_id != HOUSE_DIALOGUE_SHOP_IDENTIFY
       && ShopTexture )
     {
       ShopTexture->Release();
@@ -2039,14 +2039,14 @@
   void *v30; // eax@50
   int v31; // ecx@50
   ItemGen *v32; // esi@51
-  float v33; // ST1C_4@53
-  signed int v34; // eax@53
-  int v35; // eax@53
-  bool v36; // eax@53
+  //float v33; // ST1C_4@53
+  //signed int v34; // eax@53
+  //int v35; // eax@53
+  //bool v36; // eax@53
   unsigned int v37; // eax@53
   int v38; // eax@55
   int v39; // eax@63
-  int v40; // eax@64
+  //int v40; // eax@64
   int v41; // edx@66
   int v42; // esi@74
   signed int v43; // ebx@74
@@ -2063,7 +2063,7 @@
   unsigned int v54; // [sp+0h] [bp-B4h]@25
   int v55; // [sp+0h] [bp-B4h]@26
   int v56; // [sp+0h] [bp-B4h]@36
-  POINT v57; // [sp+10h] [bp-A4h]@49
+  //POINT v57; // [sp+10h] [bp-A4h]@49
   //POINT v58; // [sp+18h] [bp-9Ch]@18
   POINT v59; // [sp+20h] [bp-94h]@49
   POINT v60; // [sp+28h] [bp-8Ch]@9
@@ -2079,7 +2079,7 @@
   POINT v70; // [sp+78h] [bp-3Ch]@9
   POINT v71; // [sp+80h] [bp-34h]@31
   POINT v72; // [sp+88h] [bp-2Ch]@10
-  bool v73; // [sp+90h] [bp-24h]@53
+  //bool v73; // [sp+90h] [bp-24h]@53
   int v74; // [sp+94h] [bp-20h]@53
   int a6; // [sp+98h] [bp-1Ch]@57
   int a3; // [sp+9Ch] [bp-18h]@53
@@ -2129,7 +2129,7 @@
 		v21 = p2DEvents[(signed int)v19 - 1].fPriceMultiplier;
 		_this = v20;
 		v22 = v20->GetValue();
-		v23 = v0->_4B8142(v22, v21);
+		v23 = v0->GetBuyingPrice(v22, v21);
 		v80 = v23;
 		GetAsyncKeyState(VK_CONTROL);
 		if ( pParty->uNumGold < v23 )
@@ -2327,15 +2327,15 @@
 		{
 	//LABEL_49:
 		v28 = pMouse->GetCursorPos(&v59);
-		v29 = pRenderer->pActiveZBuffer[v28->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v57)->y]] & 0xFFFF;
+		v29 = pRenderer->pActiveZBuffer[v28->x + pSRZBufferLineOffsets[v28->y]] & 0xFFFF;
 		if ( !v29 )
 			return;
 		v30 = window_SpeakInHouse->ptr_1C;
 		// v31 = 9 * (v29 - 1 + 12 * (int)v30);
-		if ( dialog_menu_id == 2 )
+		if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
 		{
-			v32 = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29-1];
-			_this = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29-1];
+			v32 = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29 - 1];
+			_this = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29 - 1];
 		}
 		else
 		{
@@ -2343,23 +2343,23 @@
 			v32 = &pParty->SpecialItemsInShops[(int)v30][v29-1];//(ItemGen *)&pParty->field_C59C[v31 + 724];
 		}
 		//v33 = p2DEvents_minus1__20[13 * (signed int)v30];
-		v33 = p2DEvents[(signed int)v30 - 1].fPriceMultiplier;
-		v34 = v32->GetValue();
-		v80 = v0->_4B8142(v34, v33);
-		LOWORD(v35) = GetAsyncKeyState(VK_CONTROL);
-		v74 = v35;
-		v36 = v0->CanSteal();
+		//v33 = p2DEvents[(signed int)v30 - 1].fPriceMultiplier;
+		//v34 = v32->GetValue();
+		v80 = v0->GetBuyingPrice(v32->GetValue(), p2DEvents[(unsigned int)v30 - 1].fPriceMultiplier);
+		//LOWORD(v35) = GetAsyncKeyState(VK_CONTROL);
+		v74 = GetAsyncKeyState(VK_CONTROL);
+		//v36 = v0->CanSteal();
 		uNumSeconds = 0;
 		a3 = 0;
-		v73 = v36;
+		//v73 = v0->CanSteal();
 		v37 = pMapStats->GetMapInfo(pCurrentMapName);
 		if ( v37 )
 			a3 = pMapStats->pInfos[v37]._steal_perm;
 		v38 = GetPartyReputation();
 		v26 = 1;
-		if ( v73 == 1 )
+		if (v0->CanSteal())
 		{
-			if ( (short)v74 )
+			if ( v74 )
 			{
 			uNumSeconds = v0->StealFromShop(v32, a3, v38, 0, &a6);
 			if ( !uNumSeconds )
@@ -2377,7 +2377,7 @@
 				if ( uNumSeconds != 1 )
 				{
 					PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v24);
-					v9 = pGlobalTXT_LocalizationStrings[155];
+					v9 = pGlobalTXT_LocalizationStrings[155]; // "You don't have enough gold"
 					v54 = 2;
 					ShowStatusBarString(v9, v54);
 					return;
@@ -2388,17 +2388,19 @@
 		if ( v39 )
 		{
 			v32->SetIdentified();
-			v7 = v73 == 1;
-			v40 = (int)((char *)v0 + 36 * v39);
-			memcpy((void *)(v40 + 496), v32, 0x24u);
+			v7 = v0->CanSteal();
+			//v40 = (int)((char *)v0 + 36 * v39);
+            //memcpy((void *)(v40 + 496), v32, 0x24u);
+            memcpy(&v0->pInventoryItems[v39 - 1], v32, sizeof(ItemGen));
 			if ( v7 )
 			{
-				if ( (short)v74 )
+				if ( v74 )
 				{
 					v41 = uNumSeconds;
 					if ( uNumSeconds == 1 || uNumSeconds == 2 )
 					{
-						*(char *)(v40 + 517) |= 1u;
+						//*(char *)(v40 + 517) |= 1u;
+                        v0->pInventoryItems[v39 - 1].SetStolen();
 						sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, v41, a6);
 						viewparams->bRedrawGameUI = v26;
 						_this->Reset();
--- a/mm7_4.cpp	Fri Mar 22 22:36:26 2013 +0200
+++ b/mm7_4.cpp	Fri Mar 22 23:26:01 2013 +0200
@@ -4666,7 +4666,7 @@
                     v26 = &p2DEvents[(signed int)a4 - 1].fPriceMultiplier;
         v27 = *v26;
         v28 = a3->GetValue();
-        v29 = pPlayer->_4B8142(v28, v27);
+        v29 = pPlayer->GetBuyingPrice(v28, v27);
         if ( a5 == 3 )
         {
           v35 = *v26;
@@ -7246,11 +7246,11 @@
     return;
   if ( in_current_building_type <= BildingType_AlchemistShop )
   {
-    if ( dialog_menu_id != 2 )
-    {
-      if ( dialog_menu_id <= 2 )
+    if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
+    {
+      if ( dialog_menu_id <= HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
         return;
-      if ( dialog_menu_id <= 5 || dialog_menu_id == 94 )
+      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);
@@ -7263,7 +7263,7 @@
         GameUI_DrawItemInfo(v7);
         return;
       }
-      if ( dialog_menu_id != 95 )
+      if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_SPECIAL )
         return;
     }
     v4 = pMouse->GetCursorPos(&v11);
@@ -7273,12 +7273,12 @@
       return;
     v6 = 9 * (v5 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C);
     v7 = (ItemGen *)((char *)&pParty->pPickedItem + 4 * v6 + 4);
-    if ( dialog_menu_id != 2 )
+    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];
     goto LABEL_15;
   }
-  if ( in_current_building_type <= BildingType_16 && dialog_menu_id == BildingType_18 )
+  if ( in_current_building_type <= BildingType_16 && dialog_menu_id == HOUSE_DIALOGUE_GULD_BUY_BOOKS )
   {
     v1 = pMouse->GetCursorPos(&a2);
     v2 = v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v16)->y];
@@ -8875,7 +8875,7 @@
   else
   {
     v17 = HouseNPCData[_this + 1 - ((dword_591080 != 0) + 1)];
-    if ( dialog_menu_id == -1 )
+    if ( dialog_menu_id == HOUSE_DIALOGUE_OTHER )
     {
       pDialogueWindow->Release();
     }
@@ -9381,7 +9381,7 @@
     v4 = v3 / 3;
     v32 = v3 / 3;
   }
-  if ( dialog_menu_id != 1 )
+  if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN)
   {
     if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
     {
@@ -9393,7 +9393,7 @@
       //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass][v23 - 36]
       // or
       //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass - 1][v23 + 1]
-
+      __debugbreak(); // whacky condition - fix
       if (false
       //if ( !*(&byte_4ED94C[37 * v1->uClass / 3] + dword_F8B19C)
         || (v6 = (int)(&v1->uIntelligence + dialog_menu_id), *(short *)v6) )
@@ -9620,7 +9620,7 @@
   s1 = v4 * (100 - v1->GetMerchant()) / 100;
   if ( (signed int)s1 < v4 / 3 )
     s1 = v4 / 3;
-  if ( dialog_menu_id == 1 )
+  if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN)
   {
     if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
     {
@@ -9744,7 +9744,7 @@
   }
   else
   {
-    if ( dialog_menu_id > 104 && dialog_menu_id <= 108 )
+    if ( dialog_menu_id > HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RESULT && dialog_menu_id <= HOUSE_DIALOGUE_108 )
     {
       if ( pParty->uNumGold < s1 )
       {