changeset 458:c0ab5f64b37b

Слияние
author Ritor1
date Sun, 24 Feb 2013 20:42:44 +0600
parents e5cf03a3d98e (current diff) a812665688e4 (diff)
children a7869569e912
files mm7_2.cpp mm7_4.cpp mm7_data.cpp mm7_data.h
diffstat 8 files changed, 292 insertions(+), 231 deletions(-) [+]
line wrap: on
line diff
--- a/Game.cpp	Sun Feb 24 20:39:03 2013 +0600
+++ b/Game.cpp	Sun Feb 24 20:42:44 2013 +0600
@@ -417,16 +417,18 @@
         pTurnEngine->End(1);
         pParty->bTurnBasedModeOn = 0;
       }
-      pHealth = &pParty->pPlayers[0].sHealth;//193C
-      do
+      //pHealth = &pParty->pPlayers[0].sHealth;//193C
+      //do
+	  for(int i=0; i<4; ++i)
       {
-        memset(pHealth - 0x64F, 0, 0xA0u);//(pConditions, 0, 160)
-        memset(pHealth - 0x67, 0, 0x180u);//(pPlayerBuffs[0], 0, 384)
-        *pHealth = 1;
-        pHealth += 1743; //6CF
+        memset(pParty->pPlayers[i].pConditions, 0, 0xA0u);//(pConditions, 0, 160)
+        memset(pParty->pPlayers[i].pPlayerBuffs, 0, 0x180u);//(pPlayerBuffs[0], 0, 384)
+        //*pHealth = 1;
+		pParty->pPlayers[i].sHealth=1;
+        //pHealth += 1743; //6CF
         uActiveCharacter = 1;
       }
