changeset 886:b6573b99ca40

SalesProcess function
author Ritor1
date Tue, 02 Apr 2013 17:33:20 +0600
parents 4004fb0bf60c
children 4de9c65baa39 c684b3fb93eb 5ab8f88a121a
files Player.cpp Player.h UIHouses.cpp mm7_2.cpp
diffstat 4 files changed, 354 insertions(+), 381 deletions(-) [+]
line wrap: on
line diff
--- a/Player.cpp	Tue Apr 02 10:29:22 2013 +0600
+++ b/Player.cpp	Tue Apr 02 17:33:20 2013 +0600
@@ -220,7 +220,7 @@
 
 
 //----- (004BE2DD) --------------------------------------------------------
-void Player::_4BE2DD(unsigned int a2, int a3, int _2devent_idx)
+void Player::SalesProcess(unsigned int a2, int a3, int _2devent_idx)
 {
   Player *v4; // edi@1
   char *v5; // esi@1
@@ -6452,7 +6452,9 @@
 
     switch (i)
     {
-      case PLAYER_SKILL_FIRE:   spellbook.pFireSpellbook.bIsSpellAvailable[0] = true;
+      case PLAYER_SKILL_FIRE:
+        spellbook.pFireSpellbook.bIsSpellAvailable[0] = true;//its temporary, for test spells
+        
         spellbook.pFireSpellbook.bIsSpellAvailable[1] = true;
         spellbook.pFireSpellbook.bIsSpellAvailable[2] = true;
         spellbook.pFireSpellbook.bIsSpellAvailable[3] = true;
@@ -6460,6 +6462,10 @@
         spellbook.pFireSpellbook.bIsSpellAvailable[5] = true;
         spellbook.pFireSpellbook.bIsSpellAvailable[6] = true;
         spellbook.pFireSpellbook.bIsSpellAvailable[7] = true;
+        spellbook.pFireSpellbook.bIsSpellAvailable[8] = true;
+        spellbook.pFireSpellbook.bIsSpellAvailable[9] = true;
+        spellbook.pFireSpellbook.bIsSpellAvailable[10] = true;
+          spellbook.pAirSpellbook.bIsSpellAvailable[0] = true;
           spellbook.pAirSpellbook.bIsSpellAvailable[1] = true;
           spellbook.pAirSpellbook.bIsSpellAvailable[2] = true;
           spellbook.pAirSpellbook.bIsSpellAvailable[3] = true;
@@ -6470,7 +6476,6 @@
           spellbook.pAirSpellbook.bIsSpellAvailable[8] = true;
           spellbook.pAirSpellbook.bIsSpellAvailable[9] = true;
           spellbook.pAirSpellbook.bIsSpellAvailable[10] = true;
-    pActiveSkills[PLAYER_SKILL_WATER] = 1;
           spellbook.pWaterSpellbook.bIsSpellAvailable[0] = true;
           spellbook.pWaterSpellbook.bIsSpellAvailable[1] = true;
           spellbook.pWaterSpellbook.bIsSpellAvailable[2] = true;
@@ -6480,13 +6485,28 @@
           spellbook.pWaterSpellbook.bIsSpellAvailable[6] = true;
           spellbook.pWaterSpellbook.bIsSpellAvailable[7] = true;
           spellbook.pWaterSpellbook.bIsSpellAvailable[8] = true;
+          spellbook.pWaterSpellbook.bIsSpellAvailable[9] = true;
+          spellbook.pWaterSpellbook.bIsSpellAvailable[10] = true;
         break;
-      case PLAYER_SKILL_AIR:    spellbook.pAirSpellbook.bIsSpellAvailable[0] = true;    break;
-      case PLAYER_SKILL_WATER:  spellbook.pWaterSpellbook.bIsSpellAvailable[0] = true;  break;
-      case PLAYER_SKILL_EARTH:  spellbook.pEarthSpellbook.bIsSpellAvailable[0] = true;  break;
-      case PLAYER_SKILL_SPIRIT: spellbook.pSpiritSpellbook.bIsSpellAvailable[0] = true; break;
-      case PLAYER_SKILL_MIND:   spellbook.pMindSpellbook.bIsSpellAvailable[0] = true;   break;
-      case PLAYER_SKILL_BODY:   spellbook.pBodySpellbook.bIsSpellAvailable[0] = true;
+      case PLAYER_SKILL_AIR:
+        spellbook.pAirSpellbook.bIsSpellAvailable[0] = true;
+        break;
+      case PLAYER_SKILL_WATER:
+        spellbook.pWaterSpellbook.bIsSpellAvailable[0] = true;
+        break;
+      case PLAYER_SKILL_EARTH:
+        spellbook.pEarthSpellbook.bIsSpellAvailable[0] = true;
+        break;
+      case PLAYER_SKILL_SPIRIT:
+        spellbook.pSpiritSpellbook.bIsSpellAvailable[0] = true;
+
+        break;
+      case PLAYER_SKILL_MIND:
+        spellbook.pMindSpellbook.bIsSpellAvailable[0] = true;
+        break;
+      case PLAYER_SKILL_BODY:
+        spellbook.pBodySpellbook.bIsSpellAvailable[0] = true;
+        
         spellbook.pBodySpellbook.bIsSpellAvailable[1] = true;
         spellbook.pBodySpellbook.bIsSpellAvailable[2] = true;
         spellbook.pBodySpellbook.bIsSpellAvailable[3] = true;
@@ -6496,16 +6516,24 @@
         spellbook.pBodySpellbook.bIsSpellAvailable[7] = true;
         spellbook.pBodySpellbook.bIsSpellAvailable[8] = true;
         spellbook.pBodySpellbook.bIsSpellAvailable[9] = true;
-    pActiveSkills[PLAYER_SKILL_SPIRIT] = 1;
+        spellbook.pBodySpellbook.bIsSpellAvailable[10] = true;
         spellbook.pSpiritSpellbook.bIsSpellAvailable[1] = true;
         spellbook.pSpiritSpellbook.bIsSpellAvailable[2] = true;
         spellbook.pSpiritSpellbook.bIsSpellAvailable[3] = true;
         spellbook.pSpiritSpellbook.bIsSpellAvailable[4] = true;
         spellbook.pSpiritSpellbook.bIsSpellAvailable[5] = true;
         spellbook.pSpiritSpellbook.bIsSpellAvailable[6] = true;
+        spellbook.pSpiritSpellbook.bIsSpellAvailable[7] = true;
+        spellbook.pSpiritSpellbook.bIsSpellAvailable[8] = true;
+        spellbook.pSpiritSpellbook.bIsSpellAvailable[9] = true;
+        spellbook.pSpiritSpellbook.bIsSpellAvailable[10] = true;
         break;
-      case PLAYER_SKILL_LIGHT:  spellbook.pLightSpellbook.bIsSpellAvailable[0] = true;  break;
-      case PLAYER_SKILL_DARK:   spellbook.pDarkSpellbook.bIsSpellAvailable[0] = true;   break;
+      case PLAYER_SKILL_LIGHT:
+        spellbook.pLightSpellbook.bIsSpellAvailable[0] = true;
+        break;
+      case PLAYER_SKILL_DARK:
+        spellbook.pDarkSpellbook.bIsSpellAvailable[0] = true;
+        break;
     }
   }
 
