changeset 2112:9d79b07dc237

PlaySound() source_x
author Ritor1
date Sat, 21 Dec 2013 23:33:36 +0600
parents cdda00bb7a3e
children a94c5bee0225
files AudioPlayer.cpp Outdoor.cpp
diffstat 2 files changed, 107 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/AudioPlayer.cpp	Sat Dec 21 01:03:54 2013 +0600
+++ b/AudioPlayer.cpp	Sat Dec 21 23:33:36 2013 +0600
@@ -560,7 +560,7 @@
 }
 
 //----- (004AA306) --------------------------------------------------------
-void AudioPlayer::PlaySound(SoundID eSoundID, signed int a3, unsigned int uNumRepeats, signed int PartyX, signed int PartyY, int a7, unsigned int uVolume, int sPlaybackRate)
+void AudioPlayer::PlaySound(SoundID eSoundID, signed int a3, unsigned int uNumRepeats, signed int source_x, signed int source_y, int a7, unsigned int uVolume, int sPlaybackRate)
 {
   int v12; // edi@13
   signed int v13; // ecx@17
@@ -688,15 +688,15 @@
             sample_volume = uVolume;
           int object_type = PID_TYPE(a3),
               object_id = PID_ID(a3);
-          /*if (PartyX != -1)
+          if (source_x != -1)//срабатывает например у форта в Хермондейле звук выстрелов пушек
           {
-            if (!PartyX)
-              PartyX = pParty->vPosition.x;
-            if (!PartyY)
-              PartyY = pParty->vPosition.y;
-            AIL_set_sample_pan(pMixerChannels[v62].hSample, sub_4AB66C(PartyX, PartyY));
-            AIL_set_sample_volume(pMixerChannels[v62].hSample, GetSoundStrengthByDistanceFromParty(PartyX, PartyY, pParty->vPosition.z));
-          }	*/
+            //if (!source_x)
+              //source_x = pParty->vPosition.x;
+            //if (!source_x)
+              //source_x = pParty->vPosition.y;
+            AIL_set_sample_pan(pMixerChannels[j].hSample, sub_4AB66C(source_x, source_y));
+            AIL_set_sample_volume(pMixerChannels[j].hSample, GetSoundStrengthByDistanceFromParty(source_x, source_y, pParty->vPosition.z));
+          }
           if (uNumRepeats)
             AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1);
           pMixerChannels[j].uSourceTrackIdx = sound_id;
@@ -1082,14 +1082,14 @@
 
       int object_type = PID_TYPE(a3),
           object_id = PID_ID(a3);
-      if (PartyX != -1)
+      if (source_x != -1)
       {
-        if (!PartyX)
-          PartyX = pParty->vPosition.x;
-        if (!PartyY)
-          PartyY = pParty->vPosition.y;
-        AIL_set_sample_pan(pMixerChannels[v62].hSample, sub_4AB66C(PartyX, PartyY));
-        AIL_set_sample_volume(pMixerChannels[v62].hSample, GetSoundStrengthByDistanceFromParty(PartyX, PartyY, pParty->vPosition.z));
+        if (!source_x)
+          source_x = pParty->vPosition.x;
+        if (!source_y)
+          source_y = pParty->vPosition.y;
+        AIL_set_sample_pan(pMixerChannels[v62].hSample, sub_4AB66C(source_x, source_y));
+        AIL_set_sample_volume(pMixerChannels[v62].hSample, GetSoundStrengthByDistanceFromParty(source_x, source_y, pParty->vPosition.z));
       }
 
       if (uNumRepeats)
@@ -1338,7 +1338,7 @@
       else
         v86 = 1;
       AIL_set_3D_sample_loop_count(*(int *)v42, v86);
