changeset 1919:140ca8123384

Tavern rest fix
author Ritor1
date Wed, 23 Oct 2013 10:24:38 +0600
parents c77935190b51
children 05b433b8cb37
files Events.cpp Game.cpp Player.cpp UI/UIHouses.cpp VideoPlayer.cpp mm7_2.cpp mm7_data.h
diffstat 7 files changed, 80 insertions(+), 88 deletions(-) [+]
line wrap: on
line diff
--- a/Events.cpp	Tue Oct 22 18:55:37 2013 -0700
+++ b/Events.cpp	Wed Oct 23 10:24:38 2013 +0600
@@ -700,7 +700,7 @@
               {
                 if ( pEventID == 78 )
                 {
-                  sub_4BD8B5();
+                  HouseDialogPressCloseBtn();
                   window_SpeakInHouse->Release();
                   pParty->uFlags &= ~2;
                   if ( EnterHouse(HOUSE_DARK_GUILD_PIT) )
@@ -797,7 +797,7 @@
 
           if ( window_SpeakInHouse->par1C == 165 )
             {
-            sub_4BD8B5();
+            HouseDialogPressCloseBtn();
             pVideoPlayer->Unload();
             window_SpeakInHouse->Release();
             pParty->uFlags &= ~2;
@@ -1434,7 +1434,7 @@
               {
               pAudioPlayer->StopChannels(-1, -1);
               dialog_menu_id = HOUSE_DIALOGUE_NULL;
-              while ( sub_4BD8B5() )
+              while ( HouseDialogPressCloseBtn() )
                 ;
               pVideoPlayer->Unload();
               window_SpeakInHouse->Release();
--- a/Game.cpp	Tue Oct 22 18:55:37 2013 -0700
+++ b/Game.cpp	Wed Oct 23 10:24:38 2013 +0600
@@ -2437,12 +2437,12 @@
                         uDialogueType = 0;
                       if ( uGameState == GAME_STATE_2 )
                       {
-                        while ( sub_4BD8B5() )
+                        while ( HouseDialogPressCloseBtn() )
                           ;
                       }
                       else
                       {
-                        if ( sub_4BD8B5() )
+                        if ( HouseDialogPressCloseBtn() )
                           continue;
                       }
                       GetHouseGoodbyeSpeech();
@@ -3069,7 +3069,7 @@
             _5B65B0_npcdata_rep_or_other = v56;
             dword_5B65C0 = v55 | _5B65AC_npcdata_fame_or_other | v56 | v57;
           }
-          sub_4BD8B5();
+          HouseDialogPressCloseBtn();
           //goto LABEL_434;
           /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
           {
--- a/Player.cpp	Tue Oct 22 18:55:37 2013 -0700
+++ b/Player.cpp	Wed Oct 23 10:24:38 2013 +0600
@@ -5003,7 +5003,8 @@
     case VAR_QBits_QuestsDone:
       return _449B57_test_bit(pParty->_quest_bits, pValue);
     case VAR_PlayerItemInHands:
-      for (int i = 0; i < 138; i++)
+      //for (int i = 0; i < 138; i++)
+      for (int i = 0; i < 126; i++)
       {
         if (pInventoryItemList[i].uItemID == pValue)
         {
--- a/UI/UIHouses.cpp	Tue Oct 22 18:55:37 2013 -0700
+++ b/UI/UIHouses.cpp	Wed Oct 23 10:24:38 2013 +0600
@@ -1598,7 +1598,7 @@
           v15 = v14;
         while ( GetTickCount() < v15 )
           sqrt(3.1415926);
-        while ( sub_4BD8B5() )
+        while ( HouseDialogPressCloseBtn() )
           ;
         pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
         return;
@@ -2046,8 +2046,8 @@
       {
         Party::TakeGold(pPriceRoom);
         PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful);
-        dialog_menu_id = HOUSE_DIALOGUE_NULL;
-        sub_4BD8B5();
+        //dialog_menu_id = HOUSE_DIALOGUE_NULL;
+        HouseDialogPressCloseBtn();
         GetHouseGoodbyeSpeech();
         pVideoPlayer->Unload();
         if ( pMessageQueue_50CBD0->uNumMessages )
--- a/VideoPlayer.cpp	Tue Oct 22 18:55:37 2013 -0700
+++ b/VideoPlayer.cpp	Wed Oct 23 10:24:38 2013 +0600
@@ -1076,7 +1076,7 @@
   if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !this->pSmackerMovie )
   {
     bGameoverLoop = 1;
-    sub_4BD8B5();
+    HouseDialogPressCloseBtn();
     window_SpeakInHouse->Release();
     pParty->uFlags &= 0xFFFFFFFDu;
     if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) )
--- a/mm7_2.cpp	Tue Oct 22 18:55:37 2013 -0700
+++ b/mm7_2.cpp	Wed Oct 23 10:24:38 2013 +0600
@@ -606,10 +606,8 @@
 }
 
 //----- (004BD8B5) --------------------------------------------------------
-int sub_4BD8B5()
+int HouseDialogPressCloseBtn()
 {
-  int v0; // eax@4
-
   if ( pMessageQueue_50CBD0->uNumMessages )
     pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
   pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_CANCELLED);
@@ -617,85 +615,78 @@
   activeLevelDecoration = NULL;
   current_npc_text = 0;
   if ( pDialogueNPCCount == 0)
+    return 0;
+
+  if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_SPECIAL && ShopTexture )
   {
-	  return 0;
-  }
-
-  v0 = dialog_menu_id;
-  if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD && dialog_menu_id != HOUSE_DIALOGUE_SHOP_SELL
-    && dialog_menu_id != HOUSE_DIALOGUE_97 && dialog_menu_id != HOUSE_DIALOGUE_SHOP_REPAIR
-    && dialog_menu_id != HOUSE_DIALOGUE_SHOP_IDENTIFY && ShopTexture )
-  {
-	ShopTexture->Release();
-    v0 = dialog_menu_id;
+    ShopTexture->Release();
     ShopTexture = 0;
   }
 
-  switch(v0)
+  switch(dialog_menu_id)
   {
-	case -1:
-        _4B4224_UpdateNPCTopics((int)((char *)pDialogueNPCCount - 1));
-        pVideoPlayer->_4BF5B2();
-		break;
-
-	case 94:
-	case 96:
-	case 101:
-		pVideoPlayer->_4BF5B2();
-		UI_CreateEndConversationButton();
-		dialog_menu_id = HOUSE_DIALOGUE_MAIN;
-		InitializaDialogueOptions(in_current_building_type);
-		break;
-
-	case 3:
-	case 4:
-	case 5:
-        UI_CreateEndConversationButton();
-        dialog_menu_id = HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT;
-        InitializaDialogueOptions_Shops(in_current_building_type);
-		break;
-
-	case 102:
-	case 103:
-	case 104:
-        pVideoPlayer->_4BF5B2();
-        UI_CreateEndConversationButton();
-        dialog_menu_id = HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN;
-        InitializaDialogueOptions_Tavern(in_current_building_type);
-		break;
-
-	case 0:
-	case 1:
-		pDialogueNPCCount = 0;
-		pDialogueWindow->Release();
-		dialog_menu_id = HOUSE_DIALOGUE_NULL;
-		pDialogueWindow = 0;
-		pIcons_LOD->SyncLoadedFilesCount();
-
-		if ( uNumDialogueNPCPortraits == 1 )
-			return 0;
-		
-		pBtn_ExitCancel = window_SpeakInHouse->pControlsHead;
-		if ( uNumDialogueNPCPortraits > 0 )
-		{
-			for ( uint i = 0; i < (unsigned int)uNumDialogueNPCPortraits; ++i )
-			{
-				HouseNPCPortraitsButtonsList[i] = window_SpeakInHouse->CreateButton(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][i],
-																					  pNPCPortraits_y[uNumDialogueNPCPortraits - 1][i],
-													  63, 73, 1, 0, UIMSG_ClickHouseNPCPortrait, i, 0, byte_591180[i].data(), 0, 0, 0);
-			}
-		}
-	
-		pVideoPlayer->_4BF5B2();
-		break;
-
-	default:
-		pVideoPlayer->_4BF5B2();
-        dialog_menu_id = HOUSE_DIALOGUE_MAIN;
-        InitializaDialogueOptions(in_current_building_type);
-		break;
+    case -1:
+      _4B4224_UpdateNPCTopics((int)((char *)pDialogueNPCCount - 1));
+      pVideoPlayer->_4BF5B2();
+      break;
+
+    case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT:
+    case HOUSE_DIALOGUE_LEARN_SKILLS:
+    case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN:
+      pVideoPlayer->_4BF5B2();
+      UI_CreateEndConversationButton();
+      dialog_menu_id = HOUSE_DIALOGUE_MAIN;
+      InitializaDialogueOptions(in_current_building_type);
+      break;
+
+    case HOUSE_DIALOGUE_SHOP_SELL:
+    case HOUSE_DIALOGUE_SHOP_IDENTIFY:
+    case HOUSE_DIALOGUE_SHOP_REPAIR:
+      UI_CreateEndConversationButton();
+      dialog_menu_id = HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT;
+      InitializaDialogueOptions_Shops(in_current_building_type);
+      break;
+
+    case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RULES:
+    case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_VICTORY_CONDITIONS:
+    case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RESULT:
+      pVideoPlayer->_4BF5B2();
+      UI_CreateEndConversationButton();
+      dialog_menu_id = HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN;
+      InitializaDialogueOptions_Tavern(in_current_building_type);
+      break;
+
+    case HOUSE_DIALOGUE_NULL:
+    case HOUSE_DIALOGUE_MAIN:
+      pDialogueNPCCount = 0;
+      pDialogueWindow->Release();
+      dialog_menu_id = HOUSE_DIALOGUE_NULL;
+      pDialogueWindow = 0;
+      pIcons_LOD->SyncLoadedFilesCount();
+
+      if ( uNumDialogueNPCPortraits == 1 )
+        return 0;
+
+      pBtn_ExitCancel = window_SpeakInHouse->pControlsHead;
+      if ( uNumDialogueNPCPortraits > 0 )
+      {
+        for ( uint i = 0; i < (unsigned int)uNumDialogueNPCPortraits; ++i )
+        {
+          HouseNPCPortraitsButtonsList[i] = window_SpeakInHouse->CreateButton(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][i],
+                                            pNPCPortraits_y[uNumDialogueNPCPortraits - 1][i],
+                                            63, 73, 1, 0, UIMSG_ClickHouseNPCPortrait, i, 0, byte_591180[i].data(), 0, 0, 0);
+        }
+      }
+
+      pVideoPlayer->_4BF5B2();
+      break;
+
+    default:
+      pVideoPlayer->_4BF5B2();
+      dialog_menu_id = HOUSE_DIALOGUE_MAIN;
+      InitializaDialogueOptions(in_current_building_type);
+      break;
   }
-
   return 1;
 }
 
--- a/mm7_data.h	Tue Oct 22 18:55:37 2013 -0700
+++ b/mm7_data.h	Wed Oct 23 10:24:38 2013 +0600
@@ -1208,7 +1208,7 @@
 void SpellBookGenerator();
 void UI_CreateEndConversationButton();
 void __fastcall OnSelectShopDialogueOption(signed int uMessageParam);
-int sub_4BD8B5();
+int HouseDialogPressCloseBtn();
 bool __fastcall MerchandiseTest(ItemGen *item, int _2da_idx);
 void UIShop_Buy_Identify_Repair();
 bool __fastcall IsBModelVisible(unsigned int uModelID, int *unused);