--- a/Player.h	Tue Apr 02 10:29:22 2013 +0600
+++ b/Player.h	Tue Apr 02 17:33:20 2013 +0600
@@ -566,7 +566,7 @@
   int _4B807C(float a2);
   int _4B8040_condition_time(unsigned int uCondition);
   bool _43EEF3();
-  void _4BE2DD(unsigned int a2, int a3, int _2devent_idx);
+  void SalesProcess(unsigned int a2, int a3, int _2devent_idx);//0x4BE2DD
   bool Recover(signed int a2);
   bool CanCastSpell(unsigned int uRequiredMana);
 
--- a/UIHouses.cpp	Tue Apr 02 10:29:22 2013 +0600
+++ b/UIHouses.cpp	Tue Apr 02 17:33:20 2013 +0600
@@ -4827,7 +4827,13 @@
     }
     else
     {
-      if( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v23-36] && !pPlayers[uActiveCharacter]->pActiveSkills[v23-36] )
+      if( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v23-36] && pPlayers[uActiveCharacter]->pActiveSkills[v23-36] )
+      {
+        all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v23 - 36], &working_window, 0, 0);
+        v61++;
+        pSkillFlag = true;
+      }
+      if( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v23 - 36] && !pPlayers[uActiveCharacter]->pActiveSkills[v23 - 36] )
       {
         all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v23 - 36], &working_window, 0, 0);
         v61++;
