diff mm7_4.cpp @ 361:b803545c1b96

Слияние
author Ritor1
date Thu, 21 Feb 2013 22:42:52 +0600
parents 90017057667f 4a236657a0be
children 7f817679b60e c1a45052d634
line wrap: on
line diff
--- a/mm7_4.cpp	Thu Feb 21 22:42:35 2013 +0600
+++ b/mm7_4.cpp	Thu Feb 21 22:42:52 2013 +0600
@@ -2,6 +2,8 @@
 #include <direct.h>
 #include <assert.h>
 
+#include "MM7.h"
+
 #include "MapInfo.h"
 #include "Game.h"
 #include "GUIWindow.h"
@@ -3726,29 +3728,26 @@
 
 
 //----- (00493F79) --------------------------------------------------------
-int sub_493F79(stru351 *_this, __int64 a2)
+void sub_493F79(stru351_summoned_item *_this, __int64 a2)
 {
   signed __int64 v2; // ST2C_8@1
   signed __int64 v3; // qax@1
-  signed __int64 v4; // ST1C_8@1
+  //signed __int64 v4; // ST1C_8@1
   unsigned __int64 v5; // qax@1
   unsigned int v6; // ebx@1
-  int result; // eax@1
 
   v2 = (signed __int64)((double)a2 * 0.234375);
   v3 = v2 / 60 / 60;
-  v4 = v3;
+  //v4 = v3;
   v5 = (unsigned int)v3 / 0x18;
   v6 = (unsigned int)(v5 / 7) >> 2;
-  _this->field_0 = v2 % 60;
-  _this->field_4 = v2 / 60 % 60;
-  _this->field_8 = v4 % 24;
-  _this->field_10 = v5 / 7 & 3;
-  _this->field_C = (unsigned int)v5 % 0x1C;
-  result = v6 / 0xC + 1168;
-  _this->field_14 = v6 % 0xC;
-  _this->field_18 = result;
-  return result;
+  _this->field_0_expire_second = v2 % 60;
+  _this->field_4_expire_minute = v2 / 60 % 60;
+  _this->field_8_expire_hour = v3 % 24;
+  _this->field_10_expire_week = v5 / 7 & 3;
+  _this->field_C_expire_day = (unsigned int)v5 % 0x1C;
+  _this->field_14_exprie_month = v6 % 0xC;
+  _this->field_18_expire_year = v6 / 0xC + game_starting_year;
 }
 
 
@@ -3841,7 +3840,7 @@
   pParty->uCurrentHour = v2 % 24;
   pParty->uDaysPlayed = (unsigned int)v3 % 28;
   pParty->uCurrentMonth = v4 % 12;
-  pParty->uCurrentYear = v4 / 0xC + 1168;
+  pParty->uCurrentYear = v4 / 0xC + game_starting_year;
   if ( pParty->uCurrentHour >= 3 && ((signed int)a2 < 3 || (unsigned int)v3 % 28 > v61) )
   {
     pParty->pHirelings[0].bHasUsedTheAbility = false;
@@ -4887,8 +4886,8 @@
   int v53; // [sp-4h] [bp-13Ch]@107
   int v54; // [sp+0h] [bp-138h]@107
   __int16 v55[56]; // [sp+10h] [bp-128h]@34
-  stru351 v56; // [sp+80h] [bp-B8h]@107
-  stru351 v57; // [sp+9Ch] [bp-9Ch]@115
+  stru351_summoned_item v56; // [sp+80h] [bp-B8h]@107
+  stru351_summoned_item v57; // [sp+9Ch] [bp-9Ch]@115
   char a1[100]; // [sp+B8h] [bp-80h]@3
   unsigned int v59; // [sp+11Ch] [bp-1Ch]@3
   //size_t v60; // [sp+120h] [bp-18h]@3
@@ -5237,9 +5236,9 @@
                 if ( !a6 )
       goto _continue_strcat;
     sub_493F79(&v57, *a6);
-    v54 = v57.field_18;
-    v53 = v57.field_C + 1;
-    v50 = v57.field_14;
+    v54 = v57.field_18_expire_year;
+    v53 = v57.field_C_expire_day + 1;
+    v50 = v57.field_14_exprie_month;
     sprintf(a1, pGlobalTXT_LocalizationStrings[378], aMonthNames[v50], v53, v54);
     v11 = a1;
     goto _continue_strcat;
@@ -5261,9 +5260,9 @@
             HIDWORD(v49) = pParty->field_3C.field_440[2 * v17 + 1];
             LODWORD(v49) = pParty->field_3C.field_440[2 * v17];
             sub_493F79(&v56, v49);
-            v54 = v56.field_18;
-            v53 = v56.field_C + 1;
-            v50 = v56.field_14;
+            v54 = v56.field_18_expire_year;
+            v53 = v56.field_C_expire_day + 1;
+            v50 = v56.field_14_exprie_month;
             sprintf(a1, pGlobalTXT_LocalizationStrings[378], aMonthNames[v50], v53, v54);
             v11 = a1;
             goto _continue_strcat;
@@ -9063,7 +9062,7 @@
 //----- (004B1A2D) --------------------------------------------------------
 void __cdecl sub_4B1A2D()
 {
-  Player *v0; // edi@1
+  //Player *v0; // edi@1
   POINT *v1; // esi@5
   unsigned int v2; // eax@5
   int v3; // ecx@5
@@ -9083,7 +9082,7 @@
   POINT a2; // [sp+40h] [bp-Ch]@5
   int v18; // [sp+48h] [bp-4h]@5
 
-  v0 = pPlayers[uActiveCharacter];
+  //v0 = pPlayers[uActiveCharacter];
   if ( dword_F8B198 <= 0 )
     return;
   if ( dword_F8B198 <= 4 )
@@ -9098,9 +9097,9 @@
         v18 = (v8 >> 5) + 14 * ((pMouse->GetCursorPos((POINT *)&v14)->y - 17) >> 5);
         if ( pMouse->GetCursorPos((POINT *)&v13)->x <= 13
           || pMouse->GetCursorPos((POINT *)&v12)->x >= 462
-          || (v9 = v0->GetItemIDAtInventoryIndex(&v18)) == 0 )
+          || (v9 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&v18)) == 0 )
           return;
