diff mm7_5.cpp @ 187:49728858c35e

On player voices
author Nomad
date Fri, 15 Feb 2013 22:38:05 +0200
parents 572d821561f3
children 9b77686e2239
line wrap: on
line diff
--- a/mm7_5.cpp	Fri Feb 15 19:53:40 2013 +0200
+++ b/mm7_5.cpp	Fri Feb 15 22:38:05 2013 +0200
@@ -2879,9 +2879,9 @@
             {
               v89 = uActiveCharacter;
               v176 = 0;
-              v160 = 108;
+              v160 = SPEECH_108;
 LABEL_619:
-              pPlayers[v89]->PlaySound(v160, v176);
+              pPlayers[v89]->PlaySound((PlayerSpeech)v160, v176);
             }
           }
           else
@@ -3022,7 +3022,7 @@
           pPlayers[uActiveCharacter]->uQuickSpell = v99;
           stru_A750F8[uActiveCharacter + 3]._494836(v99, uActiveCharacter);
           if ( uActiveCharacter )
-            pPlayer10->PlaySound(12, 0);
+            pPlayer10->PlaySound(SPEECH_12, 0);
           byte_506550 = 0;
           continue;
         case UIMSG_33:
@@ -3243,7 +3243,7 @@
           pRenderer->SavePCXImage("gamma.pcx", (char *)uNumSeconds, 155, 117);
           free((void *)uNumSeconds);
           stru_506E40._40E55E("gamma.pcx", 0);
-          GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, (enum WindowType)92, (int)pBtn_GameSettings, 0);
+          GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, WINDOW_VoiceSwitcherButton, (int)pBtn_GameSettings, 0);
 //LABEL_453:
           if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
             continue;
@@ -3342,7 +3342,7 @@
             {
               *(short *)v105 = uNumSeconds + 1;
               pPlayer4->uSkillPoints -= pPlayer4->pActiveSkills[uMessageParam] & 0x3F;
-              pPlayer4->PlaySound(14, 0);
+              pPlayer4->PlaySound(SPEECH_14, 0);
               v165 = 0;
               v151 = 0;
               v144 = 0;
@@ -3744,11 +3744,11 @@
   enum PLAYER_SKILL_TYPE v6; // edi@37
   GUIWindow *pWindow; // eax@56
   unsigned int v8; // edx@56
-  Player *pCurrentPlayer; // edi@57
+  //Player *pCurrentPlayer; // edi@57
   signed int v10; // eax@58
   GUIButton *pButton; // eax@59
-  unsigned __int8 v12; // sf@62
-  signed int v13; // eax@64
+  //unsigned __int8 v12; // sf@62
+  //signed int v13; // eax@64
   unsigned int v14; // eax@66
   int v15; // edi@70
   char v16; // zf@73
@@ -3777,7 +3777,7 @@
   int v43; // [sp-10h] [bp-20h]@56
   int uNum; // [sp+4h] [bp-Ch]@3
   UIMessageType pUIMessageType; // [sp+8h] [bp-8h]@3
-  int pSex; // [sp+Ch] [bp-4h]@3
+  //int pSex; // [sp+Ch] [bp-4h]@3
   Player *pPlayer;
 
   if ( pMessageQueue_50CBD0->uNumMessages )
@@ -3787,7 +3787,9 @@
     pPlayer = pParty->pPlayers;
     do
     {
-      pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &uNum, &pSex);
+      int param2;
+      pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &uNum, &param2);
+
       switch (pUIMessageType) // For buttons of window MainMenu
       {
         case UIMSG_MainMenu_ShowPartyCreationWnd:
@@ -3816,6 +3818,99 @@
         continue;
       }
 
