changeset 502:dd5124185551

Слияние
author Ritor1
date Fri, 01 Mar 2013 17:38:04 +0600
parents 6fa3ff8ef729 (current diff) 0e20e886365d (diff)
children 7c86030324a5 cf366ba68de5
files Events.cpp GUIWindow.cpp Spells.h mm7_3.cpp mm7_4.cpp mm7_data.h stru6.cpp
diffstat 13 files changed, 266 insertions(+), 292 deletions(-) [+]
line wrap: on
line diff
--- a/Events.cpp	Fri Mar 01 17:37:47 2013 +0600
+++ b/Events.cpp	Fri Mar 01 17:38:04 2013 +0600
@@ -1562,7 +1562,7 @@
 				//v7 = "";
 				break;
 			case EVENT_SpeakInHouse: 
-				if ( EnterHouse((enum HOUSE_ID)(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8))) )
+				if ( EnterHouse((enum HOUSE_ID)EVT_DWORD(_evt->v5)))
 					{
 					if ( pRenderer->pRenderD3D && !pRenderer->bWindowMode )
 						pRenderer->_49FD3A();
@@ -1572,10 +1572,10 @@
 					if ( uCurrentHouse_Animation != 167 )
 						v104 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8);
 					window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, v104, 0);
-					window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0);
-					window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
-					window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, "", 0);
-					window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, "", 0);
+					window_SpeakInHouse->CreateButton( 61, 424, 31, 0, 2, 94, 0x6Eu, 1, 49, "", 0);
+					window_SpeakInHouse->CreateButton(177, 424, 31, 0, 2, 94, 0x6Eu, 2, 50, "", 0);
+					window_SpeakInHouse->CreateButton(292, 424, 31, 0, 2, 94, 0x6Eu, 3, 51, "", 0);
+					window_SpeakInHouse->CreateButton(407, 424, 31, 0, 2, 94, 0x6Eu, 4, 52, "", 0);
 					window_SpeakInHouse->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, "", 0);
 					}
 				++curr_seq_num;
--- a/Events2D.h	Fri Mar 01 17:37:47 2013 +0600
+++ b/Events2D.h	Fri Mar 01 17:38:04 2013 +0600
@@ -1,12 +1,45 @@
 #pragma once
 
