changeset 203:0c64754c7fd4

Voices work (at least in party creation screen)
author Nomad
date Sun, 17 Feb 2013 05:27:56 +0200
parents 30aa44013f7a
children 335db7429f7c
files Player.cpp SaveLoad.cpp mm7_2.cpp mm7_4.cpp mm7_5.cpp mm7_data.cpp mm7_data.h
diffstat 7 files changed, 149 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/Player.cpp	Sun Feb 17 00:16:48 2013 +0200
+++ b/Player.cpp	Sun Feb 17 05:27:56 2013 +0200
@@ -576,7 +576,7 @@
   //Player *pPlayer; // edi@1
   //int v4; // eax@4
   signed int v5; // esi@4
-  char *v6; // ebx@4
+  unsigned char *v6; // ebx@4
   signed int v7; // ecx@5
   unsigned __int8 v8; // al@6
   int v9; // eax@10
@@ -608,8 +608,8 @@
   //v4 = a2;//102
   v5 = 0;
   pSoundId = 0;
-  v6 = (char *)&SoundSetAction[4 * speech];//byte_4ED280 &byte_4ED3D8[4 * v4] ???
-  if ( uVoicesVolumeMultiplier )
+  v6 = SoundSetAction[speech];//byte_4ED280 &byte_4ED3D8[4 * v4] ???
+  if (uVoicesVolumeMultiplier)
   {
     v7 = 0;
     do
@@ -625,17 +625,16 @@
       v9 = rand();
       //pVoiceID = uVoiceID;
       v11 = v20[v9 % v5];
-      if ( LOBYTE((&(&dlhu_texnames_by_face[19])[25 * v11 + 3])[uVoiceID]) )
-      {
-        pSoundId = rand() % SLOBYTE((&(&dlhu_texnames_by_face[19])[25 * v11 + 3])[uVoiceID])
-            + 2 * (v11 + 50 * uVoiceID)
-            + 4998;
-        v12 = 8 * pPlayerNum + 312;
-        LOBYTE(v12) = v12 | OBJECT_Player;
+
+      if (int _v1 = byte_4ECF08[v11 - 1][uVoiceID])
+      {
+        pSoundId = rand() % _v1 + 2 * (v11 + 50 * uVoiceID) + 4998;
+        v12 = (8 * pPlayerNum + 312) | OBJECT_Player;
         pAudioPlayer->PlaySound((SoundID)pSoundId, v12, 0, -1, 0, 0, (pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0), 0);
       }
     }
   }
+
   v13 = 0;
   v14 = (int)(v6 + 3);
   do
@@ -1374,7 +1373,7 @@
 
   v11 = this;
   v3 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-  v4 = (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0);
+  v4 = (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0);
   v5 = GetSizeInInventorySlots(v3 != -1 ? pIcons_LOD->pTextures[v3].uTextureWidth : 24);
   uItemIDa = GetSizeInInventorySlots(v4->uTextureHeight);
   if ( !areWeLoadingTexture )
--- a/SaveLoad.cpp	Sun Feb 17 00:16:48 2013 +0200
+++ b/SaveLoad.cpp	Sun Feb 17 05:27:56 2013 +0200
@@ -67,18 +67,18 @@
     }
 
 
-  if (byte_4ED498)
+  if (SoundSetAction[24][0])
     for (uint i = 0; i < 4; ++i)
     {
       for (uint j = 0; j < pSoundList->uNumSounds; ++j)
-        if (pSoundList->pSounds[j].uSoundID == 2 * (byte_4ED498 + 50 * pParty->pPlayers[i].uVoiceID) + 4998)
+        if (pSoundList->pSounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4998)
         {
           pSoundList->_4A9DCD(j, 1);
           break;
         }
 
         for (uint j = 0; j < pSoundList->uNumSounds; ++j)
-        if (pSoundList->pSounds[j].uSoundID == 2 * (byte_4ED498 + 50 * pParty->pPlayers[i].uVoiceID) + 4999)
+        if (pSoundList->pSounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4999)
         {
           pSoundList->_4A9DCD(j, 1);
           break;
--- a/mm7_2.cpp	Sun Feb 17 00:16:48 2013 +0200
+++ b/mm7_2.cpp	Sun Feb 17 05:27:56 2013 +0200
@@ -13028,6 +13028,9 @@
   }
 }
 
+
+
+
 //----- (004651F4) --------------------------------------------------------
 bool MM7_Initialize()
 {
@@ -13047,7 +13050,6 @@
   }
 
 