+      
+      switch (pUIMessageType) // For buttons of Party Creation Window
+      {
+        case UIMSG_PlayerCreation_SelectAttribute:
+        {
+            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
+                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
+            uPlayerCreationUI_SelectedCharacter = uNum;
+            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
+        }
+        continue;
+
+        case UIMSG_PlayerCreation_VoicePrev:
+        {
+            auto player = &pParty->pPlayers[uNum];
+            auto sex = player->GetSexByVoice();
+            do
+            {
+              if (player->uVoiceID == 0)
+                player->uVoiceID = 19;
+              else --player->uVoiceID;
+            }
+            while (player->GetSexByVoice() != sex);
+
+            pButton = pCreationUI_BtnPressLeft2[uNum];
+            GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_VoiceSwitcherButton, (int)pButton, 1);
+            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
+            player->PlaySound(SPEECH_PickMe, 0);
+        }
+        continue;
+
+        case UIMSG_PlayerCreation_VoiceNext:
+        {
+            auto player = &pParty->pPlayers[uNum];
+            auto sex = player->GetSexByVoice();
+            do
+            {
+              player->uVoiceID = (player->uVoiceID + 1) % 20;
+            }
+            while (player->GetSexByVoice() != sex);
+
+            pButton = pCreationUI_BtnPressRight2[uNum];
+            GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_VoiceSwitcherButton, (int)pButton, 1);
+            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
+            player->PlaySound(SPEECH_PickMe, 0);
+        }
+        continue;
+
+        case UIMSG_PlayerCreation_FacePrev:
+        {
+            pPlayer = &pParty->pPlayers[uNum];
+            unsigned char v12 = (char)((int)pPlayer->uFace - 1) < 0;
+            --pPlayer->uFace;
+            if ( v12 )
+              pPlayer->uFace = 19;
+            pPlayer->uVoiceID = pPlayer->uFace;
+            pPlayer->SetInitialStats();
+            pPlayer->SetSexByVoice();
+            pPlayer->RandomizeName();
+            v25 = uNum;
+            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
+                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
+            uPlayerCreationUI_SelectedCharacter = v25;
+            GUIWindow::Create(pCreationUI_BtnPressLeft[v25]->uX, pCreationUI_BtnPressLeft[v25]->uY, 0, 0, WINDOW_VoiceSwitcherButton, (int)pCreationUI_BtnPressLeft[v25], 1);
+            //v0 = pAudioPlayer;
+            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0.0, 0);
+            pPlayer->PlaySound(SPEECH_PickMe, 0);
+            //v1 = (char *)pParty->pPlayers;
+        }
+        continue;
+
+        case UIMSG_PlayerCreation_FaceNext:
+        {
+            pPlayer = &pParty->pPlayers[uNum];
+            v20 = (char)((int)pPlayer->uFace + 1) % 20;
+            pPlayer->uFace = v20;
+            pPlayer->uVoiceID = v20;
+            pPlayer->SetInitialStats();
+            pPlayer->SetSexByVoice();
+            pPlayer->RandomizeName();
+            v21 = uNum;
+            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
+                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
+            uPlayerCreationUI_SelectedCharacter = v21;
+            GUIWindow::Create(pCreationUI_BtnPressRight[v21]->uX, pCreationUI_BtnPressRight[v21]->uY, 0, 0, WINDOW_VoiceSwitcherButton, (int)pCreationUI_BtnPressRight[v21], 1);
+            //v0 = pAudioPlayer;
+            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
+            pPlayer->PlaySound(SPEECH_PickMe, 0);
+            //v1 = (char *)pParty->pPlayers;
+        }
+        continue;
+      }
+
       switch (pUIMessageType) // For buttons of window LoadGame
       {
         case UIMSG_LoadGame:
@@ -3887,50 +3982,6 @@
       {
         if ( pUIMessageType > UIMSG_DownArrow )
         {
-          if ( pUIMessageType == UIMSG_SelectFacePlayerBack )
-          {
-            pPlayer = &pParty->pPlayers[uNum];
-            v12 = (char)((int)pPlayer->uFace - 1) < 0;
-            --pPlayer->uFace;
-            if ( v12 )
-              pPlayer->uFace = 19;
-            pPlayer->uVoiceID = pPlayer->uFace;
-            pPlayer->SetInitialStats();
-            pPlayer->SetSexByVoice();
-            pPlayer->RandomizeName();
-            v25 = uNum;
-            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
-                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
-            uPlayerCreationUI_SelectedCharacter = v25;
-            GUIWindow::Create(pCreationUI_BtnPressLeft[v25]->uX, pCreationUI_BtnPressLeft[v25]->uY, 0, 0,
-              (enum WindowType)92, (int)pCreationUI_BtnPressLeft[v25], 1);
-            //v0 = pAudioPlayer;
-            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0.0, 0);
-            pPlayer->PlaySound(102, 0);
-            //v1 = (char *)pParty->pPlayers;
-            continue;
-          }
-          if ( pUIMessageType == UIMSG_SelectFacePlayerForward )
-          {
-            pPlayer = &pParty->pPlayers[uNum];
-            v20 = (char)((int)pPlayer->uFace + 1) % 20;
-            pPlayer->uFace = v20;
-            pPlayer->uVoiceID = v20;
-            pPlayer->SetInitialStats();
-            pPlayer->SetSexByVoice();
-            pPlayer->RandomizeName();
-            v21 = uNum;
-            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
-                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
-            uPlayerCreationUI_SelectedCharacter = v21;
-            GUIWindow::Create(pCreationUI_BtnPressRight[v21]->uX, pCreationUI_BtnPressRight[v21]->uY, 0, 0, (enum WindowType)92,
-            (int)pCreationUI_BtnPressRight[v21], 1);
-            //v0 = pAudioPlayer;
-            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
-            pPlayer->PlaySound(102, 0);
-            //v1 = (char *)pParty->pPlayers;
-            continue;
-          }
           if ( pUIMessageType == UIMSG_AD )//unknow
           {
             __debugbreak();
@@ -3957,7 +4008,7 @@
             pCurrentScreen = SCREEN_GAME;
             viewparams->bRedrawGameUI = 1;
           }
-          GUIWindow::Create(602, 450, 0, 0, (enum WindowType)92, (int)pBtn_GameSettings, 0);
+          GUIWindow::Create(602, 450, 0, 0, WINDOW_VoiceSwitcherButton, (int)pBtn_GameSettings, 0);
           if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
             continue;
           pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
@@ -4045,50 +4096,6 @@
             //VideoPlayer::dtor();
           }
         }