-
+/*  296 */
+enum BildingType : unsigned short
+	{
+	BildingType_WeaponShop = 0x1,
+	BildingType_ArmorShop = 0x2,
+	BildingType_MagicShop = 0x3,
+	BildingType_AlchemistShop = 0x4,
+	BildingType_FireGuild = 0x5,
+	BildingType_AirGuild = 0x6,
+	BildingType_WaterGuild = 0x7,
+	BildingType_EarthGuild = 0x8,
+	BildingType_SpiritGuild = 0x9,
+	BildingType_MindGuild = 0xA,
+	BildingType_BodyGuild = 0xB,
+	BildingType_LightGuild = 0xC,
+	BildingType_DarkGuild = 0xD,
+	BildingType_14 = 0xE,
+	BildingType_15 = 0xF,
+	BildingType_16 = 0x10,
+	BildingType_TownHall = 0x11,
+	BildingType_18 = 0x12,
+	BildingType_19 = 0x13,
+	BildingType_Throne_Room = 0x14,
+	BildingType_Tavern = 0x15,
+	BildingType_Bank = 0x16,
+	BildingType_Temple = 0x17,
+	BildingType_Unic = 0x19,
+	BildingType_1A = 0x1A,
+	BildingType_Stables = 0x1B,
+	BildingType_Boats = 0x1C,
+	BildingType_House = 0x1D,
+	BildingType_Training = 0x1E,
+	BildingType_Jail = 0x1F,
+	};
 
 /*  168 */
 #pragma pack(push, 1)
 struct _2devent
 {
-  unsigned __int16 uType;
+  BildingType uType;
   unsigned __int16 uAnimationID;
   char *pName;
   const char *pProprieterName;
--- a/GUIWindow.cpp	Fri Mar 01 17:37:47 2013 +0600
+++ b/GUIWindow.cpp	Fri Mar 01 17:38:04 2013 +0600
@@ -403,7 +403,7 @@
   v1->pControlsTail = 0;
   v1->uNumControls = 0;
   v1->eWindowType = WINDOW_null;
-  v10 = v1->field_3C;
+  v10 = v1->numVisibleWindows;
   v11 = uNumVisibleWindows;
   while ( v10 < v11 )
   {
@@ -1146,9 +1146,7 @@
   else
   {
     sprintfex( pTmpBuf, pGlobalTXT_LocalizationStrings[429],
-      //p2DEvents_minus1_::08[13 * (unsigned int)ptr_507BC0->ptr_1C],
       p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].pProprieterName,
-      //p2DEvents_minus1__10[13 * (unsigned int)ptr_507BC0->ptr_1C]);
       p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].pProprieterTitle);
     v18.DrawTitleText(pFontCreate, 0x1E3u, 0x71u, v19, pTmpBuf, 3u);
       switch ( in_current_building_type )
@@ -1173,10 +1171,7 @@
         case BildingType_MindGuild:
         case BildingType_BodyGuild:
         case BildingType_LightGuild:
-        case BildingType_Dark:
-        //case BildingType_14:
-        //case BildingType_15:
-        //case BildingType_16:
+        case BildingType_DarkGuild:
           GuildDialog();
           break;
         case BildingType_18:
@@ -1193,7 +1188,7 @@
           BankDialog();
           break;
         case BildingType_Temple:
-          TampleDialog();
+          TempleDialog();
           break;
         case BildingType_Stables:
           TravelByTransport();
@@ -1784,9 +1779,9 @@
   pWindow->uFrameHeight = uHeight;
   pWindow->eWindowType = eWindowType;
   pWindow->field_44 = 0;
-  uNumVisibleWindows = v10;
-  pWindow->field_3C = v10;
-  pVisibleWindowsIdxs[v10] = uNextFreeWindowID + 1;
+  ++uNumVisibleWindows;
+  pWindow->numVisibleWindows = uNumVisibleWindows;
+  pVisibleWindowsIdxs[uNumVisibleWindows] = uNextFreeWindowID + 1;
   if ( (signed int)eWindowType <= 20 )
   {
     if (eWindowType != WINDOW_Chest)
@@ -1801,7 +1796,7 @@
           pCurrentScreen = SCREEN_NPC_DIALOGUE;
           pBtn_ExitCancel = pWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], //"Exit"
                          (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0);
-          if ( pWindow->ptr_1C != (void *)1 )
+          if ( pWindow->par1C != 1 )
           {
             num_menu_buttons = 0;
             v11 = LOBYTE(pFontArrus->uFontHeight) - 3;
--- a/GUIWindow.h	Fri Mar 01 17:37:47 2013 +0600
+++ b/GUIWindow.h	Fri Mar 01 17:38:04 2013 +0600
@@ -134,7 +134,10 @@
   unsigned int uFrameZ;
   unsigned int uFrameW;
   WindowType   eWindowType;
+  union{
   void *ptr_1C;
+  unsigned int par1C;
+	};
   unsigned int uNumControls;
   int field_24;
   int pNumPresenceButton; 
@@ -142,7 +145,7 @@
   int field_30;
   int field_34;
   int pStartingPosActiveItem;
-  int field_3C;
+  int numVisibleWindows;
   int field_40;
   int field_44;
   char *Hint;
@@ -156,39 +159,7 @@
 
 
 
-/*  296 */
-enum BildingType
-{
-  BildingType_WeaponShop = 0x1,
-  BildingType_ArmorShop = 0x2,
-  BildingType_MagicShop = 0x3,
-  BildingType_AlchemistShop = 0x4,
-  BildingType_FireGuild = 0x5,
-  BildingType_AirGuild = 0x6,
-  BildingType_WaterGuild = 0x7,
-  BildingType_EarthGuild = 0x8,
-  BildingType_SpiritGuild = 0x9,
-  BildingType_MindGuild = 0xA,
-  BildingType_BodyGuild = 0xB,
-  BildingType_LightGuild = 0xC,
-  BildingType_Dark = 0xD,
-  BildingType_14 = 0xE,
-  BildingType_15 = 0xF,
-  BildingType_16 = 0x10,
-  BildingType_TownHall = 0x11,
-  BildingType_18 = 0x12,
-  BildingType_19 = 0x13,
-  BildingType_20 = 0x14,
-  BildingType_Tavern = 0x15,
-  BildingType_Bank = 0x16,
-  BildingType_Temple = 0x17,
-  BildingType_1A = 0x1A,
-  BildingType_Stables = 0x1B,
-  BildingType_Boats = 0x1C,
-  BildingType_House = 0x1D,
-  BildingType_Training = 0x1E,
-  BildingType_Jail = 0x1F,
-};
+
 enum UIMessageType
 {
   UIMSG_00 = 0x0,
--- a/Party.h	Fri Mar 01 17:37:47 2013 +0600
+++ b/Party.h	Fri Mar 01 17:38:04 2013 +0600
@@ -276,10 +276,11 @@
   unsigned int uFlags;
   ItemGen StandartItemsInShops[53][12];
   ItemGen SpecialItemsInShops[53][12];   //D0EC
-  int field_12A5C[2117];
-  char field_14B70[5000];
-  char field_15EF8[250];
-  char field_15FF2[130];
+  ItemGen SpellBooksInGuilds[32][12];
+  //int field_12A5C[2117];
+ // char field_14B70[5000];
+  //char field_15EF8[250];
+  //char field_15FF2[130];
   char pHireling1Name[100];
   char pHireling2Name[100];
   int armageddon_timer;
--- a/Spells.h	Fri Mar 01 17:37:47 2013 +0600
+++ b/Spells.h	Fri Mar 01 17:38:04 2013 +0600
@@ -117,8 +117,8 @@
   SPELL_101 = 101,
   SPELL_LASER_PROJECTILE = 102,
 
-  SPELL_150 = 150,
-  SPELL_QUEST_COMPLETED = 151,
+  BECOME_MAGIC_GUILD_MEMBER = 150,
+  SPELL_151 = 151,
   SPELL_152 = 152,
   SPELL_153 = 153
 };
--- a/mm7_2.cpp	Fri Mar 01 17:37:47 2013 +0600
+++ b/mm7_2.cpp	Fri Mar 01 17:38:04 2013 +0600
@@ -1404,7 +1404,7 @@
       return result;
     }
   }
-  pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
+  pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
   v3 = 0;
   if ( dword_F8B19C == 2 )
   {
@@ -1944,7 +1944,7 @@
         return (POINT *)v104.DrawTitleText(pFontArrus, v3, (174 - v40) / 2 + 138, v88, v90, v92);
       }
     }
-    pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
+    pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
     v3 = 0;
     v114 = 0;
     if ( dword_F8B19C == 2 )
