changeset 764:90bcfb56c8f9

sound cleaning
author Gloval
date Sat, 23 Mar 2013 21:39:21 +0400
parents f24fb0d64a5c
children 777c42590ffc
files Arcomage.cpp AudioPlayer.cpp AudioPlayer.h Outdoor.cpp Outdoor.h Player.cpp SaveLoad.cpp mm7_3.cpp mm7_4.cpp
diffstat 9 files changed, 129 insertions(+), 216 deletions(-) [+]
line wrap: on
line diff
--- a/Arcomage.cpp	Sat Mar 23 17:07:08 2013 +0400
+++ b/Arcomage.cpp	Sat Mar 23 21:39:21 2013 +0400
@@ -1395,7 +1395,7 @@
   v4 = am_sounds;
   do
   {
-    pSoundList->_4A9DCD((unsigned __int16)*v4, 1);
+    pSoundList->UnloadSound((unsigned __int16)*v4, 1);
     ++v4;
   }
   while ( (signed int)v4 <= (signed int)&unk_4FAA20 );
--- a/AudioPlayer.cpp	Sat Mar 23 17:07:08 2013 +0400
+++ b/AudioPlayer.cpp	Sat Mar 23 21:39:21 2013 +0400
@@ -78,7 +78,7 @@
 
   pSoundList = this;
   a2 = 1;
-  if ( (signed int)this->uNumSounds > 1 )
+  if ( sNumSounds > 1 )
   {
     v2 = 1;
     //while ( 1 )
@@ -100,7 +100,7 @@
       if ( !pType )
         //goto LABEL_15;
 	  {
-		LOBYTE(pSoundList->pSounds[v2].bDecompressed) = 0;
+		pSoundList->pSounds[v2].bDecompressed = false;
 		goto LABEL_16;
 	  }
       v8 = pType - 1;
@@ -123,23 +123,23 @@
           if ( !AIL_decompress_ADPCM(&pInfo, &pSoundList->pSounds[v2].p3DSound, &v12) )
           {
             pSoundList->pSounds[v2].p3DSound = 0;
-            LOBYTE(pSoundList->pSounds[v2].bDecompressed) = 1;
+            pSoundList->pSounds[v2].bDecompressed = true;
           }
         }
         goto LABEL_16;
       }
 //LABEL_15:
-      LOBYTE(pSoundList->pSounds[v2].bDecompressed) = 0;
+      pSoundList->pSounds[v2].bDecompressed = false;
       goto LABEL_16;
     }
 	pSoundList->pSounds[v2].p3DSound = pSoundList->pSounds[v2].pSoundData[0];
 LABEL_16:
-    pSoundList->_4A9DCD(a2, 1);
+    pSoundList->UnloadSound(a2, 1);
 LABEL_17:
       ++a2;
       ++v2;
 	}
-    while ( a2 < (signed int)pSoundList->uNumSounds );
+    while ( a2 < pSoundList->sNumSounds );
   }
 }
 
@@ -148,12 +148,12 @@
 {
   AILSOUNDINFO v24; // [sp+84h] [bp-28h]@23
 
-  if (bNoSound || !uNumSounds)
+  if (bNoSound || !sNumSounds)
     return 0;
 
   uint       uSoundIdx = 0;
   SoundDesc *pSound = nullptr;
-  for (uint i = 1; i < uNumSounds; ++i)
+  for (uint i = 1; i < sNumSounds; ++i)
     if (pSounds[i].uSoundID == a1)
     {
       uSoundIdx = i;
@@ -202,7 +202,7 @@
         {
           pSound->p3DSound = nullptr;
           pSound->bDecompressed = true;
-          _4A9DCD(uSoundIdx, 0);
+          UnloadSound(uSoundIdx, 0);
         }
       }
       return uSoundIdx;
@@ -240,7 +240,7 @@
   //v8 = this->uNumSounds == 0;
   //v9 = (this->uNumSounds & 0x80000000u) != 0;
   v26 = 0;
-  if (!uNumSounds)
+  if (!sNumSounds)
     return 0;
 
 
@@ -262,7 +262,7 @@
       ++v26;
       v25 += 120;
       v24 += 120;
-      if ( v26 >= (signed int)uNumSounds )
+      if ( v26 >= (signed int)sNumSounds )
         return 0;
     }
     v12 = 0;
