diff mm7_2.cpp @ 677:551f74425b17

Merge
author Nomad
date Fri, 15 Mar 2013 04:17:54 +0200
parents ecfb1b3c9a39 638bd256ca46
children 066e2b29b30f
line wrap: on
line diff
--- a/mm7_2.cpp	Fri Mar 15 04:13:24 2013 +0200
+++ b/mm7_2.cpp	Fri Mar 15 04:17:54 2013 +0200
@@ -894,7 +894,8 @@
   {
 	v8 = window_SpeakInHouse;
   }
-  else
+  //else
+  if ( dialog_menu_id == 1 )
   {
 	  if ( in_current_building_type == BildingType_Training )
 	  {
@@ -923,7 +924,8 @@
 		//v3 = dword_F8B198;
 		v8 = window_SpeakInHouse;
 	  }
-	  else
+	  //else
+	  if ( in_current_building_type != BildingType_Training )
 	  {
 		  v8 = window_SpeakInHouse;
 		  if ( (in_current_building_type == BildingType_Stables || in_current_building_type == BildingType_Boats)
@@ -958,6 +960,287 @@
 		v8 = window_SpeakInHouse;
 	  }
   }
+  
+  //NEW
+  switch(in_current_building_type)
+  {
+	case 5:
+	case 6:
+	case 7:
+	case 8:
+	case 9:
+	case 10:
+	case 11:
+	case 12:
+	case 13:
+	case 14:
+	case 15:
+	case 16:
+		{
+        if ( (signed __int64)__PAIR__(
+                                *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472],
+                                *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44468]) >= (signed __int64)pParty->uTimePlayed )
+        {
+			v32 = 0;
+			do
+			{
+				//v33 = *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v32 + 12 * (unsigned int)v8->ptr_1C));
+				v33 = pParty->SpellBooksInGuilds[v8->par1C-139][v32].uItemID;
+				if ( v33 )
+				{
+				v34 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v33].pIconName, TEXTURE_16BIT_PALETTE);
+				v8 = window_SpeakInHouse;
+				ItemsInShopTexture[v32] = &pIcons_LOD->pTextures[v34];
+				}
+				++v32;
+			}
+			while ( v32 < 12 );
+        }
+        else
+        {
+			SpellBookGenerator();
+			v30 = window_SpeakInHouse->ptr_1C;
+			v31 = pParty->uTimePlayed
+				+ (signed __int64)((double)(0xA8C000
+											//* (signed int)p2DEvents_minus1[26 * (unsigned int)ptr_507BC0->ptr_1C])
+											* (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C)
+									* 0.033333335);
+			*(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44468] = v31;
+			*(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44472] = HIDWORD(v31);
+        }
+        return;
+		break;
+		}
+	case 17:
+		{
+		if ( uMessageParam == 99 )
+		{
+			v10 = (int)((char *)v8->ptr_1C - 102);
+			v56 = v10;
+			v11 = 8 * v10 + 11325428;
+			if ( (signed __int64)__PAIR__(pParty->field_3C.field_0[2 * v10 + 1], pParty->field_3C.field_0[2 * v10]) >= (signed __int64)pParty->uTimePlayed )
+			{
+				v13 = 0;
+			}
+			else
+			{
+				v12 = v10;
+				v13 = 0;
+				pParty->field_75A[v12] = 0;
+				*(_QWORD *)v11 = (signed __int64)((double)(309657600 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015)) * 0.033333335);
+				v14 = rand() % 258;
+				v15 = window_SpeakInHouse;
+				pParty->field_750[v12] = v14 + 1;
+				v16 = (int)((char *)v15->ptr_1C - 102);
+				if ( v16 )
+				{
+					v17 = v16 - 1;
+					if ( v17 )
+					{
+						v18 = v17 - 1;
+						if ( v18 )
+						{
+							v19 = v18 - 1;
+							if ( v19 )
+							{
+								if ( v19 == 1 )
+								{
+									while ( 1 )
+									{
+										v20 = pParty->field_750[v12];
+										if ( (unsigned __int16)v20 < 0x73u || (unsigned __int16)v20 > 0x84u )
+										{
+											if ( ((unsigned __int16)v20 < 0xE8u || (unsigned __int16)v20 > 0xF9u)
+											&& ((unsigned __int16)v20 < 0x85u || (unsigned __int16)v20 > 0x96u)
+											&& ((unsigned __int16)v20 < 0x97u || (unsigned __int16)v20 > 0xBAu)
+											&& ((unsigned __int16)v20 < 0xBEu || (unsigned __int16)v20 > 0xC0u)
+											&& ((unsigned __int16)v20 < 0xC4u || (unsigned __int16)v20 > 0xC6u)
+											&& ((unsigned __int16)v20 < 0x2Bu || (unsigned __int16)v20 > 0x2Du)
+											&& ((unsigned __int16)v20 < 0x6Du || (unsigned __int16)v20 > 0x6Fu)
+											&& ((unsigned __int16)v20 < 0x46u || (unsigned __int16)v20 > 0x48u)
+											&& ((unsigned __int16)v20 < 0x100u || (unsigned __int16)v20 > 0x102u)
+											&& ((unsigned __int16)v20 < 0xD9u || (unsigned __int16)v20 > 0xDBu)
+											&& ((unsigned __int16)v20 < 0xC7u || (unsigned __int16)v20 > 0xC9u)
+											&& ((unsigned __int16)v20 < 0xE5u || (unsigned __int16)v20 > 0xE7u)
+											&& ((unsigned __int16)v20 < 0xDFu || (unsigned __int16)v20 > 0xE1u)
+											&& ((unsigned __int16)v20 < 0x5Bu || (unsigned __int16)v20 > 0x5Du)
+											&& ((unsigned __int16)v20 < 0x49u || (unsigned __int16)v20 > 0x4Bu)
+											&& ((unsigned __int16)v20 < 0xFDu || (unsigned __int16)v20 > 0xFFu)
+											&& ((unsigned __int16)v20 < 0x61u || (unsigned __int16)v20 > 0x63u)
+											&& ((unsigned __int16)v20 < 0x10u || (unsigned __int16)v20 > 0x12u) )
+												break;
+										}
+										pParty->field_750[v12] = rand() % 258 + 1;
+									}
+								}
+							}
+							else
+							{
+								while ( 1 )
+								{
+									v21 = pParty->field_750[v12];
+									if ( (unsigned __int16)v21 < 0x73u || (unsigned __int16)v21 > 0x84u )
+									{
+									if ( ((unsigned __int16)v21 < 0xE8u || (unsigned __int16)v21 > 0xF9u)
+										&& ((unsigned __int16)v21 < 0x85u || (unsigned __int16)v21 > 0x96u)
+										&& ((unsigned __int16)v21 < 0x97u || (unsigned __int16)v21 > 0xBAu)
+										&& ((unsigned __int16)v21 < 0xBEu || (unsigned __int16)v21 > 0xC0u)
+										&& ((unsigned __int16)v21 < 0xC4u || (unsigned __int16)v21 > 0xC6u)
+										&& ((unsigned __int16)v21 < 0x2Bu || (unsigned __int16)v21 > 0x2Du)
+										&& ((unsigned __int16)v21 < 0x5Eu || (unsigned __int16)v21 > 0x60u)
+										&& ((unsigned __int16)v21 < 0x43u || (unsigned __int16)v21 > 0x45u)
+										&& ((unsigned __int16)v21 < 0x4Fu || (unsigned __int16)v21 > 0x51u)
+										&& ((unsigned __int16)v21 < 0xC1u || (unsigned __int16)v21 > 0xC3u)
+										&& ((unsigned __int16)v21 < 0x13u || (unsigned __int16)v21 > 0x15u)
+										&& ((unsigned __int16)v21 < 0xFDu || (unsigned __int16)v21 > 0xFFu)
+										&& ((unsigned __int16)v21 < 0x61u || (unsigned __int16)v21 > 0x63u)
+										&& ((unsigned __int16)v21 < 0x6Au || (unsigned __int16)v21 > 0x6Cu) )
+											break;
+									}
+									pParty->field_750[v12] = rand() % 258 + 1;
+								}
+							}
+						}
+						else
+						{
+							while ( 1 )
+							{
+								v22 = pParty->field_750[v12];
+								if ( (unsigned __int16)v22 < 0x73u || (unsigned __int16)v22 > 0x84u )
+								{
+									if ( ((unsigned __int16)v22 < 0xE8u || (unsigned __int16)v22 > 0xF9u)
+									&& ((unsigned __int16)v22 < 0x85u || (unsigned __int16)v22 > 0x96u)
+									&& ((unsigned __int16)v22 < 0x97u || (unsigned __int16)v22 > 0xBAu)
+									&& ((unsigned __int16)v22 < 0xBEu || (unsigned __int16)v22 > 0xC0u)
+									&& ((unsigned __int16)v22 < 0xC4u || (unsigned __int16)v22 > 0xC6u)
+									&& ((unsigned __int16)v22 < 0x2Bu || (unsigned __int16)v22 > 0x2Du)
+									&& ((unsigned __int16)v22 < 0x31u || (unsigned __int16)v22 > 0x33u)
+									&& ((unsigned __int16)v22 < 0x34u || (unsigned __int16)v22 > 0x36u)
+									&& ((unsigned __int16)v22 < 0xFDu || (unsigned __int16)v22 > 0xFFu)
+									&& ((unsigned __int16)v22 < 0x61u || (unsigned __int16)v22 > 0x63u)
+									&& ((unsigned __int16)v22 < 0x1Cu || (unsigned __int16)v22 > 0x1Eu) )
+									break;
+								}
+								pParty->field_750[v12] = rand() % 258 + 1;
+							}
+						}
+					}
+					else
+					{
+						while ( 1 )
+						{
+							v23 = pParty->field_750[v12];
+							if ( (unsigned __int16)v23 < 0x73u || (unsigned __int16)v23 > 0x84u )
+							{
+							if ( ((unsigned __int16)v23 < 0xE8u || (unsigned __int16)v23 > 0xF9u)
+								&& ((unsigned __int16)v23 < 0x85u || (unsigned __int16)v23 > 0x96u)
+								&& ((unsigned __int16)v23 < 0x97u || (unsigned __int16)v23 > 0xBAu)
+								&& ((unsigned __int16)v23 < 0xBEu || (unsigned __int16)v23 > 0xC0u)
+								&& ((unsigned __int16)v23 < 0xC4u || (unsigned __int16)v23 > 0xC6u)
+								&& ((unsigned __int16)v23 < 0x2Bu || (unsigned __int16)v23 > 0x2Du)
+								&& ((unsigned __int16)v23 < 0x52u || (unsigned __int16)v23 > 0x54u)
+								&& ((unsigned __int16)v23 < 4u || (unsigned __int16)v23 > 6u)
+								&& ((unsigned __int16)v23 < 0x37u || (unsigned __int16)v23 > 0x39u)
+								&& ((unsigned __int16)v23 < 0x3Au || (unsigned __int16)v23 > 0x3Cu)
+								&& ((unsigned __int16)v23 < 0x3Du || (unsigned __int16)v23 > 0x3Fu)
+								&& ((unsigned __int16)v23 < 0xFDu || (unsigned __int16)v23 > 0xFFu)
+								&& ((unsigned __int16)v23 < 0x61u || (unsigned __int16)v23 > 0x63u)
+								&& ((unsigned __int16)v23 < 0xCDu || (unsigned __int16)v23 > 0xCFu) )
+									break;
+							}
+							pParty->field_750[v12] = rand() % 258 + 1;
+						}
+					}
+				}
+				else
+				{
+					while ( 1 )
+					{
+						v24 = pParty->field_750[v12];
+						if ( (unsigned __int16)v24 < 0x73u || (unsigned __int16)v24 > 0x84u )
+						{
+							if ( ((unsigned __int16)v24 < 0xEBu || (unsigned __int16)v24 > 0xFCu)
+							&& ((unsigned __int16)v24 < 0x85u || (unsigned __int16)v24 > 0x96u)
+							&& ((unsigned __int16)v24 < 0x97u || (unsigned __int16)v24 > 0xBAu)
+							&& ((unsigned __int16)v24 < 0xBEu || (unsigned __int16)v24 > 0xC0u)
+							&& ((unsigned __int16)v24 < 0xC4u || (unsigned __int16)v24 > 0xC6u)
+							&& ((unsigned __int16)v24 < 0x2Bu || (unsigned __int16)v24 > 0x2Du)
+							&& ((unsigned __int16)v24 < 0xCDu || (unsigned __int16)v24 > 0xCFu)
+							&& ((unsigned __int16)v24 < 0x5Eu || (unsigned __int16)v24 > 0x60u)
+							&& ((unsigned __int16)v24 < 0xFDu || (unsigned __int16)v24 > 0xFFu)
+							&& ((unsigned __int16)v24 < 0x6Du || (unsigned __int16)v24 > 0x6Fu)
+							&& ((unsigned __int16)v24 < 0x61u || (unsigned __int16)v24 > 0x63u) )
+								break;
+						}
+						pParty->field_750[v12] = rand() % 258 + 1;
+					}
+				}
+				v10 = v56;
+			}
+			v25 = v10;
+			v26 = pParty->field_750[v25];
+			v27 = pParty->field_75A[v25] == v13;
+			word_F8B1A0 = pParty->field_750[v25];
+			if ( v27 )
+			{
+				//v1 = 0;
+				v27 = v26 == v13;
+				v29 = (int)pNPCTopics[351].pText;
+				if ( v27 )
+					v29 = (int)pNPCTopics[353].pText;
+				dword_F8B1A4 = (char *)v29;
+			}
+			else
+			{
+				if ( v26 != v13 )
+				{
+					party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)v26].uLevel, 0);
+					v28 = pParty->pPlayers;
+					do
+					{
+						v28->SetVariable(VAR_Award, 86);
+						++v28;
+					}
+					while ( (signed int)v28 < (signed int)pParty->pHirelings );
+					pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->field_750[v25]].uLevel;
+					pParty->field_750[v25] = v13;
+					pParty->field_75A[v25] = v13;
+				}
+				//v1 = 0;
+				dword_F8B1A4 = pNPCTopics[352].pText;
+			}
+		}
+		else if ( uMessageParam == 100 )
+		{
+			pKeyActionMap->EnterText(1, 10, v8);
+		}
+		break;
+		}
+	case 22:
+		{
+		if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 )
+			pKeyActionMap->EnterText(1, 10, v8);
+		return;
+		break;
+		}
+	case 1:
+	case 2:
+	case 3:
+	case 4:
+	case 21:
+	case 23:
+	case 30:
+		{
+		break;
+		}
+	default:
+		{
+		return;
+		break;
+		}
+  }
+
+  /*
   if ( in_current_building_type > BildingType_Tavern )
   {
     if ( in_current_building_type == BildingType_Bank )
@@ -969,10 +1252,9 @@
     if ( in_current_building_type != BildingType_Temple && in_current_building_type != BildingType_Training )
       return;
   }
-  else
-  {
-    if ( in_current_building_type != BildingType_Tavern )
-    {
+  //else
+  if ( in_current_building_type < BildingType_Tavern )
+  {
       if (in_current_building_type <= 0)
         return;
       if ( in_current_building_type > BildingType_AlchemistShop )
@@ -1014,232 +1296,240 @@
         }
         if ( in_current_building_type != BildingType_TownHall )
           return;
-        if ( uMessageParam == 99 )
-        {
-          v10 = (int)((char *)v8->ptr_1C - 102);
-          v56 = v10;
-          v11 = 8 * v10 + 11325428;
-          if ( (signed __int64)__PAIR__(pParty->field_3C.field_0[2 * v10 + 1], pParty->field_3C.field_0[2 * v10]) >= (signed __int64)pParty->uTimePlayed )
-          {
-            v13 = 0;
-          }
-          else
-          {
-            v12 = v10;
-            v13 = 0;
-            pParty->field_75A[v12] = 0;
-            *(_QWORD *)v11 = (signed __int64)((double)(309657600 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015)) * 0.033333335);
-            v14 = rand() % 258;
-            v15 = window_SpeakInHouse;
-            pParty->field_750[v12] = v14 + 1;
-            v16 = (int)((char *)v15->ptr_1C - 102);
-            if ( v16 )
-            {
-              v17 = v16 - 1;
-              if ( v17 )
-              {
-                v18 = v17 - 1;
-                if ( v18 )
-                {
-                  v19 = v18 - 1;
-                  if ( v19 )
-                  {
-                    if ( v19 == 1 )
-                    {
-                      while ( 1 )
-                      {
-                        v20 = pParty->field_750[v12];
-                        if ( (unsigned __int16)v20 < 0x73u || (unsigned __int16)v20 > 0x84u )
-                        {
-                          if ( ((unsigned __int16)v20 < 0xE8u || (unsigned __int16)v20 > 0xF9u)
-                            && ((unsigned __int16)v20 < 0x85u || (unsigned __int16)v20 > 0x96u)
-                            && ((unsigned __int16)v20 < 0x97u || (unsigned __int16)v20 > 0xBAu)
-                            && ((unsigned __int16)v20 < 0xBEu || (unsigned __int16)v20 > 0xC0u)
-                            && ((unsigned __int16)v20 < 0xC4u || (unsigned __int16)v20 > 0xC6u)
-                            && ((unsigned __int16)v20 < 0x2Bu || (unsigned __int16)v20 > 0x2Du)
-                            && ((unsigned __int16)v20 < 0x6Du || (unsigned __int16)v20 > 0x6Fu)
-                            && ((unsigned __int16)v20 < 0x46u || (unsigned __int16)v20 > 0x48u)
-                            && ((unsigned __int16)v20 < 0x100u || (unsigned __int16)v20 > 0x102u)
-                            && ((unsigned __int16)v20 < 0xD9u || (unsigned __int16)v20 > 0xDBu)
-                            && ((unsigned __int16)v20 < 0xC7u || (unsigned __int16)v20 > 0xC9u)
-                            && ((unsigned __int16)v20 < 0xE5u || (unsigned __int16)v20 > 0xE7u)
-                            && ((unsigned __int16)v20 < 0xDFu || (unsigned __int16)v20 > 0xE1u)
-                            && ((unsigned __int16)v20 < 0x5Bu || (unsigned __int16)v20 > 0x5Du)
-                            && ((unsigned __int16)v20 < 0x49u || (unsigned __int16)v20 > 0x4Bu)
-                            && ((unsigned __int16)v20 < 0xFDu || (unsigned __int16)v20 > 0xFFu)
-                            && ((unsigned __int16)v20 < 0x61u || (unsigned __int16)v20 > 0x63u)
-                            && ((unsigned __int16)v20 < 0x10u || (unsigned __int16)v20 > 0x12u) )
-                            break;
-                        }
-                        pParty->field_750[v12] = rand() % 258 + 1;
-                      }
-                    }
-                  }
-                  else
-                  {
-                    while ( 1 )
-                    {
-                      v21 = pParty->field_750[v12];
-                      if ( (unsigned __int16)v21 < 0x73u || (unsigned __int16)v21 > 0x84u )
-                      {
-                        if ( ((unsigned __int16)v21 < 0xE8u || (unsigned __int16)v21 > 0xF9u)
-                          && ((unsigned __int16)v21 < 0x85u || (unsigned __int16)v21 > 0x96u)
-                          && ((unsigned __int16)v21 < 0x97u || (unsigned __int16)v21 > 0xBAu)
-                          && ((unsigned __int16)v21 < 0xBEu || (unsigned __int16)v21 > 0xC0u)
-                          && ((unsigned __int16)v21 < 0xC4u || (unsigned __int16)v21 > 0xC6u)
-                          && ((unsigned __int16)v21 < 0x2Bu || (unsigned __int16)v21 > 0x2Du)
-                          && ((unsigned __int16)v21 < 0x5Eu || (unsigned __int16)v21 > 0x60u)
-                          && ((unsigned __int16)v21 < 0x43u || (unsigned __int16)v21 > 0x45u)
-                          && ((unsigned __int16)v21 < 0x4Fu || (unsigned __int16)v21 > 0x51u)
-                          && ((unsigned __int16)v21 < 0xC1u || (unsigned __int16)v21 > 0xC3u)
-                          && ((unsigned __int16)v21 < 0x13u || (unsigned __int16)v21 > 0x15u)
-                          && ((unsigned __int16)v21 < 0xFDu || (unsigned __int16)v21 > 0xFFu)
-                          && ((unsigned __int16)v21 < 0x61u || (unsigned __int16)v21 > 0x63u)
-                          && ((unsigned __int16)v21 < 0x6Au || (unsigned __int16)v21 > 0x6Cu) )
-                          break;
-                      }
-                      pParty->field_750[v12] = rand() % 258 + 1;
-                    }
-                  }
-                }
-                else
-                {
-                  while ( 1 )
-                  {
-                    v22 = pParty->field_750[v12];
-                    if ( (unsigned __int16)v22 < 0x73u || (unsigned __int16)v22 > 0x84u )
-                    {
-                      if ( ((unsigned __int16)v22 < 0xE8u || (unsigned __int16)v22 > 0xF9u)
-                        && ((unsigned __int16)v22 < 0x85u || (unsigned __int16)v22 > 0x96u)
-                        && ((unsigned __int16)v22 < 0x97u || (unsigned __int16)v22 > 0xBAu)
-                        && ((unsigned __int16)v22 < 0xBEu || (unsigned __int16)v22 > 0xC0u)
-                        && ((unsigned __int16)v22 < 0xC4u || (unsigned __int16)v22 > 0xC6u)
-                        && ((unsigned __int16)v22 < 0x2Bu || (unsigned __int16)v22 > 0x2Du)
-                        && ((unsigned __int16)v22 < 0x31u || (unsigned __int16)v22 > 0x33u)
-                        && ((unsigned __int16)v22 < 0x34u || (unsigned __int16)v22 > 0x36u)
-                        && ((unsigned __int16)v22 < 0xFDu || (unsigned __int16)v22 > 0xFFu)
-                        && ((unsigned __int16)v22 < 0x61u || (unsigned __int16)v22 > 0x63u)
-                        && ((unsigned __int16)v22 < 0x1Cu || (unsigned __int16)v22 > 0x1Eu) )
-                        break;
-                    }
-                    pParty->field_750[v12] = rand() % 258 + 1;
-                  }
-                }
-              }
-              else
-              {
-                while ( 1 )
-                {
-                  v23 = pParty->field_750[v12];
-                  if ( (unsigned __int16)v23 < 0x73u || (unsigned __int16)v23 > 0x84u )
-                  {
-                    if ( ((unsigned __int16)v23 < 0xE8u || (unsigned __int16)v23 > 0xF9u)
-                      && ((unsigned __int16)v23 < 0x85u || (unsigned __int16)v23 > 0x96u)
-                      && ((unsigned __int16)v23 < 0x97u || (unsigned __int16)v23 > 0xBAu)
-                      && ((unsigned __int16)v23 < 0xBEu || (unsigned __int16)v23 > 0xC0u)
-                      && ((unsigned __int16)v23 < 0xC4u || (unsigned __int16)v23 > 0xC6u)
-                      && ((unsigned __int16)v23 < 0x2Bu || (unsigned __int16)v23 > 0x2Du)
-                      && ((unsigned __int16)v23 < 0x52u || (unsigned __int16)v23 > 0x54u)
-                      && ((unsigned __int16)v23 < 4u || (unsigned __int16)v23 > 6u)
-                      && ((unsigned __int16)v23 < 0x37u || (unsigned __int16)v23 > 0x39u)
-                      && ((unsigned __int16)v23 < 0x3Au || (unsigned __int16)v23 > 0x3Cu)
-                      && ((unsigned __int16)v23 < 0x3Du || (unsigned __int16)v23 > 0x3Fu)
-                      && ((unsigned __int16)v23 < 0xFDu || (unsigned __int16)v23 > 0xFFu)
-                      && ((unsigned __int16)v23 < 0x61u || (unsigned __int16)v23 > 0x63u)
-                      && ((unsigned __int16)v23 < 0xCDu || (unsigned __int16)v23 > 0xCFu) )
-                      break;
-                  }
-                  pParty->field_750[v12] = rand() % 258 + 1;
-                }
-              }
-            }
-            else
-            {
-              while ( 1 )
-              {
-                v24 = pParty->field_750[v12];
-                if ( (unsigned __int16)v24 < 0x73u || (unsigned __int16)v24 > 0x84u )
-                {
-                  if ( ((unsigned __int16)v24 < 0xEBu || (unsigned __int16)v24 > 0xFCu)
-                    && ((unsigned __int16)v24 < 0x85u || (unsigned __int16)v24 > 0x96u)
-                    && ((unsigned __int16)v24 < 0x97u || (unsigned __int16)v24 > 0xBAu)
-                    && ((unsigned __int16)v24 < 0xBEu || (unsigned __int16)v24 > 0xC0u)
-                    && ((unsigned __int16)v24 < 0xC4u || (unsigned __int16)v24 > 0xC6u)
-                    && ((unsigned __int16)v24 < 0x2Bu || (unsigned __int16)v24 > 0x2Du)
-                    && ((unsigned __int16)v24 < 0xCDu || (unsigned __int16)v24 > 0xCFu)
-                    && ((unsigned __int16)v24 < 0x5Eu || (unsigned __int16)v24 > 0x60u)
-                    && ((unsigned __int16)v24 < 0xFDu || (unsigned __int16)v24 > 0xFFu)
-                    && ((unsigned __int16)v24 < 0x6Du || (unsigned __int16)v24 > 0x6Fu)
-                    && ((unsigned __int16)v24 < 0x61u || (unsigned __int16)v24 > 0x63u) )
-                    break;
-                }
-                pParty->field_750[v12] = rand() % 258 + 1;
-              }
-            }
-            v10 = v56;
-          }
-          v25 = v10;
-          v26 = pParty->field_750[v25];
-          v27 = pParty->field_75A[v25] == v13;
-          word_F8B1A0 = pParty->field_750[v25];
-          if ( v27 )
-          {
-            //v1 = 0;
-            v27 = v26 == v13;
-            v29 = (int)pNPCTopics[351].pText;
-            if ( v27 )
-              v29 = (int)pNPCTopics[353].pText;
-            dword_F8B1A4 = (char *)v29;
-          }
-          else
-          {
-            if ( v26 != v13 )
-            {
-              party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)v26].uLevel, 0);
-              v28 = pParty->pPlayers;
-              do
-              {
-                v28->SetVariable(VAR_Award, 86);
-                ++v28;
-              }
-              while ( (signed int)v28 < (signed int)pParty->pHirelings );
-              pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->field_750[v25]].uLevel;
-              pParty->field_750[v25] = v13;
-              pParty->field_75A[v25] = v13;
-            }
-            //v1 = 0;
-            dword_F8B1A4 = pNPCTopics[352].pText;
-          }
-        }
-        else if ( uMessageParam == 100 )
-        {
-          pKeyActionMap->EnterText(1, 10, v8);
-        }
-      }
-    }
-  }
-  if ( uMessageParam > 95 )
-  {
-LABEL_196:
-    switch ( uMessageParam )
-    {
-      case 96:
+		if ( in_current_building_type == BildingType_TownHall )
+		{
+			if ( uMessageParam == 99 )
+			{
+			  v10 = (int)((char *)v8->ptr_1C - 102);
+			  v56 = v10;
+			  v11 = 8 * v10 + 11325428;
+			  if ( (signed __int64)__PAIR__(pParty->field_3C.field_0[2 * v10 + 1], pParty->field_3C.field_0[2 * v10]) >= (signed __int64)pParty->uTimePlayed )
+			  {
+				v13 = 0;
+			  }
+			  else
+			  {
+				v12 = v10;
+				v13 = 0;
+				pParty->field_75A[v12] = 0;
+				*(_QWORD *)v11 = (signed __int64)((double)(309657600 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015)) * 0.033333335);
+				v14 = rand() % 258;
+				v15 = window_SpeakInHouse;
+				pParty->field_750[v12] = v14 + 1;
+				v16 = (int)((char *)v15->ptr_1C - 102);
+				if ( v16 )
+				{
+				  v17 = v16 - 1;
+				  if ( v17 )
+				  {
+					v18 = v17 - 1;
+					if ( v18 )
+					{
+					  v19 = v18 - 1;
+					  if ( v19 )
+					  {
+						if ( v19 == 1 )
+						{
+						  while ( 1 )
+						  {
+							v20 = pParty->field_750[v12];
+							if ( (unsigned __int16)v20 < 0x73u || (unsigned __int16)v20 > 0x84u )
+							{
+							  if ( ((unsigned __int16)v20 < 0xE8u || (unsigned __int16)v20 > 0xF9u)
+								&& ((unsigned __int16)v20 < 0x85u || (unsigned __int16)v20 > 0x96u)
+								&& ((unsigned __int16)v20 < 0x97u || (unsigned __int16)v20 > 0xBAu)
+								&& ((unsigned __int16)v20 < 0xBEu || (unsigned __int16)v20 > 0xC0u)
+								&& ((unsigned __int16)v20 < 0xC4u || (unsigned __int16)v20 > 0xC6u)
+								&& ((unsigned __int16)v20 < 0x2Bu || (unsigned __int16)v20 > 0x2Du)
+								&& ((unsigned __int16)v20 < 0x6Du || (unsigned __int16)v20 > 0x6Fu)
+								&& ((unsigned __int16)v20 < 0x46u || (unsigned __int16)v20 > 0x48u)
+								&& ((unsigned __int16)v20 < 0x100u || (unsigned __int16)v20 > 0x102u)
+								&& ((unsigned __int16)v20 < 0xD9u || (unsigned __int16)v20 > 0xDBu)
+								&& ((unsigned __int16)v20 < 0xC7u || (unsigned __int16)v20 > 0xC9u)
+								&& ((unsigned __int16)v20 < 0xE5u || (unsigned __int16)v20 > 0xE7u)
+								&& ((unsigned __int16)v20 < 0xDFu || (unsigned __int16)v20 > 0xE1u)
+								&& ((unsigned __int16)v20 < 0x5Bu || (unsigned __int16)v20 > 0x5Du)
+								&& ((unsigned __int16)v20 < 0x49u || (unsigned __int16)v20 > 0x4Bu)
+								&& ((unsigned __int16)v20 < 0xFDu || (unsigned __int16)v20 > 0xFFu)
+								&& ((unsigned __int16)v20 < 0x61u || (unsigned __int16)v20 > 0x63u)
+								&& ((unsigned __int16)v20 < 0x10u || (unsigned __int16)v20 > 0x12u) )
+								break;
+							}
+							pParty->field_750[v12] = rand() % 258 + 1;
+						  }
+						}
+					  }
+					  else
+					  {
+						while ( 1 )
+						{
+						  v21 = pParty->field_750[v12];
+						  if ( (unsigned __int16)v21 < 0x73u || (unsigned __int16)v21 > 0x84u )
+						  {
+							if ( ((unsigned __int16)v21 < 0xE8u || (unsigned __int16)v21 > 0xF9u)
+							  && ((unsigned __int16)v21 < 0x85u || (unsigned __int16)v21 > 0x96u)
+							  && ((unsigned __int16)v21 < 0x97u || (unsigned __int16)v21 > 0xBAu)
+							  && ((unsigned __int16)v21 < 0xBEu || (unsigned __int16)v21 > 0xC0u)
+							  && ((unsigned __int16)v21 < 0xC4u || (unsigned __int16)v21 > 0xC6u)
+							  && ((unsigned __int16)v21 < 0x2Bu || (unsigned __int16)v21 > 0x2Du)
+							  && ((unsigned __int16)v21 < 0x5Eu || (unsigned __int16)v21 > 0x60u)
+							  && ((unsigned __int16)v21 < 0x43u || (unsigned __int16)v21 > 0x45u)
+							  && ((unsigned __int16)v21 < 0x4Fu || (unsigned __int16)v21 > 0x51u)
+							  && ((unsigned __int16)v21 < 0xC1u || (unsigned __int16)v21 > 0xC3u)
+							  && ((unsigned __int16)v21 < 0x13u || (unsigned __int16)v21 > 0x15u)
+							  && ((unsigned __int16)v21 < 0xFDu || (unsigned __int16)v21 > 0xFFu)
+							  && ((unsigned __int16)v21 < 0x61u || (unsigned __int16)v21 > 0x63u)
+							  && ((unsigned __int16)v21 < 0x6Au || (unsigned __int16)v21 > 0x6Cu) )
+							  break;
+						  }
+						  pParty->field_750[v12] = rand() % 258 + 1;
+						}
+					  }
+					}
+					else
+					{
+					  while ( 1 )
+					  {
+						v22 = pParty->field_750[v12];
+						if ( (unsigned __int16)v22 < 0x73u || (unsigned __int16)v22 > 0x84u )
+						{
+						  if ( ((unsigned __int16)v22 < 0xE8u || (unsigned __int16)v22 > 0xF9u)
+							&& ((unsigned __int16)v22 < 0x85u || (unsigned __int16)v22 > 0x96u)
+							&& ((unsigned __int16)v22 < 0x97u || (unsigned __int16)v22 > 0xBAu)
+							&& ((unsigned __int16)v22 < 0xBEu || (unsigned __int16)v22 > 0xC0u)
+							&& ((unsigned __int16)v22 < 0xC4u || (unsigned __int16)v22 > 0xC6u)
+							&& ((unsigned __int16)v22 < 0x2Bu || (unsigned __int16)v22 > 0x2Du)
+							&& ((unsigned __int16)v22 < 0x31u || (unsigned __int16)v22 > 0x33u)
+							&& ((unsigned __int16)v22 < 0x34u || (unsigned __int16)v22 > 0x36u)
+							&& ((unsigned __int16)v22 < 0xFDu || (unsigned __int16)v22 > 0xFFu)
+							&& ((unsigned __int16)v22 < 0x61u || (unsigned __int16)v22 > 0x63u)
+							&& ((unsigned __int16)v22 < 0x1Cu || (unsigned __int16)v22 > 0x1Eu) )
+							break;
+						}
+						pParty->field_750[v12] = rand() % 258 + 1;
+					  }
+					}
+				  }
+				  else
+				  {
+					while ( 1 )
+					{
+					  v23 = pParty->field_750[v12];
+					  if ( (unsigned __int16)v23 < 0x73u || (unsigned __int16)v23 > 0x84u )
+					  {
+						if ( ((unsigned __int16)v23 < 0xE8u || (unsigned __int16)v23 > 0xF9u)
+						  && ((unsigned __int16)v23 < 0x85u || (unsigned __int16)v23 > 0x96u)
+						  && ((unsigned __int16)v23 < 0x97u || (unsigned __int16)v23 > 0xBAu)
+						  && ((unsigned __int16)v23 < 0xBEu || (unsigned __int16)v23 > 0xC0u)
+						  && ((unsigned __int16)v23 < 0xC4u || (unsigned __int16)v23 > 0xC6u)
+						  && ((unsigned __int16)v23 < 0x2Bu || (unsigned __int16)v23 > 0x2Du)
+						  && ((unsigned __int16)v23 < 0x52u || (unsigned __int16)v23 > 0x54u)
+						  && ((unsigned __int16)v23 < 4u || (unsigned __int16)v23 > 6u)
+						  && ((unsigned __int16)v23 < 0x37u || (unsigned __int16)v23 > 0x39u)
+						  && ((unsigned __int16)v23 < 0x3Au || (unsigned __int16)v23 > 0x3Cu)
+						  && ((unsigned __int16)v23 < 0x3Du || (unsigned __int16)v23 > 0x3Fu)
+						  && ((unsigned __int16)v23 < 0xFDu || (unsigned __int16)v23 > 0xFFu)
+						  && ((unsigned __int16)v23 < 0x61u || (unsigned __int16)v23 > 0x63u)
+						  && ((unsigned __int16)v23 < 0xCDu || (unsigned __int16)v23 > 0xCFu) )
+						  break;
+					  }
+					  pParty->field_750[v12] = rand() % 258 + 1;
+					}
+				  }
+				}
+				else
+				{
+				  while ( 1 )
+				  {
+					v24 = pParty->field_750[v12];
+					if ( (unsigned __int16)v24 < 0x73u || (unsigned __int16)v24 > 0x84u )
+					{
+					  if ( ((unsigned __int16)v24 < 0xEBu || (unsigned __int16)v24 > 0xFCu)
+						&& ((unsigned __int16)v24 < 0x85u || (unsigned __int16)v24 > 0x96u)
+						&& ((unsigned __int16)v24 < 0x97u || (unsigned __int16)v24 > 0xBAu)
+						&& ((unsigned __int16)v24 < 0xBEu || (unsigned __int16)v24 > 0xC0u)
+						&& ((unsigned __int16)v24 < 0xC4u || (unsigned __int16)v24 > 0xC6u)
+						&& ((unsigned __int16)v24 < 0x2Bu || (unsigned __int16)v24 > 0x2Du)
+						&& ((unsigned __int16)v24 < 0xCDu || (unsigned __int16)v24 > 0xCFu)
+						&& ((unsigned __int16)v24 < 0x5Eu || (unsigned __int16)v24 > 0x60u)
+						&& ((unsigned __int16)v24 < 0xFDu || (unsigned __int16)v24 > 0xFFu)
+						&& ((unsigned __int16)v24 < 0x6Du || (unsigned __int16)v24 > 0x6Fu)
+						&& ((unsigned __int16)v24 < 0x61u || (unsigned __int16)v24 > 0x63u) )
+						break;
+					}
+					pParty->field_750[v12] = rand() % 258 + 1;
+				  }
+				}
+				v10 = v56;
+			  }
+			  v25 = v10;
+			  v26 = pParty->field_750[v25];
+			  v27 = pParty->field_75A[v25] == v13;
+			  word_F8B1A0 = pParty->field_750[v25];
+			  if ( v27 )
+			  {
+				//v1 = 0;
+				v27 = v26 == v13;
+				v29 = (int)pNPCTopics[351].pText;
+				if ( v27 )
+				  v29 = (int)pNPCTopics[353].pText;
+				dword_F8B1A4 = (char *)v29;
+			  }
+			  else
+			  {
+				if ( v26 != v13 )
+				{
+				  party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)v26].uLevel, 0);
+				  v28 = pParty->pPlayers;
+				  do
+				  {
+					v28->SetVariable(VAR_Award, 86);
+					++v28;
+				  }
+				  while ( (signed int)v28 < (signed int)pParty->pHirelings );
+				  pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->field_750[v25]].uLevel;
+				  pParty->field_750[v25] = v13;
+				  pParty->field_75A[v25] = v13;
+				}
+				//v1 = 0;
+				dword_F8B1A4 = pNPCTopics[352].pText;
+			  }
+			}
+			else if ( uMessageParam == 100 )
+			{
+			  pKeyActionMap->EnterText(1, 10, v8);
+			}
+		}
+	  }
+  }
+  */
+  
+
+//LABEL_196:
+  switch ( uMessageParam )
+  {
+    case 96:
+		{
         pDialogueWindow->eWindowType = WINDOW_MainMenu;
         UI_CreateEndConversationButton();
         FillAviableSkillsToTeach(in_current_building_type);
         break;
-      case 101:
+		}
+    case 101:
+		{
         pDialogueWindow->eWindowType = WINDOW_MainMenu;
         UI_CreateEndConversationButton();
         sub_4B3A72(in_current_building_type);
         break;
-      case 102:
-        dialog_menu_id = 102;
+		}
+    case 102:
+    case 103:
+		{
+        dialog_menu_id = uMessageParam;
         break;
-      case 103:
-        dialog_menu_id = 103;
-        break;
-      case 104:
+		}
+    case 104:
+		{
         /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
         {
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)29;
@@ -1250,9 +1540,181 @@
         pMessageQueue_50CBD0->AddMessage(UIMSG_PlayArcomage, 0, 0);
         dialog_menu_id = 104;
         break;
-    }
-    return;
-  }
+		}
+	case 2:
+	case 95:
+		{
+		if ( pParty->field_3C.field_50[(unsigned int)v8->ptr_1C] < (signed __int64)pParty->uTimePlayed )
+		{
+			GenerateStandartShopItems();
+			GenerateSpecialShopItems();
+			v8 = window_SpeakInHouse;
+			v40 = window_SpeakInHouse->par1C;
+			//v3 = dword_F8B198;
+			v41 = pParty->uTimePlayed
+				//+ (signed __int64)((double)(11059200 * (signed int)p2DEvents_minus1[26 * (unsigned int)ptr_507BC0->ptr_1C])
+				+ (signed __int64)((double)(11059200 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C)
+									* 0.033333335);
+			pParty->field_3C.field_50[v40] = v41;
+   		}
+		v42 = v8->ptr_1C;
+		v43 = 0;
+		//v44 = p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C];
+		v44 = p2DEvents[(unsigned int)v8->ptr_1C - 1].uType;
+		if ( uMessageParam == 2 )
+		{
+			if ( uItemsAmountPerShopType[v44] )
+			{
+				do
+				{
+					v45 = pParty->StandartItemsInShops[(int)v42][v43].uItemID;
+					if ( v45 )
+					{
+						v46 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v45].pIconName, TEXTURE_16BIT_PALETTE);
+						//v3 = dword_F8B198;
+						v8 = window_SpeakInHouse;
+						ItemsInShopTexture[v43] = &pIcons_LOD->pTextures[v46];
+					}
+					v42 = v8->ptr_1C;
+					++v43;
+				}
+				//while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] );
+				while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] );
+			}
+			if ( in_current_building_type == BildingType_WeaponShop )
+			{
+				v47 = v8->ptr_1C;
+				v48 = 0;
+				//if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] )
+				if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] )
+				{
+					do
+					{
+						// if ( pParty->field_777C[9 * (v48 + 12 * (int)v47)] )
+						if ( pParty->StandartItemsInShops[(int)v47][v48].uItemID);
+						{
+							v49 = rand();
+							v8 = window_SpeakInHouse;
+							word_F8B158[v48] = v49 % (300 - ItemsInShopTexture[v48]->uTextureHeight);
+						}
+						v47 = v8->ptr_1C;
+						++v48;
+					}
+					//while ( v48 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] );
+					while ( v48 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] );
+				}
+			}
+		}
+		if ( uMessageParam == 95 )
+		{
+			if ( uItemsAmountPerShopType[v44] )
+			{
+				do
+				{
+					//v50 = pParty->field_C59C[9 * (v43 + 12 * (int)v42) + 724];
+					v50=pParty->SpecialItemsInShops[(unsigned int)v42][(signed int)v43].uItemID;
+					if ( v50 )
+					{
+						v51 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v50].pIconName, TEXTURE_16BIT_PALETTE);
+						//v3 = dword_F8B198;
+						v8 = window_SpeakInHouse;
+						ItemsInShopTexture[v43] = &pIcons_LOD->pTextures[v51];
+					}
+					v42 = v8->ptr_1C;
+					++v43;
+				}
+				//while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] );
+				while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] );
+			}
+			if ( in_current_building_type == BildingType_WeaponShop )
+			{
+				v52 = v8->ptr_1C;
+				v53 = 0;
+				//if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] )
+				if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] )
+				{
+					do
+					{
+						// if ( pParty->field_C59C[9 * (v53 + 12 * (int)v52) + 724] )
+						if (pParty->SpecialItemsInShops[(unsigned int)v52][v53].uItemID)
+						{
+							v54 = rand();
+							v8 = window_SpeakInHouse;
+							word_F8B158[v53] = v54 % (300 - ItemsInShopTexture[v53]->uTextureHeight);
+						}
+						v52 = v8->ptr_1C;
+						++v53;
+					}
+					//while ( v53 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] );
+					while ( v53 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType ] );
+				}
+			}
+		}
+		break;
+		}
+	case 3:
+	case 4:
+	case 5:
+		{
+		dialog_menu_id = uMessageParam;
+		sub_421B2C_PlaceInInventory_or_DropPickedItem();
+		break;
+		}
+	case 94:
+		{
+        pDialogueWindow->eWindowType = WINDOW_MainMenu;
+        UI_CreateEndConversationButton();
+        sub_4B3AD4(in_current_building_type);
+		break;
+		}
+	default:
+		{
+		if( uMessageParam >= 36 && uMessageParam <= 72 )
+		{
+			v35 = pPlayers[uActiveCharacter];
+			//v36 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)v8->ptr_1C] * 500.0);
+			v36 = (signed __int64)(p2DEvents[(unsigned int)v8->ptr_1C - 1].flt_24 * 500.0);
+			v37 = v36 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
+			if ( v37 < v36 / 3 )
+			v37 = v36 / 3;
+              
+			__debugbreak();
+			//pSkillAvailabilityPerClass[8 + v58->uClass][4 + v23]
+			// or
+			//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]
+
+			//if (false)
+			if(byte_4ED970_skill_learn_ability_by_class_table[v35->classType][uMessageParam-36])
+			//if ( *(&byte_4ED94C[37 * v35->uClass] + v55) )
+			{
+			v38 = (int)(&v35->uIntelligence + uMessageParam);
+			if ( !*(short *)v38 )
+			{
+				if ( pParty->uNumGold < v37 )
+				{
+				ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
+				if ( in_current_building_type == BildingType_Training || in_current_building_type == BildingType_Tavern )
+					v39 = 4;
+				else
+					v39 = 2;
+				HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, v39);
+				}
+				else
+				{
+				Party::TakeGold(v37);
+				dword_F8B1E4 = 1;
+				*(short *)v38 = 1;
+				v35->PlaySound(SPEECH_78, 0);
+				}
+			}
+			}
+		}
+		break;
+		}
+  }
+  /*
   if ( uMessageParam != 95 && uMessageParam != 2 )
   {
     if ( uMessageParam == 3 )
@@ -1392,7 +1854,7 @@
       }
     }
   }
-  else
+  if ( uMessageParam == 95 )
   {
     if ( uItemsAmountPerShopType[v44] )
     {
@@ -1437,6 +1899,7 @@
       }
     }
   }
+*/
 }
 
 //----- (004BD8B5) --------------------------------------------------------