@@ -2378,7 +2378,7 @@
 		break;
 	case 2: //buy standart
 		{
-		pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
+		pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
 		v55 = 0;
 		v153 = 0;
 		for(int i=0; i<8; ++i)
@@ -2580,7 +2580,7 @@
 		break;
 	case 6:
 		{
-		pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
+		pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
 		DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[195], 0);
 		if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
 			return;
@@ -2709,7 +2709,7 @@
 	case 95:  //buy spesial
 		{
 
-		pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
+		pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
 
 		v11 = 0;
 		v61 = 0;
@@ -3608,10 +3608,10 @@
 
 
 //----- (004BC8D5) --------------------------------------------------------
-Texture *__cdecl sub_4BC8D5()
-{
+void SpellBookGenerator()
+	{
   int v0; // esi@1
-  char *v1; // ebx@1
+  int v1; // ebx@1
   signed int v2; // edi@1
   signed int v3; // eax@2
   int v4; // esi@7
@@ -3619,13 +3619,13 @@
   Texture *result; // eax@15
   int v7; // [sp+10h] [bp-4h]@0
 
-  v0 = v7;
-  v1 = (char *)window_SpeakInHouse->ptr_1C - 139;
+ // v0 = v7;
+  v1 = window_SpeakInHouse->par1C - 139;
   v2 = 0;
-  do
+  for(int i=0; i<12; ++i) 
   {
     //v3 = p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C];
-    v3 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType;
+    v3 = p2DEvents[window_SpeakInHouse->par1C - 1].uType;
     if ( v3 < 5 )
       goto LABEL_12;
     if ( v3 <= 13 )
@@ -3664,15 +3664,15 @@
     }
     v5 = window_SpeakInHouse;
 
-    auto _u = (ItemGen *)&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + v2 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C;
+    ItemGen * _u = &pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i];
     _u->Reset();
-    *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v2 + 12 * (unsigned int)v5->ptr_1C)) = v0;
-    *(&pParty->pPlayers[1].pInstalledBeacons[1].field_10 + 9 * (v2++ + 12 * (unsigned int)v5->ptr_1C)) = 1;
-    result = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pItemsTable->pItems[v0].pIconName, TEXTURE_16BIT_PALETTE)];
-    *(&dword_F8B164 + v2) = result;
-  }
-  while ( v2 < 12 );
-  return result;
+    pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].uItemID= v0;
+    pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].Identified();
+
+    ItemsInShopTexture[i] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pItemsTable->pItems[v0].pIconName, TEXTURE_16BIT_PALETTE)];
+  }
+ 
+  return;
 }
 
 
@@ -3805,7 +3805,7 @@
   {
     v9 = pIcons_LOD->LoadTexture(off_4F03B8[in_current_building_type], TEXTURE_16BIT_PALETTE);
     //v3 = dword_F8B198;
-    dword_F8B164 = &pIcons_LOD->pTextures[v9];
+    ShopTexture = &pIcons_LOD->pTextures[v9];
 LABEL_13:
     v8 = window_SpeakInHouse;
   }
@@ -3837,7 +3837,8 @@
             v32 = 0;
             do
             {
-              v33 = *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v32 + 12 * (unsigned int)v8->ptr_1C));
+              //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);
@@ -3850,7 +3851,7 @@
           }
           else
           {
-            sub_4BC8D5();
+            SpellBookGenerator();
             v30 = window_SpeakInHouse->ptr_1C;
             v31 = pParty->uTimePlayed
                 + (signed __int64)((double)(0xA8C000
@@ -4313,11 +4314,11 @@
       && dword_F8B19C != 97
       && dword_F8B19C != 5
       && dword_F8B19C != 4
-      && dword_F8B164 )
-    {
-      dword_F8B164->Release();
+      && ShopTexture )
+    {
+      ShopTexture->Release();
       v0 = dword_F8B19C;
-      dword_F8B164 = 0;
+      ShopTexture = 0;
     }
     if ( v0 && v0 != 1 )
     {
--- a/mm7_3.cpp	Fri Mar 01 17:37:47 2013 +0600
+++ b/mm7_3.cpp	Fri Mar 01 17:38:04 2013 +0600
@@ -13957,126 +13957,126 @@
 					{
 					if ( !_strnicmp(test_string, "wea", 3) )
 						{
-						p2DEvents[i].uType = 1;
+						p2DEvents[i].uType = BildingType_WeaponShop;
 						break;
 						}
 					if ( !_strnicmp(test_string, "arm", 3) )
 						{
-						p2DEvents[i].uType = 2;
+						p2DEvents[i].uType = BildingType_ArmorShop;
 						break;
 						}
 					if ( !_strnicmp(test_string, "mag", 3) )
 						{
-						p2DEvents[i].uType = 3;
+						p2DEvents[i].uType = BildingType_MagicShop;
 						break;
 						}
 					if ( !_strnicmp(test_string, "alc", 3) )
 						{
-						p2DEvents[i].uType = 4;
+						p2DEvents[i].uType = BildingType_AlchemistShop;
 						break;
 						}
 					if ( !_strnicmp(test_string, "sta", 3) )
 						{
-						p2DEvents[i].uType = 27;
+						p2DEvents[i].uType = BildingType_Stables;
 						break;
 						}
 					if ( !_strnicmp(test_string, "boa", 3) )
 						{
-						p2DEvents[i].uType = 28;
+						p2DEvents[i].uType = BildingType_Boats;
 						break;
 						}
 					if ( !_strnicmp(test_string, "tem", 3) )
 						{
-						p2DEvents[i].uType = 23;
+						p2DEvents[i].uType = BildingType_Temple;
 						break;
 						}
 					if ( !_strnicmp(test_string, "tra", 3) )
 						{
-						p2DEvents[i].uType = 30;
+						p2DEvents[i].uType = BildingType_Training;
 						break;
 						}
 					if ( !_strnicmp(test_string, "tow", 3) )
 						{
-						p2DEvents[i].uType = 17;
+						p2DEvents[i].uType = BildingType_TownHall;
 						break;
 						}
 
 					if ( !_strnicmp(test_string, "tav", 3) )
 						{
-						p2DEvents[i].uType = 21;
+						p2DEvents[i].uType = BildingType_Tavern;
 						break;
 						}
 					if ( !_strnicmp(test_string, "ban", 3) )
 						{
-						p2DEvents[i].uType = 22;
+						p2DEvents[i].uType = BildingType_Bank;
 						break;
 						}
 					if ( !_strnicmp(test_string, "fir", 3) )
 						{
-						p2DEvents[i].uType = 5;
+						p2DEvents[i].uType = BildingType_FireGuild;
 						break;
 						}
 					if ( !_strnicmp(test_string, "air", 3) )
 						{
-						p2DEvents[i].uType = 6;
+						p2DEvents[i].uType = BildingType_AirGuild;
 						break;
 						}
 					if ( !_strnicmp(test_string, "wat", 3) )
 						{
-						p2DEvents[i].uType = 7;
+						p2DEvents[i].uType = BildingType_WaterGuild;
 						break;
 						}
 					if ( !_strnicmp(test_string, "ear", 3) )
 						{
-						p2DEvents[i].uType = 8;
+						p2DEvents[i].uType = BildingType_EarthGuild;
 						break;
 						}
 					if ( !_strnicmp(test_string, "spi", 3) )
 						{
-						p2DEvents[i].uType = 9;
+						p2DEvents[i].uType = BildingType_SpiritGuild;
 						break;
 						}
 					if ( !_strnicmp(test_string, "min", 3) )
 						{
-						p2DEvents[i].uType = 10;
+						p2DEvents[i].uType = BildingType_MindGuild;
 						break;
 						}
 					if ( !_strnicmp(test_string, "bod", 3) )
 						{
-						p2DEvents[i].uType = 11;
+						p2DEvents[i].uType = BildingType_BodyGuild;
 						break;
 						}
 					if ( !_strnicmp(test_string, "lig", 3) )
 						{
-						p2DEvents[i].uType = 12;
+						p2DEvents[i].uType = BildingType_LightGuild;
 						break;
 						}
 					if ( !_strnicmp(test_string, "dar", 3) )
 						{
-						p2DEvents[i].uType = 13;
+						p2DEvents[i].uType = BildingType_DarkGuild;
 						break;
 						}
 					if ( !_strnicmp(test_string, "ele", 3) )
 						{
-						p2DEvents[i].uType = 14;
+						p2DEvents[i].uType = BildingType_14;
 						break;
 						}
 					if ( !_strnicmp(test_string, "sel", 3) )
 						{
-						p2DEvents[i].uType = 15;
+						p2DEvents[i].uType = BildingType_15;
 						break;
 						}
 					if ( !_strnicmp(test_string, "mir", 3) )
 						{
-						p2DEvents[i].uType = 16;
+						p2DEvents[i].uType = BildingType_16;
 						break;
 						}
 					if ( !_strnicmp(test_string, "mer", 3) )
 						{
-						p2DEvents[i].uType = 17;
+						p2DEvents[i].uType = BildingType_TownHall;
 						break;
 						}
-					p2DEvents[i].uType = 18;
+					p2DEvents[i].uType = BildingType_18;
 					}
 					break;
 
--- a/mm7_4.cpp	Fri Mar 01 17:37:47 2013 +0600
+++ b/mm7_4.cpp	Fri Mar 01 17:38:04 2013 +0600
@@ -9263,17 +9263,11 @@
 void __fastcall HousePlaySomeSound(unsigned int uHouseID, int a2)
 {
   //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) )
-  if ( pAnimatedRooms[p2DEvents[uHouseID - 1].uAnimationID].field_d )
+  if ( pAnimatedRooms[p2DEvents[uHouseID - 1].uAnimationID].uRoomSoundId )
     pAudioPlayer->PlaySound(
       //(SoundID)(a2 + 100 * (BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) + 300)),
-      (SoundID)(a2 + 100 * (pAnimatedRooms[p2DEvents[uHouseID - 1].uAnimationID].field_d) + 300),
-      806,
-      0,
-      -1,
-      0,
-      0,
-      0,
-      0);
+      (SoundID)(a2 + 100 * (pAnimatedRooms[p2DEvents[uHouseID - 1].uAnimationID].uRoomSoundId) + 300),
+      806, 0, -1, 0, 0, 0, 0);
 }
 
 //----- (004B1ECE) --------------------------------------------------------
@@ -11726,7 +11720,7 @@
       return (int)v112.DrawTitleText(pFontArrus, v3, v6, v92, v95, v97);
     }
   }