@@ -4880,27 +4886,29 @@
           pTextColor = pColorWhite;
         working_window.DrawTitleText(pFontArrus, 0, v32, pTextColor, pText, 3);
       }
-      if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v29 - 36]
-           || pPlayers[uActiveCharacter]->pActiveSkills[v29-36] )
-      {
-        pButton->uW = 0;
-        pButton->uHeight = 0;
-        pButton->uY = 0;
-      }
       else
       {
-        pButton->uY = v58 + v26;
-        pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v29 - 36], &working_window, 0, 0);
-        v32 = pButton->uY;
-        pButton->uHeight = pTextHeight;
-        v33 = v32 + pTextHeight - 1;
-        pButton->uW = v33;
-        v26 = v33;
-        pTextColor = pColorYellow;
-        if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
-          pTextColor = pColorWhite;
-        working_window.DrawTitleText(pFontArrus, 0, v32, pTextColor, pSkillNames[v29 - 36], 3);
-      }
+        if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v29 - 36] && !pPlayers[uActiveCharacter]->pActiveSkills[v23-36] )
+        {
+          pButton->uY = v58 + v26;
+          pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v29 - 36], &working_window, 0, 0);
+          v32 = pButton->uY;
+          pButton->uHeight = pTextHeight;
+          v33 = v32 + pTextHeight - 1;
+          pButton->uW = v33;
+          v26 = v33;
+          pTextColor = pColorYellow;
+          if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum )
+            pTextColor = pColorWhite;
+          working_window.DrawTitleText(pFontArrus, 0, v32, pTextColor, pSkillNames[v29 - 36], 3);
+        }
+		else
+		{
+          pButton->uW = 0;
+          pButton->uHeight = 0;
+          pButton->uY = 0;
+		}
+	  }
       ++pItemNum;
     }
     while ( pItemNum < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
--- a/mm7_2.cpp	Tue Apr 02 10:29:22 2013 +0600
+++ b/mm7_2.cpp	Tue Apr 02 17:33:20 2013 +0600
@@ -991,14 +991,14 @@
   int v74; // [sp+94h] [bp-20h]@53
   int a6; // [sp+98h] [bp-1Ch]@57
   int a3; // [sp+9Ch] [bp-18h]@53
-  Player *v77; // [sp+A0h] [bp-14h]@1
+  //Player *v77; // [sp+A0h] [bp-14h]@1
   unsigned int uNumSeconds; // [sp+A4h] [bp-10h]@53
   unsigned int v79; // [sp+A8h] [bp-Ch]@9
   int v80; // [sp+ACh] [bp-8h]@12
   ItemGen *_this; // [sp+B0h] [bp-4h]@13
 
   v0 = pPlayers[uActiveCharacter];
-  v77 = pPlayers[uActiveCharacter];
+  //v77 = pPlayers[uActiveCharacter];
   if ( pCurrentScreen == SCREEN_E )
   {
     sub_421EA6_OnInventoryLeftClick();
@@ -1018,354 +1018,291 @@
       sub_421EA6_OnInventoryLeftClick();
       break;
     }
-    case HOUSE_DIALOGUE_GUILD_BUY_BOOKS://Ritor1: in process
-    {
-		v17 = pMouse->GetCursorPos(&v63);
-		v18 = pRenderer->pActiveZBuffer[v17->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v61)->y]] & 0xFFFF;
-		if ( !v18 )
-			return;
-		v20 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)window_SpeakInHouse->ptr_1C));
-		v21 = p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
-		_this = v20;
-		v22 = v20->GetValue();
-		v23 = v0->GetBuyingPrice(v22, v21);
-		v80 = v23;
-		GetAsyncKeyState(VK_CONTROL);
-		if ( pParty->uNumGold < v23 )
-		{
-			v24 = 2;
-			PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v24);
-			v9 = pGlobalTXT_LocalizationStrings[155];
-			v54 = 2;
-			ShowStatusBarString(v9, v54);
-			return;
-		}
-		v25 = v0->AddItem(0xFFFFFFFFu, v20->uItemID);
-		if ( v25 )
-		{
-			v26 = 1;
-			v20->SetIdentified();
-			memcpy(&v0->pInventoryItems[v25-1], v20, 0x24u);
-			dword_F8B1E4 = v26;
-			Party::TakeGold(v80);
-			viewparams->bRedrawGameUI = v26;
-			_this->Reset();
-			pRenderer->ClearZBuffer(0, 479);
-			v27 = v77;
-			v27->PlaySound((PlayerSpeech)SPEECH_75, 0);
-			return;
-		}
-		v0->PlaySound(SPEECH_NoRoom, 0);
-		ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 5);  // "Pack is Full!"
-		break;
-		}
-
-	case HOUSE_DIALOGUE_SHOP_SELL:
-		{
-		v14 = pMouse->GetCursorPos(&v71)->x - 14;
-		v79 = (v14 >> 5) + 14 * ((pMouse->GetCursorPos(&v69)->y - 17) >> 5);
-		if ( pMouse->GetCursorPos(&v67)->x <= 13
-			|| pMouse->GetCursorPos(&v65)->x >= 462
-			|| (v15 = v0->GetItemIDAtInventoryIndex((int *)&v79), (v77 = (Player *)v15) == 0) )
-			return;
-		v16 = window_SpeakInHouse;
-		if ( sub_4BDAAF((ItemGen *)&v0->pInventoryItems[v15-1], (int)window_SpeakInHouse->ptr_1C) )
-		{
-			dword_F8B1E4 = 1;
-			v0->_4BE2DD(v79, (int)((char *)v77 - 1), (int)v16->ptr_1C);
-			viewparams->bRedrawGameUI = 1;
-			pRenderer->ClearZBuffer(0, 479);
-			v53 = 0;
-			v51 = 77;
-			v27 = v0;
-			v27->PlaySound((PlayerSpeech)v51, v53);
-			return;
-		}
-		v0->PlaySound(SPEECH_79, 0);
-		v56 = 0;
-		v52 = 0;
-		v50 = 0;
-		v49 = 0;
-		v48 = -1;
-		v47 = 0;
-		v46 = 0;
-		//LABEL_87:
-		pAudioPlayer->PlaySound(SOUND_27, v46, v47, v48, v49, v50, v52, v56);
-		break;
-		}
-
-	case HOUSE_DIALOGUE_SHOP_IDENTIFY:
+    case HOUSE_DIALOGUE_GUILD_BUY_BOOKS:
+    {
+      v17 = pMouse->GetCursorPos(&v63);
+      v18 = pRenderer->pActiveZBuffer[v17->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v61)->y]] & 0xFFFF;
+      if ( !v18 )
+        return;
+      v20 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)window_SpeakInHouse->ptr_1C));
+      v21 = p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
+      _this = v20;
+      v22 = v20->GetValue();
+      v23 = pPlayers[uActiveCharacter]->GetBuyingPrice(v22, v21);
+      v80 = v23;
+      GetAsyncKeyState(VK_CONTROL);
+      if ( pParty->uNumGold < v23 )
+      {
+        v24 = 2;
+        PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v24);
+        ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);
+        return;
+      }
+      v25 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, v20->uItemID);
+      if ( v25 )
+      {
+        v26 = 1;
+        v20->SetIdentified();
+        memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v25-1], v20, 0x24u);
+        dword_F8B1E4 = v26;
+        Party::TakeGold(v80);
+        viewparams->bRedrawGameUI = v26;
+        _this->Reset();
+        pRenderer->ClearZBuffer(0, 479);
+        pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0);
+        return;
+      }
+      pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0);
+      ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 5);  // "Pack is Full!"
+      break;
+    }
+    case HOUSE_DIALOGUE_SHOP_SELL:
+    {
+      v14 = pMouse->GetCursorPos(&v71)->x - 14;
+      v79 = (v14 >> 5) + 14 * ((pMouse->GetCursorPos(&v69)->y - 17) >> 5);
+      if ( pMouse->GetCursorPos(&v67)->x <= 13
+        || pMouse->GetCursorPos(&v65)->x >= 462
+        || (v15 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79), !v15) )
+          return;
+      v16 = window_SpeakInHouse;
+      if ( sub_4BDAAF(&pPlayers[uActiveCharacter]->pInventoryItems[v15-1], (int)window_SpeakInHouse->ptr_1C) )
+      {
+        dword_F8B1E4 = 1;
+        pPlayers[uActiveCharacter]->SalesProcess(v79, v15 - 1, (int)v16->ptr_1C);
+        viewparams->bRedrawGameUI = 1;
+        pRenderer->ClearZBuffer(0, 479);
+        pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)77, 0);
+        return;
+      }
+      pPlayers[uActiveCharacter]->PlaySound(SPEECH_79, 0);
+      pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
+      break;
+    }
+    case HOUSE_DIALOGUE_SHOP_IDENTIFY:
     {
       pMouse->GetCursorPos(&v62);
-		v10 = v62.x - 14;
-		v79 = (v10 >> 5) + 14 * ((v62.y - 17) >> 5);
-		if (v62.x > 13  && v62.x < 462)
-		{
-			v11 = v0->GetItemIDAtInventoryIndex((int *)&v79);
-			if ( v11 )
-			{
-				//v80 = v0->_4B8179(p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C]);
-				v80 = v0->_4B8179(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier);
-				v12 = (int)&v0->pInventoryItems[v11-1];
-				if ( !(*(char *)(v12 + 20) & 1) )
-				{
-				_this = (ItemGen *)window_SpeakInHouse->ptr_1C;
-				if ( sub_4BDAAF((ItemGen *)v12, (int)_this) )
-				{
-					if ( pParty->uNumGold >= v80 )
-					{
-					dword_F8B1E4 = 1;
-					Party::TakeGold(v80);
-					*(int *)(v12 + 20) |= 1u;
-					v0->PlaySound(SPEECH_73, 0);
-					v9 = pGlobalTXT_LocalizationStrings[569];
-					v54 = 2;
-					ShowStatusBarString(v9, v54);
-					return;
-					}
-					v13 = _this;
-					v55 = 2;
-					PlayHouseSound((unsigned int)v13, (HouseSoundID)v55);
-					return;
-				}
-				pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
-				v53 = 0;
-				v51 = 79;
-				v27 = v0;
-				v27->PlaySound((PlayerSpeech)v51, v53);
-				return;
-				}
-				v53 = 0;
-	//LABEL_30:
-				v51 = 76;
-				v27 = v0;
-				v27->PlaySound((PlayerSpeech)v51, v53);
-				return;
-			}
-		}
-		break;
-		}
-
-	case HOUSE_DIALOGUE_SHOP_REPAIR:
-		{
-		v1 = pMouse->GetCursorPos(&a2)->x - 14;
-		v79 = (v1 >> 5) + 14 * ((pMouse->GetCursorPos(&v70)->y - 17) >> 5);
-		if ( pMouse->GetCursorPos(&v60)->x > 13 )
-		{
-			if ( pMouse->GetCursorPos(&v72)->x < 462 )
-			{
-				v2 = v0->GetItemIDAtInventoryIndex((int *)&v79);
-				if ( v2 )
-				{
-					v3 = (int)&v0->pInventoryItems[v2-1];
-					//v4 = p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C];
-					v4 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
-
-					auto _v = (ItemGen *)&v0->pInventoryItems[v2-1];
-					v5 = _v->GetValue();
-
-					v6 = v0->_4B81C3(v5, v4);
-					v7 = (*(char *)(v3 + 20) & 2) == 0;
-					v80 = v6;
-					if ( !v7 )
-					{
-						_this = (ItemGen *)window_SpeakInHouse->ptr_1C;
-						if ( sub_4BDAAF((ItemGen *)v3, (int)_this) )
-						{
-						if ( pParty->uNumGold >= v80 )
-						{
-							dword_F8B1E4 = 1;
-							Party::TakeGold(v80);
-							v8 = *(int *)(v3 + 20);
-							LOBYTE(v8) = v8 & 0xFD;
-							*(int *)(v3 + 20) = v8 | 1;
-							v0->PlaySound(SPEECH_74, 0);
-							v9 = pGlobalTXT_LocalizationStrings[570];
-			//LABEL_25:
-							v54 = 2;
-			//LABEL_71:
-							ShowStatusBarString(v9, v54);
-							return;
-						}
-			//LABEL_26:
-						v13 = _this;
-						v55 = 2;
-			//LABEL_84:
-						PlayHouseSound((unsigned int)v13, (HouseSoundID)v55);
-						return;
-						}
-						pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
-						v53 = 0;
-			//LABEL_28:
-						v51 = 79;
-			//LABEL_80:
-						v27 = v0;
-						v27->PlaySound((PlayerSpeech)v51, v53);
-					return;
-					}
-					v53 = 0;
-					v51 = 76;
-					v27 = v0;
-					v27->PlaySound((PlayerSpeech)v51, v53);
-					return;          
-				}
-			}
-		}
-		break;
-		}
-
-	case HOUSE_DIALOGUE_SHOP_BUY_STANDARD:
-	case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL:
-		{
-	//LABEL_49:
-		v28 = pMouse->GetCursorPos(&v59);
-		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 == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
-		{
-			v32 = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29 - 1];
-			_this = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29 - 1];
-		}
-		else
-		{
-			_this =&pParty->SpecialItemsInShops[(int)v30][v29-1]; //(ItemGen *)&pParty->field_C59C[v31 + 724];
-			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->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 = v0->CanSteal();
-		v37 = pMapStats->GetMapInfo(pCurrentMapName);
-		if ( v37 )
-			a3 = pMapStats->pInfos[v37]._steal_perm;
-		v38 = GetPartyReputation();
-		v26 = 1;
-		if (v0->CanSteal())
-		{
-			if ( v74 )
-			{
-			uNumSeconds = v0->StealFromShop(v32, a3, v38, 0, &a6);
-			if ( !uNumSeconds )
-			{
-				sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, 0, a6);
-				return;
-			}
-			}
-		}
-		if ( pParty->uNumGold < v80 )
-		{
-			v24 = 2;
-			if ( uNumSeconds != 2 )
-			{
-				if ( uNumSeconds != 1 )
-				{
-					PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v24);
-					v9 = pGlobalTXT_LocalizationStrings[155]; // "You don't have enough gold"
-					v54 = 2;
-					ShowStatusBarString(v9, v54);
-					return;
-				}
-			}
-		}
-		v39 = v0->AddItem(0xFFFFFFFFu, v32->uItemID);
-		if ( v39 )
-		{
-			v32->SetIdentified();
-			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 ( v74 )
-				{
-					v41 = uNumSeconds;
-					if ( uNumSeconds == 1 || uNumSeconds == 2 )
-					{
-						//*(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();
-						pRenderer->ClearZBuffer(0, 479);
-						v27 = v77;
-						v53 = 0;
-						v51 = SPEECH_75;
-						v27->PlaySound((PlayerSpeech)v51, v53);
-						return;
-					}
-				}
-			}
-	//LABEL_42:
-			dword_F8B1E4 = v26;
-			Party::TakeGold(v80);
-	//LABEL_43:
-			viewparams->bRedrawGameUI = v26;
-			_this->Reset();
-			pRenderer->ClearZBuffer(0, 479);
-			v27 = v77;
-			v53 = 0;
-			v51 = SPEECH_75;
-	//LABEL_81:
-			v27->PlaySound((PlayerSpeech)v51, v53);
-			return;
-		}
-		v0->PlaySound(SPEECH_NoRoom, 0);
-		v54 = 2;
-		v9 = pGlobalTXT_LocalizationStrings[563];   // "Pack is Full!"
-		ShowStatusBarString(v9, v54);
-		break;
-		}
-
-	default:// if click video screen in shop
-		{
-          __debugbreak(); // please do record these dialogue ids to the HOUSE_DIALOGUE_MENU  enum
-		if( dialog_menu_id >= 36 && dialog_menu_id <= 72 )
-		{
-			v42 = dialog_menu_id - 36;
-			//v43 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0);
-			v43 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
-			v44 = v43 * (100 - v0->GetMerchant()) / 100;
-			if ( v44 < v43 / 3 )
-			v44 = v43 / 3;
-			if ( byte_4ED970_skill_learn_ability_by_class_table[v0->classType][v42] )
-			{
-				pSkill = &v0->pActiveSkills[v42];
-				if ( !*pSkill )
-				{
-					if ( pParty->uNumGold < v44 )
-					{
-						ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold"
-						v13 = window_SpeakInHouse->ptr_1C;
-						if ( in_current_building_type == BildingType_Training )
-							v55 = 4;
-						else
-							v55 = 2;
-						PlayHouseSound((unsigned int)v13, (HouseSoundID)v55);
-						return;
-					}
-					Party::TakeGold(v44);
-					v53 = 0;
-					dword_F8B1E4 = 1;
-					*pSkill = 1;
-					v51 = 78;
-					v27 = v0;
-					v27->PlaySound((PlayerSpeech)v51, v53);
-					return;
-				}
-			}
-		}
-		break;
-		}
+      v10 = v62.x - 14;
+      v79 = (v10 >> 5) + 14 * ((v62.y - 17) >> 5);
+      if (v62.x > 13  && v62.x < 462)
+      {
+        v11 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79);
+        if ( v11 )
+        {
+          //v80 = v0->_4B8179(p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C]);
+          v80 = pPlayers[uActiveCharacter]->_4B8179(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier);
+          v12 = (int)&pPlayers[uActiveCharacter]->pInventoryItems[v11-1];
+          if ( !(*(char *)(v12 + 20) & 1) )
+          {
+            _this = (ItemGen *)window_SpeakInHouse->ptr_1C;
+            if ( sub_4BDAAF((ItemGen *)v12, (int)_this) )
+            {
+              if ( pParty->uNumGold >= v80 )
+              {
+                dword_F8B1E4 = 1;
+                Party::TakeGold(v80);
+                *(int *)(v12 + 20) |= 1u;
+                pPlayers[uActiveCharacter]->PlaySound(SPEECH_73, 0);
+                v9 = pGlobalTXT_LocalizationStrings[569];
+                ShowStatusBarString(v9, 2);
+                return;
+              }
+              PlayHouseSound((unsigned int)_this, (HouseSoundID)2);
+              return;
+            }
+            pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
+            pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)79, 0);
+            return;
+          }
+          pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)76, 0);
+          return;
+        }
+      }
+      break;
+    }
+    case HOUSE_DIALOGUE_SHOP_REPAIR:
+    {
+      v1 = pMouse->GetCursorPos(&a2)->x - 14;
+      v79 = (v1 >> 5) + 14 * ((pMouse->GetCursorPos(&v70)->y - 17) >> 5);
+      if ( pMouse->GetCursorPos(&v60)->x > 13 )
+      {
+        if ( pMouse->GetCursorPos(&v72)->x < 462 )
+        {
+          v2 = v0->GetItemIDAtInventoryIndex((int *)&v79);
+          if ( v2 )
+          {
+            v3 = (int)&v0->pInventoryItems[v2-1];
+            //v4 = p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C];
+            v4 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
+            auto _v = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v2-1];
+            v5 = _v->GetValue();
+            v6 = pPlayers[uActiveCharacter]->_4B81C3(v5, v4);
+            v7 = (*(char *)(v3 + 20) & 2) == 0;
+            v80 = v6;
+            if ( !v7 )
+            {
+              _this = (ItemGen *)window_SpeakInHouse->ptr_1C;
+              if ( sub_4BDAAF((ItemGen *)v3, (int)_this) )
+              {
+                if ( pParty->uNumGold >= v80 )
+                {
+                  dword_F8B1E4 = 1;
+                  Party::TakeGold(v80);
+                  v8 = *(int *)(v3 + 20);
+                  LOBYTE(v8) = v8 & 0xFD;
+                  *(int *)(v3 + 20) = v8 | 1;
+                  pPlayers[uActiveCharacter]->PlaySound(SPEECH_74, 0);
+                  v9 = pGlobalTXT_LocalizationStrings[570];
+                  ShowStatusBarString(v9, 2);
+                  return;
+                }
+                PlayHouseSound((unsigned int)_this, (HouseSoundID)2);
+                return;
+              }
+              pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
+              pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)79, 0);
+              return;
+            }
+            pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)76, 0);
+            return;
+          }
+        }
+      }
+      break;
+    }
+    case HOUSE_DIALOGUE_SHOP_BUY_STANDARD:
+    case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL:
+    {
+      v28 = pMouse->GetCursorPos(&v59);
+      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 == HOUSE_DIALOGUE_SHOP_BUY_STANDARD)
+      {
+        v32 = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29 - 1];
+        _this = (ItemGen *)&pParty->StandartItemsInShops[(int)v30][v29 - 1];
+      }
+      else
+      {
+        _this =&pParty->SpecialItemsInShops[(int)v30][v29-1]; //(ItemGen *)&pParty->field_C59C[v31 + 724];
+        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 = pPlayers[uActiveCharacter]->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 = v0->CanSteal();
+      v37 = pMapStats->GetMapInfo(pCurrentMapName);
+      if ( v37 )
+        a3 = pMapStats->pInfos[v37]._steal_perm;
+      v38 = GetPartyReputation();
+      v26 = 1;
+      if (pPlayers[uActiveCharacter]->CanSteal())
+      {
+        if ( v74 )
+        {
+          uNumSeconds = pPlayers[uActiveCharacter]->StealFromShop(v32, a3, v38, 0, &a6);
+          if ( !uNumSeconds )
+          {
+            sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, 0, a6);
+            return;
+          }
+        }
+      }
+      if ( pParty->uNumGold < v80 )
+      {
+        v24 = 2;
+        if ( uNumSeconds != 2 )
+        {
+          if ( uNumSeconds != 1 )
+          {
+            PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v24);
+            ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold"
+            return;
+          }
+        }
+      }
+      v39 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, v32->uItemID);
+      if ( v39 )
+      {
+        v32->SetIdentified();
+        v7 = pPlayers[uActiveCharacter]->CanSteal();
+        //v40 = (int)((char *)v0 + 36 * v39);
+        //memcpy((void *)(v40 + 496), v32, 0x24u);
+        memcpy(&v0->pInventoryItems[v39 - 1], v32, sizeof(ItemGen));
+        if ( v7 )
+        {
+          if ( v74 )
+          {
+            v41 = uNumSeconds;
+            if ( uNumSeconds == 1 || uNumSeconds == 2 )
+            {
+              //*(char *)(v40 + 517) |= 1u;
+              pPlayers[uActiveCharacter]->pInventoryItems[v39 - 1].SetStolen();
+              sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, v41, a6);
+              viewparams->bRedrawGameUI = v26;
+              _this->Reset();
+              pRenderer->ClearZBuffer(0, 479);
+              pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0);
+              return;
+            }
+          }
+        }
+        dword_F8B1E4 = v26;
+        Party::TakeGold(v80);
+        viewparams->bRedrawGameUI = v26;
+        _this->Reset();
+        pRenderer->ClearZBuffer(0, 479);
+        pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0);
+        return;
+      }
+      pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0);
+      v9 = pGlobalTXT_LocalizationStrings[563];   // "Pack is Full!"
+      ShowStatusBarString(v9, 2);
+      break;
+    }
+    default:// if click video screen in shop
+    {
+      __debugbreak(); // please do record these dialogue ids to the HOUSE_DIALOGUE_MENU  enum
+      if( dialog_menu_id >= 36 && dialog_menu_id <= 72 )
+      {
+        v42 = dialog_menu_id - 36;
+        //v43 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0);
+        v43 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
+        v44 = v43 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
+        if ( v44 < v43 / 3 )
+          v44 = v43 / 3;
+        if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v42] )
+        {
+          pSkill = &pPlayers[uActiveCharacter]->pActiveSkills[v42];
+          if ( !*pSkill )
+          {
+            if ( pParty->uNumGold < v44 )
+            {
+              ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold"
+              if ( in_current_building_type == BildingType_Training )
+                v55 = 4;
+              else
+                v55 = 2;
+              PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v55);
+              return;
+            }
+            Party::TakeGold(v44);
+            dword_F8B1E4 = 1;
+           *pSkill = 1;
+            pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)78, 0);
+            return;
+          }
+        }
+      }
+      break;
+    }
   }
 }