changeset 341:a8ee15a20bea

EnterHouse
author Nomad
date Thu, 21 Feb 2013 00:12:19 +0200
parents 1c681ad45653
children bf7596b71b24
files MM7.h mm7_4.cpp
diffstat 2 files changed, 60 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/MM7.h	Wed Feb 20 20:44:42 2013 +0000
+++ b/MM7.h	Thu Feb 21 00:12:19 2013 +0200
@@ -245,7 +245,11 @@
 /*  349 */
 enum HOUSE_TYPE
 {
-  HOUSE_BODY_GUILD_NOVICE_EMERALD_ISLE = 0xA3,
+  HOUSE_BODY_GUILD_NOVICE_EMERALD_ISLE = 163,
+  HOUSE_186 = 186,
+  HOUSE_JAIL = 187,
+  HOUSE_600 = 600,
+  HOUSE_601 = 601
 };
 
 
--- a/mm7_4.cpp	Wed Feb 20 20:44:42 2013 +0000
+++ b/mm7_4.cpp	Thu Feb 21 00:12:19 2013 +0200
@@ -2,6 +2,8 @@
 #include <direct.h>
 #include <assert.h>
 
+#include "MM7.h"
+
 #include "MapInfo.h"
 #include "Game.h"
 #include "GUIWindow.h"
@@ -14982,10 +14984,10 @@
 
 
 //----- (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
@@ -14993,24 +14995,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);
@@ -15020,16 +15022,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;
@@ -15072,48 +15074,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 ( !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 )
@@ -15136,25 +15142,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;
@@ -15162,7 +15168,7 @@
       }
       v18 = 1;
     }
-    HousePlaySomeSound(v20, v18);
+    HousePlaySomeSound(uHouseID, v18);
     goto LABEL_49;
   }
   ShowStatusBarString(pGlobalTXT_LocalizationStrings[191], 2u);// "You've been banned from this shop!"