-  pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
+  pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
   v3 = 0;
   v49 = 0;
   v122 = 0;
@@ -12274,11 +12268,11 @@
 
 
 //----- (004B5D7C) --------------------------------------------------------
-int __cdecl GuildDialog()
+void GuildDialog()
 {
   GUIWindow *v0; // ebx@1
-  Player *v1; // edi@1
-  signed int v2; // ebx@1
+  Player *currPlayer; // edi@1
+  signed int base_teach_price; // ebx@1
   int v3; // edi@6
   int result; // eax@11
   unsigned int v5; // ebx@13
@@ -12287,7 +12281,7 @@
   int v8; // esi@22
   signed int v9; // ecx@22
   char *v10; // eax@22
-  const char *v11; // ecx@26
+  const char *statusbar_string; // ecx@26
   POINT *v12; // esi@30
   int v13; // ecx@30
   void *v14; // ST1C_4@31
@@ -12328,12 +12322,12 @@
   char v49[100]; // [sp+19Ch] [bp-150h]@3
   POINT v50; // [sp+264h] [bp-88h]@30
   POINT v51; // [sp+26Ch] [bp-80h]@30
-  GUIWindow v52; // [sp+274h] [bp-78h]@1
+  GUIWindow working_window; // [sp+274h] [bp-78h]@1
   signed int v53; // [sp+27Ch] [bp-70h]@1
   signed int v54; // [sp+284h] [bp-68h]@1
   int v55; // [sp+2C8h] [bp-24h]@47
-  int v56; // [sp+2CCh] [bp-20h]@1
-  int v57; // [sp+2D0h] [bp-1Ch]@1
+  int main_text_color; // [sp+2CCh] [bp-20h]@1
+  int hi_text_color; // [sp+2D0h] [bp-1Ch]@1
   Player *v58; // [sp+2D4h] [bp-18h]@1
   unsigned __int8 uPlayerID; // [sp+2DBh] [bp-11h]@31
   char *Str; // [sp+2DCh] [bp-10h]@35
@@ -12342,19 +12336,19 @@
   int v63; // [sp+2E8h] [bp-4h]@1
 
   v0 = window_SpeakInHouse;
-  memcpy(&v52, window_SpeakInHouse, sizeof(v52));
+  memcpy(&working_window, window_SpeakInHouse, sizeof(GUIWindow));
   v58 = pPlayers[uActiveCharacter];
-  v1 = v58;
-  v52.uFrameX = 483;
-  v53 = 148;
-  v54 = 334;
-  v56 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  v57 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  currPlayer = v58;
+  working_window.uFrameX = 483;
+  working_window.uFrameWidth = 148;
+  working_window.uFrameZ = 334;
+  main_text_color = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+  hi_text_color = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
   //v2 = (signed __int64)(p2DEvents_minus1__20[13 * (unsigned int)v0->ptr_1C] * 500.0);
-  v2 = (signed __int64)(p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier * 500.0);
-  v63 = v2 * (100 - v1->GetMerchant()) / 100;
-  if ( v63 < v2 / 3 )
-    v63 = v2 / 3;
+  base_teach_price = (signed __int64)(p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier * 500.0);
+  v63 = base_teach_price * (100 - currPlayer->GetMerchant()) / 100;
+  if ( v63 < base_teach_price / 3 )
+    v63 = base_teach_price / 3;
   strcpy(Dest, "");
   strcpy(v46, "");
   strcpy(v47, "");
@@ -12362,14 +12356,14 @@
   strcpy(v49, "");
   if ( dword_F8B19C != 1 )
   {
-    if ( dword_F8B19C != 18 )
+    if ( dword_F8B19C != 18 ) //buy skill
     {
       if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
       {
-        v3 = (int)(&v1->uIntelligence + dword_F8B19C);
-        if ( *(short *)v3 )
-        {
-          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[403], pClassNames[dword_F8B19C + 20]);
+        //v3 = (int)(&currPlayer->uIntelligence + dword_F8B19C); //test skill
+        if ( v58->pActiveSkills[dword_F8B19C-36] )
+        {
+          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[403], pClassNames[dword_F8B19C - 16]); //"You already know the %s skill"
           ShowStatusBarString(pTmpBuf, 2u);
           pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
         }
@@ -12377,89 +12371,86 @@
         {
           if ( pParty->uNumGold < v63 )
           {
-            ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
+            ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); //"You don't have enough gold"
             HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
           }
           else
           {
             Party::TakeGold(v63);
-            *(short *)v3 = 1;
-          }
-        }
-      }
-      /*result = pMessageQueue_50CBD0->uNumMessages;
-      if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-      {
-        pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
-        pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
-        result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
-        *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
-        ++pMessageQueue_50CBD0->uNumMessages;
-      }*/
+            v58->pActiveSkills[dword_F8B19C-36] = 1;
+          }
+        }
+      }
       pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
