changeset 373:edd2d8b7e3c4

Interface reloading fix & party alignment enum
author Nomad
date Fri, 22 Feb 2013 18:40:38 +0200
parents 6a2b4d1be013
children 615e6b6f55c2 50875632e776 4a60371fd70c
files Actor.cpp Events.cpp GUIProgressBar.cpp Party.cpp Party.h Render.cpp SaveLoad.cpp SaveLoad.h mm7_1.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_5.cpp mm7_data.h
diffstat 14 files changed, 108 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Fri Feb 22 17:56:00 2013 +0200
+++ b/Actor.cpp	Fri Feb 22 18:40:38 2013 +0200
@@ -151,14 +151,14 @@
   NPCData *v4; // eax@1
   NPCData *v5; // ebp@1
   unsigned int v6; // eax@1
-  signed int v7; // eax@3
+  //signed int v7; // eax@3
   unsigned int v8; // eax@8
   int v9; // esi@8
   int v10; // eax@11
   GUIWindow *v11; // ecx@19
   signed int v12; // eax@21
   //int v13; // [sp-8h] [bp-44h]@34
-  const char *v14; // [sp-4h] [bp-40h]@4
+  //const char *v14; // [sp-4h] [bp-40h]@4
   //int v15; // [sp-4h] [bp-40h]@34
   signed int v16; // [sp-4h] [bp-40h]@35
   int v17; // [sp+10h] [bp-2Ch]@1
@@ -181,9 +181,9 @@
   v6 = v4->uFlags;
   if ( (v6 & 3) != 2 )
     v5->uFlags = v6 + 1;
-  v7 = const_2();
+  /*v7 = const_2();
   sprintf(pContainer, "evt%02d", v7);
-  if ( !pParty->uAlignment )
+  if (pParty->alignment == PartyAlignment_Good)
   {
     v14 = "-b";
     strcat(pContainer, v14);
@@ -192,7 +192,15 @@
   {
     v14 = "-c";
     strcat(pContainer, v14);
+  }*/
+
+  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;
   }
+
   v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
   array_5913D8[6] = 0;
   uNumDialogueNPCPortraits = 1;
--- a/Events.cpp	Fri Feb 22 17:56:00 2013 +0200
+++ b/Events.cpp	Fri Feb 22 18:40:38 2013 +0200
@@ -25,6 +25,7 @@
 #include "Events.h"
 #include "Events2D.h"
 #include "Weather.h"
+#include "Party.h"
 
 
 
@@ -367,11 +368,11 @@
 				v16 = RemoveQuotes(Str);
 				VideoPlayer::MovieLoop(v16, 0, v14, 1);
 				if ( !_strcmpi(v16, "arbiter good") )