@@ -322,7 +322,7 @@
 
   v1 = this;
   v2 = 0;
-  if ( (signed int)this->uNumSounds > 0 )
+  if ( (signed int)this->sNumSounds > 0 )
   {
     v3 = 0;
     do
@@ -339,7 +339,7 @@
       ++v2;
       ++v3;
     }
-    while ( v2 < (signed int)v1->uNumSounds );
+    while ( v2 < (signed int)v1->sNumSounds );
   }
   return result;
 }
@@ -356,7 +356,7 @@
 
   v2 = this;
   v3 = 0;
-  for ( i = 0; i < (signed int)v2->uNumSounds; ++v3 )
+  for ( i = 0; i < (signed int)v2->sNumSounds; ++v3 )
   {
     v5 = &v2->pSounds[v3];
     v6 = v5->eType;
@@ -375,31 +375,22 @@
 }
 
 //----- (004A9DCD) --------------------------------------------------------
-void SoundList::_4A9DCD(unsigned int uSoundID, char a3)
+void SoundList::UnloadSound(unsigned int uSoundID, char a3)
 {
-  unsigned int v3; // esi@1
-  //SoundList *v4; // edi@1
-  SoundDesc *v5; // eax@1
-  void *v6; // ecx@8
-
-  v3 = uSoundID;
-  //v4 = this;
-  v5 = &this->pSounds[uSoundID];
-  if ( v5->eType != SOUND_DESC_SYSTEM )
+  if ( pSounds[uSoundID].eType != SOUND_DESC_SYSTEM )
   {
-    if ( v5->uFlags & SOUND_DESC_SWAP && v5->p3DSound && a3 )
+    if ( (pSounds[uSoundID].uFlags & SOUND_DESC_SWAP) && pSounds[uSoundID].p3DSound && a3 )
     {
-      if ( LOBYTE(v5->bDecompressed) )
-        AIL_mem_free_lock(v5->p3DSound);
-      pSounds[v3].p3DSound = 0;
-      pSounds[v3].uFlags &= ~SOUND_DESC_SYSTEM;
+      if ( pSounds[uSoundID].bDecompressed)
+        AIL_mem_free_lock(pSounds[uSoundID].p3DSound);
+      pSounds[uSoundID].p3DSound = 0;
+      pSounds[uSoundID].uFlags &= ~SOUND_DESC_SYSTEM;
     }
-    v6 = pSounds[v3].pSoundData[0];
-    if ( v6 )
+    if ( pSounds[uSoundID].pSoundData[0] )
     {
-      ReleaseSoundData(v6);
-      pSounds[v3].pSoundData[0] = 0;
-      pSounds[v3].uFlags &= ~SOUND_DESC_SYSTEM;
+      ReleaseSoundData(pSounds[uSoundID].pSoundData[0]);
+      pSounds[uSoundID].pSoundData[0] = NULL;
+      pSounds[uSoundID].uFlags &= ~SOUND_DESC_SYSTEM;
     }
   }
 }
@@ -418,16 +409,16 @@
   if ( !v2 )
     Abortf("Unable to save dsounds.bin!");
   fwrite(v1, 4u, 1u, v2);
-  fwrite(v1->pSounds, 0x78u, v1->uNumSounds, v3);
+  fwrite(v1->pSounds, 0x78u, v1->sNumSounds, v3);
   fclose(v3);
 }
 
 //----- (004A9E89) --------------------------------------------------------
 void *SoundList::FromFile(void *pSerialized)
 {
-  uNumSounds = *(int *)pSerialized;
-  pSounds = (SoundDesc *)pAllocator->AllocNamedChunk(pSounds, 120 * uNumSounds, "Snd Des.");
-  return memcpy(pSounds, (char *)pSerialized + 4, 120 * uNumSounds);
+  sNumSounds = *(int *)pSerialized;
+  pSounds = (SoundDesc *)pAllocator->AllocNamedChunk(pSounds, 120 * sNumSounds, "Snd Des.");
+  return memcpy(pSounds, (char *)pSerialized + 4, 120 * sNumSounds);
 }
 
 //----- (004A9ED0) --------------------------------------------------------