-
   srand(GetTickCount());
   /*GetDiskFreeSpaceA(0, &SectorsPerCluster, &BytesPerSector, &hdc, &TotalNumberOfClusters);
   v4 = hdc * BytesPerSector * SectorsPerCluster;
@@ -13535,19 +13537,6 @@
       sprintf(pTmpBuf, "data\\lloyd%d%d.pcx", i, j);
       remove(pTmpBuf);
     }
-  /*do
-  {
-    v11 = 1;
-    do
-    {
-      sprintfex(pTmpBuf, "data\\lloyd%d%d.pcx", v10, v11);
-      remove(pTmpBuf);
-      ++v11;
-    }
-    while ( v11 < 6 );
-    ++v10;
-  }
-  while ( v10 < 5 );*/
 
   Initialize_GamesLOD_NewLOD();
   dword_576E2C = 512;
--- a/mm7_4.cpp	Sun Feb 17 00:16:48 2013 +0200
+++ b/mm7_4.cpp	Sun Feb 17 05:27:56 2013 +0200
@@ -2889,11 +2889,11 @@
   pTexture_PlayerFaceDead = pIcons_LOD->LoadTexturePtr("DEAD", TEXTURE_16BIT_PALETTE);
   pTexture_PlayerFaceMask = pIcons_LOD->LoadTexturePtr("FACEMASK", TEXTURE_16BIT_PALETTE);
   
-  if (byte_4ED498)
+  if (SoundSetAction[24][0])
     for (uint i = 0; i < 4; ++i)
     {
-      pSoundList->LoadSound(2 * (byte_4ED498 + 50 * pParty->pPlayers[i].uVoiceID) + 4998, 0);
-      pSoundList->LoadSound(2 * (byte_4ED498 + 50 * pParty->pPlayers[i].uVoiceID) + 4999, 0);
+      pSoundList->LoadSound(2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4998, 0);
+      pSoundList->LoadSound(2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4999, 0);
     }
 }
 