-      if ( PartyX == -1 )
+      if ( source_x == -1 )
       {
         if ( PID_TYPE(a3) == 1 )
         {
@@ -1421,8 +1421,8 @@
         v47 = (double)pLayingItem2->vPosition.z;
         goto LABEL_101;
       }
-      pRenderVertexSoft.vWorldPosition.x = (double)PartyX;
-      v43 = (double)PartyY;
+      pRenderVertexSoft.vWorldPosition.x = (double)source_x;
+      v43 = (double)source_y;
       pRenderVertexSoft.vWorldPosition.y = v43;
       v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
       goto LABEL_101;
@@ -1520,28 +1520,20 @@
   field_2D0_time_left -= pEventTimer->uTimeElapsed;
   if ( field_2D0_time_left <= 0 )
   {
-  //v3 = this->b3DSoundInitialized == 0;
   field_2D0_time_left = 32;
   if ( b3DSoundInitialized )//for 3D sound
   {
     __debugbreak(); // refactor refactor
-    //v3 = this->uNum3DSamples == 0;
-    //v5 = this->uNum3DSamples < 0;
-    
-    //if (uNum3DSamples > 0)
-    //{
-    //v6 = this->p3DSamples;
     v2 = 0;
-    //while ( 1 )
     for ( v59 = 0; v59 < pAudioPlayer->uNum3DSamples; ++v59 )
     {
       v7 = PID_TYPE(this->p3DSamples[v59].field_4);
-      if ( AIL_3D_sample_status(this->p3DSamples[v59].hSample) == 2 )
+      if ( AIL_3D_sample_status(this->p3DSamples[v59].hSample) == AIL::Sample::Done )
       {
         AIL_end_3D_sample(this->p3DSamples[v59].hSample);
         pAudioPlayer->_4ABF23(&this->p3DSamples[v59]);
       }
-      if ( AIL_3D_sample_status(this->p3DSamples[v59].hSample) != 4 )
+      if ( AIL_3D_sample_status(this->p3DSamples[v59].hSample) != AIL::Sample::Playing )
         continue;
       v8 = v7 - 1;//
       if ( v8 )//> 1
@@ -1553,13 +1545,13 @@
           if ( !v10 )//3
           {
             v13 = &pActors[PID_ID(this->p3DSamples[v59].field_4)];
-            uNumRepeats = v13->vPosition.x;
-            v14 = v13->vPosition.y;
-            a1.vWorldPosition.x = (double)uNumRepeats;
-            uNumRepeats = v13->vPosition.z;
-            a1.vWorldPosition.y = (double)v14;
-            v11 = (double)uNumRepeats;
-            a1.vWorldPosition.z = v11;
+            //uNumRepeats = v13->vPosition.x;
+            //v14 = v13->vPosition.y;
+            a1.vWorldPosition.x = (double)v13->vPosition.x;
+            //uNumRepeats = v13->vPosition.z;
+            a1.vWorldPosition.y = (double)v13->vPosition.y;
+            //v11 = (double)uNumRepeats;
+            a1.vWorldPosition.z = v13->vPosition.z;
             if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
             {
               v16 = pGame->pIndoorCameraD3D->fRotationXCosine;
@@ -1907,48 +1899,104 @@
         if (!pIndoor->pDoors[source_id].uDoorID)
           continue;
 
-        source_x = pIndoor->pDoors[source_id].pXOffsets[0];
-        source_y = pIndoor->pDoors[source_id].pYOffsets[0];
-        source_z = pIndoor->pDoors[source_id].pZOffsets[0];
+        //source_x = pIndoor->pDoors[source_id].pXOffsets[0];
+        //source_y = pIndoor->pDoors[source_id].pYOffsets[0];
+        //source_z = pIndoor->pDoors[source_id].pZOffsets[0];
+        int sound_strength = GetSoundStrengthByDistanceFromParty(pIndoor->pDoors[source_id].pXOffsets[0],
+                                                                 pIndoor->pDoors[source_id].pYOffsets[0],
+                                                                 pIndoor->pDoors[source_id].pZOffsets[0]);
+        if ( sound_strength )
+        {
+          AIL_set_sample_volume(pMixerChannels[i].hSample, sound_strength);
+          AIL_set_sample_pan(pMixerChannels[i].hSample, sub_4AB66C(pIndoor->pDoors[source_id].pXOffsets[0],
+                                                                 pIndoor->pDoors[source_id].pYOffsets[0]));
+        }
+        else
+        {
+          AIL_end_sample(pMixerChannels[i].hSample);
+          FreeChannel(&pMixerChannels[i]);
+        }
       }
-      break;
+      continue;
 
       case OBJECT_Item:
       {
         assert(source_id < uNumSpriteObjects);
 
-        source_x = pSpriteObjects[source_id].vPosition.x;
-        source_y = pSpriteObjects[source_id].vPosition.y;
-        source_z = pSpriteObjects[source_id].vPosition.z;
+        //source_x = pSpriteObjects[source_id].vPosition.x;
+        //source_y = pSpriteObjects[source_id].vPosition.y;
+        //source_z = pSpriteObjects[source_id].vPosition.z;
+        int sound_strength = GetSoundStrengthByDistanceFromParty(pSpriteObjects[source_id].vPosition.x,
+                                                                 pSpriteObjects[source_id].vPosition.y,
+                                                                 pSpriteObjects[source_id].vPosition.z);
+        if ( sound_strength )
+        {
+          AIL_set_sample_volume(pMixerChannels[i].hSample, sound_strength);
+          AIL_set_sample_pan(pMixerChannels[i].hSample, sub_4AB66C(pSpriteObjects[source_id].vPosition.x,
+                                                                   pSpriteObjects[source_id].vPosition.y));
+        }
+        else
+        {
+          AIL_end_sample(pMixerChannels[i].hSample);
+          FreeChannel(&pMixerChannels[i]);
+        }
       }
-      break;
+      continue;
 
       case OBJECT_Decoration:
       {
         assert(source_id < uNumLevelDecorations);
 
-        source_x = pLevelDecorations[source_id].vPosition.x;
-        source_y = pLevelDecorations[source_id].vPosition.y;
-        source_z = pLevelDecorations[source_id].vPosition.z;
+        //source_x = pLevelDecorations[source_id].vPosition.x;
+        //source_y = pLevelDecorations[source_id].vPosition.y;
+        //source_z = pLevelDecorations[source_id].vPosition.z;
+        int sound_strength = GetSoundStrengthByDistanceFromParty(pLevelDecorations[source_id].vPosition.x,
+                                                                 pLevelDecorations[source_id].vPosition.y,
+                                                                 pLevelDecorations[source_id].vPosition.z);
+        if ( sound_strength )
+        {
+          AIL_set_sample_volume(pMixerChannels[i].hSample, sound_strength);
+          AIL_set_sample_pan(pMixerChannels[i].hSample, sub_4AB66C(pLevelDecorations[source_id].vPosition.x,
+                                                                   pLevelDecorations[source_id].vPosition.y));
+        }
+        else
+        {
+          AIL_end_sample(pMixerChannels[i].hSample);
+          FreeChannel(&pMixerChannels[i]);
+        }
       }
-      break;
+      continue;
 
       case OBJECT_Actor:
       {
         assert(source_id < uNumActors);
 
-        source_x = pActors[source_id].vPosition.x;
-        source_y = pActors[source_id].vPosition.y;
-        source_z = pActors[source_id].vPosition.z;
+        //source_x = pActors[source_id].vPosition.x;
+        //source_y = pActors[source_id].vPosition.y;
+        //source_z = pActors[source_id].vPosition.z;
+        int sound_strength = GetSoundStrengthByDistanceFromParty(pActors[source_id].vPosition.x,
+                                                                 pActors[source_id].vPosition.y,
+                                                                 pActors[source_id].vPosition.z);
+        if ( sound_strength )
+        {
+          AIL_set_sample_volume(pMixerChannels[i].hSample, sound_strength);
+          AIL_set_sample_pan(pMixerChannels[i].hSample, sub_4AB66C(pActors[source_id].vPosition.x,
+                                                                   pActors[source_id].vPosition.y));
+        }
+        else
+        {
+          AIL_end_sample(pMixerChannels[i].hSample);
+          FreeChannel(&pMixerChannels[i]);
+        }
       }
-      break;
+      continue;
 
       default:
         assert(false);
         continue;
     }
 
-    if (int sound_strength = GetSoundStrengthByDistanceFromParty(source_x, source_y, source_z))
+    /*if (int sound_strength = GetSoundStrengthByDistanceFromParty(source_x, source_y, source_z))
     {
       AIL_set_sample_volume(pMixerChannels[i].hSample, sound_strength);
       AIL_set_sample_pan(pMixerChannels[i].hSample, sub_4AB66C(source_x, source_y));
@@ -1957,14 +2005,13 @@
     {
       AIL_end_sample(pMixerChannels[i].hSample);
       FreeChannel(&pMixerChannels[i]);
-    }
+    } */
   }
 
-  if (pCurrentScreen != SCREEN_GAME)
+  if (pCurrentScreen != SCREEN_GAME) //отключение звука декораций при переключенииокна игры
   {
-    MixerChannel* channel = &pMixerChannels[4];
-    if (AIL_sample_status(channel->hSample) == AIL::Sample::Playing)
-      AIL_end_sample(channel->hSample);
+    if (AIL_sample_status(pMixerChannels[4].hSample) == AIL::Sample::Playing)
+      AIL_end_sample(pMixerChannels[4].hSample);
     return;
   }
   if (!_6807E0_num_decorations_with_sounds_6807B8)
--- a/Outdoor.cpp	Sat Dec 21 01:03:54 2013 +0600
+++ b/Outdoor.cpp	Sat Dec 21 23:33:36 2013 +0600
@@ -4551,8 +4551,8 @@
           {
             for ( uint i = 1; i <= 4; ++i )
             {
-              v110 = pPlayers[i]->GetMaxHealth();
-              pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - pZ) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
+              //v110 = pPlayers[i]->GetMaxHealth();
+              pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - pZ) * (unsigned __int64)(signed __int64)((double)pPlayers[i]->GetMaxHealth() * 0.1)) / 256,
                 DMGT_PHISYCAL);
               v110 = 20 - pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualEndurance());
               pPlayers[i]->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));