@@ -457,7 +448,7 @@
   pAllocator->FreeChunk(this->pSounds);
   v3 = 0;
   v2->pSounds = 0;
-  v2->uNumSounds = 0;
+  v2->sNumSounds = 0;
   v4 = fopen(Args, "r");
   File = v4;
   if ( !v4 )
@@ -477,14 +468,14 @@
     v5 = Argsa;
     v3 = 0;
   }
-  v2->uNumSounds = v5;
+  v2->sNumSounds = v5;
   v6 = pAllocator->AllocNamedChunk(v2->pSounds, 120 * v5, "Snd Des.");
   v2->pSounds = (SoundDesc *)v6;
   if ( v6 == (void *)v3 )
     Abortf("SoundListClass::load - Out of Memory!");
-  memset(v6, v3, 120 * v2->uNumSounds);
+  memset(v6, v3, 120 * v2->sNumSounds);
   v7 = File;
-  v2->uNumSounds = v3;
+  v2->sNumSounds = v3;
   fseek(v7, v3, v3);
   for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
   {
@@ -492,10 +483,10 @@
     memcpy(&v19, txt_file_frametable_parser(&Buf, &v18), sizeof(v19));
     if ( v19.uPropCount && *v19.pProperties[0] != 47 )
     {
-      sprintf(v2->pSounds[v2->uNumSounds].pSoundName, "%s", v19.pProperties[0]);
+      sprintf(v2->pSounds[v2->sNumSounds].pSoundName, "%s", v19.pProperties[0]);
       v9 = atoi(v19.pProperties[1]);
       v10 = v19.pProperties[2];
-      v2->pSounds[v2->uNumSounds].uSoundID = v9;
+      v2->pSounds[v2->sNumSounds].uSoundID = v9;
       if ( _strcmpi(v10, "system") )
       {
         if ( _strcmpi(v19.pProperties[2], "swap") )
@@ -503,7 +494,7 @@
           v11 = _strcmpi(v19.pProperties[2], "lock");
           v12 = v2->pSounds;
           v13 = v11 == 0;
-          v14 = v2->uNumSounds;
+          v14 = v2->sNumSounds;
           if ( v13 )
             v12[v14].eType = SOUND_DESC_LOCK;
           else
@@ -511,19 +502,19 @@
         }
         else
         {
-          v2->pSounds[v2->uNumSounds].eType = SOUND_DESC_SWAP;
+          v2->pSounds[v2->sNumSounds].eType = SOUND_DESC_SWAP;
         }
       }
       else
       {
-        v2->pSounds[v2->uNumSounds].eType = SOUND_DESC_SYSTEM;
+        v2->pSounds[v2->sNumSounds].eType = SOUND_DESC_SYSTEM;
       }
       if ( v19.uPropCount >= 4 && !_strcmpi(v19.pProperties[3], "3D") )
       {
-        v15 = (int)&v2->pSounds[v2->uNumSounds].uFlags;
+        v15 = (int)&v2->pSounds[v2->sNumSounds].uFlags;
         *(int *)v15 |= SOUND_DESC_SWAP;
       }
-      ++v2->uNumSounds;
+      ++v2->sNumSounds;
     }
   }
   fclose(File);
@@ -610,7 +601,7 @@
                 if ( AIL_sample_status(v6->hSample) == AIL::Sample::Playing)
                 {
                   AIL_end_sample(v6->hSample);
-                  _4ABE55(v6);
+                  FreeChannel(v6);
                 }
               }
               ++v5;
@@ -740,7 +731,7 @@
 
 
   int sound_id = 0;
-  for (uint i = 0; i < pSoundList->uNumSounds; ++i)
+  for (uint i = 0; i < pSoundList->sNumSounds; ++i)
     if (pSoundList->pSounds[i].uSoundID == eSoundID)
     {
       sound_id = i;
@@ -756,7 +747,7 @@
   int start_channel = 0,
       end_channel = 0;
 
-  assert(sound_id < pSoundList->uNumSounds);
+  assert(sound_id < pSoundList->sNumSounds);
   auto sound_desc = pSoundList->pSounds + sound_id;
   if (!b3DSoundInitialized || sound_desc->Is3D())
   {
@@ -869,7 +860,7 @@
           return;                          // already playing the same sound from the same source - return
 
         AIL_end_sample(channel->hSample);  // requested new sound from the same source - end & switch
-        _4ABE55(channel);
+        FreeChannel(channel);
       }
     }
 