-      return 1; // void function actually
-    }
-    pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164);
+      return;
+    }
+    pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture);
     v5 = 0;
     v6 = 0;
     v62 = 0;
     v63 = 32;
     do
     {
-      if ( *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v6 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)) )
+		if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v6].uItemID)
+     // if ( *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v6 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)) )
+	  
       {
         pRenderer->DrawTextureTransparent(v63, 0x5Au, ItemsInShopTexture[v6]);
         ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 230528), ItemsInShopTexture[v6], v6 + 1);
-        v1 = v58;
+        currPlayer = v58;
       }
       v63 += 70;
       v62 += 280;
       ++v6;
     }
     while ( v63 < 452 );
+
     v62 = 1680;
     v7 = 6;
     v63 = 32;
     do
     {
-      if ( *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v7 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)) )
+	if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v7].uItemID)
+     // if ( *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v7 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)) )
       {
         pRenderer->DrawTextureTransparent(v63, 0xFAu, ItemsInShopTexture[v7]);
         ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 638448), ItemsInShopTexture[v7], v7 + 1);
-        v1 = v58;
+        currPlayer = v58;
       }
       v63 += 70;
       v62 += 280;
       ++v7;
     }
     while ( v63 < 452 );
-    result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-    if ( result )
+
+    if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
     {
       v8 = 0;
       v9 = 12;
-      v10 = (char *)(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 108 * (unsigned int)window_SpeakInHouse->ptr_1C);
+     // v10 = (char *)(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 108 * (unsigned int)window_SpeakInHouse->ptr_1C);
+	//  v10 =
       do
       {
-        if ( *(int *)v10 )
+        if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v9].uItemID )
           ++v8;
-        v10 += 36;
+       // v10 += 36;
         --v9;
       }
       while ( v9 );
+
       GetAsyncKeyState(17);
-      v11 = pGlobalTXT_LocalizationStrings[195];
+      statusbar_string = pGlobalTXT_LocalizationStrings[195]; //"Select the Item to Buy"
       if ( dword_F8B19C != 2 )
-        v11 = pGlobalTXT_LocalizationStrings[196];
-      DrawTextAtStatusBar(v11, 0);
+        statusbar_string = pGlobalTXT_LocalizationStrings[196]; //"Select the Special Item to Buy"	
+      DrawTextAtStatusBar(statusbar_string, 0);
       if ( !v8 )
 		  {
-        v52.DrawCurrentTime(
+        working_window.DrawCurrentTime(
                       __PAIR__(
                         *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)window_SpeakInHouse->ptr_1C + 44472],
                         *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)window_SpeakInHouse->ptr_1C + 44468])
                     - pParty->uTimePlayed);
-		return 0;
+		return;
 		  }
       v12 = pMouse->GetCursorPos(&v51);
       result = v12->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v50)->y];
@@ -12470,40 +12461,27 @@
         v15 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v13 + 12 * (int)v14));
         v16 = (int)window_SpeakInHouse->ptr_1C;
         uPlayerID = uActiveCharacter - 1;