-					{
-					pParty->uAlignment = 0;
+                {
+                  pParty->alignment = PartyAlignment_Good;
 					v18 = 0;
 					LOBYTE(v17) = 1;
-					SetUserInterface(v18, v17);
+					SetUserInterface(PartyAlignment_Good, v17);
 					if ( !v15 || v128 == 3 )
 						{
 						pCurrentScreen = v128;
@@ -392,9 +393,9 @@
 				if ( !_strcmpi(v16, "arbiter evil") )
 					{
 					v18 = 2;
-					pParty->uAlignment = 2;
+					pParty->alignment = PartyAlignment_Evil;
 					LOBYTE(v17) = 1;
-					SetUserInterface(v18, v17);
+					SetUserInterface(PartyAlignment_Evil, v17);
 					if ( !v15 || v128 == 3 )
 						{
 						pCurrentScreen = v128;
--- a/GUIProgressBar.cpp	Fri Feb 22 17:56:00 2013 +0200
+++ b/GUIProgressBar.cpp	Fri Feb 22 18:40:38 2013 +0200
@@ -1,3 +1,5 @@
+#include <assert.h>
+
 #include "GUIProgressBar.h"
 #include "LOD.h"
 #include "Mouse.h"
@@ -23,8 +25,8 @@
   int v5; // ecx@8
   int v6; // edi@8
   int v7; // edx@14
-  const char *v8; // [sp-8h] [bp-84h]@20
-  unsigned int v9; // [sp-4h] [bp-80h]@20
+  //const char *v8; // [sp-8h] [bp-84h]@20
+  //unsigned int v9; // [sp-4h] [bp-80h]@20
   char Str1[64]; // [sp+4h] [bp-78h]@16
 
   if (type < 1 || type > 1)
@@ -74,7 +76,8 @@
     Draw();
     return true;
   }
-  if ( !pParty->uAlignment )
+
+  /*if ( !pParty->uAlignment )
   {
     v9 = 2;
     v8 = "bardata-b";
@@ -92,7 +95,15 @@
     v8 = "bardata-c";
 LABEL_23:
     pIcons_LOD->_410522(&pBardata, v8, v9);
+  }*/
+  switch (pParty->alignment)
+  {
+    case PartyAlignment_Good:    pIcons_LOD->_410522(&pBardata, "bardata-b", 2); break;
+    case PartyAlignment_Neutral: pIcons_LOD->_410522(&pBardata, "bardata", 2); break;
+    case PartyAlignment_Evil:    pIcons_LOD->_410522(&pBardata, "bardata-c", 2); break;
+    default: assert(false);
   }
+
   uProgressCurrent = 0;
   uProgressMax = 26;
   Draw();
--- a/Party.cpp	Fri Feb 22 17:56:00 2013 +0200
+++ b/Party.cpp	Fri Feb 22 18:40:38 2013 +0200
@@ -555,9 +555,9 @@
   uNumGold = 200;
   uNumGoldInBank = 0;
   uNumFoodRations = 7;
-  uAlignment = 1;
 
-  SetUserInterface(uAlignment, true);
+  alignment = PartyAlignment_Neutral;
+  SetUserInterface(alignment, true);
 
   uTimePlayed = 0x21C00u;
   uLastRegenerationTime = 0x21C00;
--- a/Party.h	Fri Feb 22 17:56:00 2013 +0200
+++ b/Party.h	Fri Feb 22 18:40:38 2013 +0200
@@ -95,6 +95,12 @@
 
 
 
+enum PartyAlignment: unsigned __int32
+{
+  PartyAlignment_Good = 0,
+  PartyAlignment_Neutral = 1,
+  PartyAlignment_Evil = 2
+};
 
 
 
@@ -253,7 +259,7 @@
   unsigned int bTurnBasedModeOn;
   int field_880;
   int uFlags2;
-  unsigned int uAlignment;
+  PartyAlignment alignment;
   SpellBuff pPartyBuffs[20];
   Player pPlayers[4];
   NPCData pHirelings[2];
--- a/Render.cpp	Fri Feb 22 17:56:00 2013 +0200
+++ b/Render.cpp	Fri Feb 22 18:40:38 2013 +0200
@@ -10976,7 +10976,7 @@
       while ( v2 < (signed int)pObjectList->uNumObjects );
     }
     LOBYTE(v1) = 1;
-    SetUserInterface(pParty->uAlignment, v1);
+    SetUserInterface(pParty->alignment, v1);
     if ( pVideoPlayer->pVideoFrame.pPixels )
       pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1);
     if ( uCurrentMenuID )
--- a/SaveLoad.cpp	Fri Feb 22 17:56:00 2013 +0200
+++ b/SaveLoad.cpp	Fri Feb 22 18:40:38 2013 +0200
@@ -196,7 +196,7 @@
 
   viewparams->bRedrawGameUI = true;
 
-  SetUserInterface(pParty->uAlignment, true);
+  SetUserInterface(pParty->alignment, true);
 
   pEventTimer->Resume();
   pEventTimer->StopGameTime();
@@ -670,7 +670,8 @@
 //----- (0045E297) --------------------------------------------------------
 void SavegameList::Initialize(unsigned int bHideEmptySlots)
 {
-    memset(pSavegameList, 0, 0x3138);
+    //memset(pSavegameList, 0, 0x3138);
+  Reset();
     uNumSavegameFiles = 0;
 
   _chdir("saves");
--- a/SaveLoad.h	Fri Feb 22 17:56:00 2013 +0200
+++ b/SaveLoad.h	Fri Feb 22 18:40:38 2013 +0200
@@ -8,8 +8,16 @@
 {
   void Initialize(unsigned int a1);
 
+  inline void Reset()
+  {
+    for (int i = 0; i < 20; ++i)
+      field_0[i] = 0;
+    for (int i = 0; i < 44; ++i)
+      pSavesNames[i][0] = 0;
+  }
+
   char field_0[20];
-  char pSavesNames[40][280];
+  char pSavesNames[44][280];
 };
 #pragma pack(pop)
 
--- a/mm7_1.cpp	Fri Feb 22 17:56:00 2013 +0200
+++ b/mm7_1.cpp	Fri Feb 22 18:40:38 2013 +0200
@@ -5,6 +5,8 @@
 */
 
 //#include <defs.h>
+#include <assert.h>
+
 #include "MM7.h"
 
 #include "MapInfo.h"
@@ -6115,21 +6117,16 @@
 // 4E28F8: using guessed type int pCurrentScreen;
 
 //----- (004226EF) --------------------------------------------------------
-void __fastcall SetUserInterface(int a1, bool bReplace)
+void SetUserInterface(PartyAlignment align, bool bReplace)
 {
-  int v2; // ecx@2
   unsigned int v3; // eax@7
   unsigned __int16 v4; // dx@7
   unsigned __int16 v5; // cx@7
   unsigned __int16 v6; // [sp-4h] [bp-14h]@7
 
-  if ( a1 )
-  {
-    v2 = a1 - 1;
-    if ( v2 )
-    {
-      if ( v2 != 1 )
-        return;
+
+    if (align == PartyAlignment_Evil)
+    {
       if ( bReplace )
       {
         pTexture_RightFrame->Reload("ib-r-C.pcx");
@@ -6213,7 +6210,7 @@
       v6 = 0;
       v5 = 10;
     }
-    else
+    else if (align == PartyAlignment_Neutral)
     {
       if ( bReplace )
       {
@@ -6309,8 +6306,7 @@
       v5 = 230;
       v6 = 193;
     }
-  }
-  else
+  else if (align == PartyAlignment_Good)
   {
     if ( bReplace )
     {
@@ -6361,6 +6357,8 @@
     v4 = 225;
     v6 = 255;
   }
+  else assert(false);
+
   uGameUIFontMain = v3;
   uGameUIFontShadow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v5, v4, v6);
 }
--- a/mm7_2.cpp	Fri Feb 22 17:56:00 2013 +0200
+++ b/mm7_2.cpp	Fri Feb 22 18:40:38 2013 +0200
@@ -13431,7 +13431,7 @@
       Rect.bottom = 246;
       ClipCursor(&Rect);
     }
-    SetUserInterface(1, false);
+    SetUserInterface(PartyAlignment_Neutral, false);
     ShowIntroVideo_and_LoadingScreen();
     WriteWindowsRegistryInt("Ran once", 1);
     dword_6BE364_game_settings_1 |= 0x4000;
--- a/mm7_3.cpp	Fri Feb 22 17:56:00 2013 +0200
+++ b/mm7_3.cpp	Fri Feb 22 18:40:38 2013 +0200
@@ -14670,14 +14670,14 @@
 //----- (00444C8F) --------------------------------------------------------
 GUIWindow *__cdecl UI_CreateTravelDialogue()
 {
-  signed int v0; // eax@1
+  //signed int v0; // eax@1
   unsigned int v1; // eax@6
   GUIWindow *result; // eax@9
-  const char *v3; // [sp-4h] [bp-2Ch]@2
+  //const char *v3; // [sp-4h] [bp-2Ch]@2
   char pContainer[32]; // [sp+0h] [bp-28h]@1
 
   pEventTimer->Pause();
-  v0 = const_2();
+  /*v0 = const_2();
   sprintf(pContainer, "evt%02d", v0);
   if ( pParty->uAlignment )
   {
@@ -14690,7 +14690,15 @@
     v3 = "-b";
   }
   strcat(pContainer, v3);
-LABEL_6:
+LABEL_6:*/
+  switch (pParty->alignment)
+  {
+    case PartyAlignment_Good:    sprintf(pContainer, "evt%02d-b", const_2());
+    case PartyAlignment_Neutral: sprintf(pContainer, "evt%02d", const_2());
+    case PartyAlignment_Evil:    sprintf(pContainer, "evt%02d-c", const_2());
+    default: assert(false);
+  }
+
   pTexture_Dialogue_Background = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)];
   pTexture_outside = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("outside", TEXTURE_16BIT_PALETTE)];
   v1 = pMapStats->GetMapInfo(pCurrentMapName);
--- a/mm7_4.cpp	Fri Feb 22 17:56:00 2013 +0200
+++ b/mm7_4.cpp	Fri Feb 22 18:40:38 2013 +0200
@@ -14763,7 +14763,7 @@
 {
   unsigned int v9; // ebx@1
   int v10; // edi@1
-  signed int v11; // eax@1
+  //signed int v11; // eax@1
   unsigned int v12; // eax@6
   const char *v13; // ST0C_4@6
   unsigned int v14; // eax@8
@@ -14771,7 +14771,7 @@
   unsigned int v16; // eax@16
   unsigned int result; // eax@26
   const char *v18; // [sp-8h] [bp-40h]@9
-  const char *v19; // [sp-4h] [bp-3Ch]@2
+  //const char *v19; // [sp-4h] [bp-3Ch]@2
   char *v20; // [sp-4h] [bp-3Ch]@9
   const char *v21; // [sp-4h] [bp-3Ch]@11
   char pContainer[40]; // [sp+Ch] [bp-2Ch]@1
@@ -14790,7 +14790,15 @@
   uCurrentHouse_Animation = v9;
   pEventTimer->Pause();
   pAudioPlayer->StopChannels(-1, -1);
-  v11 = const_2();
+
+  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);
+  }
+  /*v11 = const_2();
   sprintf(pContainer, "evt%02d", v11);
   if ( pParty->uAlignment )
   {
@@ -14802,8 +14810,9 @@
   {
     v19 = "-b";
   }
-  strcat(pContainer, v19);
-LABEL_6:
+  strcat(pContainer, v19);*/
+
+//LABEL_6:
   v12 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
   v13 = pHouse_ExitPictures[v10];
   pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v12];
@@ -14999,12 +15008,12 @@
   //Player *v13; // esi@25
   int v14; // eax@25
   //Player *v15; // esi@27
-  signed int v16; // eax@32
+  //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
+  //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
@@ -15122,7 +15131,8 @@
     ++pIcons_LOD->uTexturePacksCount;
     if ( !pIcons_LOD->uNumPrevLoadedFiles )
       pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-    v16 = const_2();
+
+    /*v16 = const_2();
     sprintf(pContainer, "evt%02d", v16);
     if ( pParty->uAlignment )
     {
@@ -15134,8 +15144,16 @@
     {
       v22 = "-b";
     }
-    strcat(pContainer, v22);
-LABEL_37:
+    strcat(pContainer, v22);*/
+//LABEL_37:
+    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);
     array_5913D8[6] = 0;
     pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v17];