-        else
-        {
-          if ( pUIMessageType == UIMSG_PlayerCreationSelectQuality )
-          {
-            pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem)
-                                                      % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * uNum;
-            uPlayerCreationUI_SelectedCharacter = uNum;
-            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
-            continue;
-          }
-          if ( pUIMessageType == UIMSG_PlayerCreationVoiceBack )// есть проблема со звуками
-          {
-            pCurrentPlayer = &pPlayer[uNum];
-            pSex = pCurrentPlayer->GetSexByVoice();
-            do
-            {
-              v12 = (pCurrentPlayer->uVoiceID-- - 1) == 0;
-              if ( v12 )
-                pCurrentPlayer->uVoiceID = 19;
-              v13 = pCurrentPlayer->GetSexByVoice();
-            }
-            while ( v13 != pSex );
-            pButton = pCreationUI_BtnPressLeft2[uNum];
-            GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, (enum WindowType)92, (int)pButton, 1);
-            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
-            pCurrentPlayer->PlaySound(102, 0);
-            continue;
-          }
-          if ( pUIMessageType == UIMSG_PlayerCreationVoiceForward )
-          {
-            pCurrentPlayer = &pPlayer[uNum];
-            pSex = pCurrentPlayer->GetSexByVoice();
-            do
-            {
-              pCurrentPlayer->uVoiceID = (signed int)(pCurrentPlayer->uVoiceID + 1) % 20;
-            }
-            while ( pCurrentPlayer->GetSexByVoice() != pSex );
-            pButton = pCreationUI_BtnPressRight2[uNum];
-            GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, (enum WindowType)92, (int)pButton, 1);
-            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
-            pCurrentPlayer->PlaySound(102, 0);
-            continue;
-          }
-        }
       }
       else
       {
@@ -4133,7 +4140,7 @@
           if ( pUIMessageType == UIMSG_PlayerCreationSelectClass )
           {
             pPlayer[uPlayerCreationUI_SelectedCharacter].Reset((PLAYER_CLASS_TYPE)uNum);
-            pAudioPlayer->PlaySound((SoundID)66, 0, 0, -1, 0, 0, 0, 0);
+            pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
             continue;
           }
           if ( pUIMessageType == UIMSG_PlayerCreationClickOK )
@@ -4156,7 +4163,7 @@
             {
               uPlayerCreationUI_SelectedCharacter = uNum;
               v4 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem;
-              pSex = pGUIWindow_CurrentMenu->pStartingPosActiveItem;
+              int pSex = pGUIWindow_CurrentMenu->pStartingPosActiveItem;
               v41 = 2;
               v5 = v4 % 7 + pSex + 7 * uNum;
               pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v5;
@@ -5127,7 +5134,7 @@
 // 50FE08: using guessed type stru298 stru_50FE08;
 
 //----- (00439474) --------------------------------------------------------
-bool __fastcall DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, Vec3_int_ *pVelocity)
+void DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, Vec3_int_ *pVelocity)
 {
   signed int v3; // eax@1
   LayingItem *v4; // ebx@1
@@ -5212,8 +5219,8 @@
   }
   v5 = v3 & 7;
   uPlayerID = v3 >> 3;
-  if ( v5 != 4 )
-    return uPlayerID;
+  if (v5 != OBJECT_Player)
+    return;
   pPlayer = &pParty->pPlayers[uPlayerID];
   if ( uPlayerID < 0 && uPlayerID > 3 )
   {
@@ -5222,7 +5229,7 @@
   pMonster = &pActors[uActorID_Monster_];
   uPlayerID = pMonster->IsAlive();
   if ( uPlayerID )
-    return uPlayerID;
+    return;
   BYTE1(pMonster->uAttributes) |= 0xC0u;
   if ( pMonster->uAIState == Fleeing )
     pMonster->uAttributes |= 0x20000u;
@@ -5311,7 +5318,7 @@
     if ( uPlayerID >= 2560 )
     {
       if ( v61 >= 5120 && !(BYTE1(pMonster->uAttributes) & 4) )
-        return uPlayerID;
+        return;
       v61 = 2;
     }
     else
@@ -5363,8 +5370,8 @@
       if ( !stru_50C198.PlayerHitOrMiss(pPlayer, pMonster, v61, a4) )
       {
 LABEL_68:
-        LOWORD(uPlayerID) = pPlayer->PlaySound(52, 0);
-        return uPlayerID;
+        pPlayer->PlaySound(SPEECH_52, 0);
+        return;
       }
       goto LABEL_69;
     }
