comparison mm7_4.cpp @ 341:a8ee15a20bea

EnterHouse
author Nomad
date Thu, 21 Feb 2013 00:12:19 +0200
parents ea55d6414029
children bf7596b71b24
comparison
equal deleted inserted replaced
338:1c681ad45653 341:a8ee15a20bea
1 #include <io.h> 1 #include <io.h>
2 #include <direct.h> 2 #include <direct.h>
3 #include <assert.h> 3 #include <assert.h>
4
5 #include "MM7.h"
4 6
5 #include "MapInfo.h" 7 #include "MapInfo.h"
6 #include "Game.h" 8 #include "Game.h"
7 #include "GUIWindow.h" 9 #include "GUIWindow.h"
8 #include "GUIButton.h" 10 #include "GUIButton.h"
14980 14982
14981 14983
14982 14984
14983 14985
14984 //----- (0044622E) -------------------------------------------------------- 14986 //----- (0044622E) --------------------------------------------------------
14985 bool __fastcall EnterHouse(enum HOUSE_TYPE uHouseID) 14987 bool __fastcall EnterHouse(HOUSE_TYPE uHouseID)
14986 { 14988 {
14987 enum HOUSE_TYPE v1; // edi@1 14989 //enum HOUSE_TYPE v1; // edi@1
14988 int v2; // edi@5 14990 //int v2; // edi@5
14989 unsigned int uOpenTime; // eax@5 14991 unsigned int uOpenTime; // eax@5
14990 int uCloseTime; // esi@5 14992 int uCloseTime; // esi@5
14991 unsigned int v5; // esi@5 14993 unsigned int v5; // esi@5
14992 int v6; // edx@5 14994 int v6; // edx@5
14993 signed int v7; // ecx@10 14995 signed int v7; // ecx@10
14994 signed int v8; // eax@10 14996 signed int v8; // eax@10
14995 int v9; // esi@10 14997 int v9; // esi@10
14996 unsigned int v10; // esi@16 14998 //unsigned int v10; // esi@16
14997 int v11; // ecx@17 14999 int v11; // ecx@17
14998 unsigned int v12; // kr00_4@25 15000 unsigned int v12; // kr00_4@25
14999 Player *v13; // esi@25 15001 //Player *v13; // esi@25
15000 int v14; // eax@25 15002 int v14; // eax@25
15001 Player *v15; // esi@27 15003 //Player *v15; // esi@27
15002 signed int v16; // eax@32 15004 signed int v16; // eax@32
15003 unsigned int v17; // eax@37 15005 unsigned int v17; // eax@37
15004 signed int v18; // edi@37 15006 signed int v18; // edi@37
15005 signed int v19; // edi@41 15007 signed int v19; // edi@41
15006 unsigned int v20; // ecx@41 15008 //unsigned int v20; // ecx@41
15007 const char *v22; // [sp-4h] [bp-40h]@33 15009 const char *v22; // [sp-4h] [bp-40h]@33
15008 char pContainer[40]; // [sp+Ch] [bp-30h]@32 15010 char pContainer[40]; // [sp+Ch] [bp-30h]@32
15009 unsigned int v24; // [sp+34h] [bp-8h]@5 15011 unsigned int v24; // [sp+34h] [bp-8h]@5
15010 enum HOUSE_TYPE v25; // [sp+38h] [bp-4h]@1 15012 //enum HOUSE_TYPE v25; // [sp+38h] [bp-4h]@1
15011 15013
15012 v1 = uHouseID; 15014 //v1 = uHouseID;
15013 v25 = uHouseID; 15015 //v25 = uHouseID;
15014 GameUI_StatusBar_TimedString[0] = 0; 15016 GameUI_StatusBar_TimedString[0] = 0;
15015 pStatusBarString[0] = 0; 15017 pStatusBarString[0] = 0;
15016 ShowStatusBarString("", 2u); 15018 ShowStatusBarString("", 2u);
15017 if ( pMessageQueue_50CBD0->uNumMessages ) 15019 if ( pMessageQueue_50CBD0->uNumMessages )
15018 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; 15020 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
15019 viewparams->bRedrawGameUI = 1; 15021 viewparams->bRedrawGameUI = 1;
15020 uDialogueType = 0; 15022 uDialogueType = 0;
15021 pKeyActionMap->_459ED1(3); 15023 pKeyActionMap->_459ED1(3);
15022 pKeyActionMap->ResetKeys(); 15024 pKeyActionMap->ResetKeys();
15023 if ( v1 == 600 || v1 == 601 ) 15025 if (uHouseID == HOUSE_600 || uHouseID == HOUSE_601)
15024 { 15026 {
15025 GameOverMenu(0); 15027 GameOverMenu(0);
15026 return 0; 15028 return 0;
15027 } 15029 }
15028 v2 = 26 * v1; 15030 //v2 = 26 * v1;
15029 //uOpenTime = p2DEvents_minus1_::uOpenTime[v2]; 15031 //uOpenTime = p2DEvents_minus1_::uOpenTime[v2];
15030 uOpenTime = p2DEvents[v1 - 1].uOpenTime; 15032 uOpenTime = p2DEvents[uHouseID - 1].uOpenTime;
15031 //uCloseTime = p2DEvents_minus1_::uCloseTime[v2]; 15033 //uCloseTime = p2DEvents_minus1_::uCloseTime[v2];
15032 uCloseTime = p2DEvents[v1 - 1].uCloseTime; 15034 uCloseTime = p2DEvents[uHouseID - 1].uCloseTime;
15033 ptr_F8B1E8 = 0; 15035 ptr_F8B1E8 = 0;
15034 v24 = uOpenTime; 15036 v24 = uOpenTime;
15035 v5 = uCloseTime - 1; 15037 v5 = uCloseTime - 1;
15036 dword_F8B1E4 = 0; 15038 dword_F8B1E4 = 0;
15037 dword_F8B1F4 = 0; 15039 dword_F8B1F4 = 0;
15070 } 15072 }
15071 } 15073 }
15072 if ( pParty->uCurrentHour > v5 ) 15074 if ( pParty->uCurrentHour > v5 )
15073 goto LABEL_10; 15075 goto LABEL_10;
15074 LABEL_16: 15076 LABEL_16:
15075 v10 = v25; 15077 //v10 = uHouseID;
15076 if ( (signed int)v25 >= 53 ) 15078 if ( (signed int)uHouseID >= 53 )
15077 goto LABEL_21; 15079 goto LABEL_21;
15078 v11 = pParty->field_3C._shop_ban_times[2 * v25 + 1]; 15080 v11 = pParty->field_3C._shop_ban_times[2 * uHouseID + 1];
15079 if ( !(v11 | pParty->field_3C._shop_ban_times[2 * v25]) 15081 if ( !(v11 | pParty->field_3C._shop_ban_times[2 * uHouseID])
15080 || (signed __int64)__PAIR__(v11, pParty->field_3C._shop_ban_times[2 * v25]) <= (signed __int64)pParty->uTimePlayed ) 15082 || (signed __int64)__PAIR__(v11, pParty->field_3C._shop_ban_times[2 * uHouseID]) <= (signed __int64)pParty->uTimePlayed )
15081 { 15083 {
15082 pParty->field_3C._shop_ban_times[2 * v25] = 0; 15084 pParty->field_3C._shop_ban_times[2 * uHouseID] = 0;
15083 pParty->field_3C._shop_ban_times[2 * v10 + 1] = 0; 15085 pParty->field_3C._shop_ban_times[2 * uHouseID + 1] = 0;
15084 LABEL_21: 15086 LABEL_21:
15085 if ( !start_event_seq_number ) 15087 if ( !start_event_seq_number )
15086 pAudioPlayer->StopChannels(-1, -1); 15088 pAudioPlayer->StopChannels(-1, -1);
15087 //uCurrentHouse_Animation = p2DEvents_minus1___02[v2]; 15089 //uCurrentHouse_Animation = p2DEvents_minus1___02[v2];
15088 uCurrentHouse_Animation = p2DEvents[v2 / sizeof(_2devent) - 1].uAnimationID; 15090 uCurrentHouse_Animation = p2DEvents[uHouseID - 1].uAnimationID;
15089 dword_F8B198 = LOBYTE(pAnimatedRooms[uCurrentHouse_Animation].field_C); 15091 dword_F8B198 = LOBYTE(pAnimatedRooms[uCurrentHouse_Animation].field_C);
15090 if ( dword_F8B198 == 20 && pParty->uFine ) 15092 if ( dword_F8B198 == 20 && pParty->uFine ) // going 2 jail
15091 { 15093 {
15092 uCurrentHouse_Animation = (signed __int16)p2DEvents[186].uAnimationID; 15094 uCurrentHouse_Animation = (signed __int16)p2DEvents[186].uAnimationID;
15093 v25 = (HOUSE_TYPE)187; 15095 //v25 = HOUSE_187;
15096 uHouseID = HOUSE_JAIL;
15094 v12 = LODWORD(pParty->uTimePlayed); 15097 v12 = LODWORD(pParty->uTimePlayed);
15095 LODWORD(pParty->uTimePlayed) += 0x7620000u; 15098 LODWORD(pParty->uTimePlayed) += 0x7620000u;
15096 v13 = pParty->pPlayers;//[0].uNumDivineInterventionCastsThisDay; 15099 v14 = LOBYTE(pAnimatedRooms[(signed __int16)p2DEvents[HOUSE_186].uAnimationID].field_C);
15097 v14 = LOBYTE(pAnimatedRooms[(signed __int16)p2DEvents[186].uAnimationID].field_C);
15098 pParty->uTimePlayed = __PAIR__(HIDWORD(pParty->uTimePlayed), v12) + 0x7620000; 15100 pParty->uTimePlayed = __PAIR__(HIDWORD(pParty->uTimePlayed), v12) + 0x7620000;
15099 dword_F8B198 = v14; 15101 dword_F8B198 = v14;
15100 do 15102 //v13 = pParty->pPlayers;//[0].uNumDivineInterventionCastsThisDay;
15101 { 15103 //do
15102 v13->uTimeToRecovery = 0;
15103 memset(&v13->uTimeToRecovery, 0, 4u);
15104 ++v13;
15105 }
15106 while ( v13 <= &pParty->pPlayers[3] );
15107 ++pParty->uNumPrisonTerms; 15104 ++pParty->uNumPrisonTerms;
15108 pParty->uFine = 0; 15105 pParty->uFine = 0;
15109 v15 = pParty->pPlayers; 15106 for (uint i = 0; i < 4; ++i)
15107 {
15108 pParty->pPlayers[i].uTimeToRecovery = 0;
15109 pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0;
15110 pParty->pPlayers[i].SetVariable(VAR_Award, 87);
15111 //v13->uTimeToRecovery = 0;
15112 //memset(&v13->uTimeToRecovery, 0, 4u);
15113 //++v13;
15114 }
15115 //while ( v13 <= &pParty->pPlayers[3] );
15116 /*v15 = pParty->pPlayers;
15110 do 15117 do
15111 { 15118 {
15112 v15->SetVariable(VAR_Award, 87);
15113 ++v15; 15119 ++v15;
15114 } 15120 }
15115 while ( v15 <= &pParty->pPlayers[3] ); 15121 while ( v15 <= &pParty->pPlayers[3] );*/
15116 v10 = v25; 15122 //v10 = v25;
15117 } 15123 }
15118 ++pIcons_LOD->uTexturePacksCount; 15124 ++pIcons_LOD->uTexturePacksCount;
15119 if ( !pIcons_LOD->uNumPrevLoadedFiles ) 15125 if ( !pIcons_LOD->uNumPrevLoadedFiles )
15120 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; 15126 pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
15121 v16 = const_2(); 15127 v16 = const_2();
15134 LABEL_37: 15140 LABEL_37:
15135 v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); 15141 v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
15136 array_5913D8[6] = 0; 15142 array_5913D8[6] = 0;
15137 pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v17]; 15143 pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v17];
15138 uTextureID_507B04 = uTextureID_right_panel; 15144 uTextureID_507B04 = uTextureID_right_panel;
15139 PrepareHouse(v10); 15145 PrepareHouse(uHouseID);
15140 v18 = 1; 15146 v18 = 1;
15141 uTextureID_507B04 = uTextureID_right_panel; 15147 uTextureID_507B04 = uTextureID_right_panel;
15142 if ( uNumDialogueNPCPortraits == 1 ) 15148 if ( uNumDialogueNPCPortraits == 1 )
15143 array_5913D8[6] = (NPCData *)1; 15149 array_5913D8[6] = (NPCData *)1;
15144 pVideoPlayer->_4BF28F(pAnimatedRooms[uCurrentHouse_Animation].field_0, 1u); 15150 pVideoPlayer->_4BF28F(pAnimatedRooms[uCurrentHouse_Animation].field_0, 1u);
15145 if ( (signed int)v10 < 139 || (signed int)v10 > 172 ) 15151 if ( (signed int)uHouseID < 139 || (signed int)uHouseID > 172 )
15146 { 15152 {
15147 if ( (signed int)v10 >= 54 && (signed int)v10 <= 73 && !sub_4B68EA(v10 - 54) ) 15153 if ( (signed int)uHouseID >= 54 && (signed int)uHouseID <= 73 && !sub_4B68EA(uHouseID - 54) )
15148 goto LABEL_49; 15154 goto LABEL_49;
15149 v20 = v10; 15155 //v20 = uHouseID;
15150 } 15156 }
15151 else 15157 else
15152 { 15158 {
15153 v19 = word_4F0704[2 * v10] - 1; 15159 v19 = word_4F0704[2 * uHouseID] - 1;
15154 v20 = v10; 15160 //v20 = uHouseID;
15155 if ( !((unsigned __int8)(0x80u >> v19 % 8) & pPlayers[uActiveCharacter]->field_152[v19 >> 3]) ) 15161 if ( !((unsigned __int8)(0x80u >> v19 % 8) & pPlayers[uActiveCharacter]->field_152[v19 >> 3]) )
15156 { 15162 {
15157 HousePlaySomeSound(v10, 3); 15163 HousePlaySomeSound(uHouseID, 3);
15158 v18 = 1; 15164 v18 = 1;
15159 LABEL_49: 15165 LABEL_49:
15160 dword_5C35D4 = v18; 15166 dword_5C35D4 = v18;
15161 return v18; 15167 return v18;
15162 } 15168 }
15163 v18 = 1; 15169 v18 = 1;
15164 } 15170 }
15165 HousePlaySomeSound(v20, v18); 15171 HousePlaySomeSound(uHouseID, v18);
15166 goto LABEL_49; 15172 goto LABEL_49;
15167 } 15173 }
15168 ShowStatusBarString(pGlobalTXT_LocalizationStrings[191], 2u);// "You've been banned from this shop!" 15174 ShowStatusBarString(pGlobalTXT_LocalizationStrings[191], 2u);// "You've been banned from this shop!"
15169 return 0; 15175 return 0;
15170 } 15176 }