-        v17 = v1->_490EEE(
-                (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14,
-                3,
-                v16,
-                2);
-        v18 = BuilDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0);
-        v44 = 3;
-        v43 = v18;
-        v42 = v56;
-        v41 = 0;
-        v40 = 0;
-        v39 = &v52;
-LABEL_32:
-        v19 = pFontArrus->CalcTextHeight(v18, v39, v40, v41);
-        return (int)v52.DrawTitleText(pFontArrus, v5, (174 - v19) / 2 + 138, v42, v43, v44);
-      }
-    }
-    return result;
+        v17 = currPlayer->_490EEE( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14, 3, v16,  2);
+        v18 = BuilDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0);     
+        v19 = pFontArrus->CalcTextHeight(v18, &working_window, 0, 0);
+        working_window.DrawTitleText(pFontArrus, 0, (174 - v19) / 2 + 138,  main_text_color, v18, 3);
+        return;
+      }
+    }
+    return;
   }
   if ( !(unsigned __int16)_449B57_test_bit(
-                            (unsigned __int8 *)v1->_guilds_member_bits,
-                            word_4F0704[(unsigned int)window_SpeakInHouse->ptr_1C-139]) )
-  {
-    v36 = pNPCTopics[121].pText;
-    v37 = v57;
-    v38 = pFontArrus->CalcTextHeight(pNPCTopics[121].pText, &v52, 0, 0);
-    v52.DrawTitleText(pFontArrus, 0, (212 - v38) / 2 + 101, v37, v36, 3u);
-    result = (int)pDialogueWindow;
+                            (unsigned __int8 *)currPlayer->_guilds_member_bits,
+                            guild_mambership_flags[(unsigned int)window_SpeakInHouse->ptr_1C-139]) )
+  { //you must me member
+    v38 = pFontArrus->CalcTextHeight(pNPCTopics[121].pText, &working_window, 0, 0);
+    working_window.DrawTitleText(pFontArrus, 0, (212 - v38) / 2 + 101, hi_text_color, pNPCTopics[121].pText, 3u);
     pDialogueWindow->pNumPresenceButton = 0;
-    return result;
-  }
-  result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-  if ( !result )
-    return result;
+    return;
+  }
+
+  if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
+    return;
   v20 = pDialogueWindow;
   v5 = 0;
   v62 = 0;
@@ -12511,29 +12489,32 @@
   v21 = pDialogueWindow->pStartingPosActiveItem;
   v22 = v21 + pDialogueWindow->pNumPresenceButton;
   v61 = 0;
-  if ( v21 >= v22 )
-    goto LABEL_64;
+  if ( pDialogueWindow->pStartingPosActiveItem >= pDialogueWindow->pStartingPosActiveItem+pDialogueWindow->pNumPresenceButton )
+	  {
+	  sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); // "Seek knowledge elsewhere %s the %s"	
+	strcat(pTmpBuf, "\n \n");
+	strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further."
+	v19 = pFontArrus->CalcTextHeight(pTmpBuf, &working_window, 0, 0);
+	working_window.DrawTitleText(pFontArrus, v5, (174 - v19) / 2 + 138, hi_text_color, pTmpBuf, 3);
+	return;
+	  }
   do
   {
     v23 = v20->GetControl(v21)->uControlParam;
     if ( v23 == 18 )
     {
-      v25 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[400], &v52, 0, 0);
+      v25 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[400], &working_window, 0, 0); //"Buy Spells"
       v62 += v25;
       ++v61;
     }
     else
     {
-      __debugbreak();
-      //pSkillAvailabilityPerClass[8 + v58->uClass][4 + v23]
-      // or
-      //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass][v23 - 36]
+     
+     if((byte_4ED970_skill_learn_ability_by_class_table[v58->classType][v23-36])&&(v58->pActiveSkills[v23-36]))
       // or
       //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass - 1][v23 + 1]
-
-      //if ( *(&byte_4ED94C[37 * v58->uClass] + v23) && !*(&v58->uIntelligence + v23) )
-      {
-        v24 = pFontArrus->CalcTextHeight(pClassNames[v23 + 20], &v52, 0, 0);
+      {
+        v24 = pFontArrus->CalcTextHeight(pClassNames[v23 - 16], &working_window, 0, 0);
         v62 += v24;
         ++v61;
         ++Str;
@@ -12545,31 +12526,25 @@
   if ( !v61 )
   {
 LABEL_64:
-    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v58->pName, pClassNames[v58->classType]);
+    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v58->pName, pClassNames[v58->classType]); // "Seek knowledge elsewhere %s the %s"	
     strcat(pTmpBuf, "\n \n");
-    strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
-    v18 = pTmpBuf;
-    v44 = 3;
-    v43 = pTmpBuf;
-    v42 = v57;
-    v41 = 0;
-    v40 = 0;
-    v39 = &v52;
-    goto LABEL_32;
+    strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further."
+	v19 = pFontArrus->CalcTextHeight(pTmpBuf, &working_window, 0, 0);
+	working_window.DrawTitleText(pFontArrus, v5, (174 - v19) / 2 + 138, hi_text_color, pTmpBuf, 3);
+	return;
   }
   if ( Str )
   {
-    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v63);
-    v52.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
+    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v63); //"Skill Cost: %lu"
+    working_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
   }
   v63 = (signed int)(149 - v62) / v61;
   if ( v63 > 32 )
     v63 = 32;
-  result = v20->pStartingPosActiveItem;
   v26 = (signed int)(149 - v61 * v63 - v62) / 2 - v63 / 2 + 162;
-  v62 = result;
+  v62 = v20->pStartingPosActiveItem;
   v55 = v26;
