diff mm7_4.cpp @ 487:d5da524ec901

shop entering fixed
author Gloval
date Wed, 27 Feb 2013 22:48:10 +0400
parents 4bd56919f075
children c92dd0242fb6 0e27362ac1d9
line wrap: on
line diff
--- a/mm7_4.cpp	Wed Feb 27 17:29:05 2013 +0200
+++ b/mm7_4.cpp	Wed Feb 27 22:48:10 2013 +0400
@@ -8918,9 +8918,9 @@
     if ( v5 > 4000000 )
       pParty->uFine = 4000000;
   }
-  v6 = pParty->uTimePlayed + 368640;
-  pParty->field_3C._shop_ban_times[2 * a1] = LODWORD(pParty->uTimePlayed) + 368640;
-  pParty->field_3C._shop_ban_times[2 * a1 + 1] = HIDWORD(v6);
+
+  pParty->field_3C._shop_ban_times[a1] = pParty->uTimePlayed + 368640;
+ 
 LABEL_13:
   pParty->InTheShopFlags[a1] = 1;
   if ( v3 )
@@ -9262,10 +9262,10 @@
 void __fastcall HousePlaySomeSound(unsigned int uHouseID, int a2)
 {
   //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) )
-  if ( BYTE1(pAnimatedRooms[p2DEvents[uHouseID - 1].uAnimationID].uBuildingType) )
+  if ( pAnimatedRooms[p2DEvents[uHouseID - 1].uAnimationID].field_d )
     pAudioPlayer->PlaySound(
       //(SoundID)(a2 + 100 * (BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) + 300)),
-      (SoundID)(a2 + 100 * (BYTE1(pAnimatedRooms[p2DEvents[uHouseID - 1].uAnimationID].uBuildingType) + 300)),
+      (SoundID)(a2 + 100 * (pAnimatedRooms[p2DEvents[uHouseID - 1].uAnimationID].field_d) + 300),
       806,
       0,
       -1,
@@ -14197,7 +14197,7 @@
 LABEL_20:
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)26, 0, (int)sHouseName);
   //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * v9]].field_C) )
-  if ( BYTE1(pAnimatedRooms[p2DEvents[v9 - 1].uAnimationID].uBuildingType) )
+  if ( pAnimatedRooms[p2DEvents[v9 - 1].uAnimationID].field_d )
     HousePlaySomeSound(v9, 1);
   if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30 )
     pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0);
@@ -14332,163 +14332,157 @@
 
 //----- (0044622E) --------------------------------------------------------
 bool  EnterHouse(enum HOUSE_ID uHouseID)
