changeset 434:137c59c3dbc4

Temple of Moon and Dragon Lair can now be entered.
author Nomad
date Sun, 24 Feb 2013 01:42:35 +0200
parents 0eaed3e0d75f
children 4f451a616d3d
files GUIProgressBar.cpp GUIProgressBar.h GUIWindow.h Game.cpp Indoor.cpp LOD.h NPC.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp mm7_data.cpp mm7_data.h
diffstat 13 files changed, 66 insertions(+), 63 deletions(-) [+]
line wrap: on
line diff
--- a/GUIProgressBar.cpp	Sun Feb 24 01:08:02 2013 +0200
+++ b/GUIProgressBar.cpp	Sun Feb 24 01:42:35 2013 +0200
@@ -17,8 +17,8 @@
 
 
 
-//----- (00443484) --------------------------------------------------------
-bool GUIProgressBar::_443484(Type type)
+//----- (00Initialize) --------------------------------------------------------
+bool GUIProgressBar::Initialize(Type type)
 {
   //GUIProgressBar *v2; // esi@1
   signed int v4; // eax@7
@@ -29,10 +29,17 @@
   //unsigned int v9; // [sp-4h] [bp-80h]@20
   char Str1[64]; // [sp+4h] [bp-78h]@16
 
-  if (type < 1 || type > 1)
+  switch (type)
   {
-    __debugbreak();
-    return false;
+    case TYPE_None:
+      return true;
+
+    case TYPE_Box:
+    case TYPE_Fullscreen:
+      break;
+
+    default:
+      assert(false && "Invalid GUIProgressBar type");
   }
 
   //v2 = this;
--- a/GUIProgressBar.h	Sun Feb 24 01:08:02 2013 +0200
+++ b/GUIProgressBar.h	Sun Feb 24 01:42:35 2013 +0200
@@ -8,10 +8,12 @@
 {
   enum Type: unsigned __int32
   {
-    TYPE_Fullscreen = 1
+    TYPE_None = 0,
+    TYPE_Fullscreen = 1,
+    TYPE_Box = 2
   };
 
-  bool _443484(Type type);
+  bool Initialize(Type type);
   void Reset(unsigned __int8 uMaxProgress);
   void Progress();
   void Release();
--- a/GUIWindow.h	Sun Feb 24 01:08:02 2013 +0200
+++ b/GUIWindow.h	Sun Feb 24 01:42:35 2013 +0200
@@ -309,7 +309,7 @@
   UIMSG_195 = 0x195,
   UIMSG_OpenRestUI = 0x199,
   UIMSG_19A = 0x19A,
-  UIMSG_19B = 0x19B,
+  UIMSG_TransitionUI_Confirm = 0x19B,
   UIMSG_19C = 0x19C,
   UIMSG_OpenKeyMappingOptions = 0x19F,
   UIMSG_SelectKeyPage1 = 0x1A0,
--- a/Game.cpp	Sun Feb 24 01:08:02 2013 +0200
+++ b/Game.cpp	Sun Feb 24 01:42:35 2013 +0200
@@ -170,7 +170,7 @@
   GUI_UpdateWindows();
   pParty->UpdatePlayersAndHirelingsEmotions();
   ++stru_51076C.field_8;
-  dword_5B5924 = 0;
+  _unused_5B5924_is_travel_ui_drawn = false;
   if (v4)
     pMouse->field_14 = 1;
   pMouse->_469EA4();
--- a/Indoor.cpp	Sun Feb 24 01:08:02 2013 +0200
+++ b/Indoor.cpp	Sun Feb 24 01:42:35 2013 +0200
@@ -1794,15 +1794,10 @@
   const char *v1; // edi@1
   signed int v2; // esi@1
 
-  v1 = Str1;
-  v2 = 0;
-  while ( _strcmpi(v1, _4E6BDC_loc_names[v2]) )
-  {
-    ++v2;
-    if ( v2 >= 11 )
-      return 0;
-  }
-  return v2 + 1;
+  for (uint i = 0; i < 11; ++i)
+    if (!strcmpi(Str1, _4E6BDC_loc_names[i]))
+      return i + 1;
+  return 0;
 }
 
 
--- a/LOD.h	Sun Feb 24 01:08:02 2013 +0200
+++ b/LOD.h	Sun Feb 24 01:42:35 2013 +0200
@@ -1,6 +1,7 @@
 #pragma once
 #include <stdio.h>
 #include <memory.h>
+#include <assert.h>
 
 #include "Texture.h"
 
@@ -158,6 +159,14 @@
   void _4114F2();
   void _4355F7();
 
+  inline Texture *GetTexture(int idx)
+  {
+    assert(idx < 1000);
+    if (idx == -1)
+      return nullptr;
+    return pTextures + idx;
+  }
+
 
   /*FILE *pFile;
   unsigned __int8 pLODName[256];
--- a/NPC.cpp	Sun Feb 24 01:08:02 2013 +0200
+++ b/NPC.cpp	Sun Feb 24 01:42:35 2013 +0200
@@ -923,7 +923,7 @@
 			if (temp_str_len)
 				{
 				if ( decode_step == 1)
-					pTransitionStrings[i]=RemoveQuotes(test_string);
+					pTransitionStrings[i + 1]=RemoveQuotes(test_string);
 				}
 			else
 				{ 
--- a/mm7_2.cpp	Sun Feb 24 01:08:02 2013 +0200
+++ b/mm7_2.cpp	Sun Feb 24 01:42:35 2013 +0200
@@ -12424,7 +12424,7 @@
   v9 = bLoading;
   ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows();
   pDecalBuilder->Reset(0);
-  pGameLoadingUI_ProgressBar->_443484((GUIProgressBar::Type)v2);
+  pGameLoadingUI_ProgressBar->Initialize((GUIProgressBar::Type)v2);
   strcpy(Str1, pCurrentMapName);
   v3 = strtok(Str1, ".");
   strcpy(Str1, v3);
--- a/mm7_3.cpp	Sun Feb 24 01:08:02 2013 +0200
+++ b/mm7_3.cpp	Sun Feb 24 01:42:35 2013 +0200
@@ -14603,11 +14603,10 @@
 
 
 //----- (00444A51) --------------------------------------------------------
-char *__cdecl TransitionUI_Draw()
+void TransitionUI_Draw()
 {
   MapInfo *pMapInfo; // esi@5
   char *v1; // eax@6
-  char *result; // eax@12
   std::string v3; // [sp-18h] [bp-84h]@11
   unsigned int v4; // [sp-10h] [bp-7Ch]@12
   int v5; // [sp-Ch] [bp-78h]@12
@@ -14622,13 +14621,13 @@
   v10 = pMapStats->GetMapInfo(pCurrentMapName);
   v9 = IndoorLocation::GetLocationIndex(dword_591164_teleport_map_name);
   pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
-  pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, &pIcons_LOD->pTextures[uTextureID_50795C]);
+  pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, pIcons_LOD->GetTexture(uTextureID_50795C));
   pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside);
   uTextureID_507B04 = uTextureID_right_panel;
-  pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_right_panel != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_right_panel] : 0));
-  pRenderer->DrawTextureIndexed(556, 451, (Texture *)(uTextureID_x_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_x_u] : 0));
-  pRenderer->DrawTextureIndexed(476, 451, (Texture *)(uTextureID_x_ok_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_ok_u] : 0));
-  if ( (pVideoPlayer->AnyMovieLoaded() || v9) && *dword_591164_teleport_map_name != 48 )
+  pRenderer->DrawTextureTransparent(468, 0, pIcons_LOD->GetTexture(uTextureID_right_panel));
+  pRenderer->DrawTextureIndexed(556, 451, pIcons_LOD->GetTexture(uTextureID_x_x_u));
+  pRenderer->DrawTextureIndexed(476, 451, pIcons_LOD->GetTexture(uTextureID_x_ok_u));
+  if ( (pVideoPlayer->AnyMovieLoaded() || v9) && *dword_591164_teleport_map_name != ' ' )
     v10 = pMapStats->GetMapInfo(dword_591164_teleport_map_name);
   pMapInfo = &pMapStats->pInfos[v10];
   v8.uFrameX = 493;
@@ -14638,31 +14637,23 @@
   v8.uFrameX = 483;
   v8.uFrameWidth = 148;
   v8.uFrameZ = 334;
+
+  v1 = "";
   if ( uCurrentHouse_Animation )
   {
-    v1 = (&off_4EB080)[4 * uCurrentHouse_Animation];
-  }
-  else
-  {
-    if ( v10 )
-    {
-      sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[409], pMapInfo->pName);// "Do you wish to leave %s?"
-      v4 = (212 - pFontCreate->CalcTextHeight(pTmpBuf, &v8, 0, 0)) / 2 + 101;
-      result = v8.DrawTitleText(pFontCreate, 0, v4, 0, pTmpBuf, 3);
-      dword_5B5924 = 1;
-      return result;
-    }
-    v1 = "";
-  }
-  if ( !v1 )
-  {
-    MessageBoxW(nullptr, L"No transition text found!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1410", 0);
-    v1 = "";
-  }
-  v4 = (212 - pFontCreate->CalcTextHeight(v1, &v8, 0, 0)) / 2 + 101;
-  result = v8.DrawTitleText(pFontCreate, 0, v4, 0, v1, 3);
-  dword_5B5924 = 1;
-  return result;
+    v1 = pTransitionStrings[uCurrentHouse_Animation];
+    v4 = (212 - pFontCreate->CalcTextHeight(v1, &v8, 0, 0)) / 2 + 101;
+    v8.DrawTitleText(pFontCreate, 0, v4, 0, v1, 3);
+  }
+  else if ( v10 )
+  {
+    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[409], pMapInfo->pName);// "Do you wish to leave %s?"
+    v4 = (212 - pFontCreate->CalcTextHeight(pTmpBuf, &v8, 0, 0)) / 2 + 101;
+    v8.DrawTitleText(pFontCreate, 0, v4, 0, pTmpBuf, 3);
+  }
+  else assert(false);
+
+  _unused_5B5924_is_travel_ui_drawn = true;
 }
 
 
@@ -14782,7 +14773,7 @@
     strcat(pTmpBuf, pTmpBuf2);
     v4 = pFontCreate->CalcTextHeight(pTmpBuf, &v7, 0, 0);
     v7.DrawTitleText(pFontCreate, 0, (212 - v4) / 2 + 101, 0, pTmpBuf, 3u);
-    dword_5B5924 = 1;
+    _unused_5B5924_is_travel_ui_drawn = 1;
   }
 }
 
@@ -16872,7 +16863,7 @@
   v2 = pMapName;
   v3 = uStartingPointType;
   pAudioPlayer->StopChannels(-1, -1);
-  pGameLoadingUI_ProgressBar->_443484((GUIProgressBar::Type)0);
+  pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_None);
   if ( _strcmpi(pCurrentMapName, v2) )
     SaveGame(1, 0);
   uGameState = 2;
--- a/mm7_4.cpp	Sun Feb 24 01:08:02 2013 +0200
+++ b/mm7_4.cpp	Sun Feb 24 01:42:35 2013 +0200
@@ -1012,7 +1012,7 @@
     side1_dx = (double)(grid_pos_x1 - grid_pos_x1);
     side2_dz = (double)(grid_pos_z2 - grid_pos_z2);  // bug?  z2 - z2
     side1_dz = (double)(grid_pos_z2 - grid_pos_z2);  //       z1 - z2
-    Log::Warning(L"%s %s %u\n", __FILE__, __FUNCTION__, __LINE__);
+    Log::Warning(L"%S %S %u\n", __FILE__, __FUNCTION__, __LINE__);
     /*       |\
        side1 |  \
              |____\
@@ -10107,7 +10107,7 @@
     a1.uFrameX = 483;
     a1.uFrameWidth = 148;
     a1.uFrameZ = 334;
-    v2 = (&off_4EB080)[4 * uHouse_ExitPic];
+    v2 = pTransitionStrings[uHouse_ExitPic];
     if ( !v2 )
     {
       sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[411], v0);
--- a/mm7_5.cpp	Sun Feb 24 01:08:02 2013 +0200
+++ b/mm7_5.cpp	Sun Feb 24 01:42:35 2013 +0200
@@ -1570,7 +1570,7 @@
           }
           DrawHiredNPCs();
           continue;
-        case UIMSG_19B:
+        case UIMSG_TransitionUI_Confirm:
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
           dword_50CDC8 = v0;
@@ -1673,7 +1673,7 @@
             pStru277->_427D48(v0);
             sub_44603D();
             pEventTimer->Pause();
-            pGameLoadingUI_ProgressBar->_443484((GUIProgressBar::Type)2);
+            pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_Box);
             ++pGameLoadingUI_ProgressBar->uProgressMax;
             SaveGame(v0, 0);
             pGameLoadingUI_ProgressBar->Progress();
--- a/mm7_data.cpp	Sun Feb 24 01:08:02 2013 +0200
+++ b/mm7_data.cpp	Sun Feb 24 01:42:35 2013 +0200
@@ -1130,8 +1130,8 @@
 unsigned int saveload_dlg_zs[2] = {460, 640};
 unsigned int saveload_dlg_ws[2] = {344, 480};
 int dword_4E98BC_bApplicationActive; // weak
-char *off_4EB080; // idb
-char *pTransitionStrings[464];
+//char *off_4EB080; // idb
+char *pTransitionStrings[465] = {"", nullptr};  // 004EB080
 char aAwards_txt[777]; // idb
 char aScroll_txt[777]; // idb
 char aMerchant_txt[777]; // idb
@@ -2002,7 +2002,7 @@
 int start_event_seq_number; // weak
 char byte_5B0938[2000];
 int dword_5B5920; // weak
-int dword_5B5924; // weak
+int _unused_5B5924_is_travel_ui_drawn = false; // 005B5924
 int _5B65A8_npcdata_uflags_or_other; // weak
 int _5B65AC_npcdata_fame_or_other; // weak
 int _5B65B0_npcdata_rep_or_other; // weak
--- a/mm7_data.h	Sun Feb 24 01:08:02 2013 +0200
+++ b/mm7_data.h	Sun Feb 24 01:42:35 2013 +0200
@@ -801,8 +801,7 @@
 extern unsigned int saveload_dlg_zs[2];
 extern unsigned int saveload_dlg_ws[2];
 extern int dword_4E98BC_bApplicationActive; // weak
-extern char *off_4EB080; // idb
-extern char *pTransitionStrings[464];
+extern char *pTransitionStrings[]; // 4EB080
 extern char aAwards_txt[]; // idb
 extern char aScroll_txt[]; // idb
 extern char aMerchant_txt[]; // idb
@@ -1345,7 +1344,7 @@
 extern int start_event_seq_number; // weak
 extern char byte_5B0938[2000];
 extern int dword_5B5920; // weak
-extern int dword_5B5924; // weak
+extern int _unused_5B5924_is_travel_ui_drawn; // 005B5924
 extern int _5B65A8_npcdata_uflags_or_other; // weak
 extern int _5B65AC_npcdata_fame_or_other; // weak
 extern int _5B65B0_npcdata_rep_or_other; // weak
@@ -2013,7 +2012,7 @@
 const char *__cdecl sub_444564();
 char *__thiscall GetEventHintString(unsigned int uEventID); // idb
 unsigned int __fastcall sub_444839_move_map(unsigned int a1, int a2, int x, int y, int z, int directiony, int directionx, int a8, const char *pLocationName); // idb
-char *__cdecl TransitionUI_Draw();
+void TransitionUI_Draw();
 struct GUIWindow *__cdecl UI_CreateTravelDialogue();
 signed int __cdecl GetTravelTime();
 void __cdecl TravelUI_Draw();