@@ -5515,10 +5522,10 @@
     Actor::_43AC45(uActorID_Monster_, 1);
     if ( pMonster->pMonsterInfo.uExp )
       sub_4269A2_GivePartyExp(pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].uExp);
-    v40 = 51;
+    v40 = SPEECH_51;
     if ( rand() % 100 < 20 )
       v40 = ((signed int)pMonster->pMonsterInfo.uHP >= 100) + 1;
-    pPlayer->PlaySound(v40, 0);
+    pPlayer->PlaySound((PlayerSpeech)v40, 0);
     v41 = 0;
     if ( bShowDamage )
     {
@@ -5585,7 +5592,7 @@
     pMonster->vVelocity.y = 50 * LOWORD(pVelocity->y);
     pMonster->vVelocity.z = 50 * LOWORD(pVelocity->z);
   }
-  return Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster_, 1, v61);
+  Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster_, 1, v61);
 }
 // 4D864C: using guessed type char byte_4D864C;
 
@@ -5832,10 +5839,10 @@
                 Actor::_43AC45(uActorID, 1);
                 if ( v7->pMonsterInfo.uExp )
                   sub_4269A2_GivePartyExp(pMonsterStats->pInfos[v7->pMonsterInfo.uID].uExp);
-                v34 = 51;
+                v34 = SPEECH_51;
                 if ( rand() % 100 < 20 )
                   v34 = ((signed int)v7->pMonsterInfo.uHP >= 100) + 1;
-                v6->PlaySound(v34, 0);
+                v6->PlaySound((PlayerSpeech)v34, 0);
               }
             }
           }
@@ -5860,7 +5867,7 @@
         if ( v6->sHealth > 0 )
         {
           if ( (double)v6->GetMaxHealth() * 0.25 >= (double)v6->sHealth )
-            v6->PlaySound(48, 0);
+            v6->PlaySound(SPEECH_48, 0);
         }
       }
     }
@@ -5892,7 +5899,7 @@
       {
 		  sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[637], v45->pName);
         ShowStatusBarString(pTmpBuf, 2u);
-        v45->PlaySound(6, 0);
+        v45->PlaySound(SPEECH_6, 0);
         return;
       }
     }
@@ -6018,10 +6025,10 @@
                       Actor::_43AC45(uActorID, 1);
                       if ( v44->pMonsterInfo.uExp )
                         sub_4269A2_GivePartyExp(pMonsterStats->pInfos[v44->pMonsterInfo.uID].uExp);
-                      v64 = 51;
+                      v64 = SPEECH_51;
                       if ( rand() % 100 < 20 )
                         v64 = ((signed int)v44->pMonsterInfo.uHP >= 100) + 1;
-                      v45->PlaySound(v64, 0);
+                      v45->PlaySound((PlayerSpeech)v64, 0);
                     }
                   }
                 }
@@ -15294,7 +15301,7 @@
           continue;
         }
         v18 = v17 - 1;
-        if ( pWindowType == WINDOW_5C ) // Change page in AutonotesBook
+        if ( pWindowType == WINDOW_VoiceSwitcherButton ) // Change page in AutonotesBook
         {
           if ( pWindow->Hint != (char *)1 )
             pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0);
@@ -15890,7 +15897,7 @@
                 *(int *)(v22 + 552) |= 1u;
               if ( !dword_4E455C )
                 goto LABEL_92;
-              v0->PlaySound(16, 0);
+              v0->PlaySound(SPEECH_16, 0);
               goto LABEL_91;
             }
             if ( v45 )
@@ -15931,7 +15938,7 @@
     if ( dword_4E455C )
     {
       if ( v0->CanAct() )
-        v0->PlaySound(17, 0);
+        v0->PlaySound(SPEECH_17, 0);
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[444], 2u);
 LABEL_91:
       dword_4E455C = 0;
@@ -15979,7 +15986,7 @@
   dword_50CDCC = 1;
   if ( dword_4E455C )
   {
-    v0->PlaySound(16, 0);
+    v0->PlaySound(SPEECH_16, 0);
     dword_4E455C = 0;
   }
 }