@@ -2941,7 +2941,7 @@
   v0 = pParty->pPlayers;
   do
   {
-    if ( byte_4ED498 )
+    if (SoundSetAction[24][0])
     {
       v1 = 0;
       if ( (signed int)pSoundList->uNumSounds <= 0 )
@@ -2952,7 +2952,7 @@
       else
       {
         v2 = (char *)&pSoundList->pSounds->uSoundID;
-        while ( *(int *)v2 != 2 * ((unsigned __int8)byte_4ED498 + 50 * v0->uVoiceID) + 4998 )
+        while ( *(int *)v2 != 2 * (SoundSetAction[24][0] + 50 * v0->uVoiceID) + 4998 )
         {
           ++v1;
           v2 += 120;
@@ -2971,7 +2971,7 @@
       else
       {
         v5 = (char *)&pSoundList->pSounds->uSoundID;
-        while ( *(int *)v5 != 2 * ((unsigned __int8)byte_4ED498 + 50 * v0->uVoiceID) + 4999 )
+        while ( *(int *)v5 != 2 * (SoundSetAction[24][0] + 50 * v0->uVoiceID) + 4999 )
         {
           ++v4;
           v5 += 120;
--- a/mm7_5.cpp	Sun Feb 17 00:16:48 2013 +0200
+++ b/mm7_5.cpp	Sun Feb 17 05:27:56 2013 +0200
@@ -13148,7 +13148,7 @@
   //unsigned __int8 v8; // sf@8
   //unsigned __int8 v9; // of@8
   char pContainer[20]; // [sp+Ch] [bp-1Ch]@7
-  Texture *v11; // [sp+20h] [bp-8h]@5
+  //Texture *v11; // [sp+20h] [bp-8h]@5
   //int v12; // [sp+24h] [bp-4h]@5
 
   byte_506550 = 0;
@@ -13160,11 +13160,11 @@
   else
     dword_50654C = 0;
 
-  v11 = (Texture *)&pPlayer->field_152[11 * school + 63];
+  char *v11 = &pPlayer->field_152[11 * school + 63];
 
   for (uint i = 1; i < 12; ++i)
   {
-    if ( v11->pName[i] )
+    if (v11[i])
     {
       sprintf(pContainer, "SB%sS%02d", spellbook_texture_filename_suffices[school], pSpellbookSpellIndices[school][i]);
       dword_506408[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
--- a/mm7_data.cpp	Sun Feb 17 00:16:48 2013 +0200
+++ b/mm7_data.cpp	Sun Feb 17 05:27:56 2013 +0200
@@ -1097,16 +1097,128 @@
   "pc19lhu", "pc20lhu", "pc21lhu", "pc22lhu", "pc23lhu", "pc24lhu",
   "pc25lhu"
 };
-short SoundSetAction[192]= // 4ED3D8
+
+unsigned char byte_4ECF08[48][25] =      // 4ECF08
+{
+  {2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1},
+  {2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2}, // IMCOMPLETE
+  {2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
+  {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2},
+  {2, 2, 2, 2, 2, 1, 2, 2}
+};
+unsigned char SoundSetAction[110][8] = // 4ED3D8
 {
-	0, 0, 0, 0, 0, 0, 0, 0, 38, 0, 0, 37, 38, 45, 0, 0, 37, 0, 0, 47, 53, 0, 0, 0, 2, 0, 0, 25, 0, 0, 0, 0, 1, 0, 0, 47, 0,
-	0, 0, 0, 3, 0, 0, 41, 42, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 5, 0, 0, 21, 22, 23, 24, 45, 6, 0, 0, 47, 0, 0, 0, 0, 7, 0,
-	0, 43, 48, 0, 0, 0, 8, 0, 0, 38, 0, 0, 0, 0, 9, 0, 0, 39, 0, 0, 0, 0, 13, 0, 0, 37, 38, 0, 0, 0, 23, 0, 0, 25, 0, 0, 0,
-	0, 0, 0, 0, 37, 38, 45, 0, 0, 25, 0, 0, 25, 0, 0, 0, 0, 26, 0, 0, 38, 47, 0, 0, 0, 27, 0, 0, 41, 42, 0, 0, 0, 28, 0, 0,
-	25, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 30, 0, 0, 25, 0, 0, 0, 0, 29, 0, 0, 27, 0, 0, 0, 0, 32, 33, 0, 37, 38, 0, 0, 0,
-	34, 0, 0, 53, 0, 0, 0, 0
-}; // weak
-unsigned char byte_4ED498 = 15; // weak
+  { 0,  0,  0,  0,  0,  0,  0,  0},
+  {38,  0,  0, 37, 38, 45,  0,  0},
+  {37,  0,  0, 47, 53,  0,  0,  0},
+  { 2,  0,  0, 25,  0,  0,  0,  0},
+  { 1,  0,  0, 47,  0,  0,  0,  0},
+  { 3,  0,  0, 41, 42,  0,  0,  0},
+  { 0,  0,  0, 33,  0,  0,  0,  0},
+  { 5,  0,  0, 21, 22, 23, 24, 45},
+  { 6,  0,  0, 47,  0,  0,  0,  0},
+  { 7,  0,  0, 43, 48,  0,  0,  0},
+  { 8,  0,  0, 38,  0,  0,  0,  0},
+  { 9,  0,  0, 39,  0,  0,  0,  0},
+  {13,  0,  0, 37, 38,  0,  0,  0},
+  {23,  0,  0, 25,  0,  0,  0,  0},
+  { 0,  0,  0, 37, 38, 45,  0,  0},
+  {25,  0,  0, 25,  0,  0,  0,  0},
+  {26,  0,  0, 38, 47,  0,  0,  0},
+  {27,  0,  0, 41, 42,  0,  0,  0},
+  {28,  0,  0, 25,  0,  0,  0,  0},
+  { 0,  0,  0, 51,  0,  0,  0,  0},
+  {30,  0,  0, 25,  0,  0,  0,  0},
+  {29,  0,  0, 27,  0,  0,  0,  0},
+  {32, 33,  0, 37, 38,  0,  0,  0},
+  {34,  0,  0, 53,  0,  0,  0,  0},
+  {15,  0,  0, 34, 35, 36,  0,  0},
+  { 0,  0,  0,  3,  0,  0,  0,  0},
+  {22,  0,  0,  5,  0,  0,  0,  0},
+  {20,  0,  0,  8,  0,  0,  0,  0},
+  {20,  0,  0,  9,  0,  0,  0,  0},
+  {19,  0,  0,  7,  0,  0,  0,  0},
+  {21,  0,  0,  2,  0,  0,  0,  0},
+  {18,  0,  0,  6,  0,  0,  0,  0},
+  { 0,  0,  0, 11,  0,  0,  0,  0},
+  {17,  0,  0,  0,  0,  0,  0,  0},
+  { 0,  0,  0, 12,  0,  0,  0,  0},
+  {17,  0,  0,  0,  0,  0,  0,  0},
+  { 0,  0,  0, 37,  0,  0,  0,  0},
+  { 0,  0,  0, 49,  0,  0,  0,  0},
+  {24,  0,  0, 25,  0,  0,  0,  0},
+  {31,  0,  0, 25,  0,  0,  0,  0},
+  { 0,  0,  0, 41, 42,  0,  0,  0},
+  { 0,  0,  0, 39, 48,  0,  0,  0},
+  { 0,  0,  0, 46,  0,  0,  0,  0}, 
+  { 0,  0,  0, 39, 48,  0,  0,  0},
+  { 0,  0,  0, 41, 42,  0,  0,  0},
+  { 0,  0,  0, 39, 48,  0,  0,  0},
+  {41,  0,  0, 21,  0,  0,  0,  0},
+  {40,  0,  0, 21,  0,  0,  0,  0},
+  {16,  0,  0, 46,  0,  0,  0,  0},
+  { 0,  0,  0, 40,  0,  0,  0,  0},
+  { 0,  0,  0, 39,  0,  0,  0,  0},
+  { 0,  0,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 48, 49, 50,  0,  0},
+  { 0,  0,  0, 44,  0,  0,  0,  0},
+  { 0,  0,  0, 48,  0,  0,  0,  0},
+  { 0,  0,  0, 37, 38, 45,  0,  0},
+  { 0,  0,  0, 41, 42,  0,  0,  0},
+  { 0,  0,  0, 47,  0,  0,  0,  0},
+  { 0,  0,  0, 39, 48,  0,  0,  0},
+  { 0,  0,  0, 39, 48,  0,  0,  0},
+  { 0,  0,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 31,  0,  0,  0,  0},
+  { 0,  0,  0, 32,  0,  0,  0,  0},
+  {47,  0,  0, 46,  0,  0,  0,  0},
+  {22,  0,  0,  5,  0,  0,  0,  0},
+  { 0,  0,  0, 25,  0,  0,  0,  0},
+  { 0,  0,  0, 37,  0,  0,  0,  0},
+  { 0,  0,  0, 52,  0,  0,  0,  0},
+  { 0,  0,  0, 45,  0,  0,  0,  0},
+  { 0,  0,  0, 27,  0,  0,  0,  0},
+  { 0,  0,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 49,  0,  0,  0,  0},
+  { 0,  0,  0, 48,  0,  0,  0,  0},
+  { 0,  0,  0, 37, 38, 45,  0,  0},
+  { 0,  0,  0, 48,  0,  0,  0,  0},
+  { 0,  0,  0, 37, 38, 45,  0,  0},
+  { 0,  0,  0, 47,  0,  0,  0,  0},
+  { 0,  0,  0, 48,  0,  0,  0,  0},
+  {44,  0,  0, 39, 48,  0,  0,  0},
+  { 0,  0,  0, 48, 49,  0,  0,  0},
+  { 0,  0,  0, 38,  0,  0,  0,  0},
+  { 0,  0,  0, 31,  0,  0,  0,  0},
+  {32, 33,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 47,  0,  0,  0,  0},
+  { 0,  0,  0, 38,  0,  0,  0,  0},
+  { 0,  0,  0, 48,  0,  0,  0,  0},
+  { 0,  0,  0,  0,  0,  0,  0,  0},
+  { 0,  0,  0, 38,  0,  0,  0,  0},
+  { 0,  0,  0, 47,  0,  0,  0,  0},
+  { 0,  0,  0, 38,  0,  0,  0,  0},
+  { 0,  0,  0,  0,  0,  0,  0,  0},
+  { 0,  0,  0,  0,  0,  0,  0,  0},
+  { 0,  0,  0, 38,  0,  0,  0,  0},
+  { 0,  0,  0, 38,  0,  0,  0,  0},
+  { 0,  0,  0,  5,  0,  0,  0,  0},
+  { 0,  0,  0, 37, 38,  0,  0,  0},
+  { 0,  0,  0, 44,  0,  0,  0,  0},
+  { 0,  0,  0, 48,  0,  0,  0,  0},
+  { 4,  0,  0,  0,  0,  0,  0,  0},
+  { 0,  0,  0, 58,  0,  0,  0,  0},
+  {10,  0,  0, 45,  0,  0,  0,  0},
+  {11,  0,  0, 47,  0,  0,  0,  0},
+  {12,  0,  0, 43, 48,  0,  0,  0},
+  {39,  0,  0, 48,  0,  0,  0,  0},
+  {14,  0,  0, 48,  0,  0,  0,  0},
+  {17,  0,  0,  0,  0,  0,  0,  0}
+};
 __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[4] = {34, 149, 264, 379};
 char byte_4ED970_skill_learn_ability_by_class_table[32][37];
 int dword_4EDEA0[777]; // weak
--- a/mm7_data.h	Sun Feb 17 00:16:48 2013 +0200
+++ b/mm7_data.h	Sun Feb 17 05:27:56 2013 +0200
@@ -978,8 +978,9 @@
 extern const char *drh_texnames_by_face[25];
 extern const char *dlh_texnames_by_face[25];
 extern const char *dlhu_texnames_by_face[25];
-extern short SoundSetAction[192]; // weak
-extern unsigned char byte_4ED498; // weak
+extern unsigned char byte_4ECF08[48][25];
+extern unsigned char SoundSetAction[110][8]; // weak
+//extern unsigned char byte_4ED498; // weak
 extern __int16 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[4];
 extern char byte_4ED970_skill_learn_ability_by_class_table[32][37];
 extern int dword_4EDEA0[]; // weak