-        v7 = (ItemGen *)&v0->pInventoryItems[v9-1];
+        v7 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v9-1];
 LABEL_15:
         GameUI_DrawItemInfo(v7);
         return;
@@ -9113,7 +9112,7 @@
     v18 = v5;
     if ( !v5 )
       return;
-    v6 = 9 * (v5 + 12 * (unsigned int)ptr_507BC0->ptr_1C);
+    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];
@@ -9126,7 +9125,7 @@
     v3 = pRenderer->pActiveZBuffer[v2] & 0xFFFF;
     v18 = pRenderer->pActiveZBuffer[v2] & 0xFFFF;
     if ( v18 )
-      sub_4B1523((int *)&pParty->pPlayers[1].uExpressionTimeLength + 9 * (v3 + 12 * (unsigned int)ptr_507BC0->ptr_1C));
+      sub_4B1523((int *)&pParty->pPlayers[1].uExpressionTimeLength + 9 * (v3 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C));
   }
 }
 // F8B198: using guessed type int dword_F8B198;
@@ -9156,7 +9155,7 @@
   pParty->uCurrentMonthWeek = v4 / 7 & 3;
   pParty->uDaysPlayed = (unsigned int)v4 % 0x1C;
   pParty->uCurrentMonth = v5 % 0xC;
-  pParty->uCurrentYear = v5 / 0xC + 1168;
+  pParty->uCurrentYear = v5 / 0xC + game_starting_year;
   pParty->RestAndHeal();
   dword_507B94 = 1;
   v6 = pParty->pPlayers;//[0].uNumDivineInterventionCastsThisDay;
@@ -9198,12 +9197,12 @@
         if ( dword_F8B198 != 23 )
           return;
       }
-      v1 = (unsigned int)ptr_507BC0->ptr_1C;
+      v1 = (unsigned int)window_SpeakInHouse->ptr_1C;
 LABEL_28:
       HousePlaySomeSound(v1, v0);
       return;
     }