@@ -1646,367 +2109,365 @@
     pAudioPlayer->PlaySound(SOUND_27, v46, v47, v48, v49, v50, v52, v56);
     return;
   }
-  if ( dialog_menu_id > 18 )
-  {
-    if ( dialog_menu_id < 36 )
-      return;
-    if ( 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;
-            HousePlaySomeSound((unsigned int)v13, v55);
-            return;
-          }
-          Party::TakeGold(v44);
-          v53 = 0;
-          dword_F8B1E4 = 1;
-          *pSkill = 1;
-          v51 = 78;
-          v27 = v0;
-		  v27->PlaySound((PlayerSpeech)v51, v53);
-		  return;
-        }
-      }
-      return;
-    }
-    if ( dialog_menu_id != 94 )
-    {
-      if ( dialog_menu_id != 95 )
-        return;
-      goto LABEL_49;
-    }
-    pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
-//LABEL_73:
-    sub_421EA6_OnInventoryLeftClick();
-    return;
-  }
-  if ( dialog_menu_id == 18 )
-  {
-    v17 = pMouse->GetCursorPos(&v63);
-    v18 = pRenderer->pActiveZBuffer[v17->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v61)->y]] & 0xFFFF;
-    if ( !v18 )
-      return;
-    v19 = window_SpeakInHouse->ptr_1C;
-    v20 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)v19));
-    //v21 = p2DEvents_minus1__20[13 * (signed int)v19];
-    v21 = p2DEvents[(signed int)v19 - 1].fPriceMultiplier;
-    _this = v20;
-    v22 = v20->GetValue();
-    v23 = v0->_4B8142(v22, v21);
-    v80 = v23;
-    GetAsyncKeyState(VK_CONTROL);
-    if ( pParty->uNumGold < v23 )
-    {
-      v24 = 2;
-//LABEL_62:
-      HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 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;
-      v53 = 0;
-      v51 = SPEECH_75;
-      v27->PlaySound((PlayerSpeech)v51, v53);
-      return;
-    }
-    v0->PlaySound(SPEECH_NoRoom, 0);
-    v54 = 5;
-//LABEL_70:
-    v9 = pGlobalTXT_LocalizationStrings[563];   // "Pack is Full!"
-    ShowStatusBarString(v9, v54);
-    return;
-  }
-  if ( dialog_menu_id == 2 )
-  {
-LABEL_49:
-    v28 = pMouse->GetCursorPos(&v59);
-    v29 = pRenderer->pActiveZBuffer[v28->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v57)->y]] & 0xFFFF;
-    if ( !v29 )
-      return;
-    v30 = window_SpeakInHouse->ptr_1C;
-   // v31 = 9 * (v29 - 1 + 12 * (int)v30);
-    if ( dialog_menu_id == 2 )
-    {
-      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->_4B8142(v34, v33);
-    LOWORD(v35) = GetAsyncKeyState(VK_CONTROL);
-    v74 = v35;
-    v36 = v0->CanSteal();
-    uNumSeconds = 0;
-    a3 = 0;
-    v73 = v36;
-    v37 = pMapStats->GetMapInfo(pCurrentMapName);
-    if ( v37 )
-      a3 = pMapStats->pInfos[v37]._steal_perm;
-    v38 = GetPartyReputation();
-    v26 = 1;
-    if ( v73 == 1 )
-    {
-      if ( (short)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 )
+  switch(dialog_menu_id)
+  {
+	case 94:
+		{
+			pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
+			sub_421EA6_OnInventoryLeftClick();
+			break;
+		}
+	case 18:
+		{
+		v17 = pMouse->GetCursorPos(&v63);
+		v18 = pRenderer->pActiveZBuffer[v17->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v61)->y]] & 0xFFFF;
+		if ( !v18 )
+			return;
+		v19 = window_SpeakInHouse->ptr_1C;
+		v20 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)v19));
+		//v21 = p2DEvents_minus1__20[13 * (signed int)v19];
+		v21 = p2DEvents[(signed int)v19 - 1].fPriceMultiplier;
+		_this = v20;
+		v22 = v20->GetValue();
+		v23 = v0->_4B8142(v22, v21);
+		v80 = v23;
+		GetAsyncKeyState(VK_CONTROL);
+		if ( pParty->uNumGold < v23 )
+		{
+			v24 = 2;
+	//LABEL_62:
+			HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 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;
+			v53 = 0;
+			v51 = SPEECH_75;
+			v27->PlaySound((PlayerSpeech)v51, v53);
+			return;
+		}
+		v0->PlaySound(SPEECH_NoRoom, 0);
+		v54 = 5;
+	//LABEL_70:
+		v9 = pGlobalTXT_LocalizationStrings[563];   // "Pack is Full!"
+		ShowStatusBarString(v9, v54);
+		break;
+		}
+	case 3:
+		{
+		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) )
 		{
-		  HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, v24);
-		  v9 = pGlobalTXT_LocalizationStrings[155];
-		  v54 = 2;
-          ShowStatusBarString(v9, v54);
-          return;
+			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 4:
+		{
+		v10 = pMouse->GetCursorPos(&v62)->x - 14;
+		v79 = (v10 >> 5) + 14 * ((pMouse->GetCursorPos(&v66)->y - 17) >> 5);
+		if ( pMouse->GetCursorPos(&v58)->x > 13 )
+		{
+			if ( pMouse->GetCursorPos(&v64)->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;
+					HousePlaySomeSound((unsigned int)v13, 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;
 		}
-      }
-    }
-    v39 = v0->AddItem(0xFFFFFFFFu, v32->uItemID);
-    if ( v39 )
-    {
-      v32->SetIdentified();
-      v7 = v73 == 1;
-      v40 = (int)((char *)v0 + 36 * v39);
-      memcpy((void *)(v40 + 496), v32, 0x24u);
-      if ( v7 )
-      {
-        if ( (short)v74 )
-        {
-          v41 = uNumSeconds;
-          if ( uNumSeconds == 1 || uNumSeconds == 2 )
-          {
-            *(char *)(v40 + 517) |= 1u;
-            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);
-    return;
-  }
-  if ( dialog_menu_id == 3 )
-  {
-    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);
-    return;
-  }
-  if ( dialog_menu_id == 4 )
-  {
-    v10 = pMouse->GetCursorPos(&v62)->x - 14;
-    v79 = (v10 >> 5) + 14 * ((pMouse->GetCursorPos(&v66)->y - 17) >> 5);
-    if ( pMouse->GetCursorPos(&v58)->x > 13 )
-    {
-      if ( pMouse->GetCursorPos(&v64)->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;
-              HousePlaySomeSound((unsigned int)v13, 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;
+	case 5:
+		{
+		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:
+						HousePlaySomeSound((unsigned int)v13, 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 2:
+	case 95:
+		{
+	//LABEL_49:
+		v28 = pMouse->GetCursorPos(&v59);
+		v29 = pRenderer->pActiveZBuffer[v28->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v57)->y]] & 0xFFFF;
+		if ( !v29 )
+			return;
+		v30 = window_SpeakInHouse->ptr_1C;
+		// v31 = 9 * (v29 - 1 + 12 * (int)v30);
+		if ( dialog_menu_id == 2 )
+		{
+			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];
 		}
-      }
-    }
-  }
-  else
-  {
-    if ( dialog_menu_id == 5 )
-    {
-      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:
-                HousePlaySomeSound((unsigned int)v13, 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);
+		//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();
+		uNumSeconds = 0;
+		a3 = 0;
+		v73 = v36;
+		v37 = pMapStats->GetMapInfo(pCurrentMapName);
+		if ( v37 )
+			a3 = pMapStats->pInfos[v37]._steal_perm;
+		v38 = GetPartyReputation();
+		v26 = 1;
+		if ( v73 == 1 )
+		{
+			if ( (short)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 )
+				{
+					HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, v24);
+					v9 = pGlobalTXT_LocalizationStrings[155];
+					v54 = 2;
+					ShowStatusBarString(v9, v54);
+					return;
+				}
+			}
+		}
+		v39 = v0->AddItem(0xFFFFFFFFu, v32->uItemID);
+		if ( v39 )
+		{
+			v32->SetIdentified();
+			v7 = v73 == 1;
+			v40 = (int)((char *)v0 + 36 * v39);
+			memcpy((void *)(v40 + 496), v32, 0x24u);
+			if ( v7 )
+			{
+				if ( (short)v74 )
+				{
+					v41 = uNumSeconds;
+					if ( uNumSeconds == 1 || uNumSeconds == 2 )
+					{
+						*(char *)(v40 + 517) |= 1u;
+						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;
-            }
-            v53 = 0;
-            v51 = 76;
-            v27 = v0;
-	        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( 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;
+						HousePlaySomeSound((unsigned int)v13, v55);
+						return;
+					}
+					Party::TakeGold(v44);
+					v53 = 0;
+					dword_F8B1E4 = 1;
+					*pSkill = 1;
+					v51 = 78;
+					v27 = v0;
+					v27->PlaySound((PlayerSpeech)v51, v53);
+					return;
+				}
+			}
+		}
+		break;
+		}
   }
 }
 
@@ -10460,7 +10921,7 @@
 }
 
 bool new_sky = false;
-bool change_seasons = true;
+bool change_seasons = false;
 
 //----- (00462C94) --------------------------------------------------------
 bool MM_Main(const wchar_t *pCmdLine)