-      while ( (signed int)pHealth < (signed int)&pParty->field_871C[567] );
+    //  while ( (signed int)pHealth < (signed int)&pParty->field_871C[567] );
       if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 136) )
       {
         pParty->vPosition.x = -17331;            // respawn in harmondale
--- a/Party.cpp	Sun Feb 24 20:39:03 2013 +0600
+++ b/Party.cpp	Sun Feb 24 20:42:44 2013 +0600
@@ -398,7 +398,7 @@
     Dst.Reset();
     if ( bGiveItems )
     {
-      pItemsTable->GenerateItem(2, 40, &Dst);
+      pItemsTable->GenerateItem(2, 40, &Dst); //ring
       pCharacter->AddItem2(-1, &Dst);
       //uSkillIdx = 0;
       //v18 = 0;
--- a/Party.h	Sun Feb 24 20:39:03 2013 +0600
+++ b/Party.h	Sun Feb 24 20:42:44 2013 +0600
@@ -272,22 +272,9 @@
   NPCData pHirelings[2];
   ItemGen pPickedItem;
   unsigned int uFlags;
-  int field_777C[1000];
-  int field_871C[1000];
-  int field_96BC[1000];
-  int field_A65C[1000];
-  int field_B5FC[1000];
-  int field_C59C[1000];
-  int field_D53C[1000];
-  int field_E4DC[300];
-  int field_E98C[13];
-  int dword_E9C0;
-  int dword_E9C4;
-  char field_E9C8[5000];
-  char field_FD50[5000];
-  char field_110D8[5000];
-  char field_12460[5000];
-  char field_137E8[5000];
+  ItemGen field_777C[53][12];
+  ItemGen Recipes_Item[53][12];   //D0EC
+  int field_12A5C[2117];
   char field_14B70[5000];
   char field_15EF8[250];
   char field_15FF2[130];
@@ -296,7 +283,7 @@
   int armageddon_timer;
   int field_16140;
   int pTurnBasedPlayerRecoveryTimes[4];
-  char field_16154[212];
+  int field_16154[53];
   int uFine;
   float flt_TorchlightColorR;
   float flt_TorchlightColorG;
--- a/mm7_2.cpp	Sun Feb 24 20:39:03 2013 +0600
+++ b/mm7_2.cpp	Sun Feb 24 20:42:44 2013 +0600
@@ -961,7 +961,7 @@
       if ( v2 <= 41 )
       {
         v4 = word_4F0576[v2];
-        v9 = 22;
+        v9 = 22;  //misc
         goto LABEL_12;
       }
       if ( v2 <= 53 )
@@ -969,19 +969,19 @@
         if ( v1 >= 6 )
         {
           v4 = word_4F0578[v2];
-          v9 = 45;
+          v9 = 45;  //reagent
 LABEL_12:
           v5 = v9;
 LABEL_13:
-          pItemsTable->GenerateItem(v4, v5, (ItemGen *)&pParty->field_777C[9 * (v1 + 12 * v2)]);
+          pItemsTable->GenerateItem(v4, v5, (ItemGen *)&pParty->field_777C[v2][v1]);//9 * (v1 + 12 * v2)]);
           v0 = window_SpeakInHouse;
-          pParty->field_777C[9 * (v1 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 5] = 1;
+          pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uAttributes = 1;  //identified
           goto LABEL_14;
         }
-        auto _t = (ItemGen *)&pParty->field_777C[9 * (v1 + 12 * v2)];
+        auto _t = (ItemGen *)&pParty->field_777C[v2][v1];
         _t->Reset();
         v0 = window_SpeakInHouse;
-        pParty->field_777C[9 * (v1 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] = 220;
+        pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uItemID = 220;  //potion bottle
       }
 LABEL_14:
       v2 = (signed int)v0->ptr_1C;
@@ -1491,7 +1491,8 @@
     v109 = 0;
     do
     {
-      if ( pParty->field_777C[9 * (int)&v48[3 * (unsigned int)window_SpeakInHouse->ptr_1C]] )
+    //  if ( pParty->field_777C[9 * (int)&v48[3 * (unsigned int)window_SpeakInHouse->ptr_1C]] )
+	if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][(int)v48].uItemID);
       {
         v49 = word_F8B158[(signed int)v48];
         v50 = dword_F8B168[(signed int)v48];
@@ -1516,7 +1517,8 @@
     v108 = 0;
     do
     {
-      if ( pParty->field_C59C[9 * (int)&v109[3 * (unsigned int)window_SpeakInHouse->ptr_1C] + 724] )
+   //   if ( pParty->field_C59C[9 * (int)&v109[3 * (unsigned int)window_SpeakInHouse->ptr_1C] + 724] )
+	if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v109].uItemID)
       {
         v52 = word_F8B158[(signed int)v109] + 30;
         v53 = dword_F8B168[(signed int)v109];
@@ -1542,7 +1544,7 @@
       v106.x = 0;
       do
       {
-        if ( pParty->field_777C[9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
+        if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID);//9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
           ++v106.x;
         ++v55;
       }
@@ -1552,7 +1554,8 @@
     {
       do
       {
-        if ( pParty->field_C59C[9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+       // if ( pParty->field_C59C[9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+	  if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID)
           ++v106.x;
         ++v55;
       }
@@ -1581,10 +1584,10 @@
         v60 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1;
         v106.x = v60;
         v61 = (int)window_SpeakInHouse->ptr_1C;
-        v62 = 9 * (v60 + 12 * v61);
-        v63 = (ItemGen *)&pParty->field_777C[v62];
+      //  v62 = 9 * (v60 + 12 * v61);
+        v63 = (ItemGen *)&pParty->field_777C[(int)v61][v60];
         if ( dword_F8B19C != 2 )
-          v63 = (ItemGen *)&pParty->field_C59C[v62 + 724];
+          v63 = &pParty->Recipes_Item[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724];
         if ( !v56 || !Str )
         {
           v85 = 0;
@@ -2029,7 +2032,8 @@
     {
       do
       {
-        if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
+       // if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
+	  if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID);
         {
           v46 = dword_F8B168[v114];
           v47 = 152 - v46->uTextureHeight;
@@ -2059,7 +2063,8 @@
       v114 = 0;
       do
       {
-        if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] )
+      //  if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] )
+	  if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v114+1].uItemID);
         {
           v50 = dword_F8B168[v114 + 6];
           v51 = 308 - v50->uTextureHeight;
@@ -2091,7 +2096,8 @@
     {
       do
       {
-        if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+        //if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+	  if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID)
         {
           v54 = dword_F8B168[v114];
           v55 = 152 - v54->uTextureHeight;
@@ -2121,7 +2127,8 @@
       v114 = 0;
       do
       {
-        if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 778] )
+       // if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 778] )   //weak 
+	     if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v114].uItemID) //not itemid
         {
           v58 = dword_F8B168[v114 + 6];
           v59 = 308 - v58->uTextureHeight;
@@ -2158,7 +2165,8 @@
       {
         do
         {
-          if ( pParty->field_777C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
+         // if ( pParty->field_777C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
+		if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID);
             ++v109;
           ++v62;
         }
@@ -2168,7 +2176,8 @@
       {
         do
         {
-          if ( pParty->field_C59C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+          //if ( pParty->field_C59C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+		if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID)
             ++v109;
           ++v62;
         }
@@ -2201,10 +2210,10 @@
         v67 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1;
         v109 = v67;
         v68 = (int)window_SpeakInHouse->ptr_1C;
-        v69 = 9 * (v67 + 12 * v68);
-        v70 = (ItemGen *)&pParty->field_777C[v69];
+      //  v69 = 9 * (v67 + 12 * v68);
+        v70 = (ItemGen *)&pParty->field_777C[v68][v67];
         if ( dword_F8B19C != 2 )
-          v70 = (ItemGen *)&pParty->field_C59C[v69 + 724];
+          v70 = &pParty->Recipes_Item[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724];
         if ( !v63 || !Str )
         {
           v93 = 0;
@@ -2408,7 +2417,8 @@
       v93 = 0;
       do
       {
-        if ( pParty->field_C59C[9 * (v93 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+       // if ( pParty->field_C59C[9 * (v93 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+	  if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v93].uItemID)
           ++v149;
         ++v93;
       }
@@ -2423,9 +2433,9 @@
           --v149;
           v96 = window_SpeakInHouse->ptr_1C;
           v97 = uActiveCharacter - 1;
-          v98 = (ItemGen *)&pParty->field_C59C[9 * (v95 - 1 + 12 * (int)v96) + 724];
+       //   v98 = (ItemGen *)&pParty->field_C59C[9 * (v95 - 1 + 12 * (int)v96) + 724];
           v99 = _this->_490EEE(
-                  (ItemGen *)&pParty->field_C59C[9 * (v95 - 1 + 12 * (int)v96) + 724],
+                 &pParty->Recipes_Item[(int)v96][v95-1],// (ItemGen *)&pParty->field_C59C[9 * (v95 - 1 + 12 * (int)v96) + 724],
                   2,
                   (int)window_SpeakInHouse->ptr_1C,
                   2);
@@ -2439,7 +2449,8 @@
         v153 = 0;
         do
         {
-          if ( pParty->field_C59C[9 * (v104 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+          //if ( pParty->field_C59C[9 * (v104 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+		if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v104].uItemID)
           {
             v105 = dword_F8B168[v104];
             if ( v104 >= 4 )
@@ -2626,7 +2637,8 @@
       v153 = 0;
       do
       {
-        if ( pParty->field_777C[9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
+      //  if ( pParty->field_777C[9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
+	  if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID);
         {
           v56 = dword_F8B168[v55];
           if ( v55 >= 4 )
@@ -2660,7 +2672,8 @@
       v153 = 0;
       do
       {
-        if ( (char *)pParty->field_C59C[9 * (v61 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] != v11 )
+       // if ( (char *)pParty->field_C59C[9 * (v61 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] != v11 )
+	  if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v61].uItemID)
         {
           v62 = dword_F8B168[v61];
           if ( v61 >= 4 )
@@ -2696,7 +2709,8 @@
     {
       do
       {
-        if ( (char *)pParty->field_777C[9 * (v68 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] != v11 )
+       // if ( (char *)pParty->field_777C[9 * (v68 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] != v11 )
+	  if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v68].uItemID);
           ++v149;
         ++v68;
       }
@@ -2706,7 +2720,8 @@
     {
       do
       {
-        if ( (char *)pParty->field_C59C[9 * (v68 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] != v11 )
+       // if ( (char *)pParty->field_C59C[9 * (v68 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] != v11 )
+	  if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v68].uItemID)
           ++v149;
         ++v68;
       }
@@ -2738,7 +2753,7 @@
       if ( dword_F8B19C == 2 )
         v77 = (ItemGen *)&pParty->field_777C[v76];
       else
-        v77 = (ItemGen *)&pParty->field_C59C[v76 + 724];
+        v77 = &pParty->Recipes_Item[(int)75][v74-1];//(ItemGen *)&pParty->field_C59C[v76 + 724];
       if ( v69 == (short)v11 || Str == v11 )
       {
         v124 = (__int64 *)v11;
@@ -4215,7 +4230,7 @@
     {
       do
       {
-        v45 = pParty->field_777C[9 * (v43 + 12 * (int)v42)];
+        v45 = pParty->field_777C[(int)v42][v43].uItemID;
         if ( v45 )
         {
           v46 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v45].pIconName, TEXTURE_16BIT_PALETTE);
@@ -4238,7 +4253,8 @@
       {
         do
         {
-          if ( pParty->field_777C[9 * (v48 + 12 * (int)v47)] )
+         // if ( pParty->field_777C[9 * (v48 + 12 * (int)v47)] )
+		 if ( pParty->field_777C[(int)v47][v48].uItemID);
           {
             v49 = rand();
             v8 = window_SpeakInHouse;
@@ -4258,7 +4274,8 @@
     {
       do
       {
-        v50 = pParty->field_C59C[9 * (v43 + 12 * (int)v42) + 724];
+        //v50 = pParty->field_C59C[9 * (v43 + 12 * (int)v42) + 724];
+	  v50=pParty->Recipes_Item[(unsigned int)v42][(signed int)v43].uItemID;
         if ( v50 )
         {
           v51 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v50].pIconName, TEXTURE_16BIT_PALETTE);
@@ -4281,7 +4298,8 @@
       {
         do
         {
-          if ( pParty->field_C59C[9 * (v53 + 12 * (int)v52) + 724] )
+         // if ( pParty->field_C59C[9 * (v53 + 12 * (int)v52) + 724] )
+		if (pParty->Recipes_Item[(unsigned int)v52][v53].uItemID)
           {
             v54 = rand();
             v8 = window_SpeakInHouse;
@@ -4311,7 +4329,7 @@
   pKeyActionMap->ResetKeys();
   _5C3420_pDecoration = 0;
   ptr_F8B1E8 = 0;
-  if ( pDialogueNPCCount )
+  if ( array_5913D8[6] )
   {
     v0 = dword_F8B19C;
     if ( dword_F8B19C != 2
@@ -4329,7 +4347,7 @@
     {
       if ( v0 == -1 )
       {
-        _4B4224_UpdateNPCTopics((int)((char *)pDialogueNPCCount - 1));
+        _4B4224_UpdateNPCTopics((int)((char *)array_5913D8[6] - 1));
 LABEL_33:
         pVideoPlayer->_4BF5B2();
         return 1;
@@ -4363,7 +4381,7 @@
       UI_CreateEndConversationButton();
       goto LABEL_28;
     }
-    pDialogueNPCCount = 0;
+    array_5913D8[6] = 0;
     pDialogueWindow->Release();
     dword_F8B19C = 0;
     pDialogueWindow = 0;
@@ -4378,7 +4396,7 @@
         v3 = byte_591180;
         do
         {
-          HouseNPCData[v2 + 7] = (NPCData *)window_SpeakInHouse->CreateButton(pNPCPortraits_x[v1 - 1][v2], pNPCPortraits_y[v1 - 1][v2],
+          array_5913D8[v2 + 7] = (NPCData *)window_SpeakInHouse->CreateButton(pNPCPortraits_x[v1 - 1][v2], pNPCPortraits_y[v1 - 1][v2],
                                               0x3Fu, 0x49u, 1, 0, 0x19Au, v2, 0, v3, 0, 0, 0);
           v1 = uNumDialogueNPCPortraits;
           ++v2;
@@ -4591,16 +4609,16 @@
     if ( !v29 )
       return;
     v30 = window_SpeakInHouse->ptr_1C;
-    v31 = 9 * (v29 - 1 + 12 * (int)v30);
+   // v31 = 9 * (v29 - 1 + 12 * (int)v30);
     if ( dword_F8B19C == 2 )
     {
-      v32 = (ItemGen *)&pParty->field_777C[v31];
-      _this = (ItemGen *)&pParty->field_777C[v31];
+      v32 = (ItemGen *)&pParty->field_777C[(int)v30][v29];
+      _this = (ItemGen *)&pParty->field_777C[(int)v30][v29];
     }
     else
     {
-      _this = (ItemGen *)&pParty->field_C59C[v31 + 724];
-      v32 = (ItemGen *)&pParty->field_C59C[v31 + 724];
+      _this =&pParty->Recipes_Item[(int)v30][v29-1]; //(ItemGen *)&pParty->field_C59C[v31 + 724];
+      v32 = &pParty->Recipes_Item[(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;
@@ -11669,7 +11687,7 @@
   //HDC v9; // edi@41
   HDC v10; // edi@50
   int v11; // esi@50
-  char v12; // zf@132
+  //char v12; // zf@132
   signed int v13; // eax@135
   int v14; // eax@139
   int v15; // eax@140
@@ -11935,8 +11953,8 @@
       v37 = 0;
       v36 = 2;
       v35 = ::hWnd;
-LABEL_104:
-      SendMessageA(v35, v36, v37, v38);
+//LABEL_104:
+      SendMessageA(::hWnd, WM_DESTROY, v37, v38);
       return 0;
     }
     if ( dword_506E68 != -1 )
@@ -11948,16 +11966,16 @@
     {
       if ( pVideoPlayer->pVideoFrame.pPixels )
         pVideoPlayer->bStopBeforeSchedule = 1;
-      if ( wParam != 13 )
-      {
-        if ( wParam == 17 )
+      if ( wParam != VK_RETURN )
+      {
+        if ( wParam == VK_CONTROL )
         {
           dword_507B98_ctrl_pressed = 1;
           return 0;
         }
-        if ( wParam == 27 )
-        {
-          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
+        if ( wParam == VK_ESCAPE )
+        {
+          pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0);
           /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
           {
             v12 = window_SpeakInHouse == 0;
@@ -11968,18 +11986,19 @@
           }*/
           return 0;
         }
-        if ( wParam <= 0x24 )
+        if ( wParam <= VK_HOME )
           return 0;
-        if ( wParam > 0x28 )
-        {
-          if ( wParam != 115 || pVideoPlayer->AnyMovieLoaded() )
+        if ( wParam > VK_DOWN )
+        {
+          if ( wParam != VK_F4 || pVideoPlayer->AnyMovieLoaded() )
             return 0;
           v38 = 0;
           v37 = 104;
 LABEL_126:
           v36 = 273;
           v35 = hWnd;
-          goto LABEL_104;
+          SendMessageA(hWnd, WM_COMMAND, v37, v38);
+          return 0;
         }
         if ( pCurrentScreen
           && pCurrentScreen != SCREEN_PRESS_ESCAPE_MESSAGE )
--- a/mm7_4.cpp	Sun Feb 24 20:39:03 2013 +0600
+++ b/mm7_4.cpp	Sun Feb 24 20:42:44 2013 +0600
@@ -4915,8 +4915,8 @@
   NPCData *npc = nullptr;
   if ( dword_5C35D4 )
   {
-    __debugbreak(); // fix
-    npc = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)];
+    __debugbreak(); // fix  
+    npc = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)];
   }
   else
     npc = GetNPCData(uDialogue_SpeakingActorNPC_ID);
@@ -9112,7 +9112,8 @@
     v6 = 9 * (v5 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C);
     v7 = (ItemGen *)((char *)&pParty->pPickedItem + 4 * v6 + 4);
     if ( dword_F8B19C != 2 )
-      v7 = (ItemGen *)&pParty->field_C59C[v6 + 715];
+   //   v7 = (ItemGen *)&pParty->field_C59C[v6 + 715];
+		v7 =&pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v5];
     goto LABEL_15;
   }
   if ( dword_F8B198 <= 16 && dword_F8B19C == 18 )
@@ -9375,11 +9376,11 @@
 // F8B1A8: using guessed type int dword_F8B1A8;
 
 //----- (004B2001) --------------------------------------------------------
-void __fastcall ClickNPCTopic(signed int uMessageParam)
-{
-  //signed int v1; // eax@1
-  NPCData *pCurrentNPCInfo; // ebp@1
-  int pEventNumber; // ecx@8
+void __fastcall sub_4B2001(signed int a1)
+{
+  signed int v1; // eax@1
+  NPCData *v2; // ebp@1
+  int v3; // ecx@8
   Player *v4; // esi@20
   int v5; // eax@28
   int v6; // eax@31
@@ -9403,49 +9404,60 @@
   char *v24; // [sp-8h] [bp-14h]@73
   int v25; // [sp-4h] [bp-10h]@49
 
-  //v1 = a1;
-  uDialogueType = uMessageParam + 1;
-  pCurrentNPCInfo = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)];
-  switch ( uMessageParam )
-  {
-    case 13:
-      ptr_F8B1E8 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession].pJoinText;//(char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession);
-      ptr_F8B1E8 = BuilDialogueString((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0);
-      sub_4B40E6();
-      dialogue_show_profession_details = false;
-      goto _return;
-    case 19:
-      pEventNumber = pCurrentNPCInfo->evt_A;
-      break;
-    case 20:
-      pEventNumber = pCurrentNPCInfo->evt_B;
-      break;
-    case 21:
-      pEventNumber = pCurrentNPCInfo->evt_C;
-      break;
-    case 22:
-      pEventNumber = pCurrentNPCInfo->evt_D;
-      break;
-    case 23:
-      pEventNumber = pCurrentNPCInfo->evt_E;
-      break;
-    case 24:
-      pEventNumber = pCurrentNPCInfo->evt_F;
-      break;
-    default:
+  v1 = a1;
+  uDialogueType = a1 + 1;
+  v2 = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)];
+  if ( a1 <= 23 )
+  {
+    if ( a1 == 23 )
+    {
+      v3 = v2->evt_E;
+    }
+    else
+    {
+      if ( a1 == 13 )
+      {
+        ptr_F8B1E8 = pNPCStats->pProfessions[v2->uProfession].pJoinText;//(char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession);
+        ptr_F8B1E8 = BuilDialogueString((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0);
+        sub_4B40E6();
+        dialogue_show_profession_details = false;
         goto _return;
-  }
-  if ( pEventNumber < 200 || pEventNumber > 310 )
-    {
-      if ( pEventNumber < 400 || pEventNumber > 410 )
-      {
-        if ( pEventNumber == 139 )
+      }
+      switch ( a1 )
+      {
+        case 19:
+          v3 = v2->evt_A;
+          break;
+        case 20:
+          v3 = v2->evt_B;
+          break;
+        case 21:
+          v3 = v2->evt_C;
+          break;
+        default:
+          if ( a1 != 22 )
+            goto _return;
+          v3 = v2->evt_D;
+          break;
+      }
+    }
+    goto LABEL_84;
+  }
+  if ( a1 == 24 )
+  {
+    v3 = v2->evt_F;
+LABEL_84:
+    if ( v3 < 200 || v3 > 310 )
+    {
+      if ( v3 < 400 || v3 > 410 )
+      {
+        if ( v3 == 139 )
         {
           sub_4B1ECE();
         }
         else
         {
-          if ( pEventNumber == 311 )
+          if ( v3 == 311 )
           {
             sub_4BBA85_bounties();
           }
@@ -9453,32 +9465,32 @@
           {
             ptr_F8B1E8 = 0;
             _5C3420_pDecoration = (LevelDecoration *)1;
-            EventProcessor(pEventNumber, 0, 1);
+            EventProcessor(v3, 0, 1);
             _5C3420_pDecoration = 0;
           }
         }
       }
       else
       {
-        dword_F8B1D8 = uMessageParam;
-        DrawJoinGuildWindow(pEventNumber - 400);
+        dword_F8B1D8 = v1;
+        sub_4B3EF0(v3 - 400);
       }
     }
     else
     {
-      sub_4B3FE5(pEventNumber);
+      sub_4B3FE5(v3);
     }
     goto _return;
-  
-  if ( uMessageParam != 76 )
-  {
-    if ( uMessageParam == 77 )
-    {
-      v16 = pCurrentNPCInfo->uProfession;
+  }
+  if ( a1 != 76 )
+  {
+    if ( a1 == 77 )
+    {
+      v16 = v2->uProfession;
       if (dialogue_show_profession_details)
-        v17 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pJoinText;
+        v17 = pNPCStats->pProfessions[v2->uProfession - 1].pJoinText;
       else
-        v17 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pBenefits;
+        v17 = pNPCStats->pProfessions[v2->uProfession - 1].pBenefits;
       ptr_F8B1E8 = v17;
       v18 = BuilDialogueString(v17, uActiveCharacter - 1, 0, 0, 0, 0);
       dialogue_show_profession_details = ~dialogue_show_profession_details;
@@ -9486,7 +9498,7 @@
     }
     else
     {
-      if ( uMessageParam == 79 )
+      if ( a1 == 79 )
       {
         if ( dword_F8B1A8 )
         {
@@ -9524,7 +9536,7 @@
       }
       else
       {
-        if ( uMessageParam == 82 && dword_F8B1A8 )
+        if ( a1 == 82 && dword_F8B1A8 )
         {
           Party::TakeGold(gold_transaction_amount);
           v4 = pParty->pPlayers;
@@ -9537,36 +9549,36 @@
           switch ( dword_F8B1D8 )
           {
             case 19:
-              v10 = pCurrentNPCInfo->evt_A;
+              v10 = v2->evt_A;
               if ( (signed int)v10 >= 400 && (signed int)v10 <= 416 )
-                pCurrentNPCInfo->evt_A = 0;
+                v2->evt_A = 0;
               break;
             case 20:
-              v9 = pCurrentNPCInfo->evt_B;
+              v9 = v2->evt_B;
               if ( v9 >= 400 && v9 <= 416 )
-                pCurrentNPCInfo->evt_B = 0;
+                v2->evt_B = 0;
               break;
             case 21:
-              v8 = pCurrentNPCInfo->evt_C;
+              v8 = v2->evt_C;
               if ( v8 >= 400 && v8 <= 416 )
-                pCurrentNPCInfo->evt_C = 0;
+                v2->evt_C = 0;
               break;
             case 22:
-              v7 = pCurrentNPCInfo->evt_D;
+              v7 = v2->evt_D;
               if ( v7 >= 400 && v7 <= 416 )
-                pCurrentNPCInfo->evt_D = 0;
+                v2->evt_D = 0;
               break;
             case 23:
-              v6 = pCurrentNPCInfo->evt_E;
+              v6 = v2->evt_E;
               if ( v6 >= 400 && v6 <= 416 )
-                pCurrentNPCInfo->evt_E = 0;
+                v2->evt_E = 0;
               break;
             case 24:
-              v5 = pCurrentNPCInfo->evt_F;
+              v5 = v2->evt_F;
               if ( v5 >= 400 )
               {
                 if ( v5 <= 416 )
-                  pCurrentNPCInfo->evt_F = 0;
+                  v2->evt_F = 0;
               }
               break;
           }
@@ -9600,15 +9612,15 @@
     goto _return;
   }
   //v20 = v2->uProfession;
-  if ( pCurrentNPCInfo->uProfession != 51 )
-  {
-    v21 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].uHirePrice;
+  if ( v2->uProfession != 51 )
+  {
+    v21 = pNPCStats->pProfessions[v2->uProfession - 1].uHirePrice;
     if ( pParty->uNumGold < v21 )
     {
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
       dialogue_show_profession_details = false;
       uDialogueType = 13;
-      ptr_F8B1E8 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pJoinText;
+      ptr_F8B1E8 = pNPCStats->pProfessions[v2->uProfession - 1].pJoinText;
       ptr_F8B1E8 = BuilDialogueString((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0);
       if ( uActiveCharacter )
         pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0);
@@ -9618,19 +9630,19 @@
     Party::TakeGold(v21);
   }
   //LOBYTE(v2->uFlags) |= 0x80u;
-  pCurrentNPCInfo->uFlags = 128;
+  v2->uFlags = 128;
   pParty->field_709 = 0;
   sub_44A56A();
   if ( pParty->pHirelings[0].pName )
   {
-    memcpy(&pParty->pHirelings[1], pCurrentNPCInfo, sizeof(pParty->pHirelings[1]));
-    v24 = pCurrentNPCInfo->pName;
+    memcpy(&pParty->pHirelings[1], v2, sizeof(pParty->pHirelings[1]));
+    v24 = v2->pName;
     v22 = pParty->pHireling2Name;
   }
   else
   {
-    memcpy(pParty->pHirelings, pCurrentNPCInfo, 0x4Cu);
-    v24 = pCurrentNPCInfo->pName;
+    memcpy(pParty->pHirelings, v2, 0x4Cu);
+    v24 = v2->pName;
     v22 = pParty->pHireling1Name;
   }
   strcpy(v22, v24);
@@ -9990,14 +10002,23 @@
 
 
 //----- (004B29F2) --------------------------------------------------------
-const char *__fastcall ContractSelectText(int pEventNumber)
-{
+const char *__fastcall sub_4B29F2(int a1)
+{
+  int v1; // esi@1
+  Player *v2; // edi@1
+  int v3; // eax@1
+  Player *v4; // ecx@1
+
+  v1 = a1;
   dword_F8B1A8 = 0;
-  dword_F8B1AC_something_todo_with_awards = pEventNumber + 50;
-  gold_transaction_amount = dword_4F08EC[pEventNumber];
-  if ( pPlayers[uActiveCharacter]->CanAct() )
-  {
-    if ( (unsigned __int16)_449B57_test_bit((unsigned __int8 *)pPlayers[uActiveCharacter]->field_152, dword_F8B1AC_something_todo_with_awards) )
+  v2 = pPlayers[uActiveCharacter];
+  v3 = a1 + 50;
+  v4 = pPlayers[uActiveCharacter];
+  dword_F8B1AC_something_todo_with_awards = v3;
+  gold_transaction_amount = dword_4F08EC[v1];
+  if ( v4->CanAct() )
+  {
+    if ( (unsigned __int16)_449B57_test_bit((unsigned __int8 *)v2->field_152, dword_F8B1AC_something_todo_with_awards) )
     {
       return pNPCTopics[123].pText;
     }
@@ -10006,7 +10027,7 @@
       if ( gold_transaction_amount <= pParty->uNumGold )
       {
         dword_F8B1A8 = 1;
-        return pNPCTopics[pEventNumber + 110].pText;
+        return pNPCTopics[v1 + 110].pText;
       }
       else
       {
@@ -10022,7 +10043,7 @@
 
 
 //----- (004B2A74) --------------------------------------------------------
-char __cdecl SimpleHouseAndBoatsDialog()
+char __cdecl SimpleHouseDialog()
 {
   char *v0; // esi@3
   char *v1; // ST1C_4@3
@@ -10084,7 +10105,7 @@
   NPCData *v58; // [sp+118h] [bp-4h]@6
 
   memcpy(&a1, pDialogueWindow, sizeof(a1));
-  if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic )
+  if ( array_5913D8[6] == (NPCData *)uNumDialogueNPCPortraits && uHouse_ExitPic )
   {
     v0 = pMapStats->pInfos[uHouse_ExitPic].pName;
     v1 = pMapStats->pInfos[uHouse_ExitPic].pName;
@@ -10108,7 +10129,7 @@
   }
   a1.uFrameWidth -= 10;
   a1.uFrameZ -= 10;
-  v58 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)];
+  v58 = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)];
   v6 = v58;
   v55 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
   v7 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u);
@@ -10183,7 +10204,7 @@
         v27 = v26 - 3;
         if ( !v27 )
         {
-          v33 = (char *)ContractSelectText((int)v52.ptr_1C);
+          v33 = (char *)sub_4B29F2((int)v52.ptr_1C);
           goto LABEL_44;
         }
         v28 = v27 - 1;
@@ -11040,20 +11061,42 @@
 }
 
 //----- (004B3EF0) --------------------------------------------------------
-void __fastcall DrawJoinGuildWindow(int pEventNumber)
-{
-  //int v1; // edi@1
-
-  //v1 = a4;
+void __fastcall sub_4B3EF0(int a4)
+{
+  int v1; // edi@1
+
+  v1 = a4;
   uDialogueType = 81;
-  ptr_F8B1E8 = (char *)pNPCTopics[pEventNumber + 99].pText;
-  ContractSelectText(pEventNumber);
+  ptr_F8B1E8 = (char *)pNPCTopics[a4 + 99].pText;
+  sub_4B29F2(a4);
   pDialogueWindow->Release();
-  pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15E, WINDOW_MainMenu, pEventNumber, 0);
-  pBtn_ExitCancel = pDialogueWindow->CreateButton(0x1D7, 0x1BD, 0xA9, 0x23, 1, 0, 0x71, 0, 0, pGlobalTXT_LocalizationStrings[34],
-                 (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0);
+  pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15E, WINDOW_MainMenu, v1, 0);
+  pBtn_ExitCancel = pDialogueWindow->CreateButton(
+                 0x1D7,
+                 0x1BD,
+                 0xA9,
+                 0x23,
+                 1,
+                 0,
+                 0x71,
+                 0,
+                 0,
+                 pGlobalTXT_LocalizationStrings[34],
+                 (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0),
+                 0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0);
-  pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0xAFu, 0x52u, 0, pGlobalTXT_LocalizationStrings[122], 0);
+  pDialogueWindow->CreateButton(
+    0x1E0u,
+    0xA0u,
+    0x8Cu,
+    0x1Eu,
+    1,
+    0,
+    0xAFu,
+    0x52u,
+    0,
+    pGlobalTXT_LocalizationStrings[122],
+    0);
   pDialogueWindow->_41D08F(1, 1, 0, 2);
   dword_F8B19C = -1;
 }
@@ -11102,7 +11145,7 @@
   NPCData *v1; // edi@1
 
   v0 = 0;
-  v1 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)];
+  v1 = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)];
   pDialogueWindow->Release();
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, 0, 0);
   pBtn_ExitCancel = pDialogueWindow->CreateButton(
@@ -11167,7 +11210,7 @@
   NPCData *v17; // [sp+10h] [bp-4h]@4
 
   num_menu_buttons = 0;
-  pDialogueNPCCount = (_this + 1);
+  array_5913D8[6] = (NPCData *)(_this + 1);
   if ( _this + 1 == uNumDialogueNPCPortraits && uHouse_ExitPic )
   {
     pDialogueWindow->Release();
@@ -11184,7 +11227,7 @@
   }
   else
   {
-    v17 = HouseNPCData[_this + 1 - ((dword_591080 != 0) + 1)];
+    v17 = array_5913D8[_this + 1 - ((dword_591080 != 0) + 1)];
     if ( dword_F8B19C == -1 )
     {
       pDialogueWindow->Release();
@@ -11192,14 +11235,14 @@
     else
     {
       for ( i = 0; i < uNumDialogueNPCPortraits; ++i )
-        GUIButton::_41D0D8((GUIButton *)HouseNPCData[i + 7]);
+        GUIButton::_41D0D8((GUIButton *)array_5913D8[i + 7]);
     }
     pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0);
     pBtn_ExitCancel = pDialogueWindow->CreateButton(  471u,  445u,  169u, 35u,  1,   0, 0x71u,  0,  0,
                    pGlobalTXT_LocalizationStrings[74],// "End Conversation"
                    (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0),   0);
     pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, "", 0);
-    if ( pDialogueNPCCount == 1 && dword_591080 )
+    if ( array_5913D8[6] == (NPCData *)1 && dword_591080 )
     {
       sub_4B3B42(dword_F8B198);
     }
@@ -12167,7 +12210,8 @@
   {
     do
     {
-      if ( pParty->field_777C[9 * (v49 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
+     // if ( pParty->field_777C[9 * (v49 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
+	 if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v49].uItemID);
       {
         v50 = dword_F8B168[v49];
         v51 = 152 - v50->uTextureHeight;
@@ -12199,7 +12243,8 @@
     v122 = 0;
     do
     {
-      if ( pParty->field_777C[9 * (v122 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] )
+      //if ( pParty->field_777C[9 * (v122 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] )
+	if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v122+1].uItemID);
       {
         v54 = dword_F8B168[v122 + 6];
         v55 = 306 - v54->uTextureHeight;
@@ -12229,7 +12274,8 @@
   {
     do
     {
-      if ( pParty->field_C59C[9 * (v49 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+     // if ( pParty->field_C59C[9 * (v49 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+	if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v49].uItemID)
       {
         v58 = dword_F8B168[v49];
         v59 = 152 - v58->uTextureHeight;
@@ -12261,7 +12307,8 @@
     v122 = 0;
     do
     {
-      if ( pParty->field_C59C[9 * (v122 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 778] )
+      //if ( pParty->Spell_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v49] + 778] )  //weak
+		if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v49].uAttributes)
       {
         v62 = dword_F8B168[v122 + 6];
         v63 = 306 - v62->uTextureHeight;
@@ -12298,7 +12345,7 @@
     {
       do
       {
-        if ( pParty->field_777C[9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
+        if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID); //9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
           ++v117;
         ++v66;
       }
@@ -12308,7 +12355,8 @@
     {
       do
       {
-        if ( pParty->field_C59C[9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+        //if ( pParty->field_C59C[9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
+	  if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID)
           ++v117;
         ++v66;
       }
@@ -12341,10 +12389,11 @@
       v71 = (pRenderer->pActiveZBuffer[result] & 0xFFFF) - 1;
       v117 = v71;
       v72 = (int)window_SpeakInHouse->ptr_1C;
-      v73 = 9 * (v71 + 12 * v72);
-      v74 = (ItemGen *)&pParty->field_777C[v73];
+     // v73 = 9 * (v71 + 12 * v72);
+      v74 = (ItemGen *)&pParty->field_777C[v72][v71];
       if ( dword_F8B19C != 2 )
-        v74 = (ItemGen *)&pParty->field_C59C[v73 + 724];
+       // v74 = (ItemGen *)&pParty->field_C59C[v73 + 724];
+	      v74 =&pParty->Recipes_Item[v72][v71];
       if ( v67 && Str )
       {
         v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24"
@@ -12377,7 +12426,7 @@
   //unsigned int v1; // esi@1
   NPCData *v2; // ebp@1
   //unsigned int v3; // eax@1
-  int pEventNumber; // ecx@10
+  int v4; // ecx@10
   signed int v5; // edi@14
   char *v6; // esi@15
   const char *v7; // ecx@22
@@ -12403,12 +12452,12 @@
   {
     if ( newDialogueType == DIALOGUE_23 )
     {
-      pEventNumber = v2->evt_E;
+      v4 = v2->evt_E;
       goto LABEL_74;
     }
     if (newDialogueType == DIALOGUE_24)
     {
-      pEventNumber = v2->evt_F;
+      v4 = v2->evt_F;
       goto LABEL_74;
     }
     if (newDialogueType != DIALOGUE_76)
@@ -12530,7 +12579,7 @@
   }
   if (newDialogueType == DIALOGUE_22)
   {
-    pEventNumber = v2->evt_D;
+    v4 = v2->evt_D;
     goto LABEL_74;
   }
   if (newDialogueType == DIALOGUE_9)
@@ -12579,23 +12628,23 @@
   }
   if (newDialogueType == DIALOGUE_19)
   {
-    pEventNumber = v2->evt_A;
+    v4 = v2->evt_A;
     goto LABEL_74;
   }
   if (newDialogueType == DIALOGUE_20)
   {
-    pEventNumber = v2->evt_B;
+    v4 = v2->evt_B;
     goto LABEL_74;
   }
   if (newDialogueType == DIALOGUE_21)
   {
-    pEventNumber = v2->evt_C;
+    v4 = v2->evt_C;
 LABEL_74:
-    if ( pEventNumber < 200 || pEventNumber > 310 )
-    {
-      if ( pEventNumber < 400 || pEventNumber > 410 )
-      {
-        switch ( pEventNumber )
+    if ( v4 < 200 || v4 > 310 )
+    {
+      if ( v4 < 400 || v4 > 410 )
+      {
+        switch ( v4 )
         {
           case 139:
             sub_4B1ECE();
@@ -12609,7 +12658,7 @@
           default:
             _5C3420_pDecoration = (LevelDecoration *)1;
             ptr_F8B1E8 = 0;
-            EventProcessor(pEventNumber, 0, 1);
+            EventProcessor(v4, 0, 1);
             _5C3420_pDecoration = 0;
             break;
         }
@@ -12617,12 +12666,12 @@
       else
       {
         dword_F8B1D8 = newDialogueType;
-        DrawJoinGuildWindow(pEventNumber - 400);
+        sub_4B3EF0(v4 - 400);
       }
     }
     else
     {
-      sub_4B3FE5(pEventNumber);
+      sub_4B3FE5(v4);
     }
   }
 LABEL_87:
@@ -13441,7 +13490,7 @@
 
 
 //----- (004B8F94) --------------------------------------------------------
-void *__cdecl sub_4B8F94()
+void  sub_4B8F94()
 {
   GUIWindow *v0; // edi@1
   signed int v1; // ebp@1
@@ -13491,18 +13540,21 @@
 LABEL_12:
           v6 = v12;
 LABEL_13:
-          pItemsTable->GenerateItem(v5, v6, (ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724]);
+          pItemsTable->GenerateItem(v5, v6,&pParty->Recipes_Item[v3][v1]);//(ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724]);
           v0 = window_SpeakInHouse;
           v2 = (int)&window_SpeakInHouse->ptr_1C;
-          pParty->field_C59C[9 * (v1 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 729] = 1;
+         // pParty->field_C59C[9 * (v1 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 729] = 1;
+		  pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uAttributes= 1;
           goto LABEL_14;
         }
-        auto _a = (ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724];
+       // auto _a = (ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724];
+		 auto _a =&pParty->Recipes_Item[v3][v1];
         _a->Reset();
-        v2 = (int)&v0->ptr_1C;
-        v10 = rand();
-        v0 = window_SpeakInHouse;
-        pParty->field_C59C[9 * (v1 + 12 * *(int *)v2) + 724] = v10 % 32 + 740;
+	//	v2 = (int)&v0->ptr_1C;
+		//v10 = rand();
+	//	v0 = window_SpeakInHouse;
+       // pParty->field_C59C[9 * (v1 + 12 * *(int *)v2) + 724] = v10 % 32 + 740;
+		   pParty->Recipes_Item[(int)v0->ptr_1C][v1].uItemID= rand() % 32 + 740;
       }
 LABEL_14:
       v3 = *(int *)v2;
@@ -13519,8 +13571,7 @@
   }
 LABEL_15:
   result = v0->ptr_1C;
-  *(int *)&pParty->field_16154[4 * (int)result] = 0;
-  return result;
+  pParty->field_16154[(int)v0->ptr_1C] = 0;
 }
 
 
@@ -14785,7 +14836,7 @@
         //if ( !(*(char *)v6 & 0x80) )
       {
         v7 = uNumDialogueNPCPortraits++ - dword_591080 ? 1 : 0;
-        HouseNPCData[v7] = npc;
+        array_5913D8[v7] = npc;
         //v6 = v17;
         //*(&v13 + v2) = *(v17 - 1);
         Dst[uNumDialogueNPCPortraits - 1] = npc->uPortraitID;
@@ -14999,14 +15050,14 @@
     }
 
     v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-    pDialogueNPCCount = 0;
+    array_5913D8[6] = 0;
     pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v17];
     uTextureID_507B04 = uTextureID_right_panel;
     PrepareHouse(uHouseID);
     v18 = 1;
     uTextureID_507B04 = uTextureID_right_panel;
     if ( uNumDialogueNPCPortraits == 1 )
-      pDialogueNPCCount = 1;
+      array_5913D8[6] = (NPCData *)1;
     pVideoPlayer->_4BF28F(pAnimatedRooms[uCurrentHouse_Animation].field_0, 1u);
     if ( (signed int)uHouseID < 139 || (signed int)uHouseID > 172 )
     {
--- a/mm7_6.cpp	Sun Feb 24 20:39:03 2013 +0600
+++ b/mm7_6.cpp	Sun Feb 24 20:42:44 2013 +0600
@@ -2359,7 +2359,7 @@
       }
       ++v15;
     }
-    while ( (signed int)v15 < (signed int)&unk_50C190 );
+    while (v15 < pStru277 + 10);
     int result = pStru277->PushStru277(a2a, a3a, a4, v6, a6);
     if ( result != -1 )
     {
--- a/mm7_data.cpp	Sun Feb 24 20:39:03 2013 +0600
+++ b/mm7_data.cpp	Sun Feb 24 20:42:44 2013 +0600
@@ -1660,7 +1660,9 @@
 
 __int16 word_4F0578[777]; // weak
 __int16 word_4F05AE[777]; // weak
-char _4F063C_smthn_by_2da_uType[777]; // weak
+char _4F063C_smthn_by_2da_uType[31]={ // weak
+0, 6, 8, 12, 12, 0, 0, 0, 0, 0, 0, 0, 2, 0, 25, 0, 30,
+0, 20, 0, 20, 0, 2, 0, 23, 0, 24, 0, 28, 0, 20};
 __int16 word_4F063E[290];
 __int16 word_4F06D8[22];
 __int16 word_4F0704[40];
--- a/mm7_data.h	Sun Feb 24 20:39:03 2013 +0600
+++ b/mm7_data.h	Sun Feb 24 20:42:44 2013 +0600
@@ -2331,7 +2331,7 @@
 void __cdecl _4B7D7E_bank();
 void __cdecl TavernDialog();
 void *__cdecl GenerateShopItems();
-void *__cdecl sub_4B8F94();
+void sub_4B8F94();
 char *__cdecl WeaponShopDialog();
 POINT *__cdecl AlchemistDialog();
 void __cdecl ArmorShopDialog();