-  if ( result < result + v20->pNumPresenceButton )
+  if (v20->pStartingPosActiveItem < v20->pStartingPosActiveItem + v20->pNumPresenceButton )
   {
     v61 = 2;
     while ( 1 )
@@ -12580,30 +12555,33 @@
       if ( v29 == 18 )
         break;
 
-      __debugbreak();
+    //  __debugbreak();
       //pSkillAvailabilityPerClass[8 + v58->uClass][4 + v23]
       // or
-      //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass][v23 - 36]
+      if ((byte_4ED970_skill_learn_ability_by_class_table[v58->classType][v29 - 36])&&(v58->pActiveSkills[v29-36]))
       // or
       //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass - 1][v23 + 1]
 
-      //if ( *(&byte_4ED94C[37 * v58->uClass] + v29) && !*(&v58->uIntelligence + v29) )
-      {
-        v30 = pClassNames[v29 + 20];
+      {
+        v30 = pClassNames[v29 -16];
 LABEL_55:
         Str = v30;
         v28->uY = v63 + v55;
-        v31 = pFontArrus->CalcTextHeight(v30, &v52, 0, 0);
+        v31 = pFontArrus->CalcTextHeight(v30, &working_window, 0, 0);
         v32 = v28->uY;
         v28->uHeight = v31;
         v33 = v32 + v31 - 1;
         v28->uW = v33;
         v55 = v33;
-        v34 = v57;
+        v34 = hi_text_color;
         if ( pDialogueWindow->pCurrentPosActiveItem != v61 )
-          v34 = v56;
-        v52.DrawTitleText(pFontArrus, 0, v32, v34, Str, 3u);
-        goto LABEL_58;
+          v34 = main_text_color;
+        working_window.DrawTitleText(pFontArrus, 0, v32, v34, Str, 3u);
+		v35 = v20->pStartingPosActiveItem;
+		++v62;
+		++v61;
+		if ( (signed int)v62 >=v20->pNumPresenceButton +v20->pStartingPosActiveItem  )
+			return;
       }
       v28->uW = 0;
       v28->uHeight = 0;
@@ -12611,22 +12589,21 @@
 LABEL_58:
       v35 = v20->pStartingPosActiveItem;
       ++v62;
-      result = v20->pNumPresenceButton + v35;
       ++v61;
-      if ( (signed int)v62 >= result )
-        return result;
-    }
-    v30 = pGlobalTXT_LocalizationStrings[400];
+      if ( (signed int)v62 >=v20->pNumPresenceButton +v20->pStartingPosActiveItem  )
+        return;
+    }
+    v30 = pGlobalTXT_LocalizationStrings[400]; //"Buy Spells"
     goto LABEL_55;
   }
-  return result;
+  return;
 }
 
 
 
 //----- (004B705E) --------------------------------------------------------
-int __cdecl TampleDialog()
-{
+void TempleDialog()
+	{
   GUIWindow *v0; // ebx@1
   Player *v1; // esi@1
   int v2; // edi@1
@@ -12710,11 +12687,10 @@
     {
       if ( dword_F8B19C != 11 )
       {
-        result = dword_F8B19C - 96;
+
         if ( dword_F8B19C == 96 )
         {
-          result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win();
-          if ( result )
+          if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
           {
             v4 = pDialogueWindow;
             v61 = pDialogueWindow;
@@ -12808,7 +12784,7 @@
             }
           }
         }
-        return result;
+        return;
       }
 
       // DONATION
@@ -12873,9 +12849,8 @@
       }
       goto LABEL_55;
     }
-    result = v1->_4B6FF9();
-    if ( !result )
-      return result;
+    if ( !v1->_4B6FF9() )
+      return;
     v25 = 0;
     if ( pParty->uNumGold < v2 )
     {
@@ -12931,17 +12906,8 @@
     v1->PlaySound(SPEECH_82, 0);
     pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536);
 LABEL_46:
-    /*result = pMessageQueue_50CBD0->uNumMessages;
-    if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-    {
-      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
-      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
-      result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
-      *(&pMessageQueue_50CBD0->uNumMessages + result) = v25;
-      ++pMessageQueue_50CBD0->uNumMessages;
-    }*/
     pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25);
-    return result; // void func
+    return ; // void func
   }
   v63 = 1;
   v41 = pDialogueWindow->GetControl(pDialogueWindow->pStartingPosActiveItem);
@@ -12976,10 +12942,9 @@
   v64 = (174 - (signed int)v66) / v46;
   if ( v64 > 32 )
     v64 = 32;
-  result = v43->pStartingPosActiveItem;
   v47 = (174 - v64 * v46 - (signed int)v66) / 2 - v64 / 2 + 138;
-  v65 = v42 + result;
-  if ( v42 + result < result + v43->pNumPresenceButton )
+  v65 = v42 + v43->pStartingPosActiveItem;
+  if ( v42 + v43->pStartingPosActiveItem < v43->pStartingPosActiveItem + v43->pNumPresenceButton )
   {
     v61 = (GUIWindow *)(v42 + 2);
     v66 = (DDM_DLV_Header *)&a1[100 * v42];
@@ -13002,11 +12967,10 @@
       v66 = (DDM_DLV_Header *)((char *)v66 + 100);
       v61 = (GUIWindow *)((char *)v61 + 1);
       ++v65;
-      result = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem;
-    }
-    while ( (signed int)v65 < result );
-  }
-  return result;
+    }
+    while ( (signed int)v65 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem );
+  }
+  return;
 }
 
 
@@ -14186,7 +14150,7 @@
 LABEL_20:
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)26, 0, (int)sHouseName);
   //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * v9]].field_C) )
-  if ( pAnimatedRooms[p2DEvents[v9 - 1].uAnimationID].field_d )
+  if ( pAnimatedRooms[p2DEvents[v9 - 1].uAnimationID].uRoomSoundId )
     HousePlaySomeSound(v9, 1);
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30 )
     pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0);