@@ -883,7 +874,7 @@
         {
           AIL_end_sample(channel->hSample);
           if (channel->uSourceTrackIdx)
-            _4ABE55(channel);
+            FreeChannel(channel);
           break;
         }
       }
@@ -947,7 +938,7 @@
 
         auto channel = &pMixerChannels[v62];
         AIL_end_sample(channel->hSample);
-        _4ABE55(channel);
+        FreeChannel(channel);
       }
 
       if (v62 > end_channel)//10!=13
@@ -1001,7 +992,7 @@
         if (!GetSoundStrengthByDistanceFromParty(door->pXOffsets[0], door->pYOffsets[0], door->pZOffsets[0]))
         {
           AIL_end_sample(channel->hSample);
-          _4ABE55(channel);
+          FreeChannel(channel);
           return;
         }
         AIL_set_sample_pan(channel->hSample, sub_4AB66C(door->pXOffsets[0], door->pYOffsets[0]));
@@ -1622,7 +1613,7 @@
     if (AIL_sample_status(channel->hSample) == AIL::Sample::Done)
     {
       AIL_end_sample(channel->hSample);
-      _4ABE55(channel);
+      FreeChannel(channel);
     }
   }
 
@@ -1706,7 +1697,7 @@
     else
     {
       AIL_end_sample(channel->hSample);
-      _4ABE55(channel);
+      FreeChannel(channel);
     }
   }
 
@@ -1882,7 +1873,7 @@
           && pSoundList->pSounds[pChannel->uSourceTrackIdx].eType != SOUND_DESC_SYSTEM)
         {
           AIL_end_sample(pChannel->hSample);
-          _4ABE55(pChannel);
+          FreeChannel(pChannel);
           pChannel->source_pid = 0;
         }
         ++v6;
@@ -2205,7 +2196,7 @@
 }
 
 //----- (004ABE55) --------------------------------------------------------