--- a/mm7_5.cpp	Fri Feb 22 17:56:00 2013 +0200
+++ b/mm7_5.cpp	Fri Feb 22 18:40:38 2013 +0200
@@ -6273,8 +6273,8 @@
   char pContainer[128]; // [sp+24h] [bp-14h]@12
 
   uTextureID_MAGNIF_B = pIcons_LOD->LoadTexture("MAGNIF-B", TEXTURE_16BIT_PALETTE);
-  if ( !pParty->uAlignment || pParty->uAlignment == 1 || pParty->uAlignment == 2 )
-    uTextureID_BACKDOLL = pIcons_LOD->LoadTexture("BACKDOLL", TEXTURE_16BIT_PALETTE);
+  //if ( !pParty->uAlignment || pParty->uAlignment == 1 || pParty->uAlignment == 2 )
+  uTextureID_BACKDOLL = pIcons_LOD->LoadTexture("BACKDOLL", TEXTURE_16BIT_PALETTE);
   uTextureID_507B04 = uTextureID_right_panel;
   v30 = 0;
   uTextureID_BACKHAND = pIcons_LOD->LoadTexture("BACKHAND", TEXTURE_16BIT_PALETTE);
--- a/mm7_data.h	Fri Feb 22 17:56:00 2013 +0200
+++ b/mm7_data.h	Fri Feb 22 18:40:38 2013 +0200
@@ -1915,7 +1915,7 @@
 void __cdecl sub_421EA6_OnInventoryLeftClick();
 void __cdecl OnGameViewportClick();
 bool PauseGameDrawing();
-void __fastcall SetUserInterface(int a1, bool bReplace);
+void SetUserInterface(enum PartyAlignment alignment, bool bReplace);
 void __cdecl reset_some_strus_flt_2Cs();
 void __cdecl j_sub_423B4A();
 void __cdecl sub_423B4A();