@@ -14236,7 +14200,8 @@
     if ( uExitMapID > 0 )
     {
       //v17 = (unsigned int *)(uExitMapID - 1);
-      if ( !((unsigned __int8)(0x80u >> (uExitMapID - 1) % 8) & pParty->_quest_bits[(uExitMapID - 1) >> 3]) )
+	  if(_449B57_test_bit(pParty->_quest_bits,uExitMapID))
+     // if ( !((unsigned __int8)(0x80u >> (uExitMapID - 1) % 8) & pParty->_quest_bits[(uExitMapID - 1) >> 3]) )
       {
         //uExitPic = 0;
         uHouse_ExitPic = 0;
@@ -14416,7 +14381,7 @@
 
 		uCurrentHouse_Animation = p2DEvents[uHouseID - 1].uAnimationID;
 		in_current_building_type = pAnimatedRooms[uCurrentHouse_Animation].uBuildingType;
-		if ( in_current_building_type == BildingType_20 && pParty->uFine )   // going 2 jail
+		if ( in_current_building_type == BildingType_Throne_Room && pParty->uFine )   // going 2 jail
 			{
 			uCurrentHouse_Animation = (signed __int16)p2DEvents[186].uAnimationID;
 			uHouseID = HOUSE_JAIL;
@@ -14462,9 +14427,10 @@
 			}
 		else
 			{ //guilds
-			v19 = word_4F0704[uHouseID-139] - 1; //some gild flag check
+			v19 = guild_mambership_flags[uHouseID-139]; //guilds flags 
 			//v20 = uHouseID;
-			if ( !((unsigned __int8)(0x80u >> v19 % 8) & pPlayers[uActiveCharacter]->_guilds_member_bits[v19 /8]) )
+			//if ( !((unsigned __int8)(0x80u >> v19 % 8) & pPlayers[uActiveCharacter]->_guilds_member_bits[v19 /8]) )
+			if(_449B57_test_bit((unsigned char*)pPlayers[uActiveCharacter]->_guilds_member_bits,v19))
 				{
 				HousePlaySomeSound(uHouseID, 3);
 				return 1;
--- a/mm7_data.cpp	Fri Mar 01 17:37:47 2013 +0600
+++ b/mm7_data.cpp	Fri Mar 01 17:38:04 2013 +0600
@@ -1664,7 +1664,7 @@
 
 //__int16 word_4F063E[290];
 //__int16 word_4F06D8[22];
-int word_4F0704[32]={
+int guild_mambership_flags[32]={
    54, 54, 54, 54, 52, 52, 52, 52, 55, 55, 55, 55, 53, 53,
 	   53, 53, 58, 58, 58, 58, 57, 57, 57, 57, 56, 56,
 	   56, 56, 59, 59, 60, 60};
@@ -1690,7 +1690,15 @@
 char _4F0D38_TravelInfo[777]; // weak
 int dword_4F0E10[32];
 Vec2_int_ pMonsterArenaPlacements[20];
-__int16 word_4F0F30[777]; // weak
+__int16 word_4F0F30[32] ={ 4, 7, 10, 11,                                              
+						   4, 7, 10, 11,
+					       4, 7, 10, 11,
+						   4, 7, 10, 11,
+					       4, 7, 10, 11,
+					       4, 7, 10, 11,
+					       4, 7, 10, 11,
+					       7, 11,
+						   7, 11};
 char aS03d[777]; // idb
 char byte_4F0F98; // idb
 char sz[777]; // idb
@@ -2343,7 +2351,7 @@
 int dword_F8B144; // idb
 char byte_F8B148[16];
 __int16 word_F8B158[777]; // weak
-struct Texture *dword_F8B164; // idb
+struct Texture *ShopTexture; // idb
 struct Texture *ItemsInShopTexture[12];
 int in_current_building_type; // 0xF8B198
 int dword_F8B19C; // weak
--- a/mm7_data.h	Fri Mar 01 17:37:47 2013 +0600
+++ b/mm7_data.h	Fri Mar 01 17:38:04 2013 +0600
@@ -1008,7 +1008,7 @@
 extern char uItemsAmountPerShopType[]; // weak
 //extern __int16 word_4F063E[290];
 //extern __int16 word_4F06D8[22];
-extern int word_4F0704[32];
+extern int guild_mambership_flags[32];
 extern __int16 word_4F0754[49];
 //extern __int16 word_4F07B6[88];
 extern __int16 word_4F0866[14];
@@ -1022,7 +1022,7 @@
 extern char _4F0D38_TravelInfo[]; // weak
 extern int dword_4F0E10[32];
 extern Vec2_int_ pMonsterArenaPlacements[20];
-extern __int16 word_4F0F30[]; // weak
+extern __int16 word_4F0F30[32]; // weak
 extern char aS03d[]; // idb
 extern char byte_4F0F98; // idb
 extern char sz[]; // idb
@@ -1684,7 +1684,7 @@
 extern int dword_F8B144; // idb
 extern char byte_F8B148[16];
 extern __int16 word_F8B158[]; // weak
-extern struct Texture *dword_F8B164; // idb
+extern struct Texture *ShopTexture; // idb
 extern struct Texture *ItemsInShopTexture[12];
 extern int in_current_building_type; // weak
 extern int dword_F8B19C; // weak
@@ -2322,11 +2322,11 @@
 int __cdecl TrainingDialog();
 char *__cdecl JailDialog();
 int __cdecl MagicShopDialog();
-int __cdecl GuildDialog();
+void  GuildDialog();
 int __cdecl sub_4B6478();
 bool __fastcall sub_4B68EA(int a1);
 void __cdecl TravelByTransport();
-int __cdecl TampleDialog();
+void TempleDialog();
 void __cdecl TownHallDialog();
 void __cdecl BankDialog();
 void __cdecl TavernDialog();
@@ -2339,7 +2339,7 @@
 void __cdecl sub_4BBCDD();
 void __fastcall _4BBF61_summon_actor(int a1, __int16 x, int y, int z); // idb
 void __cdecl ArenaFight();
-struct Texture *__cdecl sub_4BC8D5();
+void  SpellBookGenerator();
 struct GUIButton *__cdecl UI_CreateEndConversationButton();
 void __fastcall DrawLearnSkillDialog(signed int uMessageParam);
 signed int __cdecl sub_4BD8B5();
--- a/stru159.h	Fri Mar 01 17:37:47 2013 +0600
+++ b/stru159.h	Fri Mar 01 17:38:04 2013 +0600
@@ -10,7 +10,7 @@
   int field_4;
   int field_8;
   unsigned __int8 uBuildingType;
-  unsigned __int8 field_d;
+  unsigned __int8 uRoomSoundId;
   unsigned __int16 padding_e;
 };
 #pragma pack(pop)
--- a/stru6.cpp	Fri Mar 01 17:37:47 2013 +0600
+++ b/stru6.cpp	Fri Mar 01 17:38:04 2013 +0600
@@ -1341,8 +1341,7 @@
       v6 = "zapp";
     break;
       
-    case SPELL_150:
-      __debugbreak(); // spell id == 150 wtf
+    case BECOME_MAGIC_GUILD_MEMBER:
     case SPELL_AIR_FEATHER_FALL:
     case SPELL_SPIRIT_DETECT_LIFE:
     case SPELL_SPIRIT_FATE: