changeset 473:7f1b00901cf7

Skill learning menu in shops
author Gloval
date Tue, 26 Feb 2013 02:09:56 +0400
parents c43f156a95c9
children 442afd6c34a4
files GUIWindow.cpp Items.cpp mm7_2.cpp mm7_4.cpp mm7_data.cpp mm7_data.h
diffstat 6 files changed, 243 insertions(+), 524 deletions(-) [+]
line wrap: on
line diff
--- a/GUIWindow.cpp	Mon Feb 25 23:33:15 2013 +0400
+++ b/GUIWindow.cpp	Tue Feb 26 02:09:56 2013 +0400
@@ -1070,7 +1070,7 @@
   v18.uFrameZ += 8;
   if ( !pDialogueNPCCount )
   {
-    if ( dword_F8B198 == 31 )
+    if ( in_current_bilding_type == 31 )
     {
       sub_4B4F4F();
       goto LABEL_58;
@@ -1151,9 +1151,9 @@
       //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);
-    if ( dword_F8B198 <= 18 )
+    if ( in_current_bilding_type <= 18 )
     {
-      switch ( dword_F8B198 )
+      switch ( in_current_bilding_type )
       {
         case 18:
           sub_4B6478();
@@ -1171,15 +1171,15 @@
           AlchemistDialog();
           break;
         default:
-          if ( dword_F8B198 > 4 )
+          if ( in_current_bilding_type > 4 )
           {
-            if ( dword_F8B198 <= 16 )
+            if ( in_current_bilding_type <= 16 )
             {
               GuildDialog();
             }
             else
             {
-              if ( dword_F8B198 == 17 )
+              if ( in_current_bilding_type == 17 )
                 sub_4B7911();
             }
           }
@@ -1187,7 +1187,7 @@
       }
       goto LABEL_58;
     }
-    switch ( dword_F8B198 )
+    switch ( in_current_bilding_type )
     {
       case 21:
         TavernDialog();
@@ -1199,17 +1199,17 @@
         TampleDialog();
         break;
       default:
-        if ( dword_F8B198 <= 26 )
+        if ( in_current_bilding_type <= 26 )
           break;
-        if ( dword_F8B198 <= 28 )
+        if ( in_current_bilding_type <= 28 )
         {
           TravelByTransport();
         }
         else
         {
-          if ( dword_F8B198 != 30 )
+          if ( in_current_bilding_type != 30 )
           {
-            if ( dword_F8B198 != 31 )
+            if ( in_current_bilding_type != 31 )
               break;
             sub_4B4F4F();
             goto LABEL_58;
--- a/Items.cpp	Mon Feb 25 23:33:15 2013 +0400
+++ b/Items.cpp	Tue Feb 26 02:09:56 2013 +0400
@@ -2243,383 +2243,137 @@
 
 // 4505CC: using guessed type int var_A0[32];
 	//----- (004B3703) --------------------------------------------------------
-	int  sub_4B3703( int _this )
+void FillAviableSkillsToTeach( int _this )
+	{
+	char *v30; // ecx@65
+	unsigned int v29; // edx@56
+	int v15; // ecx@19
+	int v33; // [sp-4h] [bp-2Ch]@23
+	int v34; // [sp-4h] [bp-2Ch]@43
+	int v21; // ecx@34
+	int v35[5]; // [sp+Ch] [bp-1Ch]@8
+	int v37=0; // [sp+24h] [bp-4h]@1*
+	int i=0;
+
+	dword_F8B1DC = 0;
+
+	switch (_this)
 		{
-		signed int v1; // edi@1
-		int v2; // eax@1
-		int v3; // ecx@1
-		signed int v4; // ebx@1
-		int v5; // ecx@2
-		int v6; // ecx@3
-		int v7; // ecx@4
-		int v8; // ecx@5
-		int v9; // ecx@6
-		signed int v10; // ebx@13
-		signed int v11; // edi@14
-		signed int v12; // esi@15
-		unsigned int v13; // ecx@16
-		int v14; // ecx@16
-		int v15; // ecx@17
-		int v16; // ecx@19
-		int v17; // ecx@20
-		int v18; // ecx@21
-		signed int v19; // esi@32
-		char *v20; // ecx@33
-		int v21; // ecx@34
-		int v22; // ecx@36
-		int v23; // ecx@37
-		int v24; // ecx@38
-		int v25; // ecx@39
-		int v26; // ecx@40
-		int v27; // ecx@41
-		int *v28; // esi@54
-		unsigned int v29; // edx@56
-		char *v30; // ecx@65
-		int v31; // ecx@106
-		int result; // eax@107
-		int v33; // [sp-4h] [bp-2Ch]@23
-		int v34; // [sp-4h] [bp-2Ch]@43
-		int v35[5]; // [sp+Ch] [bp-1Ch]@8
-		int a2; // [sp+20h] [bp-8h]@1
-		int v37; // [sp+24h] [bp-4h]@1
+	case 1:  //shop weapon
+		for (int i=0; i<2; ++i)
+			{
+			for (int j=0; j<4; ++j)
+				{
+				if ( i )
+					v21 = shopWeap_variation_spc[(unsigned int)window_SpeakInHouse->ptr_1C].item_class[j];
+				else
+					v21 = shopWeap_variation_ord[(unsigned int)window_SpeakInHouse->ptr_1C].item_class[j];
 
-		//need fixing
-		__debugbreak();
-		v1 = 0;
-		v2 = 0;
-		v3 = _this - 1;
-		a2 = 0;
-		v37 = 0;
-		dword_F8B1DC = 0;
-		v4 = 2;
-		if ( !v3 )
-			{
-			while ( 1 )
-				{
-				v19 = 1;
-				do
+				switch (v21)
 					{
-					v20 = (char *)window_SpeakInHouse->ptr_1C + 4 * (unsigned int)window_SpeakInHouse->ptr_1C + v19;
-					/*if ( v1 )
-						v21 = word_4F063E[(signed int)v20];
-					else
-						v21 = word_4F0404[(signed int)v20 - 4];//word_4F03FE[(signed int)v20];*/
-					v22 = v21 - 23;
-					if ( v22 )
-						{
-						v23 = v22 - 1;
-						if ( v23 )
-							{
-							v24 = v23 - 1;
-							if ( v24 )
-								{
-								v25 = v24 - 1;
-								if ( v25 )
-									{
-									v26 = v25 - 1;
-									if ( v26 )
-										{
-										v27 = v26 - 1;
-										if ( v27 )
-											{
-											if ( v27 != v4 )
-												goto LABEL_51;
-											v34 = 36;
-											}
-										else
-											{
-											v34 = 42;
-											}
-										}
-									else
-										{
-										v34 = 41;
-										}
-									}
-								else
-									{
-									v34 = 40;
-									}
-								}
-							else
-								{
-								v34 = 39;
-								}
-							}
-						else
-							{
-							v34 = 38;
-							}
-						}
-					else
-						{
-						v34 = 37;
-						}
-					v37 = sub_4BE571(v34, v35, v37, 5);
-					v2 = dword_F8B1DC;
-					v4 = 2;
-LABEL_51:
-					++v19;
-					}
-					while ( v19 <= 4 );
-					++v1;
-					if ( v1 >= v4 )
-						goto LABEL_53;
+				case 23:  v34 = 37;	break;
+				case 24:  v34 = 38;	break;
+				case 25:  v34 = 39;	break;
+				case 26:  v34 = 40;	break;
+				case 27:  v34 = 41;	break;
+				case 28:  v34 = 42; break;
+				case 30:  v34 = 36;	break;
+				default:
+					continue;
+					}	
+				v37 = sub_4BE571(v34, v35, v37, 5);
 				}
 			}
-		v5 = (int)(v3 - 1);
-		if ( !v5 )
+		break;
+	case 2: //shop armor
+
+		for (int i=0; i<2; ++i)
 			{
-			v10 = 0;
-			while ( 1 )
+			for (int j=0; j<2; ++j)
 				{
-				v11 = 0;
-				do
+				for (int k=0; k<4; ++k)
 					{
-					v12 = 1;
-					do
+					if ( i )
+						v15 = shopArmr_variation_spc[(unsigned int)window_SpeakInHouse->ptr_1C-15+j].item_class[k];
+					else
+						v15 = shopArmr_variation_ord[(unsigned int)window_SpeakInHouse->ptr_1C-15+j].item_class[k];
+					switch (v15)
 						{
-						v13 = v11 + 2 * (unsigned int)window_SpeakInHouse->ptr_1C - 30;
-						v14 = v12 + 4 * v13 + v13;
-					/*	if ( v10 )
-							v15 = word_4F06D8[v14];
-						else
-							v15 = word_4F0498[v14];*/
-						v16 = v15 - 31;
-						if ( v16 )
-							{
-							v17 = v16 - 1;
-							if ( v17 )
-								{
-								v18 = v17 - 1;
-								if ( v18 )
-									{
-									if ( v18 != 1 )
-										goto LABEL_28;
-									v33 = 44;
-									}
-								else
-									{
-									v33 = 47;
-									}
-								}
-							else
-								{
-								v33 = 46;
-								}
-							}
-						else
-							{
-							v33 = 45;
-							}
-						v37 = sub_4BE571(v33, v35, v37, 5);
-						v2 = dword_F8B1DC;
-LABEL_28:
-						++v12;
+					case 31: v33 = 45; break;
+					case 32: v33 = 46; break;
+					case 33: v33 = 47; break;
+					case 34: v33 = 44; break;
+					default:
+						continue;
 						}
-						while ( v12 <= 4 );
-						++v11;
+					v37 = sub_4BE571(v33, v35, v37, 5);
 					}
-					while ( v11 < 2 );
-					++v10;
-					if ( v10 >= 2 )
-						goto LABEL_53;
 				}
 			}
-		v6 = v5 - 1;
-		if ( v6 )
-			{
-			v7 = v6 - 1;
-			if ( v7 )
-				{
-				v8 = v7 - 17;
-				if ( v8 )
-					{
-					v9 = v8 - 2;
-					if ( v9 )
-						{
-						if ( v9 == 7 )
-							{
-							v37 = 2;
-							v35[0] = 69;
-							v35[1] = 60;
-							}
-						}
-					else
-						{
-						v37 = 3;
-						v35[0] = 67;
-						v35[1] = 66;
-						v35[2] = 58;
-						}
-					}
-				else
-					{
-					v37 = 3;
-					v35[0] = 70;
-					v35[1] = 65;
-					v35[2] = 62;
-					}
-				}
-			else
-				{
-				v37 = 2;
-				v35[0] = 71;
-				v35[1] = 68;
-				}
-			}
-		else
-			{
-			v37 = 2;
-			v35[0] = 57;
-			v35[1] = 59;
-			}
-LABEL_53:
-		if ( v37 > 0 )
+		break;
+	case 3:  //shop magic
+		v37 = 2;
+		v35[0] = 57;
+		v35[1] = 59;
+		break;
+	case 4: //shop alchemist
+		v37 = 2;
+		v35[0] = 71;
+		v35[1] = 68;
+		break;
+	case 21:  //tavern
+		v37 = 3;
+		v35[0] = 70;
+		v35[1] = 65;
+		v35[2] = 62;
+		break;
+	case 23:  //temple
+		v37 = 3;
+		v35[0] = 67;
+		v35[1] = 66;
+		v35[2] = 58;
+		break;
+	case 30:  ///trainig
+		v37 = 2;
+		v35[0] = 69;
+		v35[1] = 60;
+		break;
+		}
+	for(i=0;i<v37;++i) 
+		{
+		v29=v35[i];
+		switch(v29)
 			{
-			v28 = v35;
-			while ( 1 )
-				{
-				v29 = *v28;
-				if ( *v28 <= 47 )
-					break;
-				if ( (signed int)v29 <= 66 )
-					{
-					if ( v29 == 66 )
-						{
-						v30 = pSkillNames[30];
-						goto LABEL_106;
-						}
-					if ( v29 == 57 )
-						{
-						v30 = pSkillNames[21];
-						goto LABEL_106;
-						}
-					if ( v29 == 58 )
-						{
-						v30 = pSkillNames[22];
-						goto LABEL_106;
-						}
-					if ( v29 == 60 )
-						{
-						v30 = pSkillNames[24];
-						goto LABEL_106;
-						}
-					if ( v29 == 62 )
-						{
-						v30 = pSkillNames[26];
-						goto LABEL_106;
-						}
-					if ( v29 == 65 )
-						{
-						v30 = pSkillNames[29];
-						goto LABEL_106;
-						}
-					goto LABEL_100;
-					}
-				switch ( v29 )
-					{
-				case 0x43u:
-					v30 = pSkillNames[31];
-					break;
-				case 0x44u:
-					v30 = pSkillNames[32];
-					break;
-				case 0x45u:
-					v30 = pSkillNames[33];
-					break;
-				case 0x46u:
-					v30 = pSkillNames[34];
-					break;
-				default:
-					if ( v29 != 71 )
-						goto LABEL_100;
-					v30 = pSkillNames[35];
-					break;
-					}
-LABEL_106:
-				pShopOptions[v2] = v30;
-				v31 = a2++;
-				dword_F8B1DC = v2 + 1;
-				sub_4B36CC(v31, v29);
-				++v28;
-				if ( a2 >= v37 )
-					goto LABEL_107;
-				v2 = dword_F8B1DC;
-				}
-			if ( *v28 == 47 )
-				{
-				v30 = pSkillNames[11];
-				goto LABEL_106;
-				}
-			if ( (signed int)v29 > 40 )
-				{
-				if ( v29 == 41 )
-					{
-					v30 = pSkillNames[5];
-					goto LABEL_106;
-					}
-				if ( v29 == 42 )
-					{
-					v30 = pSkillNames[6];
-					goto LABEL_106;
-					}
-				if ( v29 == 44 )
-					{
-					v30 = pSkillNames[8];
-					goto LABEL_106;
-					}
-				if ( v29 == 45 )
-					{
-					v30 = pSkillNames[9];
-					goto LABEL_106;
-					}
-				if ( v29 == 46 )
-					{
-					v30 = pSkillNames[10];
-					goto LABEL_106;
-					}
-				}
-			else
-				{
-				if ( v29 == 40 )
-					{
-					v30 = pSkillNames[4];
-					goto LABEL_106;
-					}
-				if ( v29 == 5 )
-					{
-					v30 = pSkillNames[23];
-					goto LABEL_106;
-					}
-				if ( v29 == 36 )
-					{
-					v30 = pSkillNames[0];
-					goto LABEL_106;
-					}
-				if ( v29 == 37 )
-					{
-					v30 = pSkillNames[1];
-					goto LABEL_106;
-					}
-				if ( v29 == 38 )
-					{
-					v30 = pSkillNames[2];
-					goto LABEL_106;
-					}
-				if ( v29 == 39 )
-					{
-					v30 = pSkillNames[3];
-					goto LABEL_106;
-					}
-				}
-LABEL_100:
+		case 40 :v30 = pSkillNames[4];	break;
+		case 5 : v30 = pSkillNames[23];	break;
+		case 36 :v30 = pSkillNames[0];	break;
+		case 37 :v30 = pSkillNames[1];	break;
+		case 38 :v30 = pSkillNames[2];	break;
+		case 39 :v30 = pSkillNames[3];	break;
+		case 41 :v30 = pSkillNames[5];	break;
+		case 42 :v30 = pSkillNames[6];	break;
+		case 44 :v30 = pSkillNames[8];	break;
+		case 45 :v30 = pSkillNames[9];	break;
+		case 46 :v30 = pSkillNames[10];	break;
+		case 47 :v30 = pSkillNames[11];	break;
+		case 66 :v30 = pSkillNames[30];	break;
+		case 57 :v30 = pSkillNames[21];	break;
+		case 58 :v30 = pSkillNames[22];	break;
+		case 60 :v30 = pSkillNames[24];	break;
+		case 62 :v30 = pSkillNames[26];	break;
+		case 65 :v30 = pSkillNames[29];	break;
+		case 67:v30 = pSkillNames[31];	break;
+		case 68:v30 = pSkillNames[32];	break;
+		case 69:v30 = pSkillNames[33];	break;
+		case 70:v30 = pSkillNames[34];	break;
+		case 71:v30 = pSkillNames[35]; break;
+		default:
 			v30 = pGlobalTXT_LocalizationStrings[127]; //"No Text!"
-			goto LABEL_106;
 			}
-LABEL_107:
-		pDialogueWindow->_41D08F(a2, 1, 0, 2);
-		result = pDialogueWindow->pNumPresenceButton;
-		dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
-		return result;
+		pShopOptions[dword_F8B1DC] = v30;
+		++dword_F8B1DC;
+		CreateButtonInColumn(i+1, v29);
 		}
+	pDialogueWindow->_41D08F(i, 1, 0, 2);
+	dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
+	}
--- a/mm7_2.cpp	Mon Feb 25 23:33:15 2013 +0400
+++ b/mm7_2.cpp	Tue Feb 26 02:09:56 2013 +0400
@@ -3757,7 +3757,7 @@
   //v3 = dword_F8B198;
   if ( dword_F8B19C != 1 )
     goto LABEL_13;
-  if ( dword_F8B198 == 30 )
+  if ( in_current_bilding_type == 30 )
   {
     if ( uMessageParam == 17 )
     {
@@ -3778,9 +3778,9 @@
     goto LABEL_9;
   }
   v8 = window_SpeakInHouse;
-  if ( (dword_F8B198 == 27 || dword_F8B198 == 28)
+  if ( (in_current_bilding_type == 27 || in_current_bilding_type == 28)
     && (v1 = 0, *(&byte_4F09B1[32 * (unsigned __int8)*(&byte_4F0CCF[4 * (unsigned int)window_SpeakInHouse->ptr_1C] + uMessageParam)] + pParty->uDaysPlayed % 7))
-    || dword_F8B198 != 23 || uMessageParam != 10 )
+    || in_current_bilding_type != 23 || uMessageParam != 10 )
   {
 LABEL_9:
     pDialogueWindow->Release();
@@ -3801,34 +3801,34 @@
   }
 LABEL_11:
   dword_F8B19C = uMessageParam;
-  if ( dword_F8B198 < 19 )
-  {
-    v9 = pIcons_LOD->LoadTexture(off_4F03B8[dword_F8B198], TEXTURE_16BIT_PALETTE);
+  if ( in_current_bilding_type < 19 )
+  {
+    v9 = pIcons_LOD->LoadTexture(off_4F03B8[in_current_bilding_type], TEXTURE_16BIT_PALETTE);
     //v3 = dword_F8B198;
     dword_F8B164 = &pIcons_LOD->pTextures[v9];
 LABEL_13:
     v8 = window_SpeakInHouse;
   }
-  if ( dword_F8B198 > 21 )
-  {
-    if ( dword_F8B198 == 22 )
+  if ( in_current_bilding_type > 21 )
+  {
+    if ( in_current_bilding_type == 22 )
     {
       if ( dword_F8B19C >= 7 && dword_F8B19C <= 8 )
         pKeyActionMap->EnterText(1, 10, v8);
       return;
     }
-    if ( dword_F8B198 != 23 && dword_F8B198 != 30 )
+    if ( in_current_bilding_type != 23 && in_current_bilding_type != 30 )
       return;
   }
   else
   {
-    if ( dword_F8B198 != 21 )
-    {
-      if ( dword_F8B198 <= (signed int)v1 )
+    if ( in_current_bilding_type != 21 )
+    {
+      if ( in_current_bilding_type <= (signed int)v1 )
         return;
-      if ( dword_F8B198 > 4 )
-      {
-        if ( dword_F8B198 <= 16 )
+      if ( in_current_bilding_type > 4 )
+      {
+        if ( in_current_bilding_type <= 16 )
         {
           if ( (signed __int64)__PAIR__(
                                  *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472],
@@ -3864,7 +3864,7 @@
           }
           return;
         }
-        if ( dword_F8B198 != 17 )
+        if ( in_current_bilding_type != 17 )
           return;
         if ( uMessageParam == 99 )
         {
@@ -4080,12 +4080,12 @@
       case 96:
         pDialogueWindow->eWindowType = WINDOW_MainMenu;
         UI_CreateEndConversationButton();
-        sub_4B3703(dword_F8B198);
+        FillAviableSkillsToTeach(in_current_bilding_type);
         break;
       case 101:
         pDialogueWindow->eWindowType = WINDOW_MainMenu;
         UI_CreateEndConversationButton();
-        sub_4B3A72(dword_F8B198);
+        sub_4B3A72(in_current_bilding_type);
         break;
       case 102:
         dword_F8B19C = 102;
@@ -4150,7 +4150,7 @@
                   if ( pParty->uNumGold < v37 )
                   {
                     ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
-                    if ( dword_F8B198 == 30 || dword_F8B198 == 21 )
+                    if ( in_current_bilding_type == 30 || in_current_bilding_type == 21 )
                       v39 = 4;
                     else
                       v39 = 2;
@@ -4172,7 +4172,7 @@
               {
                 pDialogueWindow->eWindowType = WINDOW_MainMenu;
                 UI_CreateEndConversationButton();
-                sub_4B3AD4(dword_F8B198);
+                sub_4B3AD4(in_current_bilding_type);
               }
             }
           }
@@ -4222,7 +4222,7 @@
       //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 ( dword_F8B198 == 1 )
+    if ( in_current_bilding_type == 1 )
     {
       v47 = v8->ptr_1C;
       v48 = 0;
@@ -4267,7 +4267,7 @@
       //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 ( dword_F8B198 == 1 )
+    if ( in_current_bilding_type == 1 )
     {
       v52 = v8->ptr_1C;
       v53 = 0;
@@ -4336,7 +4336,7 @@
         {
           UI_CreateEndConversationButton();
           dword_F8B19C = 94;
-          sub_4B3AD4(dword_F8B198);
+          sub_4B3AD4(in_current_bilding_type);
         }
         else
         {
@@ -4345,13 +4345,13 @@
             pVideoPlayer->_4BF5B2();
 LABEL_28:
             dword_F8B19C = 1;
-            sub_4B3B42(dword_F8B198);
+            sub_4B3B42(in_current_bilding_type);
             return 1;
           }
           pVideoPlayer->_4BF5B2();
           UI_CreateEndConversationButton();
           dword_F8B19C = 101;
-          sub_4B3A72(dword_F8B198);
+          sub_4B3A72(in_current_bilding_type);
         }
         return 1;
       }
@@ -4514,7 +4514,7 @@
           {
             ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold"
             v13 = window_SpeakInHouse->ptr_1C;
-            if ( dword_F8B198 == 30 )
+            if ( in_current_bilding_type == 30 )
               v55 = 4;
             else
               v55 = 2;
--- a/mm7_4.cpp	Mon Feb 25 23:33:15 2013 +0400
+++ b/mm7_4.cpp	Tue Feb 26 02:09:56 2013 +0400
@@ -9080,9 +9080,9 @@
   int v18; // [sp+48h] [bp-4h]@5
 
   //v0 = pPlayers[uActiveCharacter];
-  if ( dword_F8B198 <= 0 )
+  if ( in_current_bilding_type <= 0 )
     return;
-  if ( dword_F8B198 <= 4 )
+  if ( in_current_bilding_type <= 4 )
   {
     if ( dword_F8B19C != 2 )
     {
@@ -9116,7 +9116,7 @@
 		v7 =&pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v5];
     goto LABEL_15;
   }
-  if ( dword_F8B198 <= 16 && dword_F8B19C == 18 )
+  if ( in_current_bilding_type <= 16 && dword_F8B19C == 18 )
   {
     v1 = pMouse->GetCursorPos(&a2);
     v2 = v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v16)->y];
@@ -9180,19 +9180,19 @@
   int v6; // esi@20
   int v7[4]; // [sp+Ch] [bp-10h]@12
 
-  if ( dword_F8B198 > 0 )
+  if ( in_current_bilding_type > 0 )
   {
     v0 = 3;
-    if ( dword_F8B198 > 3 )
-    {
-      if ( dword_F8B198 == 22 )
+    if ( in_current_bilding_type > 3 )
+    {
+      if ( in_current_bilding_type == 22 )
       {
         if ( !dword_F8B1E4 )
           return;
       }
       else
       {
-        if ( dword_F8B198 != 23 )
+        if ( in_current_bilding_type != 23 )
           return;
       }
       v1 = (unsigned int)window_SpeakInHouse->ptr_1C;
@@ -10349,94 +10349,61 @@
 
 
 //----- (004B36CC) --------------------------------------------------------
-GUIButton *__fastcall sub_4B36CC(int a1, unsigned int a2)
-{
-  return pDialogueWindow->CreateButton(
-           0x1E0u,
-           30 * a1 + 146,
-           0x8Cu,
-           0x1Eu,
-           1,
-           0,
-           0x195u,
-           a2,
-           0,
-           "",
-           0);
+void CreateButtonInColumn( int column_pos, unsigned int control_id )
+	{
+     pDialogueWindow->CreateButton( 480, 30 * column_pos + 146, 140, 30,  1,  0, 0x195u,  control_id,  0,   "",   0);
 }
 
 
 
 //----- (004B3A72) --------------------------------------------------------
-int __thiscall sub_4B3A72(int a1)
-{
-  int v1; // esi@1
-  int result; // eax@4
-
-  v1 = 0;
+void sub_4B3A72( int a1 )
+	{
+  int num_buttons; // esi@1
+
+  num_buttons = 0;
   if ( a1 == 21 )
   {
-    sub_4B36CC(0, 0x66u);
-    v1 = 2;
-    sub_4B36CC(1, 0x67u);
-    if ( pParty->HasItem(0x28Bu) )
-    {
-      v1 = 3;
-      sub_4B36CC(2, 0x68u);
-    }
-  }
-  pDialogueWindow->_41D08F(v1, 1, 0, 2);
-  result = pDialogueWindow->pNumPresenceButton;
+    CreateButtonInColumn(0, 0x66u);
+    num_buttons = 2;
+    CreateButtonInColumn(1, 0x67u);
+	if ( pParty->HasItem(651) ) //Arcomage Deck
+    {
+      num_buttons = 3;
+      CreateButtonInColumn(2, 0x68u);
+    }
+  }
+  pDialogueWindow->_41D08F(num_buttons, 1, 0, 2);
   dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
-  return result;
 }
 // F8B1E0: using guessed type int dword_F8B1E0;
 
 //----- (004B3AD4) --------------------------------------------------------
-int __fastcall sub_4B3AD4(signed int a1)
-{
-  int result; // eax@7
-  int v2; // [sp-10h] [bp-10h]@4
-  int v3; // [sp-Ch] [bp-Ch]@4
-  int v4; // [sp-8h] [bp-8h]@4
-  int v5; // [sp-4h] [bp-4h]@4
-
+void sub_4B3AD4( signed int a1 )
+	{
   if ( a1 > 0 )
   {
     if ( a1 <= 3 )
     {
-      sub_4B36CC(0, 3u);
-      sub_4B36CC(1, 4u);
-      sub_4B36CC(2, 5u);
-      v5 = 2;
-      v4 = 0;
-      v3 = 1;
-      v2 = 3;
-      goto LABEL_6;
+      CreateButtonInColumn(0, 3u);
+      CreateButtonInColumn(1, 4u);
+      CreateButtonInColumn(2, 5u);
+       pDialogueWindow->_41D08F(3, 1, 0, 2);
     }
     if ( a1 == 4 )
     {
-      sub_4B36CC(0, 3u);
-      sub_4B36CC(1, 4u);
-      v5 = 2;
-      v4 = 0;
-      v3 = 1;
-      v2 = 2;
-LABEL_6:
-      pDialogueWindow->_41D08F(v2, v3, v4, v5);
-      goto LABEL_7;
-    }
-  }
-LABEL_7:
-  result = pDialogueWindow->pNumPresenceButton;
+      CreateButtonInColumn(0, 3u);
+      CreateButtonInColumn(1, 4u);
+      pDialogueWindow->_41D08F(2, 1, 0, 2);
+    }
+  }
   dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
-  return result;
 }
 // F8B1E0: using guessed type int dword_F8B1E0;
 
 //----- (004B3B42) --------------------------------------------------------
-int __fastcall sub_4B3B42(signed int a1)
-{
+void sub_4B3B42( signed int a1 )
+	{
   int v1; // ecx@18
   int v2; // ecx@19
   int v3; // ecx@20
@@ -10461,11 +10428,11 @@
     {
       if ( a1 == 23 )
       {
-        sub_4B36CC(0, 0xAu);
-        sub_4B36CC(1, 0xBu);
+        CreateButtonInColumn(0, 0xAu);
+        CreateButtonInColumn(1, 0xBu);
         v14 = 96;
 LABEL_41:
-        sub_4B36CC(2, v14);
+        CreateButtonInColumn(2, v14);
         v17 = 2;
         v11 = 0;
         v10 = 1;
@@ -10478,31 +10445,31 @@
       {
         if ( a1 != 30 )
           goto LABEL_43;
-        sub_4B36CC(0, 0x11u);
+        CreateButtonInColumn(0, 0x11u);
         v16 = 96;
         goto LABEL_37;
       }
-      sub_4B36CC(0, 0x69u);
-      sub_4B36CC(1, 0x6Au);
-      sub_4B36CC(2, 0x6Bu);
+      CreateButtonInColumn(0, 0x69u);
+      CreateButtonInColumn(1, 0x6Au);
+      CreateButtonInColumn(2, 0x6Bu);
       v12 = 108;
     }
     else
     {
       if ( a1 == 22 )
       {
-        sub_4B36CC(0, 7u);
+        CreateButtonInColumn(0, 7u);
         v16 = 8;
         goto LABEL_37;
       }
       v1 = a1 - 14;
       if ( !v1 )
       {
-        sub_4B36CC(0, 0x12u);
-        sub_4B36CC(1, 0x30u);
-        sub_4B36CC(2, 0x31u);
-        sub_4B36CC(3, 0x32u);
-        sub_4B36CC(4, 0x33u);
+        CreateButtonInColumn(0, 0x12u);
+        CreateButtonInColumn(1, 0x30u);
+        CreateButtonInColumn(2, 0x31u);
+        CreateButtonInColumn(3, 0x32u);
+        CreateButtonInColumn(4, 0x33u);
         v17 = 2;
         v11 = 0;
         v10 = 1;
@@ -10517,10 +10484,10 @@
         {
           if ( v3 != 4 )
             goto LABEL_43;
-          sub_4B36CC(0, 0xFu);
-          sub_4B36CC(1, 0x10u);
+          CreateButtonInColumn(0, 0xFu);
+          CreateButtonInColumn(1, 0x10u);
           v4 = 3;
-          sub_4B36CC(2, 0x60u);
+          CreateButtonInColumn(2, 0x60u);
           v5 = (signed int)window_SpeakInHouse->ptr_1C;
           if ( v5 < 108 || v5 > 120 )
             goto LABEL_28;
@@ -10531,7 +10498,7 @@
         else
         {
           v4 = 1;
-          sub_4B36CC(0, 0x63u);
+          CreateButtonInColumn(0, 0x63u);
           if ( !pParty->uFine )
           {
 LABEL_28:
@@ -10547,16 +10514,16 @@
           v7 = 1;
           v6 = 100;
         }
-        sub_4B36CC(v7, v6);
+        CreateButtonInColumn(v7, v6);
         goto LABEL_28;
       }
-      sub_4B36CC(0, 0x12u);
-      sub_4B36CC(1, 0x34u);
-      sub_4B36CC(2, 0x35u);
+      CreateButtonInColumn(0, 0x12u);
+      CreateButtonInColumn(1, 0x34u);
+      CreateButtonInColumn(2, 0x35u);
       v12 = 54;
     }
 LABEL_39:
-    sub_4B36CC(3, v12);
+    CreateButtonInColumn(3, v12);
     v17 = 2;
     v11 = 0;
     v10 = 1;
@@ -10565,10 +10532,10 @@
   }
   if ( a1 == 13 )
   {
-    sub_4B36CC(0, 0x12u);
+    CreateButtonInColumn(0, 0x12u);
     v16 = 56;
 LABEL_37:
-    sub_4B36CC(1, v16);
+    CreateButtonInColumn(1, v16);
     v17 = 2;
     v11 = 0;
     v10 = 1;
@@ -10581,56 +10548,54 @@
     case 2:
     case 3:
     case 4:
-      sub_4B36CC(0, 2u);
-      sub_4B36CC(1, 0x5Fu);
-      sub_4B36CC(2, 0x5Eu);
+      CreateButtonInColumn(0, 2u);
+      CreateButtonInColumn(1, 0x5Fu);
+      CreateButtonInColumn(2, 0x5Eu);
       v12 = 96;
       goto LABEL_39;
     case 5:
-      sub_4B36CC(0, 0x12u);
+      CreateButtonInColumn(0, 0x12u);
       v13 = 48;
       goto LABEL_9;
     case 6:
-      sub_4B36CC(0, 0x12u);
+      CreateButtonInColumn(0, 0x12u);
       v13 = 49;
       goto LABEL_9;
     case 7:
-      sub_4B36CC(0, 0x12u);
+      CreateButtonInColumn(0, 0x12u);
       v13 = 50;
       goto LABEL_9;
     case 8:
-      sub_4B36CC(0, 0x12u);
+      CreateButtonInColumn(0, 0x12u);
       v13 = 51;
 LABEL_9:
-      sub_4B36CC(1, v13);
+      CreateButtonInColumn(1, v13);
       v14 = 72;
       goto LABEL_41;
     case 9:
-      sub_4B36CC(0, 0x12u);
+      CreateButtonInColumn(0, 0x12u);
       v15 = 52;
       goto LABEL_13;
     case 10:
-      sub_4B36CC(0, 0x12u);
+      CreateButtonInColumn(0, 0x12u);
       v15 = 53;
       goto LABEL_13;
     case 11:
-      sub_4B36CC(0, 0x12u);
+      CreateButtonInColumn(0, 0x12u);
       v15 = 54;
 LABEL_13:
-      sub_4B36CC(1, v15);
+      CreateButtonInColumn(1, v15);
       v14 = 61;
       goto LABEL_41;
     case 12:
-      sub_4B36CC(0, 0x12u);
+      CreateButtonInColumn(0, 0x12u);
       v16 = 55;
       goto LABEL_37;
     default:
       break;
   }
 LABEL_43:
-  result = pDialogueWindow->pNumPresenceButton;
   dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
-  return result;
 }
 // F8B1E0: using guessed type int dword_F8B1E0;
 
@@ -10815,7 +10780,7 @@
     pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, "", 0);
     if ( pDialogueNPCCount == 1 && dword_591080 )
     {
-      sub_4B3B42(dword_F8B198);
+      sub_4B3B42(in_current_bilding_type);
     }
     else
     {
@@ -14472,8 +14437,8 @@
       pAudioPlayer->StopChannels(-1, -1);
     //uCurrentHouse_Animation = p2DEvents_minus1___02[v2];
     uCurrentHouse_Animation = p2DEvents[uHouseID - 1].uAnimationID;
-    dword_F8B198 = LOBYTE(pAnimatedRooms[uCurrentHouse_Animation].field_C);
-    if ( dword_F8B198 == 20 && pParty->uFine )   // going 2 jail
+    in_current_bilding_type = LOBYTE(pAnimatedRooms[uCurrentHouse_Animation].field_C);
+    if ( in_current_bilding_type == 20 && pParty->uFine )   // going 2 jail
     {
       uCurrentHouse_Animation = (signed __int16)p2DEvents[186].uAnimationID;
       //v25 = HOUSE_187;
@@ -14482,7 +14447,7 @@
       LODWORD(pParty->uTimePlayed) += 0x7620000u;
       v14 = LOBYTE(pAnimatedRooms[(signed __int16)p2DEvents[HOUSE_186].uAnimationID].field_C);
       pParty->uTimePlayed = __PAIR__(HIDWORD(pParty->uTimePlayed), v12) + 0x7620000;
-      dword_F8B198 = v14;
+      in_current_bilding_type = v14;
       //v13 = pParty->pPlayers;//[0].uNumDivineInterventionCastsThisDay;
       //do
       ++pParty->uNumPrisonTerms;
--- a/mm7_data.cpp	Mon Feb 25 23:33:15 2013 +0400
+++ b/mm7_data.cpp	Tue Feb 26 02:09:56 2013 +0400
@@ -1610,7 +1610,7 @@
 int dword_4EFA84; // weak
 void *off_4EFDB0; // weak
 int dword_4F031C[777]; // weak
-const char *off_4F03B8[] =
+const char *off_4F03B8[19] =
 {
   "",         "WEPNTABL", "ARMORY",   "MAGSHELF",
   "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF",
@@ -2341,7 +2341,7 @@
 __int16 word_F8B158[777]; // weak
 struct Texture *dword_F8B164; // idb
 struct Texture *ItemsInShopTexture[12];
-int dword_F8B198; // weak
+int in_current_bilding_type; // weak
 int dword_F8B19C; // weak
 __int16 word_F8B1A0; // weak
 const char *dword_F8B1A4; // idb
--- a/mm7_data.h	Mon Feb 25 23:33:15 2013 +0400
+++ b/mm7_data.h	Tue Feb 26 02:09:56 2013 +0400
@@ -1686,7 +1686,7 @@
 extern __int16 word_F8B158[]; // weak
 extern struct Texture *dword_F8B164; // idb
 extern struct Texture *ItemsInShopTexture[12];
-extern int dword_F8B198; // weak
+extern int in_current_bilding_type; // weak
 extern int dword_F8B19C; // weak
 extern __int16 word_F8B1A0; // weak
 extern const char *dword_F8B1A4; // idb
@@ -2307,11 +2307,11 @@
 char *__thiscall _4B254D_SkillMasteryTeacher(int _this);
 const char *__fastcall ContractSelectText(int pEventNumber);
 char __cdecl SimpleHouseAndBoatsDialog();
-struct GUIButton *__fastcall sub_4B36CC(int a1, unsigned int a2);
-int sub_4B3703(int _this);
-int __thiscall sub_4B3A72(int a1); // idb
-int __fastcall sub_4B3AD4(signed int a1);
-int __fastcall sub_4B3B42(signed int a1);
+void  CreateButtonInColumn(int a1, unsigned int a2);
+void FillAviableSkillsToTeach(int _this);
+void  sub_4B3A72(int a1); // idb
+void sub_4B3AD4(signed int a1);
+void sub_4B3B42(signed int a1);
 void __cdecl sub_4B3E1E();
 void __fastcall DrawJoinGuildWindow(int pEventNumber);
 void __fastcall sub_4B3FE5(int a4);