-    v1 = (unsigned int)ptr_507BC0->ptr_1C;
+    v1 = (unsigned int)window_SpeakInHouse->ptr_1C;
     if ( (signed __int64)__PAIR__(pParty->field_3C._shop_ban_times[2 * v1 + 1], pParty->field_3C._shop_ban_times[2 * v1]) <= (signed __int64)pParty->uTimePlayed )
     {
       if ( pParty->uNumGold <= 0x2710 )
@@ -9649,7 +9648,7 @@
   strcpy(v22, v24);
   pParty->field_709 = 0;
   sub_44A56A();
-  PrepareHouse((unsigned int)ptr_507BC0->ptr_1C);
+  PrepareHouse((HOUSE_TYPE)(int)window_SpeakInHouse->ptr_1C);
   dword_F8B19C = 1;
   if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
   {
@@ -10170,7 +10169,7 @@
   v56 = v52.pStartingPosActiveItem;
   if ( v52.pStartingPosActiveItem < v52.pStartingPosActiveItem + v52.pNumPresenceButton )
   {
-    v15 = (char *)v54;
+    v15 = "";//(char *)v54;
     while ( 1 )
     {
       v16 = v52.GetControl(v56);
@@ -10444,7 +10443,7 @@
       v19 = 1;
       do
       {
-        v20 = (char *)ptr_507BC0->ptr_1C + 4 * (unsigned int)ptr_507BC0->ptr_1C + v19;
+        v20 = (char *)window_SpeakInHouse->ptr_1C + 4 * (unsigned int)window_SpeakInHouse->ptr_1C + v19;
         if ( v1 )
           v21 = word_4F063E[(signed int)v20];
         else
@@ -10524,7 +10523,7 @@
         v12 = 1;
         do
         {
-          v13 = v11 + 2 * (unsigned int)ptr_507BC0->ptr_1C - 30;
+          v13 = v11 + 2 * (unsigned int)window_SpeakInHouse->ptr_1C - 30;
           v14 = v12 + 4 * v13 + v13;
           if ( v10 )
             v15 = word_4F06D8[v14];
@@ -10924,7 +10923,7 @@
           sub_4B36CC(1, 0x10u);
           v4 = 3;
           sub_4B36CC(2, 0x60u);
-          v5 = (signed int)ptr_507BC0->ptr_1C;
+          v5 = (signed int)window_SpeakInHouse->ptr_1C;
           if ( v5 < 108 || v5 > 120 )
             goto LABEL_28;
           v4 = 4;
@@ -11544,7 +11543,7 @@
   int v73; // [sp+80h] [bp-4h]@14
 
   v0 = pPlayers[uActiveCharacter];
-  memcpy(&v65, ptr_507BC0, sizeof(v65));
+  memcpy(&v65, window_SpeakInHouse, sizeof(v65));
   v65.uFrameX = 483;
   v65.uFrameWidth = 148;
   v65.uFrameZ = 334;
@@ -11558,7 +11557,7 @@
     v3 += v4 + 1;
   v5 = 1000 * v3;
   v6 = HIDWORD(v0->uExperience);
-  v7 = ptr_507BC0->ptr_1C;
+  v7 = window_SpeakInHouse->ptr_1C;
   v68 = (unsigned __int16)word_4F0866[(signed int)v7];
   v66 = 1000 * v3;
   if ( (signed __int64)__PAIR__(v6, LODWORD(v0->uExperience)) >= v66 )
@@ -11592,7 +11591,7 @@
             i = 0;
             v13 = pDialogueWindow;
             //v14 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0);
-            v14 = (signed __int64)(p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].flt_24 * 500.0);
+            v14 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0);
             v73 = v14 * (100 - v0->GetMerchant()) / 100;
             if ( v73 < v14 / 3 )
               v73 = v14 / 3;
@@ -11695,7 +11694,7 @@
           if ( pParty->uNumGold >= i )
           {
             Party::TakeGold(i);
-            HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 2);
+            HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
             ++v0->uLevel;
             v0->uSkillPoints += v0->uLevel / 10 + 5;
             v0->sHealth = v0->GetMaxHealth();
@@ -11714,7 +11713,7 @@
             if ( *v39 > v37 )
             {
               v40 = sub_494820(pParty->uCurrentHour);
-              v41 = ptr_507BC0->ptr_1C;
+              v41 = window_SpeakInHouse->ptr_1C;
               v42 = 60 * (v40 + 4) - pParty->uCurrentMinute;
               if ( v41 == (void *)94 || v41 == (void *)95 )
                 v42 += 720;
@@ -11731,7 +11730,7 @@
           ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold"
           v63 = 4;
 LABEL_55:
-          HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, v63);
+          HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, v63);
 LABEL_56:
           result = pMessageQueue_50CBD0->uNumMessages;
           if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
@@ -11990,7 +11989,7 @@
 
   v0 = pPlayers[uActiveCharacter];
   _this = pPlayers[uActiveCharacter];
-  memcpy(&v112, ptr_507BC0, sizeof(v112));
+  memcpy(&v112, window_SpeakInHouse, sizeof(v112));
   v112.uFrameX = 483;
   v112.uFrameWidth = 148;
   v112.uFrameZ = 334;
@@ -12060,7 +12059,7 @@
         {
           v31 = pDialogueWindow;
           v3 = 0;
-          v32 = ptr_507BC0->ptr_1C;
+          v32 = window_SpeakInHouse->ptr_1C;
           v118 = 0;
             //v33 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (signed int)v32] * 500.0);
             v33 = (signed __int64)(p2DEvents[(signed int)v32 - 1].flt_24 * 500.0);
@@ -12171,9 +12170,9 @@
         return result;
       v96 = 0;
       v94 = 5;
-      v93 = ptr_507BC0->ptr_1C;
+      v93 = window_SpeakInHouse->ptr_1C;
       v90 = (ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5];
-      v28 = (int)ptr_507BC0->ptr_1C;
+      v28 = (int)window_SpeakInHouse->ptr_1C;
       uPlayerID = uActiveCharacter - 1;
       v29 = _this->_490EEE((ItemGen *)&_this->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5], 3, v28, 5);
       v9 = uPlayerID;
@@ -12265,16 +12264,16 @@
                   v4 = (char *)&_this->pInventoryItems[result-1];
                   if ( v4[20] & 1 )
                   {
-                    v5 = BuilDialogueString("%24", uActiveCharacter - 1, (ItemGen *)v4, (char *)ptr_507BC0->ptr_1C, 4, 0);
+                    v5 = BuilDialogueString("%24", uActiveCharacter - 1, (ItemGen *)v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0);
                     v97 = 3;
                     v95 = v5;
                     v92 = white;
                     v6 = (212 - pFontArrus->CalcTextHeight(v5, &v112, 0, 0)) / 2 + 101;
                     return (int)v112.DrawTitleText(pFontArrus, v3, v6, v92, v95, v97);
                   }
-                  v93 = ptr_507BC0->ptr_1C;
+                  v93 = window_SpeakInHouse->ptr_1C;
                   v90 = (ItemGen *)v4;
-                  v7 = (int)ptr_507BC0->ptr_1C;
+                  v7 = (int)window_SpeakInHouse->ptr_1C;
                   uPlayerID = uActiveCharacter - 1;
                   v8 = ((Player *)_this)->_490EEE((ItemGen *)v4, 3, v7, 4);
                   v9 = uPlayerID;
@@ -12301,9 +12300,9 @@
         return result;
       v96 = 0;
       v94 = 3;
-      v93 = ptr_507BC0->ptr_1C;
+      v93 = window_SpeakInHouse->ptr_1C;
       v90 = (ItemGen *)&_this->pInventoryItems[result-1];
-      v12 = (int)ptr_507BC0->ptr_1C;
+      v12 = (int)window_SpeakInHouse->ptr_1C;
       uPlayerID = uActiveCharacter - 1;
       v13 = _this->_490EEE(v90, 3, v12, 3);
       v9 = uPlayerID;
@@ -12329,7 +12328,7 @@
   {
     do
     {
-      if ( pParty->field_777C[9 * (v49 + 12 * (unsigned int)ptr_507BC0->ptr_1C)] )
+      if ( pParty->field_777C[9 * (v49 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
       {
         v50 = dword_F8B168[v49];
         v51 = 152 - v50->uTextureHeight;
@@ -12361,7 +12360,7 @@
     v122 = 0;
     do
     {
-      if ( pParty->field_777C[9 * (v122 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 54] )
+      if ( pParty->field_777C[9 * (v122 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] )
       {
         v54 = dword_F8B168[v122 + 6];
         v55 = 306 - v54->uTextureHeight;
@@ -12391,7 +12390,7 @@
   {
     do
     {
-      if ( pParty->field_C59C[9 * (v49 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 724] )
+      if ( pParty->field_C59C[9 * (v49 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
       {
         v58 = dword_F8B168[v49];
         v59 = 152 - v58->uTextureHeight;
@@ -12423,7 +12422,7 @@
     v122 = 0;
     do
     {
-      if ( pParty->field_C59C[9 * (v122 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 778] )
+      if ( pParty->field_C59C[9 * (v122 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 778] )
       {
         v62 = dword_F8B168[v122 + 6];
         v63 = 306 - v62->uTextureHeight;
@@ -12460,7 +12459,7 @@
     {
       do
       {
-        if ( pParty->field_777C[9 * (v66 + 12 * (unsigned int)ptr_507BC0->ptr_1C)] )
+        if ( pParty->field_777C[9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] )
           ++v117;
         ++v66;
       }
@@ -12470,7 +12469,7 @@
     {
       do
       {
-        if ( pParty->field_C59C[9 * (v66 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 724] )
+        if ( pParty->field_C59C[9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] )
           ++v117;
         ++v66;
       }
@@ -12493,8 +12492,8 @@
     if ( !v117 )
       return (int)v112._4B1854(
                     __PAIR__(
-                      pParty->field_3C.field_50[2 * (unsigned int)ptr_507BC0->ptr_1C + 1],
-                      pParty->field_3C.field_50[2 * (unsigned int)ptr_507BC0->ptr_1C])
+                      pParty->field_3C.field_50[2 * (unsigned int)window_SpeakInHouse->ptr_1C + 1],
+                      pParty->field_3C.field_50[2 * (unsigned int)window_SpeakInHouse->ptr_1C])
                   - pParty->uTimePlayed);
     v70 = pMouse->GetCursorPos(&v102);
     result = v70->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v100)->y];
@@ -12502,7 +12501,7 @@
     {
       v71 = (pRenderer->pActiveZBuffer[result] & 0xFFFF) - 1;
       v117 = v71;
-      v72 = (int)ptr_507BC0->ptr_1C;
+      v72 = (int)window_SpeakInHouse->ptr_1C;
       v73 = 9 * (v71 + 12 * v72);
       v74 = (ItemGen *)&pParty->field_777C[v73];
       if ( dword_F8B19C != 2 )
@@ -12512,7 +12511,7 @@
         v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24"
         v96 = 0;
         v94 = 2;
-        v93 = ptr_507BC0->ptr_1C;
+        v93 = window_SpeakInHouse->ptr_1C;
         v90 = v74;
         v9 = uActiveCharacter - 1;
       }
@@ -12520,7 +12519,7 @@
       {
         v96 = 0;
         v94 = 2;
-        v93 = ptr_507BC0->ptr_1C;
+        v93 = window_SpeakInHouse->ptr_1C;
         v90 = v74;
         uPlayerID = uActiveCharacter - 1;
         v75 = _this->_490EEE(v74, 3, v72, 2);
@@ -12927,8 +12926,8 @@
   unsigned int v62; // [sp+2E4h] [bp-8h]@13
   int v63; // [sp+2E8h] [bp-4h]@1
 
-  v0 = ptr_507BC0;
-  memcpy(&v52, ptr_507BC0, sizeof(v52));
+  v0 = window_SpeakInHouse;
+  memcpy(&v52, window_SpeakInHouse, sizeof(v52));
   v58 = pPlayers[uActiveCharacter];
   v1 = v58;
   v52.uFrameX = 483;
@@ -12964,7 +12963,7 @@
           if ( pParty->uNumGold < v63 )
           {
             ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
-            HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 2);
+            HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
           }
           else
           {
@@ -12991,7 +12990,7 @@
     v63 = 32;
     do
     {
-      if ( *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v6 + 12 * (unsigned int)ptr_507BC0->ptr_1C)) )
+      if ( *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v6 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)) )
       {
         pRenderer->DrawTextureTransparent(v63, 0x5Au, dword_F8B168[v6]);
         ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 230528), dword_F8B168[v6], v6 + 1);
@@ -13007,7 +13006,7 @@
     v63 = 32;
     do
     {
-      if ( *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v7 + 12 * (unsigned int)ptr_507BC0->ptr_1C)) )
+      if ( *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v7 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)) )
       {
         pRenderer->DrawTextureTransparent(v63, 0xFAu, dword_F8B168[v7]);
         ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 638448), dword_F8B168[v7], v7 + 1);
@@ -13023,7 +13022,7 @@
     {
       v8 = 0;
       v9 = 12;
-      v10 = (char *)(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 108 * (unsigned int)ptr_507BC0->ptr_1C);
+      v10 = (char *)(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 108 * (unsigned int)window_SpeakInHouse->ptr_1C);
       do
       {
         if ( *(int *)v10 )
@@ -13040,17 +13039,17 @@
       if ( !v8 )
         return (int)v52._4B1854(
                       __PAIR__(
-                        *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)ptr_507BC0->ptr_1C + 44472],
-                        *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)ptr_507BC0->ptr_1C + 44468])
+                        *(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);
       v12 = pMouse->GetCursorPos(&v51);
       result = v12->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v50)->y];
       v13 = pRenderer->pActiveZBuffer[result] & 0xFFFF;
       if ( pRenderer->pActiveZBuffer[result] & 0xFFFF )
       {
-        v14 = ptr_507BC0->ptr_1C;
+        v14 = window_SpeakInHouse->ptr_1C;
         v15 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v13 + 12 * (int)v14));
-        v16 = (int)ptr_507BC0->ptr_1C;
+        v16 = (int)window_SpeakInHouse->ptr_1C;
         uPlayerID = uActiveCharacter - 1;
         v17 = v1->_490EEE(
                 (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14,
@@ -13073,7 +13072,7 @@
   }
   if ( !(unsigned __int16)_449B57_test_bit(
                             (unsigned __int8 *)v1->field_152,
-                            word_4F0704[2 * (unsigned int)ptr_507BC0->ptr_1C]) )
+                            word_4F0704[2 * (unsigned int)window_SpeakInHouse->ptr_1C]) )
   {
     v36 = pNPCTopics[121].pText;
     v37 = v57;
@@ -13277,8 +13276,8 @@
   unsigned int v65; // [sp+1BCh] [bp-8h]@6
   DDM_DLV_Header *v66; // [sp+1C0h] [bp-4h]@6
 
-  v0 = ptr_507BC0;
-  memcpy(&v57, ptr_507BC0, sizeof(v57));
+  v0 = window_SpeakInHouse;
+  memcpy(&v57, window_SpeakInHouse, sizeof(v57));
   v57.uFrameX = 483;
   v57.uFrameWidth = 148;
   v57.uFrameZ = 334;
@@ -13302,7 +13301,7 @@
           {
             v4 = pDialogueWindow;
             v61 = pDialogueWindow;
-            v5 = ptr_507BC0->ptr_1C;
+            v5 = window_SpeakInHouse->ptr_1C;
             v66 = 0;
             //v65 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (signed int)v5] * 500.0);
             v65 = (signed __int64)(p2DEvents[(signed int)v5 - 1].flt_24 * 500.0);
@@ -13395,7 +13394,7 @@
         return result;
       }
       //v24 = p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C];
-      v24 = p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].fPriceMultiplier;
+      v24 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
       v25 = 0;
       if ( pParty->uNumGold >= (unsigned int)(signed __int64)v24 )
       {
@@ -13469,7 +13468,7 @@
     {
 LABEL_55:
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
-      HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 2);
+      HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
       goto LABEL_46;
     }
     Party::TakeGold(v2);
@@ -13481,7 +13480,7 @@
     memset(v1, 0, 0xA0u);
     v1->sHealth = v1->GetMaxHealth();
     v1->sMana = v1->GetMaxMana();
-    v36 = (signed int)ptr_507BC0->ptr_1C;
+    v36 = (signed int)window_SpeakInHouse->ptr_1C;
     if ( v36 != 78 && (v36 <= 80 || v36 > 82) )
     {
       if ( (unsigned int)v61 | v35 )
@@ -13615,12 +13614,12 @@
   void *result; // eax@15
   signed int v12; // [sp-4h] [bp-18h]@7
 
-  v0 = ptr_507BC0;
+  v0 = window_SpeakInHouse;
   v1 = 0;
-  v2 = (int)&ptr_507BC0->ptr_1C;
-  v3 = (signed int)ptr_507BC0->ptr_1C;
+  v2 = (int)&window_SpeakInHouse->ptr_1C;
+  v3 = (signed int)window_SpeakInHouse->ptr_1C;
   //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C]] )
-  if ( _4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].uType] )
+  if ( _4F063C_smthn_by_2da_uType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] )
   {
     while ( v3 > 14 )
     {
@@ -13650,16 +13649,16 @@
           v6 = v12;
 LABEL_13:
           pItemsTable->GenerateItem(v5, v6, (ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724]);
-          v0 = ptr_507BC0;
-          v2 = (int)&ptr_507BC0->ptr_1C;
-          pParty->field_C59C[9 * (v1 + 12 * (unsigned int)ptr_507BC0->ptr_1C) + 729] = 1;
+          v0 = window_SpeakInHouse;
+          v2 = (int)&window_SpeakInHouse->ptr_1C;
+          pParty->field_C59C[9 * (v1 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 729] = 1;
           goto LABEL_14;
         }
         auto _a = (ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724];
         _a->Reset();
         v2 = (int)&v0->ptr_1C;
         v10 = rand();
-        v0 = ptr_507BC0;
+        v0 = window_SpeakInHouse;
         pParty->field_C59C[9 * (v1 + 12 * *(int *)v2) + 724] = v10 % 32 + 740;
       }
 LABEL_14:
@@ -13722,8 +13721,8 @@
   int v34; // [sp+74h] [bp-8h]@17
   int v35; // [sp+78h] [bp-4h]@17
 
-  v0 = ptr_507BC0;
-  memcpy(&v28, ptr_507BC0, sizeof(v28));
+  v0 = window_SpeakInHouse;
+  memcpy(&v28, window_SpeakInHouse, sizeof(v28));
   v1 = pPlayers[uActiveCharacter];
   v28.uFrameX = 483;
   v28.uFrameWidth = 148;
@@ -13774,7 +13773,7 @@
           *(short *)v6 = 1;
           v27 = 2;
         }
-        HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, v27);
+        HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, v27);
       }
     }
     else
@@ -13794,7 +13793,7 @@
   }
   if ( !(unsigned __int16)_449B57_test_bit(
                             (unsigned __int8 *)v1->field_152,
-                            word_4F0754[2 * (unsigned int)ptr_507BC0->ptr_1C]) )
+                            word_4F0754[2 * (unsigned int)window_SpeakInHouse->ptr_1C]) )
   {
     v24 = pNPCTopics[171].pText;
     v25 = v31;
@@ -13965,8 +13964,8 @@
   unsigned int s1; // [sp+288h] [bp-8h]@1
   int v66; // [sp+28Ch] [bp-4h]@48
 
-  v0 = ptr_507BC0;
-  memcpy(&v53, ptr_507BC0, sizeof(v53));
+  v0 = window_SpeakInHouse;
+  memcpy(&v53, window_SpeakInHouse, sizeof(v53));
   v2 = 255;
   v61 = pPlayers[uActiveCharacter];
   v1 = v61;
@@ -14009,7 +14008,7 @@
       while ( 1 )
       {
         v47[1] = (const char *)v60;
-        v22 = ptr_507BC0->ptr_1C;
+        v22 = window_SpeakInHouse->ptr_1C;
         v23 = (Player *)(unsigned __int8)*(&_4F0D38_TravelInfo[4 * (signed int)v22] + v62);
         v61 = (Player *)(unsigned __int8)*(&_4F0D38_TravelInfo[4 * (signed int)v22] + v62);
         v24 = v16->GetControl(v60);
@@ -14027,7 +14026,7 @@
           v47[1] = v27;
           sprintf(a1, format_4E2DC8, v27);
           v66 = (unsigned __int8)byte_4F09B8[v26 * 4];
-          if ( (signed int)ptr_507BC0->ptr_1C >= 63 )
+          if ( (signed int)window_SpeakInHouse->ptr_1C >= 63 )
           {
             if ( CheckHiredNPCSpeciality(8u) )
               v66 -= 2;
@@ -14130,7 +14129,7 @@
       if ( pParty->uNumGold < s1 )
       {
         ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);
-        HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 3);
+        HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 3);
         if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
           return;
         pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113;
@@ -14139,7 +14138,7 @@
       }
       Party::TakeGold(s1);
       v47[1] = (const char *)7;
-      v5 = &byte_4F09B0[32 * (unsigned __int8)*(&byte_4F0CCF[4 * (unsigned int)ptr_507BC0->ptr_1C] + dword_F8B19C)];
+      v5 = &byte_4F09B0[32 * (unsigned __int8)*(&byte_4F0CCF[4 * (unsigned int)window_SpeakInHouse->ptr_1C] + dword_F8B19C)];
       if ( v5[pParty->uDaysPlayed % 7 + 1] )
       {
         if ( _strcmpi(pCurrentMapName, pMapStats->pInfos[(unsigned __int8)*v5].pFilename) )
@@ -14173,9 +14172,9 @@
           pParty->uFallStartY = pParty->vPosition.z;
           pParty->sRotationY = *((int *)v5 + 6);
         }
-        HousePlaySomeSound((unsigned int)ptr_507BC0->ptr_1C, 2);
+        HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 2);
         v12 = (unsigned __int8)v5[8];
-        if ( (signed int)ptr_507BC0->ptr_1C >= 63 )
+        if ( (signed int)window_SpeakInHouse->ptr_1C >= 63 )
         {
           v63 = SPEECH_72;
           v13 = 2500;
@@ -14867,124 +14866,134 @@
 }
 
 //----- (0044606A) --------------------------------------------------------
-int __fastcall PrepareHouse(unsigned int uHouseID)
-{
-  unsigned int v1; // ebx@1
-  signed int v2; // esi@1
-  int uExitPic; // edi@1
+void PrepareHouse(HOUSE_TYPE house)
+{
+  //unsigned int v1; // ebx@1
+  //signed int v2; // esi@1
+  //int uExitPic; // edi@1
   __int16 uExitMapID; // ax@2
-  int result; // eax@5
-  unsigned int *v6; // ecx@8
+  //int result; // eax@5
+  //unsigned int *v6; // ecx@8
   int v7; // ebx@11
-  int v8; // esi@16
-  unsigned int v9; // eax@16
-  unsigned int v10; // eax@19
-  int v11; // ecx@19
-  char pContainer[36]; // [sp+Ch] [bp-54h]@16
+  //int v8; // esi@16
+  //unsigned int v9; // eax@16
+  //unsigned int v10; // eax@19
+  //int v11; // ecx@19
+  //char pContainer[36]; // [sp+Ch] [bp-54h]@16
   int v13; // [sp+30h] [bp-30h]@11
   int Dst[6]; // [sp+34h] [bp-2Ch]@1
-  unsigned int v15; // [sp+4Ch] [bp-14h]@1
+  //unsigned int v15; // [sp+4Ch] [bp-14h]@1
   int uAnimationID; // [sp+50h] [bp-10h]@1
-  unsigned int *v17; // [sp+54h] [bp-Ch]@3
-  unsigned int v18; // [sp+58h] [bp-8h]@1
-  int v19; // [sp+5Ch] [bp-4h]@7
-
-  v15 = uHouseID;
-  v1 = 52 * uHouseID;
+  //unsigned int *v17; // [sp+54h] [bp-Ch]@3
+  //unsigned int v18; // [sp+58h] [bp-8h]@1
+  //int v19; // [sp+5Ch] [bp-4h]@7
+
+  //v15 = uHouseID;
+  //v1 = 52 * uHouseID;
   //uAnimationID = p2DEvents_minus1___02[26 * uHouseID];
-  uAnimationID = p2DEvents[uHouseID - 1].uAnimationID;
-  v2 = 0;
-  v18 = 52 * uHouseID;
+  uAnimationID = p2DEvents[house - 1].uAnimationID;
+  //v18 = 52 * uHouseID;
   memset(Dst, 0, 0x18u);
   //uExitPic = *(__int16 *)((char *)p2DEvents_minus1_::2C + v1);
-  uExitPic = p2DEvents[uHouseID - 1].uExitPicID;
+  //uExitPic = p2DEvents[uHouseID - 1].uExitPicID;
   uNumDialogueNPCPortraits = 0;
-  uHouse_ExitPic = uExitPic;
-  if ( uExitPic )
+  uHouse_ExitPic = p2DEvents[house - 1].uExitPicID;
+  if ( uHouse_ExitPic )
   {
     //uExitMapID = *(__int16 *)((char *)p2DEvents_minus1_::30 + v1);
-    uExitMapID = p2DEvents[uHouseID - 1]._quest_related;
+    uExitMapID = p2DEvents[house - 1]._quest_related;
     if ( uExitMapID > 0 )
     {
-      v17 = (unsigned int *)(uExitMapID - 1);
-      if ( !((unsigned __int8)(0x80u >> (signed int)v17 % 8) & pParty->_award_bits[(uExitMapID - 1) >> 3]) )
-      {
-        uExitPic = 0;
+      //v17 = (unsigned int *)(uExitMapID - 1);
+      if ( !((unsigned __int8)(0x80u >> (uExitMapID - 1) % 8) & pParty->_award_bits[(uExitMapID - 1) >> 3]) )
+      {
+        //uExitPic = 0;
         uHouse_ExitPic = 0;
       }
     }
   }
+
   dword_591080 = pAnimatedRooms[uAnimationID].field_8;
-  result = dword_591080;
+  //result = dword_591080;
+
+  //v2 = 0;
+  uNumDialogueNPCPortraits = 0;
   if ( dword_591080 )
   {
-    v2 = 1;
+    //v2 = 1;
     Dst[0] = dword_591080;
     uNumDialogueNPCPortraits = 1;
   }
-  v19 = 1;
-  if ( (signed int)pNPCStats->uNumNewNPCs > 1 )
-  {
-    v6 = &pNPCStats->pNewNPCData[1].uFlags;
-    v17 = &pNPCStats->pNewNPCData[1].uFlags;
-    do
-    {
-      if ( v6[3] == v15 )
-      {
-        if ( !(*(char *)v6 & 0x80) )
-        {
-          v7 = v2++ - (result != 0);
-          array_5913D8[v7] = (NPCData *)(v6 - 2);
-          v6 = v17;
-          *(&v13 + v2) = *(v17 - 1);
-          v1 = v18;
-          if ( (*v6 & 3) != 2 )
-            ++*v6;
-        }
-      }
-      ++v19;
-      v6 += 19;
-      v17 = v6;
-    }
-    while ( v19 < (signed int)pNPCStats->uNumNewNPCs );
-    uNumDialogueNPCPortraits = v2;
-  }
-  v19 = 0;
-  if ( v2 > 0 )
-  {
-    do
-    {
-      v8 = v19;
-      sprintf(pContainer, "npc%03u", Dst[v19]);
-      v9 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-      ++v19;
-      pDialogueNPCPortraits[v8] = &pIcons_LOD->pTextures[v9];
-      result = v19;
-    }
-    while ( v19 < uNumDialogueNPCPortraits );
-    uExitPic = uHouse_ExitPic;
-  }
-  if ( uExitPic )
-  {
-    v10 = pIcons_LOD->LoadTexture(pHouse_ExitPictures[uExitPic], TEXTURE_16BIT_PALETTE);
-    v11 = uNumDialogueNPCPortraits++;
-    pDialogueNPCPortraits[v11] = &pIcons_LOD->pTextures[v10];
+
+  //v19 = 1;
+  for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i)
+  {
+    auto npc = pNPCStats->pNewNPCData + i;
+    //v6 = &pNPCStats->pNewNPCData[1].uFlags;
+    //v17 = &pNPCStats->pNewNPCData[1].uFlags;
+    //do
+    //{
+    if (npc->Location2D == house )
+    {
+      if (~npc->uFlags & 0x80)
+        //if ( !(*(char *)v6 & 0x80) )
+      {
+        v7 = uNumDialogueNPCPortraits++ - dword_591080 ? 1 : 0;
+        array_5913D8[v7] = npc;
+        //v6 = v17;
+        //*(&v13 + v2) = *(v17 - 1);
+        Dst[uNumDialogueNPCPortraits - 1] = npc->uPortraitID;
+          //v1 = v18;
+        if ((npc->uFlags & 3) != 2)
+          ++npc->uFlags;
+      }
+    }
+      //++v19;
+      //v6 += 19;
+      //v17 = v6;
+    //}
+    //while ( v19 < (signed int)pNPCStats->uNumNewNPCs );
+  }
+  //uNumDialogueNPCPortraits = v2;
+
+  //v19 = 0;
+  for (uint i = 0; i < uNumDialogueNPCPortraits; ++i)
+  //if ( v2 > 0 )
+  {
+    //do
+    //{
+      //v8 = v19;
+    char icon_name[128];
+    sprintfex(icon_name, "npc%03u", Dst[i]);
+    //v9 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+    //++v19;
+    pDialogueNPCPortraits[i] = pIcons_LOD->LoadTexturePtr(icon_name, TEXTURE_16BIT_PALETTE);
+    //result = v19;
+    //}
+    //while ( v19 < uNumDialogueNPCPortraits );
+    //uExitPic = uHouse_ExitPic;
+  }
+
+  if (uHouse_ExitPic)
+  {
+    //v10 = pIcons_LOD->LoadTexture(pHouse_ExitPictures[uHouse_ExitPic], TEXTURE_16BIT_PALETTE);
+    //v11 = uNumDialogueNPCPortraits++;
+    pDialogueNPCPortraits[uNumDialogueNPCPortraits++] = pIcons_LOD->LoadTexturePtr(pHouse_ExitPictures[uHouse_ExitPic], TEXTURE_16BIT_PALETTE);
     //result = *(__int16 *)((char *)p2DEvents_minus1_::2E + v1);
-    result = p2DEvents[uHouseID - 1].uExitMapID;
-    uHouse_ExitPic = result;
-  }
-  return result;
-}
-
+    //result = p2DEvents[house - 1].uExitMapID;
+    uHouse_ExitPic = p2DEvents[house - 1].uExitMapID;
+  }
+  //return result;
+}
 
 
 
 
 //----- (0044622E) --------------------------------------------------------
-bool __fastcall EnterHouse(enum HOUSE_TYPE uHouseID)
-{
-  enum HOUSE_TYPE v1; // edi@1
-  int v2; // edi@5
+bool __fastcall EnterHouse(HOUSE_TYPE uHouseID)
+{
+  //enum HOUSE_TYPE v1; // edi@1
+  //int v2; // edi@5
   unsigned int uOpenTime; // eax@5
   int uCloseTime; // esi@5
   unsigned int v5; // esi@5
@@ -14992,24 +15001,24 @@
   signed int v7; // ecx@10
   signed int v8; // eax@10
   int v9; // esi@10
-  unsigned int v10; // esi@16
+  //unsigned int v10; // esi@16
   int v11; // ecx@17
   unsigned int v12; // kr00_4@25
-  Player *v13; // esi@25
+  //Player *v13; // esi@25
   int v14; // eax@25
-  Player *v15; // esi@27
+  //Player *v15; // esi@27
   signed int v16; // eax@32
   unsigned int v17; // eax@37
   signed int v18; // edi@37
   signed int v19; // edi@41
-  unsigned int v20; // ecx@41
+  //unsigned int v20; // ecx@41
   const char *v22; // [sp-4h] [bp-40h]@33
   char pContainer[40]; // [sp+Ch] [bp-30h]@32
   unsigned int v24; // [sp+34h] [bp-8h]@5
-  enum HOUSE_TYPE v25; // [sp+38h] [bp-4h]@1
-
-  v1 = uHouseID;
-  v25 = uHouseID;
+  //enum HOUSE_TYPE v25; // [sp+38h] [bp-4h]@1
+
+  //v1 = uHouseID;
+  //v25 = uHouseID;
   GameUI_StatusBar_TimedString[0] = 0;
   pStatusBarString[0] = 0;
   ShowStatusBarString("", 2u);
@@ -15019,16 +15028,16 @@
   uDialogueType = 0;
   pKeyActionMap->_459ED1(3);
   pKeyActionMap->ResetKeys();
-  if ( v1 == 600 || v1 == 601 )
+  if (uHouseID == HOUSE_600 || uHouseID == HOUSE_601)
   {
     GameOverMenu(0);
     return 0;
   }
-  v2 = 26 * v1;
+  //v2 = 26 * v1;
   //uOpenTime = p2DEvents_minus1_::uOpenTime[v2];
-  uOpenTime = p2DEvents[v1 - 1].uOpenTime;
+  uOpenTime = p2DEvents[uHouseID - 1].uOpenTime;
   //uCloseTime = p2DEvents_minus1_::uCloseTime[v2];
-  uCloseTime = p2DEvents[v1 - 1].uCloseTime;
+  uCloseTime = p2DEvents[uHouseID - 1].uCloseTime;
   ptr_F8B1E8 = 0;
   v24 = uOpenTime;
   v5 = uCloseTime - 1;
@@ -15071,48 +15080,52 @@
   if ( pParty->uCurrentHour > v5 )
     goto LABEL_10;
 LABEL_16:
-  v10 = v25;
-  if ( (signed int)v25 >= 53 )
+  //v10 = uHouseID;
+  if ( (signed int)uHouseID >= 53 )
     goto LABEL_21;
-  v11 = pParty->field_3C._shop_ban_times[2 * v25 + 1];
-  if ( !(v11 | pParty->field_3C._shop_ban_times[2 * v25])
-    || (signed __int64)__PAIR__(v11, pParty->field_3C._shop_ban_times[2 * v25]) <= (signed __int64)pParty->uTimePlayed )
-  {
-    pParty->field_3C._shop_ban_times[2 * v25] = 0;
-    pParty->field_3C._shop_ban_times[2 * v10 + 1] = 0;
+  v11 = pParty->field_3C._shop_ban_times[2 * uHouseID + 1];
+  if ( !(v11 | pParty->field_3C._shop_ban_times[2 * uHouseID])
+    || (signed __int64)__PAIR__(v11, pParty->field_3C._shop_ban_times[2 * uHouseID]) <= (signed __int64)pParty->uTimePlayed )
+  {
+    pParty->field_3C._shop_ban_times[2 * uHouseID] = 0;
+    pParty->field_3C._shop_ban_times[2 * uHouseID + 1] = 0;
 LABEL_21:
-    if ( !dword_597F18 )
+    if ( !start_event_seq_number )
       pAudioPlayer->StopChannels(-1, -1);
     //uCurrentHouse_Animation = p2DEvents_minus1___02[v2];
-    uCurrentHouse_Animation = p2DEvents[v2 / sizeof(_2devent) - 1].uAnimationID;
+    uCurrentHouse_Animation = p2DEvents[uHouseID - 1].uAnimationID;
     dword_F8B198 = LOBYTE(pAnimatedRooms[uCurrentHouse_Animation].field_C);
-    if ( dword_F8B198 == 20 && pParty->uFine )
+    if ( dword_F8B198 == 20 && pParty->uFine )   // going 2 jail
     {
       uCurrentHouse_Animation = (signed __int16)p2DEvents[186].uAnimationID;
-      v25 = (HOUSE_TYPE)187;
+      //v25 = HOUSE_187;
+      uHouseID = HOUSE_JAIL;
       v12 = LODWORD(pParty->uTimePlayed);
       LODWORD(pParty->uTimePlayed) += 0x7620000u;
-      v13 = pParty->pPlayers;//[0].uNumDivineInterventionCastsThisDay;
-      v14 = LOBYTE(pAnimatedRooms[(signed __int16)p2DEvents[186].uAnimationID].field_C);
+      v14 = LOBYTE(pAnimatedRooms[(signed __int16)p2DEvents[HOUSE_186].uAnimationID].field_C);
       pParty->uTimePlayed = __PAIR__(HIDWORD(pParty->uTimePlayed), v12) + 0x7620000;
       dword_F8B198 = v14;
-      do
-      {
-		v13->uTimeToRecovery = 0;
-		memset(&v13->uTimeToRecovery, 0, 4u);
-        ++v13;
-      }
-      while ( v13 <= &pParty->pPlayers[3] );
+      //v13 = pParty->pPlayers;//[0].uNumDivineInterventionCastsThisDay;
+      //do
       ++pParty->uNumPrisonTerms;
       pParty->uFine = 0;
-      v15 = pParty->pPlayers;
+      for (uint i = 0; i < 4; ++i)
+      {
+        pParty->pPlayers[i].uTimeToRecovery = 0;
+        pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0;
+        pParty->pPlayers[i].SetVariable(VAR_Award, 87);
+		//v13->uTimeToRecovery = 0;
+		//memset(&v13->uTimeToRecovery, 0, 4u);
+        //++v13;
+      }
+      //while ( v13 <= &pParty->pPlayers[3] );
+      /*v15 = pParty->pPlayers;
       do
       {
-        v15->SetVariable(VAR_Award, 87);
         ++v15;
       }
-      while ( v15 <= &pParty->pPlayers[3] );
-      v10 = v25;
+      while ( v15 <= &pParty->pPlayers[3] );*/
+      //v10 = v25;
     }
     ++pIcons_LOD->uTexturePacksCount;
     if ( !pIcons_LOD->uNumPrevLoadedFiles )
@@ -15135,25 +15148,25 @@
     array_5913D8[6] = 0;
     pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v17];
     uTextureID_507B04 = uTextureID_right_panel;
-    PrepareHouse(v10);
+    PrepareHouse(uHouseID);
     v18 = 1;
     uTextureID_507B04 = uTextureID_right_panel;
     if ( uNumDialogueNPCPortraits == 1 )
       array_5913D8[6] = (NPCData *)1;
     pVideoPlayer->_4BF28F(pAnimatedRooms[uCurrentHouse_Animation].field_0, 1u);
-    if ( (signed int)v10 < 139 || (signed int)v10 > 172 )
-    {
-      if ( (signed int)v10 >= 54 && (signed int)v10 <= 73 && !sub_4B68EA(v10 - 54) )
+    if ( (signed int)uHouseID < 139 || (signed int)uHouseID > 172 )
+    {
+      if ( (signed int)uHouseID >= 54 && (signed int)uHouseID <= 73 && !sub_4B68EA(uHouseID - 54) )
         goto LABEL_49;
-      v20 = v10;
+      //v20 = uHouseID;
     }
     else
     {
-      v19 = word_4F0704[2 * v10] - 1;
-      v20 = v10;
+      v19 = word_4F0704[2 * uHouseID] - 1;
+      //v20 = uHouseID;
       if ( !((unsigned __int8)(0x80u >> v19 % 8) & pPlayers[uActiveCharacter]->field_152[v19 >> 3]) )
       {
-        HousePlaySomeSound(v10, 3);
+        HousePlaySomeSound(uHouseID, 3);
         v18 = 1;
 LABEL_49:
         dword_5C35D4 = v18;
@@ -15161,7 +15174,7 @@
       }
       v18 = 1;
     }
-    HousePlaySomeSound(v20, v18);
+    HousePlaySomeSound(uHouseID, v18);
     goto LABEL_49;
   }
   ShowStatusBarString(pGlobalTXT_LocalizationStrings[191], 2u);// "You've been banned from this shop!"