-{
-  //enum HOUSE_ID v1; // edi@1
-  //int v2; // edi@5
-  signed int uOpenTime; // eax@5
-  signed int uCloseTime; // esi@5
-  unsigned int v5; // esi@5
-  int v6; // edx@5
-  signed int am_pm_flag_open; // ecx@10
-  signed int am_pm_flag_close; // eax@10
-  int v9; // esi@10
-  //unsigned int v10; // esi@16
-  int v11; // ecx@17
-  unsigned int v12; // kr00_4@25
-  //Player *v13; // esi@25
-  int v14; // eax@25
-  //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
-  //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_ID v25; // [sp+38h] [bp-4h]@1
-
-  //v1 = uHouseID;
-  //v25 = uHouseID;
-  GameUI_StatusBar_TimedString[0] = 0;
-  pStatusBarString[0] = 0;
-  ShowStatusBarString("", 2u);
-  if ( pMessageQueue_50CBD0->uNumMessages )
-	  pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
-  viewparams->bRedrawGameUI = 1;
-  uDialogueType = 0;
-  pKeyActionMap->_459ED1(3);
-  pKeyActionMap->ResetKeys();
-  if (uHouseID == HOUSE_600 || uHouseID == HOUSE_601)
-	  {
-	  GameOverMenu(0);
-	  return 0;
-	  }
-  uOpenTime = p2DEvents[uHouseID - 1].uOpenTime;
-  uCloseTime = p2DEvents[uHouseID - 1].uCloseTime;
-  ptr_F8B1E8 = 0;
-  dword_F8B1E4 = 0;
-  dword_F8B1F4 = 0;
-  memset(byte_F8B1F0, 0, 4);
-  memset(byte_F8B148, 0, 16);
-  pRenderer->ClearZBuffer(0, 479);
-  if ( uCloseTime - 1 <= uOpenTime )
-	  {
-	  if ( pParty->uCurrentHour >= uOpenTime )
-		  {
-		  //v10 = uHouseID;
-		  if ( (signed int)uHouseID < 53 )
-			  {
-			  if ( !(pParty->field_3C._shop_ban_times[uHouseID])
-				  ||  (pParty->field_3C._shop_ban_times[uHouseID] <= pParty->uTimePlayed) )
-				  {
-				  pParty->field_3C._shop_ban_times[uHouseID] = 0;
-
-				  }
-			  else
-				  {
-				  ShowStatusBarString(pGlobalTXT_LocalizationStrings[191], 2u);// "You've been banned from this shop!"
-				  return 0;
-				  }
-			  }
-		  if ( !start_event_seq_number )
-			  pAudioPlayer->StopChannels(-1, -1);
-
-		  uCurrentHouse_Animation = p2DEvents[uHouseID - 1].uAnimationID;
-		  in_current_building_type = pAnimatedRooms[uCurrentHouse_Animation].uBuildingType;
-		  if ( in_current_building_type == BildingType_20 && pParty->uFine )   // going 2 jail
-			  {
-			  uCurrentHouse_Animation = (signed __int16)p2DEvents[186].uAnimationID;
-			  uHouseID = HOUSE_JAIL;
-			  pParty->uTimePlayed = pParty->uTimePlayed+ 0x7620000;
-			  in_current_building_type = pAnimatedRooms[p2DEvents[HOUSE_LORD_AND_JUDGE].uAnimationID].uBuildingType;
-			  ++pParty->uNumPrisonTerms;
-			  pParty->uFine = 0;
-			  for (uint i = 0; i < 4; ++i)
-				  {
-				  pParty->pPlayers[i].uTimeToRecovery = 0;
-				  pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0;
-				  pParty->pPlayers[i].SetVariable(VAR_Award, 87);
-				  }
-			  }
-		  ++pIcons_LOD->uTexturePacksCount;
-		  if ( !pIcons_LOD->uNumPrevLoadedFiles )
-			  pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-
-		  switch (pParty->alignment)
-			  {
-		  case PartyAlignment_Good:    sprintf(pContainer, "evt%02d-b", const_2()); break;
-		  case PartyAlignment_Neutral: sprintf(pContainer, "evt%02d", const_2()); break;
-		  case PartyAlignment_Evil:    sprintf(pContainer, "evt%02d-c", const_2()); break;
-		  default: assert(false);
-			  }
-
-		  v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-		  pDialogueNPCCount = 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;
-		  pVideoPlayer->_4BF28F(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u);  
-		  dword_5C35D4 = 1;
-		  if ( (signed int)uHouseID < 139 || (signed int)uHouseID > 172 )
-			  {
-			  if ( (signed int)uHouseID >= 54 && (signed int)uHouseID <= 73 && !sub_4B68EA(uHouseID - 54) )
-				  {
-				  return 1;
-				  }
-			  }
-		  else
-			  { //guilds
-			  v19 = word_4F0704[uHouseID-139] - 1; //some gild flag check
-			  //v20 = uHouseID;
-			  if ( !((unsigned __int8)(0x80u >> v19 % 8) & pPlayers[uActiveCharacter]->_guilds_member_bits[v19 /8]) )
-				  {
-				  HousePlaySomeSound(uHouseID, 3);
-				  return 1;
-				  }
-			  }
-		  HousePlaySomeSound(uHouseID, 1);
-		  dword_5C35D4 = 1;
-		  return 1;
-		  }
-	  }
-  else
-	  {
-	  if (( pParty->uCurrentHour < uOpenTime)||( pParty->uCurrentHour > uCloseTime - 1 ))
-		  {
-		  am_pm_flag_open = 0;
-		  am_pm_flag_close = 0;
-		  if (uOpenTime > 12 )
-			  {
-			  uOpenTime -= 12;
-			  am_pm_flag_open = 1;
-			  }
-		  if ( uCloseTime > 12 )
-			  {
-			  uCloseTime -= 12;
-			  am_pm_flag_close = 1;
-			  }
-		  sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[414], uOpenTime, aAMPMNames[am_pm_flag_open], 
-			  uCloseTime, aAMPMNames[am_pm_flag_close]); //"This place is open from %d%s to %d%s"
-		  ShowStatusBarString(pTmpBuf, 2u);
-		  if ( uActiveCharacter )
-			  pPlayers[uActiveCharacter]->PlaySound(SPEECH_3, 0);
-		  return 0;
-		  }
-	  }
-
-}
+	{
+	//enum HOUSE_ID v1; // edi@1
+	//int v2; // edi@5
+	signed int uOpenTime; // eax@5
+	signed int uCloseTime; // esi@5
+	unsigned int v5; // esi@5
+	int v6; // edx@5
+	signed int am_pm_flag_open; // ecx@10
+	signed int am_pm_flag_close; // eax@10
+	int v9; // esi@10
+	//unsigned int v10; // esi@16
+	int v11; // ecx@17
+	unsigned int v12; // kr00_4@25
+	//Player *v13; // esi@25
+	int v14; // eax@25
+	//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
+	//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_ID v25; // [sp+38h] [bp-4h]@1
+
+	//v1 = uHouseID;
+	//v25 = uHouseID;
+	GameUI_StatusBar_TimedString[0] = 0;
+	pStatusBarString[0] = 0;
+	ShowStatusBarString("", 2u);
+	if ( pMessageQueue_50CBD0->uNumMessages )
+		pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+	viewparams->bRedrawGameUI = 1;
+	uDialogueType = 0;
+	pKeyActionMap->_459ED1(3);
+	pKeyActionMap->ResetKeys();
+	if (uHouseID == HOUSE_600 || uHouseID == HOUSE_601)
+		{
+		GameOverMenu(0);
+		return 0;
+		}
+	uOpenTime = p2DEvents[uHouseID - 1].uOpenTime;
+	uCloseTime = p2DEvents[uHouseID - 1].uCloseTime;
+	ptr_F8B1E8 = 0;
+	dword_F8B1E4 = 0;
+	dword_F8B1F4 = 0;
+	memset(byte_F8B1F0, 0, 4);
+	memset(byte_F8B148, 0, 16);
+	pRenderer->ClearZBuffer(0, 479);
+
+	if (((uCloseTime - 1 <= uOpenTime)&&((pParty->uCurrentHour >=uOpenTime)||(pParty->uCurrentHour <=(uCloseTime - 1))))||
+		((uCloseTime - 1 >  uOpenTime)&&((pParty->uCurrentHour < uOpenTime)||(pParty->uCurrentHour > (uCloseTime - 1))))) 
+
+		{
+		am_pm_flag_open = 0;
+		am_pm_flag_close = 0;
+		if (uOpenTime > 12 )
+			{
+			uOpenTime -= 12;
+			am_pm_flag_open = 1;
+			}
+		if ( uCloseTime > 12 )
+			{
+			uCloseTime -= 12;
+			am_pm_flag_close = 1;
+			}
+		sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[414], uOpenTime, aAMPMNames[am_pm_flag_open], 
+			uCloseTime, aAMPMNames[am_pm_flag_close]); //"This place is open from %d%s to %d%s"
+		ShowStatusBarString(pTmpBuf, 2u);
+		if ( uActiveCharacter )
+			pPlayers[uActiveCharacter]->PlaySound(SPEECH_3, 0);
+		return 0;
+		}
+	else
+		{
+		//v10 = uHouseID;
+		if ( (signed int)uHouseID < 53 ) //entering shops and guilds
+			{
+			if ( !(pParty->field_3C._shop_ban_times[uHouseID])
+				||  (pParty->field_3C._shop_ban_times[uHouseID] <= pParty->uTimePlayed) )
+				{
+				pParty->field_3C._shop_ban_times[uHouseID] = 0;
+				}
+			else
+				{
+				ShowStatusBarString(pGlobalTXT_LocalizationStrings[191], 2u);// "You've been banned from this shop!"
+				return 0;
+				}
+			}
+		if ( !start_event_seq_number )
+			pAudioPlayer->StopChannels(-1, -1);
+
+		uCurrentHouse_Animation = p2DEvents[uHouseID - 1].uAnimationID;
+		in_current_building_type = pAnimatedRooms[uCurrentHouse_Animation].uBuildingType;
+		if ( in_current_building_type == BildingType_20 && pParty->uFine )   // going 2 jail
+			{
+			uCurrentHouse_Animation = (signed __int16)p2DEvents[186].uAnimationID;
+			uHouseID = HOUSE_JAIL;
+			pParty->uTimePlayed = pParty->uTimePlayed+ 0x7620000;
+			in_current_building_type = pAnimatedRooms[p2DEvents[HOUSE_LORD_AND_JUDGE].uAnimationID].uBuildingType;
+			++pParty->uNumPrisonTerms;
+			pParty->uFine = 0;
+			for (uint i = 0; i < 4; ++i)
+				{
+				pParty->pPlayers[i].uTimeToRecovery = 0;
+				pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0;
+				pParty->pPlayers[i].SetVariable(VAR_Award, 87);
+				}
+			}
+		++pIcons_LOD->uTexturePacksCount;
+		if ( !pIcons_LOD->uNumPrevLoadedFiles )
+			pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
+		switch (pParty->alignment)
+			{
+		case PartyAlignment_Good:    sprintf(pContainer, "evt%02d-b", const_2()); break;
+		case PartyAlignment_Neutral: sprintf(pContainer, "evt%02d", const_2()); break;
+		case PartyAlignment_Evil:    sprintf(pContainer, "evt%02d-c", const_2()); break;
+		default: assert(false);
+			}
+
+		v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
+		pDialogueNPCCount = 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;
+		pVideoPlayer->_4BF28F(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u);  
+		dword_5C35D4 = 1;
+		if ( (signed int)uHouseID < 139 || (signed int)uHouseID > 172 )
+			{
+			if ( (signed int)uHouseID >= 54 && (signed int)uHouseID <= 73 && !sub_4B68EA(uHouseID - 54) )
+				{
+				return 1;
+				}
+			}
+		else
+			{ //guilds
+			v19 = word_4F0704[uHouseID-139] - 1; //some gild flag check
+			//v20 = uHouseID;
+			if ( !((unsigned __int8)(0x80u >> v19 % 8) & pPlayers[uActiveCharacter]->_guilds_member_bits[v19 /8]) )
+				{
+				HousePlaySomeSound(uHouseID, 3);
+				return 1;
+				}
+			}
+		HousePlaySomeSound(uHouseID, 1);
+		dword_5C35D4 = 1;
+		return 1;
+		}
+	}