-void AudioPlayer::_4ABE55(MixerChannel *pChannel)
+void AudioPlayer::FreeChannel(MixerChannel *pChannel)
 {
   int v2; // ebx@1
   //AudioPlayer *v3; // esi@1
@@ -2213,14 +2204,14 @@
   unsigned __int8 v5; // zf@5
   unsigned __int8 v6; // sf@5
   char *v7; // edi@6
-  int v8; // eax@8
+  int num_same_sound_on_channels; // eax@8
   int v9; // ST04_4@8
   int v10; // ecx@12
   int v11; // edi@13
   int v12; // eax@13
   unsigned __int8 v13; // of@13
   int v14[16]; // [sp+Ch] [bp-48h]@8
-  int v15; // [sp+4Ch] [bp-8h]@5
+  int num_playing_channels; // [sp+4Ch] [bp-8h]@5
   int v16; // [sp+50h] [bp-4h]@5
 
   v2 = 0;
@@ -2229,49 +2220,41 @@
     return;
  
     v4 = &pSoundList->pSounds[pChannel->uSourceTrackIdx];
-    if ( v4->eType == SOUND_DESC_SWAP)
+    if ( pSoundList->pSounds[pChannel->uSourceTrackIdx].eType == SOUND_DESC_SWAP)
     {
-      if ( v4->pSoundData[0] && !(v4->uFlags & SOUND_DESC_SYSTEM) )
+      if ( pSoundList->pSounds[pChannel->uSourceTrackIdx].pSoundData[0] && 
+          !(pSoundList->pSounds[pChannel->uSourceTrackIdx].uFlags & SOUND_DESC_SYSTEM) )
       {
-        v5 = this->uMixerChannels == 0;
-        v6 = this->uMixerChannels < 0;
-        v15 = 0;
-        v16 = 0;
-        if ( v6 | v5 )
+        num_playing_channels = 0;
+        num_same_sound_on_channels = 0;
+        if ( this->uMixerChannels <=0 )
           goto LABEL_16;
-        v7 = (char *)this->pMixerChannels;
         do
         {
-          if ( pChannel->uSourceTrackID == *((int *)v7 + 3) )
+          if ( pChannel->uSourceTrackID ==pMixerChannels[v2].uSourceTrackID )
           {
-            v8 = v16;
-            v9 = *(int *)v7;
-            ++v16;
-            v14[v8] = v2;
-            if ( AIL_sample_status((HSAMPLE)v9) == AIL::Sample::Playing)
-              ++v15;
+            v14[num_same_sound_on_channels++] = v2;
+            if ( AIL_sample_status((HSAMPLE)pMixerChannels[v2].hSample) == AIL::Sample::Playing)
+              ++num_playing_channels;
           }
           ++v2;
-          v7 += 16;
         }
         while ( v2 < uMixerChannels );
-        if ( !v15 )
+        if ( !num_playing_channels )
         {
 LABEL_16:
-          pSoundList->_4A9DCD(pChannel->uSourceTrackIdx, 1);
+          pSoundList->UnloadSound(pChannel->uSourceTrackIdx, 1);
           v10 = 0;
-          if ( v16 > 0 )
+          if ( num_same_sound_on_channels  > 0 )
           {
             do
             {
               v11 = v14[v10];
-              v12 = 16 * (v14[v10++] + 47);
+              v10++;
               pMixerChannels[v11].uSourceTrackID = 0;
-              v13 = __OFSUB__(v10, v16);
-              v6 = v10 - v16 < 0;
-              *(unsigned int *)((char *)&bEAXSupported + v12) = 0;
+               pMixerChannels[v11].hSample = NULL;
             }
-            while ( v6 ^ v13 );
+            while (v10<num_same_sound_on_channels);
           }
         }
       }
@@ -2398,7 +2381,7 @@
         if ( !v14 )
         {
 LABEL_16:
-          pSoundList->_4A9DCD(a2->field_8, 1);
+          pSoundList->UnloadSound(a2->field_8, 1);
           v10 = 0;
           if ( v15 > 0 )
           {
@@ -2675,9 +2658,10 @@
   v3 = pOutBuff;
   v4 = 0;
   for (uint i = 0; i < 3000; ++i)
-    if (pSounds[i].uID == uID)
-      return pSounds[i].pSoundData;
-
+      {
+      if (pSounds[i].uID == uID)
+          return pSounds[i].pSoundData;
+      }
   FindSound_BinSearch(0, pAudioPlayer->uNumSoundHeaders, pSoundName_);
   if ( uFindSound_BinSearch_ResultID == -1 )
   {
--- a/AudioPlayer.h	Sat Mar 23 17:07:08 2013 +0400
+++ b/AudioPlayer.h	Sat Mar 23 21:39:21 2013 +0400
@@ -152,7 +152,7 @@
   void Initialize(HWND hWnd);
   LSTATUS CheckA3DSupport(char a2);
   void Release();
-  void _4ABE55(MixerChannel *pChannel);
+  void FreeChannel(MixerChannel *pChannel);
   void _4ABF23(AudioPlayer_3DSample *a2);
   void SetEAXPreferences();
   void SetMapEAX();
@@ -256,7 +256,7 @@
 struct SoundList
 {
   inline SoundList():
-    uNumSounds(0), pSounds(nullptr), uTotalLoadedSoundSize(0)
+    sNumSounds(0), pSounds(nullptr), uTotalLoadedSoundSize(0)
   {}
 
   void Initialize();
@@ -264,12 +264,12 @@
   int LoadSound(unsigned int a2, LPVOID lpBuffer, int uBufferSizeLeft, int *pOutSoundSize, int a6);
   SoundDesc *Release();
   void _4A9D79(int a2);
-  void _4A9DCD(unsigned int uSoundID, char a3);
+  void UnloadSound(unsigned int uSoundID, char a3);
   void ToFile();
   void *FromFile(void *pSerialized);
   int FromFileTxt(const char *Args);
 
-  unsigned int uNumSounds;
+  signed int sNumSounds;
   SoundDesc *pSounds;
   unsigned int uTotalLoadedSoundSize;
 };
--- a/Outdoor.cpp	Sat Mar 23 17:07:08 2013 +0400
+++ b/Outdoor.cpp	Sat Mar 23 21:39:21 2013 +0400
@@ -527,7 +527,7 @@
   v5 = WorldPosToGridCellX(pParty->vPosition.x);
   v6 = WorldPosToGridCellZ(pParty->vPosition.y);
   v7 = _47ED83(v5, v6 - 1);
-  v8 = pTileTable->pTiles[_47ECC1(v7)].tileset;
+  v8 = pTileTable->pTiles[GetTileIdByTileMapId(v7)].tileset;
   if ( v8 )
   {
     v9 = v8 - 1;
@@ -2342,7 +2342,7 @@
 }
 
 //----- (0047ECC1) --------------------------------------------------------
-int OutdoorLocation::_47ECC1(signed int a2)
+int OutdoorLocation::GetTileIdByTileMapId(signed int a2)
 {
   signed int result; // eax@2
   int v3; // eax@3
@@ -2465,101 +2465,43 @@
 }
 
 //----- (0047EE49) --------------------------------------------------------
-int OutdoorLocation::_47EE49(signed int a2, signed int a3, int a4)
-{
+int OutdoorLocation::GetSoundIdByPosition( signed int X_pos, signed int Y_pos, int running )
+    {
   signed int v4; // eax@5
   signed int v5; // eax@7
   int v6; // eax@8
   signed int v8; // eax@9
-  int v9; // eax@12
-  int v10; // eax@13
-  int v11; // eax@14
-  int v12; // eax@16
-  int v13; // eax@17
-  int v14; // eax@18
-  int v15; // eax@19
-  int v16; // eax@20
-  int v17; // eax@21
-  int v18; // eax@28
-  int v19; // eax@29
-  int v20; // eax@30
+  int modif=0;
 
-  if ( a2 < 0 || a2 > 127 || a3 < 0 || a3 > 127 )
+  if ( X_pos < 0 || X_pos > 127 || Y_pos < 0 || Y_pos > 127 )
     v4 = 0;
   else
-    v4 = *(&this->pTerrain.pTilemap[128 * a3] + a2);
-  v5 = _47ECC1(v4);
+    v4 = this->pTerrain.pTilemap[128 * Y_pos + X_pos];
+  v5 = GetTileIdByTileMapId(v4);
+  if (running)
+      modif=-39;
   if ( !v5 )
-  {
-    v6 = -(a4 != 0);
-    LOBYTE(v6) = v6 & 0xD9;
-    return v6 + 92;
-  }
-  v8 = pTileTable->pTiles[v5].tileset;
-  if ( v8 <= 6 )
+    return 92+modif;
+   
+  switch (pTileTable->pTiles[v5].tileset)
   {
-    if ( v8 == Tileset_6 )
-    {
-      v17 = -(a4 != 0);
-      LOBYTE(v17) = v17 & 0xD9;
-      return v17 + 88;
-    }
-    if ( v8 )
-    {
-      v9 = v8 - 1;
-      if ( !v9 )
-      {
-        v15 = -(a4 != 0);
-        LOBYTE(v15) = v15 & 0xD9;
-        return v15 + 97;
-      }
-      v10 = v9 - 1;
-      if ( !v10 )
-      {
-        v14 = -(a4 != 0);
-        LOBYTE(v14) = v14 & 0xD9;
-        return v14 + 91;
-      }
-      v11 = v10 - 1;
-      if ( !v11 )
-      {
-        v13 = -(a4 != 0);
-        LOBYTE(v13) = v13 & 0xD9;
-        return v13 + 90;
-      }
-      if ( v11 == 2 )
-      {
-        v12 = -(a4 != 0);
-        LOBYTE(v12) = v12 & 0xD9;
-        return v12 + 101;
-      }
-LABEL_29:
-      v19 = -(a4 != 0);
-      LOBYTE(v19) = v19 & 0xD9;
-      return v19 + 95;
-    }
-    goto LABEL_20;
+  case 0:  return 93+ modif; 
+  case 1:  return 97+ modif; 
+  case 2:  return 91+ modif;
+  case 3:  return 90+ modif;
+  case 4:  return 101+ modif;
+  case 5:  return 95+ modif;
+  case 6:  return 88+ modif;
+  case 7: return 100+ modif;
+  case 8: return 93+ modif;
+ default:
+     v8=pTileTable->pTiles[v5].tileset;
+     if ( (v8 > 9 && v8 <= 17) || (v8 > 21 && v8 <= 27) )
+        return 96+ modif;
+     else
+        return 95+ modif;
   }
-  if ( v8 != 7 )
-  {
-    if ( v8 != 8 )
-    {
-      if ( v8 > 9 && (v8 <= 17 || v8 > 21 && v8 <= 27) )
-      {
-        v18 = -(a4 != 0);
-        LOBYTE(v18) = v18 & 0xD9;
-        return v18 + 96;
-      }
-      goto LABEL_29;
-    }
-LABEL_20:
-    v16 = -(a4 != 0);
-    LOBYTE(v16) = v16 & 0xD9;
-    return v16 + 93;
-  }
-  v20 = -(a4 != 0);
-  LOBYTE(v20) = v20 & 0xD9;
-  return v20 + 100;
+
 }
 
 //----- (0047EF60) --------------------------------------------------------
@@ -2705,7 +2647,7 @@
         _6807B8_level_decorations_ids[v5] = i;
       }
       if ( v8 && decor->uCog == 20 )
-        LOBYTE(decor->field_2) |= 0x40u;
+        decor->field_2 |= 0x0040u;
       if ( !decor->field_16_event_id )
       {
         if ( decor->IsInteractive() )
@@ -2715,7 +2657,7 @@
             v6 = v1 + 75;
             decor->_idx_in_stru123 = v6;
             if ( !stru_5E4C90._decor_events[v1++] )
-              LOBYTE(decor->field_2) |= 0x20u;
+              decor->field_2 |= 0x0020u;
           }
         }
       }
--- a/Outdoor.h	Sat Mar 23 17:07:08 2013 +0400
+++ b/Outdoor.h	Sat Mar 23 21:39:21 2013 +0400
@@ -153,12 +153,12 @@
   void CreateDebugLocation();
   void Release();
   bool Load(const char *pFilename, ODMFace *File, size_t a4, int thisa);
-  int _47ECC1(signed int a2);
+  int GetTileIdByTileMapId(signed int a2);
   unsigned int DoGetTileTexture(unsigned int uX, unsigned int uZ);
   int _47ED83(signed int a2, signed int a3);
   int ActuallyGetSomeOtherTileInfo(unsigned int uX, unsigned int uY);
   int DoGetHeightOnTerrain(unsigned int uX, unsigned int uZ);
-  int _47EE49(signed int a2, signed int a3, int a4);
+  int GetSoundIdByPosition(signed int X_pos, signed int Y_pos, int a4);
   int UpdateDiscoveredArea(int a2, int a3, int a4);
   bool _47F04C(signed int a2, signed int a3);
   bool _47F097(signed int a2, signed int a3);
--- a/Player.cpp	Sat Mar 23 17:07:08 2013 +0400
+++ b/Player.cpp	Sat Mar 23 21:39:21 2013 +0400
@@ -632,7 +632,7 @@
     if (expression == CHARACTER_EXPRESSION_21 && pSoundId )
     {
       v17 = 0;
-      if ( (signed int)pSoundList->uNumSounds <= 0 )
+      if ( (signed int)pSoundList->sNumSounds <= 0 )
       {
 LABEL_23:
         v17 = 0;
@@ -644,7 +644,7 @@
         {
           ++v17;
           pSoundID += 120;
-          if ( v17 >= (signed int)pSoundList->uNumSounds )
+          if ( v17 >= (signed int)pSoundList->sNumSounds )
             goto LABEL_23;
         }
       }
--- a/SaveLoad.cpp	Sat Mar 23 17:07:08 2013 +0400
+++ b/SaveLoad.cpp	Sat Mar 23 21:39:21 2013 +0400
@@ -70,17 +70,17 @@
   if (SoundSetAction[24][0])
     for (uint i = 0; i < 4; ++i)
     {
-      for (uint j = 0; j < pSoundList->uNumSounds; ++j)
+      for (uint j = 0; j < pSoundList->sNumSounds; ++j)
         if (pSoundList->pSounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4998)
         {
-          pSoundList->_4A9DCD(j, 1);
+          pSoundList->UnloadSound(j, 1);
           break;
         }
 
-        for (uint j = 0; j < pSoundList->uNumSounds; ++j)
+        for (uint j = 0; j < pSoundList->sNumSounds; ++j)
         if (pSoundList->pSounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4999)
         {
-          pSoundList->_4A9DCD(j, 1);
+          pSoundList->UnloadSound(j, 1);
           break;
         }
     }
--- a/mm7_3.cpp	Sat Mar 23 17:07:08 2013 +0400
+++ b/mm7_3.cpp	Sat Mar 23 21:39:21 2013 +0400
@@ -3046,20 +3046,14 @@
       if ( !v107
         && !(BYTE1(pOutdoor->pBModels[pParty->field_6F4_packedid >> 9].pFaces[(pParty->field_6F4_packedid >> 3) & 0x3F].uAttributes) & 0x20) )
       {
-        v96 = 0;
-        v94 = 0;
-        v92 = 0;
-        v91 = 0;
+        
         v90 = -1;
         v89 = 1;
         v88 = 804;
         v87 = 64;
         goto LABEL_257;
       }
-      v96 = 0;
-      v94 = 0;
-      v92 = 0;
-      v91 = 0;
+     
       v90 = -1;
       v89 = 1;
       v88 = 804;
@@ -3067,7 +3061,7 @@
 LABEL_255:
       v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
       v64 = WorldPosToGridCellX(pParty->vPosition.x);
-      v87 = pOutdoor->_47EE49(v64, v63, v86);
+      v87 = pOutdoor->GetSoundIdByPosition(v64, v63, v86);
       goto LABEL_257;
     }
     if ( v124 && (!bJumping || v101) )
@@ -3075,26 +3069,19 @@
       if ( v107
         || BYTE1(pOutdoor->pBModels[pParty->field_6F4_packedid >> 9].pFaces[(pParty->field_6F4_packedid >> 3) & 0x3F].uAttributes) & 0x20 )
       {
-        v96 = 0;
-        v94 = 0;
-        v92 = 0;
-        v91 = 0;
+        
         v90 = -1;
         v89 = 1;
         v88 = 804;
         v86 = 0;
         goto LABEL_255;
       }
-      v96 = 0;
-      v94 = 0;
-      v92 = 0;
-      v91 = 0;
       v90 = -1;
       v89 = 1;
       v88 = 804;
       v87 = 103;
 LABEL_257:
-      pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, v91, v92, v94, v96);
+      pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0);
     }
     else
     {
--- a/mm7_4.cpp	Sat Mar 23 17:07:08 2013 +0400
+++ b/mm7_4.cpp	Sat Mar 23 21:39:21 2013 +0400
@@ -1864,7 +1864,7 @@
     if (SoundSetAction[24][0])
     {
       v1 = 0;
-      if ( (signed int)pSoundList->uNumSounds <= 0 )
+      if ( (signed int)pSoundList->sNumSounds <= 0 )
       {
 LABEL_7:
         v3 = 0;
@@ -1876,14 +1876,14 @@
         {
           ++v1;
           v2 += 120;
-          if ( v1 >= (signed int)pSoundList->uNumSounds )
+          if ( v1 >= (signed int)pSoundList->sNumSounds )
             goto LABEL_7;
         }
         v3 = v1;
       }
-      pSoundList->_4A9DCD(v3, 1);
+      pSoundList->UnloadSound(v3, 1);
       v4 = 0;
-      if ( (signed int)pSoundList->uNumSounds <= 0 )
+      if ( (signed int)pSoundList->sNumSounds <= 0 )
       {
 LABEL_12:
         v4 = 0;
@@ -1895,11 +1895,11 @@
         {
           ++v4;
           v5 += 120;
-          if ( (signed int)v4 >= (signed int)pSoundList->uNumSounds )
+          if ( (signed int)v4 >= (signed int)pSoundList->sNumSounds )
             goto LABEL_12;
         }
       }
-      pSoundList->_4A9DCD(v4, 1);
+      pSoundList->UnloadSound(v4, 1);
     }
     ++v0;
   }